From patchwork Fri Feb 24 15:11:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124531 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 018C941D5F; Fri, 24 Feb 2023 16:13:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1FE842D3F; Fri, 24 Feb 2023 16:12:25 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 6564442D3C for ; Fri, 24 Feb 2023 16:12:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9QDwi+7WhFrIcDtHhsxTZ9Ark+m4xRxs7VV2a6EW9og=; b=QUQeKw8eTgAgcYsnkq5+hCeUzu/P9Tyv9LPTChrvEV7GkpXb0YGVLOROILYaDCxSvZBaNz vXsZA+gVKpeICSK5wVaYGRSPOAW1RyI6H0Sl6Z6O8mdMYOFeTPWeL6j/Nw8+/YU31TQ3fC v/NBIsFjoBlMhPiUC3vrhCvwrjzKa7Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-1MfDLGJNOhGDp4TeNmMuAg-1; Fri, 24 Feb 2023 10:12:20 -0500 X-MC-Unique: 1MfDLGJNOhGDp4TeNmMuAg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5115285A588; Fri, 24 Feb 2023 15:12:20 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EFB4404BEC0; Fri, 24 Feb 2023 15:12:19 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Andrew Rybchenko Subject: [PATCH v2 10/20] net/sfc: inherit lock annotations Date: Fri, 24 Feb 2023 16:11:33 +0100 Message-Id: <20230224151143.3274897-11-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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(-) 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)