Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: lan743x: Initialize eth_syslock spinlock before use
@ 2026-06-26 16:32 Andrea Righi
  2026-06-26 19:50 ` David Thompson
  2026-06-30 15:47 ` Paolo Abeni
  0 siblings, 2 replies; 4+ messages in thread
From: Andrea Righi @ 2026-06-26 16:32 UTC (permalink / raw)
  To: Bryan Whitehead, UNGLinuxDriver
  Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Raju Lakkaraju, David Thompson, netdev, linux-kernel

lan743x_hardware_init() calls pci11x1x_strap_get_status() during the
PCI11x1x probe sequence. That helper acquires the Ethernet subsystem
hardware lock via lan743x_hs_syslock_acquire(), which relies on
adapter->eth_syslock_spinlock to serialize access.

The spinlock is currently initialized only after the strap status is
read. With CONFIG_DEBUG_SPINLOCK enabled, taking the zeroed initialized
spinlock can trip the spinlock debug check.

Fix by initializing adapter->eth_syslock_spinlock before reading the
strap status so the probe path never attempts to lock an uninitialized
spinlock.

Fixes: 46b777ad9a8c ("net: lan743x: Add support to SGMII 1G and 2.5G")
Cc: stable@vger.kernel.org # v6.0+
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
 drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index 1cdce35e14239..e759171bfd766 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -3541,8 +3541,8 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
 		adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS;
 		adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS;
 		adapter->max_vector_count = PCI11X1X_MAX_VECTOR_COUNT;
-		pci11x1x_strap_get_status(adapter);
 		spin_lock_init(&adapter->eth_syslock_spinlock);
+		pci11x1x_strap_get_status(adapter);
 		mutex_init(&adapter->sgmii_rw_lock);
 		pci11x1x_set_rfe_rd_fifo_threshold(adapter);
 		sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
-- 
2.54.0


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

* RE: [PATCH] net: lan743x: Initialize eth_syslock spinlock before use
  2026-06-26 16:32 [PATCH] net: lan743x: Initialize eth_syslock spinlock before use Andrea Righi
@ 2026-06-26 19:50 ` David Thompson
  2026-06-30  7:09   ` Thangaraj.S
  2026-06-30 15:47 ` Paolo Abeni
  1 sibling, 1 reply; 4+ messages in thread
From: David Thompson @ 2026-06-26 19:50 UTC (permalink / raw)
  To: Andrea Righi, Bryan Whitehead, UNGLinuxDriver@microchip.com
  Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Raju Lakkaraju, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org

> -----Original Message-----
> From: Andrea Righi <arighi@nvidia.com>
> Sent: Friday, June 26, 2026 12:32 PM
> To: Bryan Whitehead <bryan.whitehead@microchip.com>;
> UNGLinuxDriver@microchip.com
> Cc: Andrew Lunn <andrew+netdev@lunn.ch>; David S . Miller
> <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub
> Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Raju
> Lakkaraju <Raju.Lakkaraju@microchip.com>; David Thompson
> <davthompson@nvidia.com>; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: [PATCH] net: lan743x: Initialize eth_syslock spinlock before use
> 
> lan743x_hardware_init() calls pci11x1x_strap_get_status() during the PCI11x1x
> probe sequence. That helper acquires the Ethernet subsystem hardware lock
> via lan743x_hs_syslock_acquire(), which relies on
> adapter->eth_syslock_spinlock to serialize access.
> 
> The spinlock is currently initialized only after the strap status is read. With
> CONFIG_DEBUG_SPINLOCK enabled, taking the zeroed initialized spinlock can
> trip the spinlock debug check.
> 
> Fix by initializing adapter->eth_syslock_spinlock before reading the strap status
> so the probe path never attempts to lock an uninitialized spinlock.
> 
> Fixes: 46b777ad9a8c ("net: lan743x: Add support to SGMII 1G and 2.5G")
> Cc: stable@vger.kernel.org # v6.0+
> Signed-off-by: Andrea Righi <arighi@nvidia.com>
> ---
>  drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c
> b/drivers/net/ethernet/microchip/lan743x_main.c
> index 1cdce35e14239..e759171bfd766 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -3541,8 +3541,8 @@ static int lan743x_hardware_init(struct
> lan743x_adapter *adapter,
>  		adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS;
>  		adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS;
>  		adapter->max_vector_count =
> PCI11X1X_MAX_VECTOR_COUNT;
> -		pci11x1x_strap_get_status(adapter);
>  		spin_lock_init(&adapter->eth_syslock_spinlock);
> +		pci11x1x_strap_get_status(adapter);
>  		mutex_init(&adapter->sgmii_rw_lock);
>  		pci11x1x_set_rfe_rd_fifo_threshold(adapter);
>  		sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
> --
> 2.54.0

Reviewed-by: David Thompson <davthompson@nvidia.com>


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

* RE: [PATCH] net: lan743x: Initialize eth_syslock spinlock before use
  2026-06-26 19:50 ` David Thompson
@ 2026-06-30  7:09   ` Thangaraj.S
  0 siblings, 0 replies; 4+ messages in thread
From: Thangaraj.S @ 2026-06-30  7:09 UTC (permalink / raw)
  To: davthompson, arighi, Bryan.Whitehead, UNGLinuxDriver
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, Raju.Lakkaraju,
	netdev, linux-kernel

Reviewed-by: Thangaraj Samynathan<Thangaraj.s@microchip.com>

> -----Original Message-----
> From: David Thompson <davthompson@nvidia.com>
> Sent: Saturday, June 27, 2026 1:21 AM
> To: Andrea Righi <arighi@nvidia.com>; Bryan Whitehead - C21958
> <Bryan.Whitehead@microchip.com>; UNGLinuxDriver
> <UNGLinuxDriver@microchip.com>
> Cc: Andrew Lunn <andrew+netdev@lunn.ch>; David S . Miller
> <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub
> Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Raju
> Lakkaraju <Raju.Lakkaraju@microchip.com>; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: RE: [PATCH] net: lan743x: Initialize eth_syslock spinlock before use
> 
> EXTERNAL EMAIL: Do not click links or open attachments unless you know
> the content is safe
> 
> > -----Original Message-----
> > From: Andrea Righi <arighi@nvidia.com>
> > Sent: Friday, June 26, 2026 12:32 PM
> > To: Bryan Whitehead <bryan.whitehead@microchip.com>;
> > UNGLinuxDriver@microchip.com
> > Cc: Andrew Lunn <andrew+netdev@lunn.ch>; David S . Miller
> > <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub
> > Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Raju
> > Lakkaraju <Raju.Lakkaraju@microchip.com>; David Thompson
> > <davthompson@nvidia.com>; netdev@vger.kernel.org; linux-
> > kernel@vger.kernel.org
> > Subject: [PATCH] net: lan743x: Initialize eth_syslock spinlock before
> > use
> >
> > lan743x_hardware_init() calls pci11x1x_strap_get_status() during the
> > PCI11x1x probe sequence. That helper acquires the Ethernet subsystem
> > hardware lock via lan743x_hs_syslock_acquire(), which relies on
> > adapter->eth_syslock_spinlock to serialize access.
> >
> > The spinlock is currently initialized only after the strap status is
> > read. With CONFIG_DEBUG_SPINLOCK enabled, taking the zeroed
> > initialized spinlock can trip the spinlock debug check.
> >
> > Fix by initializing adapter->eth_syslock_spinlock before reading the
> > strap status so the probe path never attempts to lock an uninitialized
> spinlock.
> >
> > Fixes: 46b777ad9a8c ("net: lan743x: Add support to SGMII 1G and 2.5G")
> > Cc: stable@vger.kernel.org # v6.0+
> > Signed-off-by: Andrea Righi <arighi@nvidia.com>
> > ---
> >  drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/microchip/lan743x_main.c
> > b/drivers/net/ethernet/microchip/lan743x_main.c
> > index 1cdce35e14239..e759171bfd766 100644
> > --- a/drivers/net/ethernet/microchip/lan743x_main.c
> > +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> > @@ -3541,8 +3541,8 @@ static int lan743x_hardware_init(struct
> > lan743x_adapter *adapter,
> >               adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS;
> >               adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS;
> >               adapter->max_vector_count = PCI11X1X_MAX_VECTOR_COUNT;
> > -             pci11x1x_strap_get_status(adapter);
> >               spin_lock_init(&adapter->eth_syslock_spinlock);
> > +             pci11x1x_strap_get_status(adapter);
> >               mutex_init(&adapter->sgmii_rw_lock);
> >               pci11x1x_set_rfe_rd_fifo_threshold(adapter);
> >               sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
> > --
> > 2.54.0
> 
> Reviewed-by: David Thompson <davthompson@nvidia.com>


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

* Re: [PATCH] net: lan743x: Initialize eth_syslock spinlock before use
  2026-06-26 16:32 [PATCH] net: lan743x: Initialize eth_syslock spinlock before use Andrea Righi
  2026-06-26 19:50 ` David Thompson
@ 2026-06-30 15:47 ` Paolo Abeni
  1 sibling, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2026-06-30 15:47 UTC (permalink / raw)
  To: Andrea Righi, Bryan Whitehead, UNGLinuxDriver
  Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Raju Lakkaraju, David Thompson, netdev, linux-kernel

On 6/26/26 6:32 PM, Andrea Righi wrote:
> lan743x_hardware_init() calls pci11x1x_strap_get_status() during the
> PCI11x1x probe sequence. That helper acquires the Ethernet subsystem
> hardware lock via lan743x_hs_syslock_acquire(), which relies on
> adapter->eth_syslock_spinlock to serialize access.
> 
> The spinlock is currently initialized only after the strap status is
> read. With CONFIG_DEBUG_SPINLOCK enabled, taking the zeroed initialized
> spinlock can trip the spinlock debug check.
> 
> Fix by initializing adapter->eth_syslock_spinlock before reading the
> strap status so the probe path never attempts to lock an uninitialized
> spinlock.
> 
> Fixes: 46b777ad9a8c ("net: lan743x: Add support to SGMII 1G and 2.5G")
> Cc: stable@vger.kernel.org # v6.0+
> Signed-off-by: Andrea Righi <arighi@nvidia.com>

The PW bot is on holiday, no automated notifications for a while.

Applied, thanks!

/P


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

end of thread, other threads:[~2026-06-30 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26 16:32 [PATCH] net: lan743x: Initialize eth_syslock spinlock before use Andrea Righi
2026-06-26 19:50 ` David Thompson
2026-06-30  7:09   ` Thangaraj.S
2026-06-30 15:47 ` Paolo Abeni

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