[10/14] net/sfc: inherit lock annotations

Message ID 20230224081642.2566619-11-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, 8:16 a.m. UTC
  Due to clang limitation, inline helpers don't inherit lock annotations
from the EAL lock API.
Replace them with macros.

One additional change is required in sfc_ev_qpoll() so that clang does
see the same lock is being manipulated.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/sfc/sfc.h      | 41 ++++++--------------------------------
 drivers/net/sfc/sfc_ev.c   |  6 ++++--
 drivers/net/sfc/sfc_repr.c | 38 +++++------------------------------
 3 files changed, 15 insertions(+), 70 deletions(-)
  

Patch

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 0a1e224fa2..730d054aea 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -333,41 +333,12 @@  sfc_sa2shared(struct sfc_adapter *sa)
  * change the lock in one place.
  */
 
-static inline void
-sfc_adapter_lock_init(struct sfc_adapter *sa)
-{
-	rte_spinlock_init(&sa->lock);
-}
-
-static inline int
-sfc_adapter_is_locked(struct sfc_adapter *sa)
-{
-	return rte_spinlock_is_locked(&sa->lock);
-}
-
-static inline void
-sfc_adapter_lock(struct sfc_adapter *sa)
-{
-	rte_spinlock_lock(&sa->lock);
-}
-
-static inline int
-sfc_adapter_trylock(struct sfc_adapter *sa)
-{
-	return rte_spinlock_trylock(&sa->lock);
-}
-
-static inline void
-sfc_adapter_unlock(struct sfc_adapter *sa)
-{
-	rte_spinlock_unlock(&sa->lock);
-}
-
-static inline void
-sfc_adapter_lock_fini(__rte_unused struct sfc_adapter *sa)
-{
-	/* Just for symmetry of the API */
-}
+#define sfc_adapter_lock_init(sa) rte_spinlock_init(&(sa)->lock)
+#define sfc_adapter_is_locked(sa) rte_spinlock_is_locked(&(sa)->lock)
+#define sfc_adapter_lock(sa) rte_spinlock_lock(&(sa)->lock)
+#define sfc_adapter_trylock(sa) rte_spinlock_trylock(&(sa)->lock)
+#define sfc_adapter_unlock(sa) rte_spinlock_unlock(&(sa)->lock)
+#define sfc_adapter_lock_fini(sa) RTE_SET_USED(sa)
 
 static inline unsigned int
 sfc_nb_counter_rxq(const struct sfc_adapter_shared *sas)
diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c
index f949abbfc3..c0d58c9554 100644
--- a/drivers/net/sfc/sfc_ev.c
+++ b/drivers/net/sfc/sfc_ev.c
@@ -570,6 +570,8 @@  static const efx_ev_callbacks_t sfc_ev_callbacks_dp_tx = {
 void
 sfc_ev_qpoll(struct sfc_evq *evq)
 {
+	struct sfc_adapter *sa;
+
 	SFC_ASSERT(evq->init_state == SFC_EVQ_STARTED ||
 		   evq->init_state == SFC_EVQ_STARTING);
 
@@ -577,8 +579,8 @@  sfc_ev_qpoll(struct sfc_evq *evq)
 
 	efx_ev_qpoll(evq->common, &evq->read_ptr, evq->callbacks, evq);
 
-	if (unlikely(evq->exception) && sfc_adapter_trylock(evq->sa)) {
-		struct sfc_adapter *sa = evq->sa;
+	sa = evq->sa;
+	if (unlikely(evq->exception) && sfc_adapter_trylock(sa)) {
 		int rc;
 
 		if (evq->dp_rxq != NULL) {
diff --git a/drivers/net/sfc/sfc_repr.c b/drivers/net/sfc/sfc_repr.c
index 4b03b101d8..017c3fb247 100644
--- a/drivers/net/sfc/sfc_repr.c
+++ b/drivers/net/sfc/sfc_repr.c
@@ -112,39 +112,11 @@  sfc_repr_by_eth_dev(struct rte_eth_dev *eth_dev)
  * change the lock in one place.
  */
 
-static inline void
-sfc_repr_lock_init(struct sfc_repr *sr)
-{
-	rte_spinlock_init(&sr->lock);
-}
-
-#if defined(RTE_LIBRTE_SFC_EFX_DEBUG) || defined(RTE_ENABLE_ASSERT)
-
-static inline int
-sfc_repr_lock_is_locked(struct sfc_repr *sr)
-{
-	return rte_spinlock_is_locked(&sr->lock);
-}
-
-#endif
-
-static inline void
-sfc_repr_lock(struct sfc_repr *sr)
-{
-	rte_spinlock_lock(&sr->lock);
-}
-
-static inline void
-sfc_repr_unlock(struct sfc_repr *sr)
-{
-	rte_spinlock_unlock(&sr->lock);
-}
-
-static inline void
-sfc_repr_lock_fini(__rte_unused struct sfc_repr *sr)
-{
-	/* Just for symmetry of the API */
-}
+#define sfc_repr_lock_init(sr) rte_spinlock_init(&(sr)->lock)
+#define sfc_repr_lock_is_locked(sr) rte_spinlock_is_locked(&(sr)->lock)
+#define sfc_repr_lock(sr) rte_spinlock_lock(&(sr)->lock)
+#define sfc_repr_unlock(sr) rte_spinlock_unlock(&(sr)->lock)
+#define sfc_repr_lock_fini(sr) RTE_SET_USED(sr)
 
 static void
 sfc_repr_rx_queue_stop(void *queue)