Skip to content

Commit b52acd0

Browse files
committed
Merge tag 'linux-can-fixes-for-6.6-20231009' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says: ==================== pull-request: can 2023-10-09 Lukas Magel's patch for the CAN ISO-TP protocol fixes the TX state detection and wait behavior. John Watts contributes a patch to only show the sun4i_can Kconfig option on ARCH_SUNXI. A patch by Miquel Raynal fixes the soft-reset workaround for Renesas SoCs in the sja1000 driver. Markus Schneider-Pargmann's patch for the tcan4x5x m_can glue driver fixes the id2 register for the tcan4553. 2 patches by Haibo Chen fix the flexcan stop mode for the imx93 SoC. * tag 'linux-can-fixes-for-6.6-20231009' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can: can: tcan4x5x: Fix id2_register for tcan4553 can: flexcan: remove the auto stop mode for IMX93 can: sja1000: Always restart the Tx queue after an overrun arm64: dts: imx93: add the Flex-CAN stop mode by GPR can: sun4i_can: Only show Kconfig if ARCH_SUNXI is set can: isotp: isotp_sendmsg(): fix TX state detection and wait behavior ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 31c07df + c881047 commit b52acd0

File tree

7 files changed

+33
-50
lines changed

7 files changed

+33
-50
lines changed

arch/arm64/boot/dts/freescale/imx93.dtsi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
#size-cells = <1>;
186186
ranges;
187187

188-
anomix_ns_gpr: syscon@44210000 {
188+
aonmix_ns_gpr: syscon@44210000 {
189189
compatible = "fsl,imx93-aonmix-ns-syscfg", "syscon";
190190
reg = <0x44210000 0x1000>;
191191
};
@@ -319,6 +319,7 @@
319319
assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>;
320320
assigned-clock-rates = <40000000>;
321321
fsl,clk-source = /bits/ 8 <0>;
322+
fsl,stop-mode = <&aonmix_ns_gpr 0x14 0>;
322323
status = "disabled";
323324
};
324325

@@ -591,6 +592,7 @@
591592
assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>;
592593
assigned-clock-rates = <40000000>;
593594
fsl,clk-source = /bits/ 8 <0>;
595+
fsl,stop-mode = <&wakeupmix_gpr 0x0c 2>;
594596
status = "disabled";
595597
};
596598

drivers/net/can/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ config CAN_SLCAN
190190

191191
config CAN_SUN4I
192192
tristate "Allwinner A10 CAN controller"
193-
depends on MACH_SUN4I || MACH_SUN7I || RISCV || COMPILE_TEST
193+
depends on MACH_SUN4I || MACH_SUN7I || (RISCV && ARCH_SUNXI) || COMPILE_TEST
194194
help
195195
Say Y here if you want to use CAN controller found on Allwinner
196196
A10/A20/D1 SoCs.

drivers/net/can/flexcan/flexcan-core.c

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {
348348
static struct flexcan_devtype_data fsl_imx93_devtype_data = {
349349
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
350350
FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
351-
FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_AUTO_STOP_MODE |
351+
FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR |
352352
FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC |
353353
FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |
354354
FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
@@ -544,11 +544,6 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
544544
} else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) {
545545
regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
546546
1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
547-
} else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE) {
548-
/* For the auto stop mode, software do nothing, hardware will cover
549-
* all the operation automatically after system go into low power mode.
550-
*/
551-
return 0;
552547
}
553548

554549
return flexcan_low_power_enter_ack(priv);
@@ -574,12 +569,6 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
574569
reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
575570
priv->write(reg_mcr, &regs->mcr);
576571

577-
/* For the auto stop mode, hardware will exist stop mode
578-
* automatically after system go out of low power mode.
579-
*/
580-
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
581-
return 0;
582-
583572
return flexcan_low_power_exit_ack(priv);
584573
}
585574

@@ -1994,13 +1983,18 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
19941983
ret = flexcan_setup_stop_mode_scfw(pdev);
19951984
else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR)
19961985
ret = flexcan_setup_stop_mode_gpr(pdev);
1997-
else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
1998-
ret = 0;
19991986
else
20001987
/* return 0 directly if doesn't support stop mode feature */
20011988
return 0;
20021989

2003-
if (ret)
1990+
/* If ret is -EINVAL, this means SoC claim to support stop mode, but
1991+
* dts file lack the stop mode property definition. For this case,
1992+
* directly return 0, this will skip the wakeup capable setting and
1993+
* will not block the driver probe.
1994+
*/
1995+
if (ret == -EINVAL)
1996+
return 0;
1997+
else if (ret)
20041998
return ret;
20051999

20062000
device_set_wakeup_capable(&pdev->dev, true);
@@ -2320,16 +2314,8 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device)
23202314
if (netif_running(dev)) {
23212315
int err;
23222316

2323-
if (device_may_wakeup(device)) {
2317+
if (device_may_wakeup(device))
23242318
flexcan_enable_wakeup_irq(priv, true);
2325-
/* For auto stop mode, need to keep the clock on before
2326-
* system go into low power mode. After system go into
2327-
* low power mode, hardware will config the flexcan into
2328-
* stop mode, and gate off the clock automatically.
2329-
*/
2330-
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
2331-
return 0;
2332-
}
23332319

23342320
err = pm_runtime_force_suspend(device);
23352321
if (err)
@@ -2347,15 +2333,9 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device)
23472333
if (netif_running(dev)) {
23482334
int err;
23492335

2350-
/* For the wakeup in auto stop mode, no need to gate on the
2351-
* clock here, hardware will do this automatically.
2352-
*/
2353-
if (!(device_may_wakeup(device) &&
2354-
priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)) {
2355-
err = pm_runtime_force_resume(device);
2356-
if (err)
2357-
return err;
2358-
}
2336+
err = pm_runtime_force_resume(device);
2337+
if (err)
2338+
return err;
23592339

23602340
if (device_may_wakeup(device))
23612341
flexcan_enable_wakeup_irq(priv, false);

drivers/net/can/flexcan/flexcan.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
#define FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR BIT(15)
6969
/* Device supports RX via FIFO */
7070
#define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16)
71-
/* auto enter stop mode to support wakeup */
72-
#define FLEXCAN_QUIRK_AUTO_STOP_MODE BIT(17)
7371

7472
struct flexcan_devtype_data {
7573
u32 quirks; /* quirks needed for different IP cores */

drivers/net/can/m_can/tcan4x5x-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static const struct tcan4x5x_version_info tcan4x5x_versions[] = {
125125
},
126126
[TCAN4553] = {
127127
.name = "4553",
128-
.id2_register = 0x32353534,
128+
.id2_register = 0x33353534,
129129
},
130130
/* generic version with no id2_register at the end */
131131
[TCAN4X5X] = {

drivers/net/can/sja1000/sja1000.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,13 @@ static irqreturn_t sja1000_reset_interrupt(int irq, void *dev_id)
392392
struct net_device *dev = (struct net_device *)dev_id;
393393

394394
netdev_dbg(dev, "performing a soft reset upon overrun\n");
395-
sja1000_start(dev);
395+
396+
netif_tx_lock(dev);
397+
398+
can_free_echo_skb(dev, 0, NULL);
399+
sja1000_set_mode(dev, CAN_MODE_START);
400+
401+
netif_tx_unlock(dev);
396402

397403
return IRQ_HANDLED;
398404
}

net/can/isotp.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -948,21 +948,18 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
948948
if (!so->bound || so->tx.state == ISOTP_SHUTDOWN)
949949
return -EADDRNOTAVAIL;
950950

951-
wait_free_buffer:
952-
/* we do not support multiple buffers - for now */
953-
if (wq_has_sleeper(&so->wait) && (msg->msg_flags & MSG_DONTWAIT))
954-
return -EAGAIN;
951+
while (cmpxchg(&so->tx.state, ISOTP_IDLE, ISOTP_SENDING) != ISOTP_IDLE) {
952+
/* we do not support multiple buffers - for now */
953+
if (msg->msg_flags & MSG_DONTWAIT)
954+
return -EAGAIN;
955955

956-
/* wait for complete transmission of current pdu */
957-
err = wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE);
958-
if (err)
959-
goto err_event_drop;
960-
961-
if (cmpxchg(&so->tx.state, ISOTP_IDLE, ISOTP_SENDING) != ISOTP_IDLE) {
962956
if (so->tx.state == ISOTP_SHUTDOWN)
963957
return -EADDRNOTAVAIL;
964958

965-
goto wait_free_buffer;
959+
/* wait for complete transmission of current pdu */
960+
err = wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE);
961+
if (err)
962+
goto err_event_drop;
966963
}
967964

968965
/* PDU size > default => try max_pdu_size */

0 commit comments

Comments
 (0)