[v2,06/20] drivers: inherit lock annotations for Intel drivers

Message ID 20230224151143.3274897-7-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Enable lock annotations on most libraries and drivers |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand Feb. 24, 2023, 3:11 p.m. UTC
  Due to clang limitation, inline helpers don't inherit lock annotations
from the EAL lock API.
Replace them with macros.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/common/iavf/iavf_osdep.h       | 39 ++++++--------------------
 drivers/common/iavf/iavf_prototype.h   |  6 ----
 drivers/common/idpf/base/idpf_osdep.h  | 26 +++--------------
 drivers/net/i40e/base/i40e_osdep.h     |  8 +++---
 drivers/net/i40e/base/i40e_prototype.h |  5 ----
 drivers/net/i40e/i40e_ethdev.c         | 24 ----------------
 drivers/net/ice/base/ice_osdep.h       | 26 +++--------------
 7 files changed, 20 insertions(+), 114 deletions(-)
  

Patch

diff --git a/drivers/common/iavf/iavf_osdep.h b/drivers/common/iavf/iavf_osdep.h
index 31d3d809f9..263d92400c 100644
--- a/drivers/common/iavf/iavf_osdep.h
+++ b/drivers/common/iavf/iavf_osdep.h
@@ -170,11 +170,6 @@  struct iavf_virt_mem {
 	u32 size;
 } __rte_packed;
 
-/* SW spinlock */
-struct iavf_spinlock {
-	rte_spinlock_t spinlock;
-};
-
 #define iavf_allocate_dma_mem(h, m, unused, s, a) \
 			iavf_allocate_dma_mem_d(h, m, s, a)
 #define iavf_free_dma_mem(h, m) iavf_free_dma_mem_d(h, m)
@@ -182,32 +177,14 @@  struct iavf_spinlock {
 #define iavf_allocate_virt_mem(h, m, s) iavf_allocate_virt_mem_d(h, m, s)
 #define iavf_free_virt_mem(h, m) iavf_free_virt_mem_d(h, m)
 
-static inline void
-iavf_init_spinlock_d(struct iavf_spinlock *sp)
-{
-	rte_spinlock_init(&sp->spinlock);
-}
-
-static inline void
-iavf_acquire_spinlock_d(struct iavf_spinlock *sp)
-{
-	rte_spinlock_lock(&sp->spinlock);
-}
-
-static inline void
-iavf_release_spinlock_d(struct iavf_spinlock *sp)
-{
-	rte_spinlock_unlock(&sp->spinlock);
-}
-
-static inline void
-iavf_destroy_spinlock_d(__rte_unused struct iavf_spinlock *sp)
-{
-}
+/* SW spinlock */
+struct iavf_spinlock {
+	rte_spinlock_t spinlock;
+};
 
-#define iavf_init_spinlock(_sp) iavf_init_spinlock_d(_sp)
-#define iavf_acquire_spinlock(_sp) iavf_acquire_spinlock_d(_sp)
-#define iavf_release_spinlock(_sp) iavf_release_spinlock_d(_sp)
-#define iavf_destroy_spinlock(_sp) iavf_destroy_spinlock_d(_sp)
+#define iavf_init_spinlock(sp) rte_spinlock_init(&(sp)->spinlock)
+#define iavf_acquire_spinlock(sp) rte_spinlock_lock(&(sp)->spinlock)
+#define iavf_release_spinlock(sp) rte_spinlock_unlock(&(sp)->spinlock)
+#define iavf_destroy_spinlock(sp) RTE_SET_USED(sp)
 
 #endif /* _IAVF_OSDEP_H_ */
diff --git a/drivers/common/iavf/iavf_prototype.h b/drivers/common/iavf/iavf_prototype.h
index b5124de5bf..ba78ec5169 100644
--- a/drivers/common/iavf/iavf_prototype.h
+++ b/drivers/common/iavf/iavf_prototype.h
@@ -76,12 +76,6 @@  STATIC INLINE struct iavf_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype)
 	return iavf_ptype_lookup[ptype];
 }
 
-/* prototype for functions used for SW spinlocks */
-void iavf_init_spinlock(struct iavf_spinlock *sp);
-void iavf_acquire_spinlock(struct iavf_spinlock *sp);
-void iavf_release_spinlock(struct iavf_spinlock *sp);
-void iavf_destroy_spinlock(struct iavf_spinlock *sp);
-
 __rte_internal
 void iavf_vf_parse_hw_config(struct iavf_hw *hw,
 			     struct virtchnl_vf_resource *msg);
diff --git a/drivers/common/idpf/base/idpf_osdep.h b/drivers/common/idpf/base/idpf_osdep.h
index 99ae9cf60a..49bd7c4b21 100644
--- a/drivers/common/idpf/base/idpf_osdep.h
+++ b/drivers/common/idpf/base/idpf_osdep.h
@@ -210,28 +210,10 @@  struct idpf_lock {
 	rte_spinlock_t spinlock;
 };
 
-static inline void
-idpf_init_lock(struct idpf_lock *sp)
-{
-	rte_spinlock_init(&sp->spinlock);
-}
-
-static inline void
-idpf_acquire_lock(struct idpf_lock *sp)
-{
-	rte_spinlock_lock(&sp->spinlock);
-}
-
-static inline void
-idpf_release_lock(struct idpf_lock *sp)
-{
-	rte_spinlock_unlock(&sp->spinlock);
-}
-
-static inline void
-idpf_destroy_lock(__rte_unused struct idpf_lock *sp)
-{
-}
+#define idpf_init_lock(sp) rte_spinlock_init(&(sp)->spinlock)
+#define idpf_acquire_lock(sp) rte_spinlock_lock(&(sp)->spinlock)
+#define idpf_release_lock(sp) rte_spinlock_unlock(&(sp)->spinlock)
+#define idpf_destroy_lock(sp) RTE_SET_USED(sp)
 
 struct idpf_hw;
 
diff --git a/drivers/net/i40e/base/i40e_osdep.h b/drivers/net/i40e/base/i40e_osdep.h
index 51537c5cf3..aa5dc61841 100644
--- a/drivers/net/i40e/base/i40e_osdep.h
+++ b/drivers/net/i40e/base/i40e_osdep.h
@@ -215,10 +215,10 @@  struct i40e_spinlock {
 	rte_spinlock_t spinlock;
 };
 
-#define i40e_init_spinlock(_sp) i40e_init_spinlock_d(_sp)
-#define i40e_acquire_spinlock(_sp) i40e_acquire_spinlock_d(_sp)
-#define i40e_release_spinlock(_sp) i40e_release_spinlock_d(_sp)
-#define i40e_destroy_spinlock(_sp) i40e_destroy_spinlock_d(_sp)
+#define i40e_init_spinlock(sp) rte_spinlock_init(&(sp)->spinlock)
+#define i40e_acquire_spinlock(sp) rte_spinlock_lock(&(sp)->spinlock)
+#define i40e_release_spinlock(sp) rte_spinlock_unlock(&(sp)->spinlock)
+#define i40e_destroy_spinlock(sp) RTE_SET_USED(sp)
 
 #define I40E_NTOHS(a) rte_be_to_cpu_16(a)
 #define I40E_NTOHL(a) rte_be_to_cpu_32(a)
diff --git a/drivers/net/i40e/base/i40e_prototype.h b/drivers/net/i40e/base/i40e_prototype.h
index 29c86c7fe8..691c977172 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -546,11 +546,6 @@  i40e_virtchnl_link_speed(enum i40e_aq_link_speed link_speed)
 	}
 }
 #endif /* PF_DRIVER */
-/* prototype for functions used for SW spinlocks */
-void i40e_init_spinlock(struct i40e_spinlock *sp);
-void i40e_acquire_spinlock(struct i40e_spinlock *sp);
-void i40e_release_spinlock(struct i40e_spinlock *sp);
-void i40e_destroy_spinlock(struct i40e_spinlock *sp);
 
 /* i40e_common for VF drivers*/
 void i40e_vf_parse_hw_config(struct i40e_hw *hw,
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 7726a89d99..cf2969f6ce 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -4622,30 +4622,6 @@  i40e_free_virt_mem_d(__rte_unused struct i40e_hw *hw,
 	return I40E_SUCCESS;
 }
 
-void
-i40e_init_spinlock_d(struct i40e_spinlock *sp)
-{
-	rte_spinlock_init(&sp->spinlock);
-}
-
-void
-i40e_acquire_spinlock_d(struct i40e_spinlock *sp)
-{
-	rte_spinlock_lock(&sp->spinlock);
-}
-
-void
-i40e_release_spinlock_d(struct i40e_spinlock *sp)
-{
-	rte_spinlock_unlock(&sp->spinlock);
-}
-
-void
-i40e_destroy_spinlock_d(__rte_unused struct i40e_spinlock *sp)
-{
-	return;
-}
-
 /**
  * Get the hardware capabilities, which will be parsed
  * and saved into struct i40e_hw.
diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h
index 4b92057521..0e14b934c8 100644
--- a/drivers/net/ice/base/ice_osdep.h
+++ b/drivers/net/ice/base/ice_osdep.h
@@ -211,28 +211,10 @@  struct ice_lock {
 	rte_spinlock_t spinlock;
 };
 
-static inline void
-ice_init_lock(struct ice_lock *sp)
-{
-	rte_spinlock_init(&sp->spinlock);
-}
-
-static inline void
-ice_acquire_lock(struct ice_lock *sp)
-{
-	rte_spinlock_lock(&sp->spinlock);
-}
-
-static inline void
-ice_release_lock(struct ice_lock *sp)
-{
-	rte_spinlock_unlock(&sp->spinlock);
-}
-
-static inline void
-ice_destroy_lock(__rte_unused struct ice_lock *sp)
-{
-}
+#define ice_init_lock(sp) rte_spinlock_init(&(sp)->spinlock)
+#define ice_acquire_lock(sp) rte_spinlock_lock(&(sp)->spinlock)
+#define ice_release_lock(sp) rte_spinlock_unlock(&(sp)->spinlock)
+#define ice_destroy_lock(sp) RTE_SET_USED(sp)
 
 struct ice_hw;