Skip to content

Commit fd99d6e

Browse files
Haibo Chenmarckleinebudde
authored andcommitted
can: flexcan: only change CAN state when link up in system PM
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: 4de349e ("can: flexcan: fix resume function") Cc: [email protected] Signed-off-by: Haibo Chen <[email protected]> Link: https://patch.msgid.link/[email protected] Reported-by: Marc Kleine-Budde <[email protected]> Closes: https://lore.kernel.org/all/[email protected] [mkl: add newlines] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent d5cd454 commit fd99d6e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/can/flexcan/flexcan-core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,8 +2266,9 @@ static int __maybe_unused flexcan_suspend(struct device *device)
22662266
}
22672267
netif_stop_queue(dev);
22682268
netif_device_detach(dev);
2269+
2270+
priv->can.state = CAN_STATE_SLEEPING;
22692271
}
2270-
priv->can.state = CAN_STATE_SLEEPING;
22712272

22722273
return 0;
22732274
}
@@ -2278,7 +2279,6 @@ static int __maybe_unused flexcan_resume(struct device *device)
22782279
struct flexcan_priv *priv = netdev_priv(dev);
22792280
int err;
22802281

2281-
priv->can.state = CAN_STATE_ERROR_ACTIVE;
22822282
if (netif_running(dev)) {
22832283
netif_device_attach(dev);
22842284
netif_start_queue(dev);
@@ -2298,6 +2298,8 @@ static int __maybe_unused flexcan_resume(struct device *device)
22982298

22992299
flexcan_chip_interrupts_enable(dev);
23002300
}
2301+
2302+
priv->can.state = CAN_STATE_ERROR_ACTIVE;
23012303
}
23022304

23032305
return 0;

0 commit comments

Comments
 (0)