Skip to content

Commit 77972b5

Browse files
geertudavem330
authored andcommitted
Revert "ravb: Fixed to be able to unload modules"
This reverts commit 1838d6c. This commit moved the ravb_mdio_init() call (and thus the of_mdiobus_register() call) from the ravb_probe() to the ravb_open() call. This causes a regression during system resume (s2idle/s2ram), as new PHY devices cannot be bound while suspended. During boot, the Micrel PHY is detected like this: Micrel KSZ9031 Gigabit PHY e6800000.ethernet-ffffffff:00: attached PHY driver [Micrel KSZ9031 Gigabit PHY] (mii_bus:phy_addr=e6800000.ethernet-ffffffff:00, irq=228) ravb e6800000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off During system suspend, (A) defer_all_probes is set to true, and (B) usermodehelper_disabled is set to UMH_DISABLED, to avoid drivers being probed while suspended. A. If CONFIG_MODULES=n, phy_device_register() calling device_add() merely adds the device, but does not probe it yet, as really_probe() returns early due to defer_all_probes being set: dpm_resume+0x128/0x4f8 device_resume+0xcc/0x1b0 dpm_run_callback+0x74/0x340 ravb_resume+0x190/0x1b8 ravb_open+0x84/0x770 of_mdiobus_register+0x1e0/0x468 of_mdiobus_register_phy+0x1b8/0x250 of_mdiobus_phy_device_register+0x178/0x1e8 phy_device_register+0x114/0x1b8 device_add+0x3d4/0x798 bus_probe_device+0x98/0xa0 device_initial_probe+0x10/0x18 __device_attach+0xe4/0x140 bus_for_each_drv+0x64/0xc8 __device_attach_driver+0xb8/0xe0 driver_probe_device.part.11+0xc4/0xd8 really_probe+0x32c/0x3b8 Later, phy_attach_direct() notices no PHY driver has been bound, and falls back to the Generic PHY, leading to degraded operation: Generic PHY e6800000.ethernet-ffffffff:00: attached PHY driver [Generic PHY] (mii_bus:phy_addr=e6800000.ethernet-ffffffff:00, irq=POLL) ravb e6800000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off B. If CONFIG_MODULES=y, request_module() returns early with -EBUSY due to UMH_DISABLED, and MDIO initialization fails completely: mdio_bus e6800000.ethernet-ffffffff:00: error -16 loading PHY driver module for ID 0x00221622 ravb e6800000.ethernet eth0: failed to initialize MDIO PM: dpm_run_callback(): ravb_resume+0x0/0x1b8 returns -16 PM: Device e6800000.ethernet failed to resume: error -16 Ignoring -EBUSY in phy_request_driver_module(), like was done for -ENOENT in commit 21e1944 ("net: phy: fix issue with loading PHY driver w/o initramfs"), would makes it fall back to the Generic PHY, like in the CONFIG_MODULES=n case. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Cc: stable@vger.kernel.org Reviewed-by: Sergei Shtylyov <sergei.shtylyov@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ef59b19 commit 77972b5

1 file changed

Lines changed: 55 additions & 55 deletions

File tree

‎drivers/net/ethernet/renesas/ravb_main.c‎

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,51 +1342,6 @@ static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler,
13421342
return error;
13431343
}
13441344

1345-
/* MDIO bus init function */
1346-
static int ravb_mdio_init(struct ravb_private *priv)
1347-
{
1348-
struct platform_device *pdev = priv->pdev;
1349-
struct device *dev = &pdev->dev;
1350-
int error;
1351-
1352-
/* Bitbang init */
1353-
priv->mdiobb.ops = &bb_ops;
1354-
1355-
/* MII controller setting */
1356-
priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb);
1357-
if (!priv->mii_bus)
1358-
return -ENOMEM;
1359-
1360-
/* Hook up MII support for ethtool */
1361-
priv->mii_bus->name = "ravb_mii";
1362-
priv->mii_bus->parent = dev;
1363-
snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
1364-
pdev->name, pdev->id);
1365-
1366-
/* Register MDIO bus */
1367-
error = of_mdiobus_register(priv->mii_bus, dev->of_node);
1368-
if (error)
1369-
goto out_free_bus;
1370-
1371-
return 0;
1372-
1373-
out_free_bus:
1374-
free_mdio_bitbang(priv->mii_bus);
1375-
return error;
1376-
}
1377-
1378-
/* MDIO bus release function */
1379-
static int ravb_mdio_release(struct ravb_private *priv)
1380-
{
1381-
/* Unregister mdio bus */
1382-
mdiobus_unregister(priv->mii_bus);
1383-
1384-
/* Free bitbang info */
1385-
free_mdio_bitbang(priv->mii_bus);
1386-
1387-
return 0;
1388-
}
1389-
13901345
/* Network device open function for Ethernet AVB */
13911346
static int ravb_open(struct net_device *ndev)
13921347
{
@@ -1395,13 +1350,6 @@ static int ravb_open(struct net_device *ndev)
13951350
struct device *dev = &pdev->dev;
13961351
int error;
13971352

1398-
/* MDIO bus init */
1399-
error = ravb_mdio_init(priv);
1400-
if (error) {
1401-
netdev_err(ndev, "failed to initialize MDIO\n");
1402-
return error;
1403-
}
1404-
14051353
napi_enable(&priv->napi[RAVB_BE]);
14061354
napi_enable(&priv->napi[RAVB_NC]);
14071355

@@ -1479,7 +1427,6 @@ static int ravb_open(struct net_device *ndev)
14791427
out_napi_off:
14801428
napi_disable(&priv->napi[RAVB_NC]);
14811429
napi_disable(&priv->napi[RAVB_BE]);
1482-
ravb_mdio_release(priv);
14831430
return error;
14841431
}
14851432

@@ -1789,8 +1736,6 @@ static int ravb_close(struct net_device *ndev)
17891736
ravb_ring_free(ndev, RAVB_BE);
17901737
ravb_ring_free(ndev, RAVB_NC);
17911738

1792-
ravb_mdio_release(priv);
1793-
17941739
return 0;
17951740
}
17961741

@@ -1942,6 +1887,51 @@ static const struct net_device_ops ravb_netdev_ops = {
19421887
.ndo_set_features = ravb_set_features,
19431888
};
19441889

1890+
/* MDIO bus init function */
1891+
static int ravb_mdio_init(struct ravb_private *priv)
1892+
{
1893+
struct platform_device *pdev = priv->pdev;
1894+
struct device *dev = &pdev->dev;
1895+
int error;
1896+
1897+
/* Bitbang init */
1898+
priv->mdiobb.ops = &bb_ops;
1899+
1900+
/* MII controller setting */
1901+
priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb);
1902+
if (!priv->mii_bus)
1903+
return -ENOMEM;
1904+
1905+
/* Hook up MII support for ethtool */
1906+
priv->mii_bus->name = "ravb_mii";
1907+
priv->mii_bus->parent = dev;
1908+
snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
1909+
pdev->name, pdev->id);
1910+
1911+
/* Register MDIO bus */
1912+
error = of_mdiobus_register(priv->mii_bus, dev->of_node);
1913+
if (error)
1914+
goto out_free_bus;
1915+
1916+
return 0;
1917+
1918+
out_free_bus:
1919+
free_mdio_bitbang(priv->mii_bus);
1920+
return error;
1921+
}
1922+
1923+
/* MDIO bus release function */
1924+
static int ravb_mdio_release(struct ravb_private *priv)
1925+
{
1926+
/* Unregister mdio bus */
1927+
mdiobus_unregister(priv->mii_bus);
1928+
1929+
/* Free bitbang info */
1930+
free_mdio_bitbang(priv->mii_bus);
1931+
1932+
return 0;
1933+
}
1934+
19451935
static const struct of_device_id ravb_match_table[] = {
19461936
{ .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 },
19471937
{ .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 },
@@ -2184,6 +2174,13 @@ static int ravb_probe(struct platform_device *pdev)
21842174
eth_hw_addr_random(ndev);
21852175
}
21862176

2177+
/* MDIO bus init */
2178+
error = ravb_mdio_init(priv);
2179+
if (error) {
2180+
dev_err(&pdev->dev, "failed to initialize MDIO\n");
2181+
goto out_dma_free;
2182+
}
2183+
21872184
netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll, 64);
21882185
netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll, 64);
21892186

@@ -2205,6 +2202,8 @@ static int ravb_probe(struct platform_device *pdev)
22052202
out_napi_del:
22062203
netif_napi_del(&priv->napi[RAVB_NC]);
22072204
netif_napi_del(&priv->napi[RAVB_BE]);
2205+
ravb_mdio_release(priv);
2206+
out_dma_free:
22082207
dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
22092208
priv->desc_bat_dma);
22102209

@@ -2236,6 +2235,7 @@ static int ravb_remove(struct platform_device *pdev)
22362235
unregister_netdev(ndev);
22372236
netif_napi_del(&priv->napi[RAVB_NC]);
22382237
netif_napi_del(&priv->napi[RAVB_BE]);
2238+
ravb_mdio_release(priv);
22392239
pm_runtime_disable(&pdev->dev);
22402240
free_netdev(ndev);
22412241
platform_set_drvdata(pdev, NULL);

0 commit comments

Comments
 (0)