From: "Markus Schneider-Pargmann (TI)" <msp@baylibre.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol@kernel.org>,
Sean Nyekjaer <sean@geanix.com>
Cc: Kendall Willis <k-willis@ti.com>,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
"Markus Schneider-Pargmann (TI)" <msp@baylibre.com>
Subject: [PATCH] can: m_can: Fix suspend deinit() error path
Date: Fri, 18 Sep 2026 10:29:14 +0200 [thread overview]
Message-ID: <20260918-v7-3-topic-mcan-suspend-fix-fix-v1-1-e24fa70c754e@baylibre.com> (raw)
When suspending mcan, deinit is called and its return value is returned,
but nothing is restored. Returning an error in the suspend function will
stop suspending and resume the system immediately. So on error the
device should be restored to its previous state.
Fixes: ad1ddb3bfb0c ("can: m_can: call deinit/init callback when going into suspend/resume")
Signed-off-by: Markus Schneider-Pargmann (TI) <msp@baylibre.com>
---
drivers/net/can/m_can/m_can.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 16f80607e150..91a0c5eca260 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -2612,8 +2612,14 @@ int m_can_class_suspend(struct device *dev)
hrtimer_cancel(&cdev->hrtimer);
m_can_write(cdev, M_CAN_IE, IR_RF0N);
- if (cdev->ops->deinit)
+ if (cdev->ops->deinit) {
ret = cdev->ops->deinit(cdev);
+ if (ret) {
+ netdev_err(cdev->net, "failed to deinit device while suspending %pe\n",
+ ERR_PTR(ret));
+ goto err_restore_interface;
+ }
+ }
} else {
m_can_stop(ndev);
}
@@ -2625,6 +2631,21 @@ int m_can_class_suspend(struct device *dev)
if (!m_can_class_wakeup_pinctrl_enabled(cdev))
pinctrl_pm_select_sleep_state(dev);
+ return 0;
+
+err_restore_interface:
+ if (netif_running(ndev)) {
+ if (cdev->pm_wake_source) {
+ /* Enable interrupts that trigger immediately if
+ * something is there and keep the hrtimer off
+ */
+ cdev->active_interrupts |= IR_RF0N | IR_TEFN;
+ m_can_write(cdev, M_CAN_IE, cdev->active_interrupts);
+ }
+ netif_device_attach(ndev);
+ netif_start_queue(ndev);
+ }
+
return ret;
}
EXPORT_SYMBOL_GPL(m_can_class_suspend);
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260914-v7-3-topic-mcan-suspend-fix-fix-b943929d8fef
Best regards,
--
Markus Schneider-Pargmann <msp@baylibre.com>
next reply other threads:[~2026-09-18 8:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 8:29 Markus Schneider-Pargmann (TI) [this message]
2026-09-18 19:21 ` Kendall Willis
2026-09-29 8:26 ` Markus Schneider-Pargmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260918-v7-3-topic-mcan-suspend-fix-fix-v1-1-e24fa70c754e@baylibre.com \
--to=msp@baylibre.com \
--cc=k-willis@ti.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=sean@geanix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®