From: haibo.chen@nxp.com
To: mkl@pengutronix.de, mailhol.vincent@wanadoo.fr
Cc: haibo.chen@nxp.com, ciprianmarian.costea@oss.nxp.com,
u.kleine-koenig@baylibre.com, fabio.estevam@nxp.com,
festevam@gmail.com, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
imx@lists.linux.dev, han.xu@nxp.com
Subject: [PATCH v3 1/2] can: flexcan: only change CAN state when link up in system PM
Date: Fri, 14 Mar 2025 19:01:44 +0800 [thread overview]
Message-ID: <20250314110145.899179-1-haibo.chen@nxp.com> (raw)
From: Haibo Chen <haibo.chen@nxp.com>
After a suspend/resume cycle on a down interface, it will come up as
ERROR-ACTIVE.
$ ip -details -s -s a s dev flexcan0
3: flexcan0: <NOARP,ECHO> mtu 16 qdisc pfifo_fast state DOWN group default qlen 10
link/can promiscuity 0 allmulti 0 minmtu 0 maxmtu 0
can state STOPPED (berr-counter tx 0 rx 0) restart-ms 1000
$ sudo systemctl suspend
$ ip -details -s -s a s dev flexcan0
3: flexcan0: <NOARP,ECHO> mtu 16 qdisc pfifo_fast state DOWN group default qlen 10
link/can promiscuity 0 allmulti 0 minmtu 0 maxmtu 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 1000
And only set CAN state to CAN_STATE_ERROR_ACTIVE when resume process
has no issue, otherwise keep in CAN_STATE_SLEEPING as suspend did.
Fixes: 4de349e786a3 ("can: flexcan: fix resume function")
Cc: stable@vger.kernel.org
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
Changes for v3:
- only handle priv->can.state when netif_running(dev) return true in PM.
---
drivers/net/can/flexcan/flexcan-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index b347a1c93536..d4d342d8f490 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -2299,8 +2299,8 @@ static int __maybe_unused flexcan_suspend(struct device *device)
}
netif_stop_queue(dev);
netif_device_detach(dev);
+ priv->can.state = CAN_STATE_SLEEPING;
}
- priv->can.state = CAN_STATE_SLEEPING;
return 0;
}
@@ -2311,7 +2311,6 @@ static int __maybe_unused flexcan_resume(struct device *device)
struct flexcan_priv *priv = netdev_priv(dev);
int err;
- priv->can.state = CAN_STATE_ERROR_ACTIVE;
if (netif_running(dev)) {
netif_device_attach(dev);
netif_start_queue(dev);
@@ -2331,6 +2330,7 @@ static int __maybe_unused flexcan_resume(struct device *device)
flexcan_chip_interrupts_enable(dev);
}
+ priv->can.state = CAN_STATE_ERROR_ACTIVE;
}
return 0;
--
2.34.1
next reply other threads:[~2025-03-14 11:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 11:01 haibo.chen [this message]
2025-03-14 11:01 ` [PATCH v3 2/2] can: flexcan: disable transceiver during system PM haibo.chen
2025-03-14 12:27 ` [PATCH v3 1/2] can: flexcan: only change CAN state when link up in " Marc Kleine-Budde
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=20250314110145.899179-1-haibo.chen@nxp.com \
--to=haibo.chen@nxp.com \
--cc=ciprianmarian.costea@oss.nxp.com \
--cc=fabio.estevam@nxp.com \
--cc=festevam@gmail.com \
--cc=han.xu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mkl@pengutronix.de \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.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