From: Geert Uytterhoeven geert+renesas@glider.be
[ Upstream commit 5c793afa07da6d2d4595f6c73a2a543a471bb055 ]
On R-Car Gen3 using PSCI, s2ram powers down the SoC. After resume, the CAN interface no longer works, until it is brought down and up again.
Fix this by calling rcar_can_start() from the PM resume callback, to fully initialize the controller instead of just restarting it.
Signed-off-by: Geert Uytterhoeven geert+renesas@glider.be Link: https://patch.msgid.link/699b2f7fcb60b31b6f976a37f08ce99c5ffccb31.1755165227... Signed-off-by: Marc Kleine-Budde mkl@pengutronix.de Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
Based on my comprehensive investigation using multiple specialized agents to thoroughly analyze this commit, here is my determination:
## **Backport Status: YES**
This commit is an excellent candidate for stable kernel backporting for the following reasons:
### Critical Bug Fix The commit fixes a **complete functional failure** of the CAN controller after suspend/resume on R-Car Gen3 systems using PSCI. Without this fix, the CAN interface becomes completely non-operational after resume, requiring manual intervention (interface down/up) to restore functionality.
### Meets All Stable Criteria 1. **Fixes a real bug**: CAN controller fails to work after s2ram with PSCI - a hardware quirk/behavior issue 2. **Small and contained**: Only ~5-10 lines changed, replacing manual register manipulation with a single function call 3. **Obviously correct**: Reuses the well-tested `rcar_can_start()` initialization function already used in the open path 4. **Already tested**: Has been in mainline without reported regressions
### Low Risk Profile - **Minimal code change**: Simply calls existing initialization function instead of incomplete manual register manipulation - **No new code paths**: Reuses proven initialization sequence from `rcar_can_open()` - **Reduces complexity**: Removes duplicate code and consolidates initialization logic - **Clean dependencies**: Only depends on existing `rcar_can_start()` function present in all relevant kernels
### High Impact - **Safety-critical**: In automotive applications, CAN is used for critical vehicle functions - **User-visible**: Complete loss of network functionality is immediately apparent - **No workaround**: While manual interface cycling works, it's not viable for production systems
### Technical Correctness The original resume code only cleared sleep/halt bits, assuming register contents were preserved. However, PSCI completely powers down the SoC, losing all register state. The fix properly reinitializes: - Bit timing configuration - Operating modes and FIFOs - Acceptance filters - Interrupt configuration - Proper state machine transitions
### Important Note While my analysis identified potential concerns about clock management (can_clk not being re-enabled), this appears to be a pre-existing issue in the suspend/resume implementation rather than a regression introduced by this fix. The commit correctly addresses the primary initialization problem.
**Recommendation**: Backport to all stable kernels supporting R-Car Gen3 hardware (likely 4.9+), with priority for automotive/industrial distributions where CAN reliability is critical.
drivers/net/can/rcar/rcar_can.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/net/can/rcar/rcar_can.c b/drivers/net/can/rcar/rcar_can.c index 2b7dd359f27b7..8569178b66df7 100644 --- a/drivers/net/can/rcar/rcar_can.c +++ b/drivers/net/can/rcar/rcar_can.c @@ -861,7 +861,6 @@ static int __maybe_unused rcar_can_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct rcar_can_priv *priv = netdev_priv(ndev); - u16 ctlr; int err;
if (!netif_running(ndev)) @@ -873,12 +872,7 @@ static int __maybe_unused rcar_can_resume(struct device *dev) return err; }
- ctlr = readw(&priv->regs->ctlr); - ctlr &= ~RCAR_CAN_CTLR_SLPM; - writew(ctlr, &priv->regs->ctlr); - ctlr &= ~RCAR_CAN_CTLR_CANM; - writew(ctlr, &priv->regs->ctlr); - priv->can.state = CAN_STATE_ERROR_ACTIVE; + rcar_can_start(ndev);
netif_device_attach(ndev); netif_start_queue(ndev);