If the interface is down, the CAN controller might be powered down, the
clock disabled, and/or it's external reset asserted.
Don't wake up the controller to read the CAN bus error counters, if the
interface is down.
Fixes: ec56acfef2af1 ("can: flexcan: flexcan_get_berr_counter(): switch on clocks before accessing ecr register")
Cc: stable@vger.kernel.org
Signed-off-by: ChunYuZhiQiang <redacted>
---
v1 -> v2:
- Reword the commit message to drop the MDIS reasoning.
- Add Fixes: tag.
v2 -> v3:
- Use the title and commit message suggested by Bough Chen.
- Drop the i.MX8QXP-specific crash dump and erratum explanation;
the fix addresses a generic logic problem that exists on all
platforms.
- Drop the m_can reference.
- Drop the Link: tag (added by the maintainer at merge time).
drivers/net/can/flexcan/flexcan-core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index 06d5d35fc1b5..b08779ee2a0a 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -765,6 +765,9 @@ static int flexcan_get_berr_counter(const struct net_device *dev,
const struct flexcan_priv *priv = netdev_priv(dev);
int err;
+ if (!netif_running(dev))
+ return 0;
+
err = pm_runtime_resume_and_get(priv->dev);
if (err < 0)
return err;
--
2.47.3