summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZong Li <zong.li@sifive.com>2021-05-22 12:16:11 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-06-16 13:01:37 +0300
commita385cbf31ed0deceb2e09c3950b605f94c9a4f0a (patch)
tree672f80d15fae3e0b1bec018459dfc2c09d29e629
parentbbb48789b62aa3dfd6ca3d731105efe528d91455 (diff)
downloadlinux-a385cbf31ed0deceb2e09c3950b605f94c9a4f0a.tar.xz
net: macb: ensure the device is available before accessing GEMGXL control registers
[ Upstream commit 5eff1461a6dec84f04fafa9128548bad51d96147 ] If runtime power menagement is enabled, the gigabit ethernet PLL would be disabled after macb_probe(). During this period of time, the system would hang up if we try to access GEMGXL control registers. We can't put runtime_pm_get/runtime_pm_put/ there due to the issue of sleep inside atomic section (7fa2955ff70ce453 ("sh_eth: Fix sleeping function called from invalid context"). Add netif_running checking to ensure the device is available before accessing GEMGXL device. Changed in v2: - Use netif_running instead of its own flag Signed-off-by: Zong Li <zong.li@sifive.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/ethernet/cadence/macb_main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 390f45e49eaf..1e8bf6b9834b 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -2709,6 +2709,9 @@ static struct net_device_stats *gem_get_stats(struct macb *bp)
struct gem_stats *hwstat = &bp->hw_stats.gem;
struct net_device_stats *nstat = &bp->dev->stats;
+ if (!netif_running(bp->dev))
+ return nstat;
+
gem_update_stats(bp);
nstat->rx_errors = (hwstat->rx_frame_check_sequence_errors +