[dpdk-dev] [PATCH 3/4] net/sfc: make adapter lock recursive

Andrew Rybchenko andrew.rybchenko at oktetlabs.ru
Fri Nov 5 09:33:32 CET 2021


Adapter lock is held when mempool for MAE counter packets is populated.
Follow up patch will add a callback on mempool creation which
requires to take lock as well. However, the callback will be called for
other mempools as well when adapter lock is not held.

Signed-off-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
Reviewed-by: Ivan Malov <ivan.malov at oktetlabs.ru>
---
 drivers/net/sfc/sfc.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index fee1738d1d..f292f9f41b 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -217,7 +217,7 @@ struct sfc_adapter {
 	 * and add device level lock. Adapter control operations which
 	 * change its state should acquire the lock.
 	 */
-	rte_spinlock_t			lock;
+	rte_spinlock_recursive_t	lock;
 	enum sfc_ethdev_state		state;
 	struct rte_eth_dev		*eth_dev;
 	struct rte_kvargs		*kvargs;
@@ -331,31 +331,31 @@ sfc_sa2shared(struct sfc_adapter *sa)
 static inline void
 sfc_adapter_lock_init(struct sfc_adapter *sa)
 {
-	rte_spinlock_init(&sa->lock);
+	rte_spinlock_recursive_init(&sa->lock);
 }
 
 static inline int
 sfc_adapter_is_locked(struct sfc_adapter *sa)
 {
-	return rte_spinlock_is_locked(&sa->lock);
+	return rte_spinlock_is_locked(&sa->lock.sl);
 }
 
 static inline void
 sfc_adapter_lock(struct sfc_adapter *sa)
 {
-	rte_spinlock_lock(&sa->lock);
+	rte_spinlock_recursive_lock(&sa->lock);
 }
 
 static inline int
 sfc_adapter_trylock(struct sfc_adapter *sa)
 {
-	return rte_spinlock_trylock(&sa->lock);
+	return rte_spinlock_recursive_trylock(&sa->lock);
 }
 
 static inline void
 sfc_adapter_unlock(struct sfc_adapter *sa)
 {
-	rte_spinlock_unlock(&sa->lock);
+	rte_spinlock_recursive_unlock(&sa->lock);
 }
 
 static inline void
-- 
2.30.2



More information about the dev mailing list