]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: altera-tse: Warn on bad revision at probe time
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Mon, 3 Nov 2025 10:49:25 +0000 (11:49 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 5 Nov 2025 02:15:15 +0000 (18:15 -0800)
Instead of reading the core revision at probe time, and print a warning
for an unexecpected version at .ndo_open() time, let's print that
warning directly in .probe().

This allows getting rid of the "revision" private field, and also
prevent a potential race between reading the revision in .probe() after
netdev registration, and accessing that revision in .ndo_open().

By printing the warning after register_netdev(), we are sure that we
have a netdev name, and that we try to print the revision after having
read it from the internal registers.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20251103104928.58461-3-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/altera/altera_tse.h
drivers/net/ethernet/altera/altera_tse_main.c

index 82f2363a45cd058d47b6b0d42dca79197c73c85a..e5a56bb989daf4ed531b8796f0b4f06c3d2fe213 100644 (file)
@@ -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;
index 6ba1249f027df6bf463e6dc567045bc735b4061d..343c78a493a1bd549db247d996a7b1d04dd7ae04 100644 (file)
@@ -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) {
@@ -1395,12 +1393,14 @@ static int altera_tse_probe(struct platform_device *pdev)
                goto err_register_netdev;
        }
 
-       priv->revision = ioread32(&priv->mac_dev->megacore_revision);
+       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",
-                        (priv->revision >> 8) & 0xff,
-                        priv->revision & 0xff,
+                        (revision >> 8) & 0xff, revision & 0xff,
                         (unsigned long) control_port->start, priv->rx_irq,
                         priv->tx_irq);