Skip to content

Commit a9e30a2

Browse files
can: m_can: fix CAN state in system PM
A suspend/resume cycle on a down interface results in the interface coming up in Error Active state. A suspend/resume cycle on an Up interface will always result in Error Active state, regardless of the actual CAN state. During suspend, only set running interfaces to CAN_STATE_SLEEPING. During resume only touch the CAN state of running interfaces. For wakeup sources, set the CAN state depending on the Protocol Status Regitser (PSR), for non wakeup source interfaces m_can_start() will do the same. Fixes: e0d1f48 ("can: m_can: add Bosch M_CAN controller support") Reviewed-by: Markus Schneider-Pargmann <[email protected]> Link: https://patch.msgid.link/20250929-m_can-fix-state-handling-v4-4-682b49b49d9a@pengutronix.de Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 4942c42 commit a9e30a2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,12 +2503,11 @@ int m_can_class_suspend(struct device *dev)
25032503
}
25042504

25052505
m_can_clk_stop(cdev);
2506+
cdev->can.state = CAN_STATE_SLEEPING;
25062507
}
25072508

25082509
pinctrl_pm_select_sleep_state(dev);
25092510

2510-
cdev->can.state = CAN_STATE_SLEEPING;
2511-
25122511
return ret;
25132512
}
25142513
EXPORT_SYMBOL_GPL(m_can_class_suspend);
@@ -2521,8 +2520,6 @@ int m_can_class_resume(struct device *dev)
25212520

25222521
pinctrl_pm_select_default_state(dev);
25232522

2524-
cdev->can.state = CAN_STATE_ERROR_ACTIVE;
2525-
25262523
if (netif_running(ndev)) {
25272524
ret = m_can_clk_start(cdev);
25282525
if (ret)
@@ -2540,6 +2537,8 @@ int m_can_class_resume(struct device *dev)
25402537
if (cdev->ops->init)
25412538
ret = cdev->ops->init(cdev);
25422539

2540+
cdev->can.state = m_can_state_get_by_psr(cdev);
2541+
25432542
m_can_write(cdev, M_CAN_IE, cdev->active_interrupts);
25442543
} else {
25452544
ret = m_can_start(ndev);

0 commit comments

Comments
 (0)