Skip to content

Commit 7ed47a3

Browse files
marckleinebuddegregkh
authored andcommitted
can: m_can: fix CAN state in system PM
[ Upstream commit a9e30a2 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b7f989b commit 7ed47a3

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
@@ -2506,12 +2506,11 @@ int m_can_class_suspend(struct device *dev)
25062506
}
25072507

25082508
m_can_clk_stop(cdev);
2509+
cdev->can.state = CAN_STATE_SLEEPING;
25092510
}
25102511

25112512
pinctrl_pm_select_sleep_state(dev);
25122513

2513-
cdev->can.state = CAN_STATE_SLEEPING;
2514-
25152514
return ret;
25162515
}
25172516
EXPORT_SYMBOL_GPL(m_can_class_suspend);
@@ -2524,8 +2523,6 @@ int m_can_class_resume(struct device *dev)
25242523

25252524
pinctrl_pm_select_default_state(dev);
25262525

2527-
cdev->can.state = CAN_STATE_ERROR_ACTIVE;
2528-
25292526
if (netif_running(ndev)) {
25302527
ret = m_can_clk_start(cdev);
25312528
if (ret)
@@ -2543,6 +2540,8 @@ int m_can_class_resume(struct device *dev)
25432540
if (cdev->ops->init)
25442541
ret = cdev->ops->init(cdev);
25452542

2543+
cdev->can.state = m_can_state_get_by_psr(cdev);
2544+
25462545
m_can_write(cdev, M_CAN_IE, cdev->active_interrupts);
25472546
} else {
25482547
ret = m_can_start(ndev);

0 commit comments

Comments
 (0)