Skip to content

Commit 8a0b6dc

Browse files
grygoriySdavem330
authored andcommitted
drivers: net: cpsw: fix wrong regs access in cpsw_remove
The L3 error will be generated and system will crash during unloading of CPSW driver if CPSW is used as module and ethX devices are down. This happens because CPSW can be power off by PM runtime now when ethX devices are down. Hence, ensure that CPSW powered up by PM runtime before performing any deinitialization actions which require CPSW registers access. In case of PM runtime error just leave cpsw_remove() as we can't do anything anymore. Signed-off-by: Grygorii Strashko <[email protected]> Reviewed-by: Mugunthan V N <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fccd5ba commit 8a0b6dc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,15 +2577,23 @@ static int cpsw_remove(struct platform_device *pdev)
25772577
{
25782578
struct net_device *ndev = platform_get_drvdata(pdev);
25792579
struct cpsw_priv *priv = netdev_priv(ndev);
2580+
int ret;
2581+
2582+
ret = pm_runtime_get_sync(&pdev->dev);
2583+
if (ret < 0) {
2584+
pm_runtime_put_noidle(&pdev->dev);
2585+
return ret;
2586+
}
25802587

25812588
if (priv->data.dual_emac)
25822589
unregister_netdev(cpsw_get_slave_ndev(priv, 1));
25832590
unregister_netdev(ndev);
25842591

25852592
cpsw_ale_destroy(priv->ale);
25862593
cpdma_ctlr_destroy(priv->dma);
2587-
pm_runtime_disable(&pdev->dev);
25882594
device_for_each_child(&pdev->dev, NULL, cpsw_remove_child_device);
2595+
pm_runtime_put_sync(&pdev->dev);
2596+
pm_runtime_disable(&pdev->dev);
25892597
if (priv->data.dual_emac)
25902598
free_netdev(cpsw_get_slave_ndev(priv, 1));
25912599
free_netdev(ndev);

0 commit comments

Comments
 (0)