Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration
@ 2026-05-15 21:52 David Thompson
  2026-05-20  1:41 ` Jakub Kicinski
  0 siblings, 1 reply; 5+ messages in thread
From: David Thompson @ 2026-05-15 21:52 UTC (permalink / raw)
  To: bryan.whitehead, UNGLinuxDriver, andrew+netdev, davem, edumazet,
	kuba, pabeni
  Cc: netdev, linux-kernel, David Thompson

This patch updates the lan743x driver to prevent the use of netdev-based
logging APIs (such as netdev_dbg) before the network device has been
successfully registered. Using netdev-based logging prior to registration
results in log messages referencing "(unnamed net_device) (uninitialized)",
which can be confusing and less informative.

The driver must use netif_msg_x APIs and device-based logging (e.g. dev_dbg)
until netdev registration is complete. This ensures log entries are
associated with the correct device context and improves log clarity. After
registration, netdev-based logging APIs can be used safely.

Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
Signed-off-by: David Thompson <davthompson@nvidia.com>
---
 drivers/net/ethernet/microchip/lan743x_main.c | 72 ++++++++++++-------
 1 file changed, 45 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index f3332417162e..53492573f08d 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -108,9 +108,10 @@ static int lan743x_pci_init(struct lan743x_adapter *adapter,
 	if (ret)
 		goto return_error;
 
-	netif_info(adapter, probe, adapter->netdev,
-		   "PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
-		   pdev->vendor, pdev->device);
+	if (netif_msg_probe(adapter))
+		pci_info(pdev,
+			 "PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
+			 pdev->vendor, pdev->device);
 	bars = pci_select_bars(pdev, IORESOURCE_MEM);
 	if (!test_bit(0, &bars))
 		goto disable_device;
@@ -192,10 +193,11 @@ static int lan743x_csr_init(struct lan743x_adapter *adapter)
 
 	csr->id_rev = lan743x_csr_read(adapter, ID_REV);
 	csr->fpga_rev = lan743x_csr_read(adapter, FPGA_REV);
-	netif_info(adapter, probe, adapter->netdev,
-		   "ID_REV = 0x%08X, FPGA_REV = %d.%d\n",
-		   csr->id_rev,	FPGA_REV_GET_MAJOR_(csr->fpga_rev),
-		   FPGA_REV_GET_MINOR_(csr->fpga_rev));
+	if (netif_msg_probe(adapter))
+		dev_info(&adapter->pdev->dev,
+			 "ID_REV = 0x%08X, FPGA_REV = %d.%d\n",
+			 csr->id_rev, FPGA_REV_GET_MAJOR_(csr->fpga_rev),
+			 FPGA_REV_GET_MINOR_(csr->fpga_rev));
 	if (!ID_REV_IS_VALID_CHIP_ID_(csr->id_rev))
 		return -ENODEV;
 
@@ -953,8 +955,9 @@ int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr)
 	u32 val;
 
 	if (mmd > 31) {
-		netif_err(adapter, probe, adapter->netdev,
-			  "%s mmd should <= 31\n", __func__);
+		if (netif_msg_probe(adapter))
+			dev_err(&adapter->pdev->dev,
+				"%s mmd should <= 31\n", __func__);
 		return -EINVAL;
 	}
 
@@ -983,8 +986,9 @@ static int lan743x_sgmii_write(struct lan743x_adapter *adapter,
 	int ret;
 
 	if (mmd > 31) {
-		netif_err(adapter, probe, adapter->netdev,
-			  "%s mmd should <= 31\n", __func__);
+		if (netif_msg_probe(adapter))
+			dev_err(&adapter->pdev->dev,
+				"%s mmd should <= 31\n", __func__);
 		return -EINVAL;
 	}
 	mutex_lock(&adapter->sgmii_rw_lock);
@@ -1215,8 +1219,14 @@ static void lan743x_mac_set_address(struct lan743x_adapter *adapter,
 	lan743x_csr_write(adapter, MAC_RX_ADDRH, addr_hi);
 
 	ether_addr_copy(adapter->mac_address, addr);
-	netif_info(adapter, drv, adapter->netdev,
-		   "MAC address set to %pM\n", addr);
+	if (netif_msg_drv(adapter)) {
+		if (adapter->netdev->reg_state == NETREG_REGISTERED)
+			netdev_info(adapter->netdev,
+				    "MAC address set to %pM\n", addr);
+		else
+			dev_info(&adapter->pdev->dev,
+				 "MAC address set to %pM\n", addr);
+	}
 }
 
 static int lan743x_mac_init(struct lan743x_adapter *adapter)
@@ -1370,8 +1380,9 @@ static void lan743x_phy_interface_select(struct lan743x_adapter *adapter)
 	else
 		adapter->phy_interface = PHY_INTERFACE_MODE_RGMII;
 
-	netif_dbg(adapter, drv, adapter->netdev,
-		  "selected phy interface: 0x%X\n", adapter->phy_interface);
+	if (netif_msg_drv(adapter))
+		dev_dbg(&adapter->pdev->dev,
+			"selected phy interface: 0x%X\n", adapter->phy_interface);
 }
 
 static void lan743x_rfe_open(struct lan743x_adapter *adapter)
@@ -3168,7 +3179,7 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
 	}
 
 	adapter->phylink = pl;
-	netdev_dbg(netdev, "lan743x phylink created");
+	dev_dbg(&adapter->pdev->dev, "lan743x phylink created");
 
 	return 0;
 }
@@ -3581,30 +3592,36 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
 	adapter->mdiobus->priv = (void *)adapter;
 	if (adapter->is_pci11x1x) {
 		if (adapter->is_sgmii_en) {
-			netif_dbg(adapter, drv, adapter->netdev,
-				  "SGMII operation\n");
+			if (netif_msg_drv(adapter))
+				dev_dbg(&adapter->pdev->dev,
+					"SGMII operation\n");
 			adapter->mdiobus->read = lan743x_mdiobus_read_c22;
 			adapter->mdiobus->write = lan743x_mdiobus_write_c22;
 			adapter->mdiobus->read_c45 = lan743x_mdiobus_read_c45;
 			adapter->mdiobus->write_c45 = lan743x_mdiobus_write_c45;
 			adapter->mdiobus->name = "lan743x-mdiobus-c45";
-			netif_dbg(adapter, drv, adapter->netdev,
-				  "lan743x-mdiobus-c45\n");
+			if (netif_msg_drv(adapter))
+				dev_dbg(&adapter->pdev->dev,
+					"lan743x-mdiobus-c45\n");
 		} else {
-			netif_dbg(adapter, drv, adapter->netdev,
-				  "RGMII operation\n");
+			if (netif_msg_drv(adapter))
+				dev_dbg(&adapter->pdev->dev,
+					"RGMII operation\n");
 			// Only C22 support when RGMII I/F
 			adapter->mdiobus->read = lan743x_mdiobus_read_c22;
 			adapter->mdiobus->write = lan743x_mdiobus_write_c22;
 			adapter->mdiobus->name = "lan743x-mdiobus";
-			netif_dbg(adapter, drv, adapter->netdev,
-				  "lan743x-mdiobus\n");
+			if (netif_msg_drv(adapter))
+				dev_dbg(&adapter->pdev->dev,
+					"lan743x-mdiobus\n");
 		}
 	} else {
 		adapter->mdiobus->read = lan743x_mdiobus_read_c22;
 		adapter->mdiobus->write = lan743x_mdiobus_write_c22;
 		adapter->mdiobus->name = "lan743x-mdiobus";
-		netif_dbg(adapter, drv, adapter->netdev, "lan743x-mdiobus\n");
+		if (netif_msg_drv(adapter))
+			dev_dbg(&adapter->pdev->dev,
+				"lan743x-mdiobus\n");
 	}
 
 	snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE,
@@ -3696,8 +3713,9 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
 
 	ret = lan743x_phylink_create(adapter);
 	if (ret < 0) {
-		netif_err(adapter, probe, netdev,
-			  "failed to setup phylink (%d)\n", ret);
+		if (netif_msg_probe(adapter))
+			dev_err(&pdev->dev,
+				"failed to setup phylink (%d)\n", ret);
 		goto cleanup_mdiobus;
 	}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration
  2026-05-15 21:52 [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration David Thompson
@ 2026-05-20  1:41 ` Jakub Kicinski
  2026-05-20 19:59   ` David Thompson
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2026-05-20  1:41 UTC (permalink / raw)
  To: David Thompson
  Cc: bryan.whitehead, UNGLinuxDriver, andrew+netdev, davem, edumazet,
	pabeni, netdev, linux-kernel

On Fri, 15 May 2026 21:52:29 +0000 David Thompson wrote:
> This patch updates the lan743x driver to prevent the use of netdev-based
> logging APIs (such as netdev_dbg) before the network device has been
> successfully registered. Using netdev-based logging prior to registration
> results in log messages referencing "(unnamed net_device) (uninitialized)",
> which can be confusing and less informative.
> 
> The driver must use netif_msg_x APIs and device-based logging (e.g. dev_dbg)
> until netdev registration is complete. This ensures log entries are
> associated with the correct device context and improves log clarity. After
> registration, netdev-based logging APIs can be used safely.
> 
> Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")

Not a fix

> Signed-off-by: David Thompson <davthompson@nvidia.com>
> ---
>  drivers/net/ethernet/microchip/lan743x_main.c | 72 ++++++++++++-------
>  1 file changed, 45 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index f3332417162e..53492573f08d 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -108,9 +108,10 @@ static int lan743x_pci_init(struct lan743x_adapter *adapter,
>  	if (ret)
>  		goto return_error;
>  
> -	netif_info(adapter, probe, adapter->netdev,
> -		   "PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
> -		   pdev->vendor, pdev->device);
> +	if (netif_msg_probe(adapter))

please drop these checks. They are always true.
And the message categorization is not encouraged.
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration
  2026-05-20  1:41 ` Jakub Kicinski
@ 2026-05-20 19:59   ` David Thompson
  2026-05-27 17:27     ` David Thompson
  0 siblings, 1 reply; 5+ messages in thread
From: David Thompson @ 2026-05-20 19:59 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: bryan.whitehead@microchip.com, UNGLinuxDriver@microchip.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org



> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Tuesday, May 19, 2026 9:41 PM
> To: David Thompson <davthompson@nvidia.com>
> Cc: bryan.whitehead@microchip.com; UNGLinuxDriver@microchip.com;
> andrew+netdev@lunn.ch; davem@davemloft.net; edumazet@google.com;
> pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH net] net: lan743x: avoid netdev-based logging before
> netdev registration
> 
> On Fri, 15 May 2026 21:52:29 +0000 David Thompson wrote:
> > This patch updates the lan743x driver to prevent the use of
> > netdev-based logging APIs (such as netdev_dbg) before the network
> > device has been successfully registered. Using netdev-based logging
> > prior to registration results in log messages referencing "(unnamed
> > net_device) (uninitialized)", which can be confusing and less informative.
> >
> > The driver must use netif_msg_x APIs and device-based logging (e.g.
> > dev_dbg) until netdev registration is complete. This ensures log
> > entries are associated with the correct device context and improves
> > log clarity. After registration, netdev-based logging APIs can be used safely.
> >
> > Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x
> > driver")
> 
> Not a fix
> 

Fair enough.  I'll create a v2 and post it to net-next.

> > Signed-off-by: David Thompson <davthompson@nvidia.com>
> > ---
> >  drivers/net/ethernet/microchip/lan743x_main.c | 72
> > ++++++++++++-------
> >  1 file changed, 45 insertions(+), 27 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/microchip/lan743x_main.c
> > b/drivers/net/ethernet/microchip/lan743x_main.c
> > index f3332417162e..53492573f08d 100644
> > --- a/drivers/net/ethernet/microchip/lan743x_main.c
> > +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> > @@ -108,9 +108,10 @@ static int lan743x_pci_init(struct lan743x_adapter
> *adapter,
> >  	if (ret)
> >  		goto return_error;
> >
> > -	netif_info(adapter, probe, adapter->netdev,
> > -		   "PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
> > -		   pdev->vendor, pdev->device);
> > +	if (netif_msg_probe(adapter))
> 
> please drop these checks. They are always true.

Good point, I will drop these checks in v2.

> And the message categorization is not encouraged.

Are you requesting that I change pci_info/dev_info portions of the patch into pci_dbg/dev_dbg?

> --
> pw-bot: cr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration
  2026-05-20 19:59   ` David Thompson
@ 2026-05-27 17:27     ` David Thompson
  2026-05-27 21:56       ` Jakub Kicinski
  0 siblings, 1 reply; 5+ messages in thread
From: David Thompson @ 2026-05-27 17:27 UTC (permalink / raw)
  To: David Thompson, Jakub Kicinski
  Cc: bryan.whitehead@microchip.com, UNGLinuxDriver@microchip.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org

> -----Original Message-----
> From: David Thompson <davthompson@nvidia.com>
> Sent: Wednesday, May 20, 2026 3:59 PM
> To: Jakub Kicinski <kuba@kernel.org>
> Cc: bryan.whitehead@microchip.com; UNGLinuxDriver@microchip.com;
> andrew+netdev@lunn.ch; davem@davemloft.net; edumazet@google.com;
> pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: RE: [PATCH net] net: lan743x: avoid netdev-based logging before
> netdev registration
> 
> 
> 
> > -----Original Message-----
> > From: Jakub Kicinski <kuba@kernel.org>
> > Sent: Tuesday, May 19, 2026 9:41 PM
> > To: David Thompson <davthompson@nvidia.com>
> > Cc: bryan.whitehead@microchip.com; UNGLinuxDriver@microchip.com;
> > andrew+netdev@lunn.ch; davem@davemloft.net; edumazet@google.com;
> > pabeni@redhat.com; netdev@vger.kernel.org;
> > linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH net] net: lan743x: avoid netdev-based logging
> > before netdev registration
> >
> > On Fri, 15 May 2026 21:52:29 +0000 David Thompson wrote:
> > > This patch updates the lan743x driver to prevent the use of
> > > netdev-based logging APIs (such as netdev_dbg) before the network
> > > device has been successfully registered. Using netdev-based logging
> > > prior to registration results in log messages referencing "(unnamed
> > > net_device) (uninitialized)", which can be confusing and less informative.
> > >
> > > The driver must use netif_msg_x APIs and device-based logging (e.g.
> > > dev_dbg) until netdev registration is complete. This ensures log
> > > entries are associated with the correct device context and improves
> > > log clarity. After registration, netdev-based logging APIs can be used safely.
> > >
> > > Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x
> > > driver")
> >
> > Not a fix
> >
> 
> Fair enough.  I'll create a v2 and post it to net-next.
> 
> > > Signed-off-by: David Thompson <davthompson@nvidia.com>
> > > ---
> > >  drivers/net/ethernet/microchip/lan743x_main.c | 72
> > > ++++++++++++-------
> > >  1 file changed, 45 insertions(+), 27 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/microchip/lan743x_main.c
> > > b/drivers/net/ethernet/microchip/lan743x_main.c
> > > index f3332417162e..53492573f08d 100644
> > > --- a/drivers/net/ethernet/microchip/lan743x_main.c
> > > +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> > > @@ -108,9 +108,10 @@ static int lan743x_pci_init(struct
> > > lan743x_adapter
> > *adapter,
> > >  	if (ret)
> > >  		goto return_error;
> > >
> > > -	netif_info(adapter, probe, adapter->netdev,
> > > -		   "PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
> > > -		   pdev->vendor, pdev->device);
> > > +	if (netif_msg_probe(adapter))
> >
> > please drop these checks. They are always true.
> 
> Good point, I will drop these checks in v2.
> 

While preparing v2, I realized it makes more sense to add a module parameter to control the initial value of msg_enable, instead of hardcoding it during probe. I'll update v2 to include this change, which means I'll also need to keep the checks that were previously always true.

> > And the message categorization is not encouraged.
> 
> Are you requesting that I change pci_info/dev_info portions of the patch into
> pci_dbg/dev_dbg?
> 
> > --
> > pw-bot: cr


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration
  2026-05-27 17:27     ` David Thompson
@ 2026-05-27 21:56       ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2026-05-27 21:56 UTC (permalink / raw)
  To: David Thompson
  Cc: bryan.whitehead@microchip.com, UNGLinuxDriver@microchip.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, 27 May 2026 17:27:13 +0000 David Thompson wrote:
> While preparing v2, I realized it makes more sense to add a module
> parameter to control the initial value of msg_enable, instead of
> hardcoding it during probe. I'll update v2 to include this change,
> which means I'll also need to keep the checks that were previously
> always true.

Sigh, no. Please don't perpetuate this stupid log categorization.
The module param is not present, that means nobody needs it.

Also when you repost please target net-next and drop the Fixes tag.
I don't think it will make the cut as a fix given Linus's message 
from -rc5 announcement.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-27 21:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15 21:52 [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration David Thompson
2026-05-20  1:41 ` Jakub Kicinski
2026-05-20 19:59   ` David Thompson
2026-05-27 17:27     ` David Thompson
2026-05-27 21:56       ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox