Skip to content

Commit a651261

Browse files
scosumarckleinebudde
authored andcommitted
can: m_can: Reset coalescing during suspend/resume
During resume the interrupts are limited to IR_RF0N and the chip keeps running. In this case if coalescing is enabled and active we may miss waterlevel interrupts during suspend. It is safer to reset the coalescing by stopping the timer and adding IR_RF0N | IR_TEFN to the interrupts. This is a theoratical issue and probably extremely rare. Cc: Martin Hundebøll <martin@geanix.com> Fixes: 4a94d7e ("can: m_can: allow keeping the transceiver running in suspend") Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Link: https://lore.kernel.org/all/20240805183047.305630-2-msp@baylibre.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 06d4ef3 commit a651261

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

drivers/net/can/m_can/m_can.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,12 +2430,15 @@ int m_can_class_suspend(struct device *dev)
24302430
netif_device_detach(ndev);
24312431

24322432
/* leave the chip running with rx interrupt enabled if it is
2433-
* used as a wake-up source.
2433+
* used as a wake-up source. Coalescing needs to be reset then,
2434+
* the timer is cancelled here, interrupts are done in resume.
24342435
*/
2435-
if (cdev->pm_wake_source)
2436+
if (cdev->pm_wake_source) {
2437+
hrtimer_cancel(&cdev->hrtimer);
24362438
m_can_write(cdev, M_CAN_IE, IR_RF0N);
2437-
else
2439+
} else {
24382440
m_can_stop(ndev);
2441+
}
24392442

24402443
m_can_clk_stop(cdev);
24412444
}
@@ -2465,6 +2468,13 @@ int m_can_class_resume(struct device *dev)
24652468
return ret;
24662469

24672470
if (cdev->pm_wake_source) {
2471+
/* Restore active interrupts but disable coalescing as
2472+
* we may have missed important waterlevel interrupts
2473+
* between suspend and resume. Timers are already
2474+
* stopped in suspend. Here we enable all interrupts
2475+
* again.
2476+
*/
2477+
cdev->active_interrupts |= IR_RF0N | IR_TEFN;
24682478
m_can_write(cdev, M_CAN_IE, cdev->active_interrupts);
24692479
} else {
24702480
ret = m_can_start(ndev);

0 commit comments

Comments
 (0)