mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
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:
+10
-4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user