mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
Merge branch 'net-altera-tse-cleanup-init-sequence'
Maxime Chevallier says: ==================== net: altera-tse: Cleanup init sequence Altera TSE cleanup to make sure everything is properly intialized before registering the netdev. When Altera TSE was converted to phylink, the PCS and phylink creation were added after register_netdev(), which is wrong as this may race with .ndo_open() once the netdev is registered. This series makes so that we register the netdev once all resources are cleanly initialised, that includes PCS and phylink creation as well as a few other operations such as reading the IP version. No errors were found in the wild, so this series doesn't target net, but given that we fix some racy-ness, a point could be made to send that to net. This series doesn't introduce functional changes, however the internal mii_bus for PCS configuration is renamed. v1: https://lore.kernel.org/20251030102418.114518-1-maxime.chevallier@bootlin.com ==================== Link: https://patch.msgid.link/20251103104928.58461-1-maxime.chevallier@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -401,9 +401,6 @@ struct altera_tse_private {
|
||||
/* MAC address space */
|
||||
struct altera_tse_mac __iomem *mac_dev;
|
||||
|
||||
/* TSE Revision */
|
||||
u32 revision;
|
||||
|
||||
/* mSGDMA Rx Dispatcher address space */
|
||||
void __iomem *rx_dma_csr;
|
||||
void __iomem *rx_dma_desc;
|
||||
|
||||
@@ -892,9 +892,6 @@ static int tse_open(struct net_device *dev)
|
||||
netdev_warn(dev, "device MAC address %pM\n",
|
||||
dev->dev_addr);
|
||||
|
||||
if ((priv->revision < 0xd00) || (priv->revision > 0xe00))
|
||||
netdev_warn(dev, "TSE revision %x\n", priv->revision);
|
||||
|
||||
spin_lock(&priv->mac_cfg_lock);
|
||||
|
||||
ret = reset_mac(priv);
|
||||
@@ -1142,6 +1139,7 @@ static int altera_tse_probe(struct platform_device *pdev)
|
||||
struct net_device *ndev;
|
||||
void __iomem *descmap;
|
||||
int ret = -ENODEV;
|
||||
u32 revision;
|
||||
|
||||
ndev = alloc_etherdev(sizeof(struct altera_tse_private));
|
||||
if (!ndev) {
|
||||
@@ -1150,6 +1148,7 @@ static int altera_tse_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
SET_NETDEV_DEV(ndev, &pdev->dev);
|
||||
platform_set_drvdata(pdev, ndev);
|
||||
|
||||
priv = netdev_priv(ndev);
|
||||
priv->device = &pdev->dev;
|
||||
@@ -1387,25 +1386,7 @@ static int altera_tse_probe(struct platform_device *pdev)
|
||||
spin_lock_init(&priv->tx_lock);
|
||||
spin_lock_init(&priv->rxdma_irq_lock);
|
||||
|
||||
netif_carrier_off(ndev);
|
||||
ret = register_netdev(ndev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to register TSE net device\n");
|
||||
goto err_register_netdev;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, ndev);
|
||||
|
||||
priv->revision = ioread32(&priv->mac_dev->megacore_revision);
|
||||
|
||||
if (netif_msg_probe(priv))
|
||||
dev_info(&pdev->dev, "Altera TSE MAC version %d.%d at 0x%08lx irq %d/%d\n",
|
||||
(priv->revision >> 8) & 0xff,
|
||||
priv->revision & 0xff,
|
||||
(unsigned long) control_port->start, priv->rx_irq,
|
||||
priv->tx_irq);
|
||||
|
||||
snprintf(mrc.name, MII_BUS_ID_SIZE, "%s-pcs-mii", ndev->name);
|
||||
snprintf(mrc.name, MII_BUS_ID_SIZE, "%s-pcs-mii", dev_name(&pdev->dev));
|
||||
pcs_bus = devm_mdio_regmap_register(&pdev->dev, &mrc);
|
||||
if (IS_ERR(pcs_bus)) {
|
||||
ret = PTR_ERR(pcs_bus);
|
||||
@@ -1442,12 +1423,30 @@ static int altera_tse_probe(struct platform_device *pdev)
|
||||
goto err_init_phylink;
|
||||
}
|
||||
|
||||
ret = register_netdev(ndev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to register TSE net device\n");
|
||||
goto err_register_netdev;
|
||||
}
|
||||
|
||||
revision = ioread32(&priv->mac_dev->megacore_revision);
|
||||
|
||||
if (revision < 0xd00 || revision > 0xe00)
|
||||
netdev_warn(ndev, "TSE revision %x\n", revision);
|
||||
|
||||
if (netif_msg_probe(priv))
|
||||
dev_info(&pdev->dev, "Altera TSE MAC version %d.%d at 0x%08lx irq %d/%d\n",
|
||||
(revision >> 8) & 0xff, revision & 0xff,
|
||||
(unsigned long)control_port->start, priv->rx_irq,
|
||||
priv->tx_irq);
|
||||
|
||||
return 0;
|
||||
|
||||
err_register_netdev:
|
||||
phylink_destroy(priv->phylink);
|
||||
err_init_phylink:
|
||||
lynx_pcs_destroy(priv->pcs);
|
||||
err_init_pcs:
|
||||
unregister_netdev(ndev);
|
||||
err_register_netdev:
|
||||
netif_napi_del(&priv->napi);
|
||||
altera_tse_mdio_destroy(ndev);
|
||||
err_free_netdev:
|
||||
|
||||
Reference in New Issue
Block a user