Hi Geert, > -----Original Message----- > From: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> > Sent: 22 August 2025 10:51 > To: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>; Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>; Biju Das > <biju.das.jz@xxxxxxxxxxxxxx> > Cc: linux-can@xxxxxxxxxxxxxxx; linux-renesas-soc@xxxxxxxxxxxxxxx; Geert Uytterhoeven > <geert+renesas@xxxxxxxxx> > Subject: [PATCH/RFC 6/6] can: rcar_canfd: Add suspend/resume support > > On R-Car Gen3 using PSCI, s2ram powers down the SoC. After resume, the CAN-FD interface no longer > works. Trying to bring it up again fails: > > # ip link set can0 up > RTNETLINK answers: Connection timed out > > # dmesg > ... > channel 0 communication state failed > > Fix this by populating the (currently empty) suspend and resume callbacks, to stop/start the individual > CAN-FD channels, and (de)initialize the CAN-FD controller. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> > --- > While this fixes CAN-FD after resume from s2ram on R-Car E3 (Ebisu-4D), it does introduce a regression > on R-Car V4H (White Hawk): after resume from s2idle (White Hawk does not support s2ram), CAN frames > sent by other devices are no longer received, and the other side sometimes reports a "bus-off". > > However, the underlying issue is pre-existing, and can be reproduced without this patch: the CAN-FD > controller fails in the same way after driver unbind/rebind. So something must be missing in the > (de)initialization sequence for the R-Car Gen4 CAN-FD register layout. > Note that it keeps on working after ifdown/ifup, which does not reinitialize the full controller. > --- > drivers/net/can/rcar/rcar_canfd.c | 53 +++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > > diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c > index eedce83b91414c57..6b0c563e894f74b3 100644 > --- a/drivers/net/can/rcar/rcar_canfd.c > +++ b/drivers/net/can/rcar/rcar_canfd.c > @@ -2236,11 +2236,64 @@ static void rcar_canfd_remove(struct platform_device *pdev) > > static int rcar_canfd_suspend(struct device *dev) { > + struct rcar_canfd_global *gpriv = dev_get_drvdata(dev); > + int err; > + u32 ch; > + > + for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) { > + struct rcar_canfd_channel *priv = gpriv->ch[ch]; > + struct net_device *ndev = priv->ndev; > + > + if (!netif_running(ndev)) > + continue; > + > + netif_device_detach(ndev); > + > + err = rcar_canfd_close(ndev); > + if (err) { > + netdev_err(ndev, "rcar_canfd_close() failed %pe\n", > + ERR_PTR(err)); > + return err; > + } > + > + priv->can.state = CAN_STATE_SLEEPING; > + } > + > + /* TODO Skip if wake-up (which is not yet supported) is enabled */ > + rcar_canfd_global_deinit(gpriv, false); > + > return 0; > } > > static int rcar_canfd_resume(struct device *dev) { > + struct rcar_canfd_global *gpriv = dev_get_drvdata(dev); > + int err; > + u32 ch; > + > + err = rcar_canfd_global_init(gpriv); > + if (err) { > + dev_err(dev, "rcar_canfd_open() failed %pe\n", ERR_PTR(err)); > + return err; > + } > + > + for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) { > + struct rcar_canfd_channel *priv = gpriv->ch[ch]; > + struct net_device *ndev = priv->ndev; > + > + if (!netif_running(ndev)) > + continue; > + > + err = rcar_canfd_open(ndev); > + if (err) { > + netdev_err(ndev, "rcar_canfd_open() failed %pe\n", > + ERR_PTR(err)); > + return err; > + } > + > + netif_device_attach(ndev); > + } > + > return 0; > } > This patch does not work on RZ/G3E, please see the logs Bind/Unbind: ------------- root@smarc-rzg3e:/cip-test-scripts# cd /sys/bus/platform/drivers/rcar_canfd n > unbindroot@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# echo 12440000.can > unbind root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# echo 12440000.can > bind [ 67.645615] rcar_canfd 12440000.can: can_clk rate is 80000000 [ 67.655044] rcar_canfd 12440000.can: device registered (channel 1) [ 67.661788] rcar_canfd 12440000.can: can_clk rate is 80000000 [ 67.671258] rcar_canfd 12440000.can: device registered (channel 4) [ 67.677603] rcar_canfd 12440000.can: global operational state (canfd clk, fd mode) root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# /cip-test-scripts/canfd_t_003.sh [INFO] Testing can0<->can1 with bitrate 1000000 and dbitrate 4000000 [INFO] Bringing down can0 can1 [INFO] Bringing up can0 can1 [INFO] Testing can1 as producer and can0 as consumer [INFO] Testing can0 as producer and can1 as consumer [INFO] Testing can0<->can1 with bitrate 500000 and dbitrate 2000000 [INFO] Bringing down can0 can1 [INFO] Bringing up can0 can1 [INFO] Testing can1 as producer and can0 as consumer [INFO] Testing can0 as producer and can1 as consumer [INFO] Testing can0<->can1 with bitrate 250000 and dbitrate 1000000 [INFO] Bringing down can0 can1 [INFO] Bringing up can0 can1 [INFO] Testing can1 as producer and can0 as consumer [INFO] Testing can0 as producer and can1 as consumer EXIT|PASS|canfd_t_003.sh|[00:00:25] || G3E S2Idle: ------------ root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# echo s2idle > /sys/power/mem_sleep root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# echo mem > /sys/power/state [ 160.231921] PM: suspend entry (s2idle) [ 160.236099] Filesystems sync: 0.000 seconds [ 160.248409] Freezing user space processes [ 160.255200] Freezing user space processes completed (elapsed 0.002 seconds) [ 160.262354] OOM killer disabled. [ 160.265681] Freezing remaining freezable tasks [ 160.271723] Freezing remaining freezable tasks completed (elapsed 0.001 seconds) [ 160.279253] printk: Suspending console(s) (use no_console_suspend to debug) [ 160.311505] sd 0:0:0:0: [sda] Synchronizing SCSI cache [ 160.377382] renesas-gbeth 15c30000.ethernet end0: Link is Down [ 162.226309] dwmac4: Master AXI performs fixed burst length [ 162.227718] renesas-gbeth 15c30000.ethernet end0: No Safety Features support found [ 162.227788] renesas-gbeth 15c30000.ethernet end0: IEEE 1588-2008 Advanced Timestamp supported [ 162.232919] renesas-gbeth 15c30000.ethernet end0: configuring for phy/rgmii-id link mode [ 162.252982] dwmac4: Master AXI performs fixed burst length [ 162.254258] renesas-gbeth 15c40000.ethernet end1: No Safety Features support found [ 162.254321] renesas-gbeth 15c40000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported [ 162.259706] renesas-gbeth 15c40000.ethernet end1: configuring for phy/rgmii-id link mode [ 162.307564] usb usb1: root hub lost power or was reset [ 162.307607] usb usb2: root hub lost power or was reset [ 164.471610] usb 2-1: reset SuperSpeed Plus Gen 2x1 USB device number 2 using xhci-renesas-hcd [ 164.584382] OOM killer enabled. [ 164.587540] Restarting tasks: Starting [ 164.593757] Restarting tasks: Done [ 164.597263] random: crng reseeded on system resumption [ 164.602497] PM: suspend exit root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# [ 164.959424] renesas-gbeth 15c30000.ethernet end0: Link is Up - 1Gbps/Full - flow control rx/tx root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# /cip-test-scripts/canfd_t_003.sh [INFO] Testing can0<->can1 with bitrate 1000000 and dbitrate 4000000 [INFO] Bringing down can0 can1 [INFO] Bringing up can0 can1 [INFO] Testing can1 as producer and can0 as consumer [INFO] Testing can0 as producer and can1 as consumer [INFO] Testing can0<->can1 with bitrate 500000 and dbitrate 2000000 [INFO] Bringing down can0 can1 [INFO] Bringing up can0 can1 [INFO] Testing can1 as producer and can0 as consumer [INFO] Testing can0 as producer and can1 as consumer [INFO] Testing can0<->can1 with bitrate 250000 and dbitrate 1000000 [INFO] Bringing down can0 can1 [INFO] Bringing up can0 can1 [INFO] Testing can1 as producer and can0 as consumer [INFO] Testing can0 as producer and can1 as consumer EXIT|PASS|canfd_t_003.sh|[00:00:25] || G3E STR: -------- root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# echo deep > /sys/power/mem_sleep root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# echo mem > /sys/power/state [ 237.863858] PM: suspend entry (deep) [ 237.867860] Filesystems sync: 0.000 seconds [ 237.878623] Freezing user space processes [ 237.885330] Freezing user space processes completed (elapsed 0.002 seconds) [ 237.892455] OOM killer disabled. [ 237.895804] Freezing remaining freezable tasks [ 237.902064] Freezing remaining freezable tasks completed (elapsed 0.001 seconds) [ 237.909648] printk: Suspending console(s) (use no_console_suspend to debug) NOTICE: BL2: v2.10.5(release):2.10.5/rz_soc_dev-169-g1410189b0 NOTICE: BL2: Built : 12:53:12, Jul 15 2025 NOTICE: BL2: SYS_LSI_MODE: 0x13e06 NOTICE: BL2: SYS_LSI_DEVID: 0x8679447 NOTICE: BL2: SYS_LSI_PRR: 0x0 NOTICE: BL2: Booting BL31 [ 237.943571] sd 0:0:0:0: [sda] Synchronizing SCSI cache [ 237.992789] renesas-gbeth 15c30000.ethernet end0: Link is Down [ 238.006388] Disabling non-boot CPUs ... [ 238.011104] psci: CPU3 killed (polled 0 ms) [ 238.017799] psci: CPU2 killed (polled 0 ms) [ 238.023704] psci: CPU1 killed (polled 4 ms) [ 238.028259] Enabling non-boot CPUs ... [ 238.028474] Detected VIPT I-cache on CPU1 [ 238.028521] GICv3: CPU1: found redistributor 100 region 0:0x0000000014960000 [ 238.028558] CPU1: Booted secondary processor 0x0000000100 [0x412fd050] [ 238.029374] CPU1 is up [ 238.029470] Detected VIPT I-cache on CPU2 [ 238.029492] GICv3: CPU2: found redistributor 200 region 0:0x0000000014980000 [ 238.029513] CPU2: Booted secondary processor 0x0000000200 [0x412fd050] [ 238.030046] CPU2 is up [ 238.030145] Detected VIPT I-cache on CPU3 [ 238.030167] GICv3: CPU3: found redistributor 300 region 0:0x00000000149a0000 [ 238.030189] CPU3: Booted secondary processor 0x0000000300 [0x412fd050] [ 238.030873] CPU3 is up [ 238.047257] dwmac4: Master AXI performs fixed burst length [ 238.048165] renesas-gbeth 15c30000.ethernet end0: No Safety Features support found [ 238.048185] renesas-gbeth 15c30000.ethernet end0: IEEE 1588-2008 Advanced Timestamp supported [ 238.051680] renesas-gbeth 15c30000.ethernet end0: configuring for phy/rgmii-id link mode [ 238.069106] dwmac4: Master AXI performs fixed burst length [ 238.070002] renesas-gbeth 15c40000.ethernet end1: No Safety Features support found [ 238.070018] renesas-gbeth 15c40000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported [ 238.073613] renesas-gbeth 15c40000.ethernet end1: configuring for phy/rgmii-id link mode [ 238.119909] usb usb1: root hub lost power or was reset [ 238.119918] usb usb2: root hub lost power or was reset [ 240.279309] usb 2-1: reset SuperSpeed Plus Gen 2x1 USB device number 2 using xhci-renesas-hcd [ 240.468214] OOM killer enabled. [ 240.471358] Restarting tasks: Starting [ 240.475721] Restarting tasks: Done [ 240.479171] random: crng reseeded on system resumption [ 240.484426] PM: suspend exit root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# [ 240.692426] renesas-gbeth 15c30000.ethernet end0: Link is Up - 1Gbps/Full - flow control rx/tx root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd# /cip-test-scripts/canfd_t_003.sh [INFO] Testing can0<->can1 with bitrate 1000000 and dbitrate 4000000 [INFO] Bringing down can0 can1 [INFO] Bringing up can0 can1 [INFO] Testing can1 as producer and can0 as consumer EXIT|FAIL|canfd_t_003.sh|[00:00:04] Problems while producing data from can1 and consuming from can0|| root@smarc-rzg3e:/sys/bus/platform/drivers/rcar_canfd#