net: mvmdio: defer probe of orion-mdio if a clock is not ready
authorJosua Mayer <josua@solid-run.com>
Tue, 9 Jul 2019 13:01:01 +0000 (15:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jul 2019 05:28:33 +0000 (07:28 +0200)
[ Upstream commit 433a06d7d74e677c40b1148c70c48677ff62fb6b ]

Defer probing of the orion-mdio interface when getting a clock returns
EPROBE_DEFER. This avoids locking up the Armada 8k SoC when mdio is used
before all clocks have been enabled.

Signed-off-by: Josua Mayer <josua@solid-run.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/marvell/mvmdio.c

index 0495487f7b42e7e80d416a2212fad2d8ca786f71..c8e3c11193131d64d5619ec64d0d32842e3bf136 100644 (file)
@@ -321,6 +321,10 @@ static int orion_mdio_probe(struct platform_device *pdev)
 
        for (i = 0; i < ARRAY_SIZE(dev->clk); i++) {
                dev->clk[i] = of_clk_get(pdev->dev.of_node, i);
+               if (PTR_ERR(dev->clk[i]) == -EPROBE_DEFER) {
+                       ret = -EPROBE_DEFER;
+                       goto out_clk;
+               }
                if (IS_ERR(dev->clk[i]))
                        break;
                clk_prepare_enable(dev->clk[i]);
@@ -365,6 +369,7 @@ out_mdio:
        if (dev->err_interrupt > 0)
                writel(0, dev->regs + MVMDIO_ERR_INT_MASK);
 
+out_clk:
        for (i = 0; i < ARRAY_SIZE(dev->clk); i++) {
                if (IS_ERR(dev->clk[i]))
                        break;