drivers/net: replace critical_section with spinlock

so as to better support multi-core scenarios

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-06-23 14:20:21 +08:00
committed by archer
parent fe822145a3
commit 521e319aa3
7 changed files with 52 additions and 30 deletions
+10 -4
View File
@@ -151,6 +151,10 @@ struct igc_driver_s
FAR uint32_t *mta;
#endif
/* A spinlock for protecting the driving state */
spinlock_t lock;
};
/*****************************************************************************
@@ -876,12 +880,12 @@ static int igc_ifup(FAR struct netdev_lowerhalf_s *dev)
dev->netdev.d_ipv6addr[6], dev->netdev.d_ipv6addr[7]);
#endif
flags = enter_critical_section();
flags = spin_lock_irqsave(&priv->lock);
/* Enable the Ethernet */
igc_enable(priv);
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->lock, flags);
/* Update link status in case link status interrupt is missing */
@@ -912,7 +916,7 @@ static int igc_ifdown(FAR struct netdev_lowerhalf_s *dev)
FAR struct igc_driver_s *priv = (FAR struct igc_driver_s *)dev;
irqstate_t flags;
flags = enter_critical_section();
flags = spin_lock_irqsave(&priv->lock);
/* Put the EMAC in its reset, non-operational state. This should be
* a known configuration that will guarantee the igc_ifup() always
@@ -923,7 +927,7 @@ static int igc_ifdown(FAR struct netdev_lowerhalf_s *dev)
/* Mark the device "down" */
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->lock, flags);
return OK;
}
@@ -1432,6 +1436,8 @@ static int igc_probe(FAR struct pci_device_s *dev)
return ret;
}
spin_lock_init(&priv->lock);
/* Register the network device */
netdev->quota[NETPKT_TX] = IGC_TX_QUOTA;