From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EE05E41D5F; Fri, 24 Feb 2023 16:13:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B164742D3C; Fri, 24 Feb 2023 16:12:35 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 992C241151 for ; Fri, 24 Feb 2023 16:12:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251552; 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=xCxK/xLB+oxeBoLgNQJynT94ZXelKq+BK0zch25nYyc=; b=B5mA0mdycT4Ug31Se3gTNmO4daxNcrnX8V8eZgVDjkn/gWni5P3nVwwabsuYFnlh0QqN/L c62fGGNYMQhSMpoYGmK5BK3o41yQSIicmw8EUem2I+/vFEi8ep5Q7SRYupXkygyEe/hF3q FxUia9pguNAzE9LBrkG4B2IkzxEPXRg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-595-_kLBxya6NxOgn_wMmJlTQQ-1; Fri, 24 Feb 2023 10:12:29 -0500 X-MC-Unique: _kLBxya6NxOgn_wMmJlTQQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA2B31C041A2; Fri, 24 Feb 2023 15:12:28 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B4FC2026D4B; Fri, 24 Feb 2023 15:12:27 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Vijay Kumar Srivastava Subject: [PATCH v2 13/20] vdpa/sfc: inherit lock annotations Date: Fri, 24 Feb 2023 16:11:36 +0100 Message-Id: <20230224151143.3274897-14-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.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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. sfc_vdpa_ops.c was relying on an implicit cast of the dev_handle to a vdpa adapter object. Add an explicit conversion. Signed-off-by: David Marchand --- drivers/vdpa/sfc/sfc_vdpa.h | 41 +++++---------------------------- drivers/vdpa/sfc/sfc_vdpa_ops.c | 14 +++++------ 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/drivers/vdpa/sfc/sfc_vdpa.h b/drivers/vdpa/sfc/sfc_vdpa.h index b25eb3a5fe..2b843e563d 100644 --- a/drivers/vdpa/sfc/sfc_vdpa.h +++ b/drivers/vdpa/sfc/sfc_vdpa.h @@ -122,40 +122,11 @@ sfc_vdpa_adapter_by_dev_handle(void *dev_handle) * Add wrapper functions to acquire/release lock to be able to remove or * change the lock in one place. */ -static inline void -sfc_vdpa_adapter_lock_init(struct sfc_vdpa_adapter *sva) -{ - rte_spinlock_init(&sva->lock); -} - -static inline int -sfc_vdpa_adapter_is_locked(struct sfc_vdpa_adapter *sva) -{ - return rte_spinlock_is_locked(&sva->lock); -} - -static inline void -sfc_vdpa_adapter_lock(struct sfc_vdpa_adapter *sva) -{ - rte_spinlock_lock(&sva->lock); -} - -static inline int -sfc_vdpa_adapter_trylock(struct sfc_vdpa_adapter *sva) -{ - return rte_spinlock_trylock(&sva->lock); -} - -static inline void -sfc_vdpa_adapter_unlock(struct sfc_vdpa_adapter *sva) -{ - rte_spinlock_unlock(&sva->lock); -} - -static inline void -sfc_vdpa_adapter_lock_fini(__rte_unused struct sfc_vdpa_adapter *sva) -{ - /* Just for symmetry of the API */ -} +#define sfc_vdpa_adapter_lock_init(sva) rte_spinlock_init(&(sva)->lock) +#define sfc_vdpa_adapter_is_locked(sva) rte_spinlock_is_locked(&(sva)->lock) +#define sfc_vdpa_adapter_lock(sva) rte_spinlock_lock(&(sva)->lock) +#define sfc_vdpa_adapter_trylock(sva) rte_spinlock_trylock(&(sva)->lock) +#define sfc_vdpa_adapter_unlock(sva) rte_spinlock_unlock(&(sva)->lock) +#define sfc_vdpa_adapter_lock_fini(sva) RTE_SET_USED(sva) #endif /* _SFC_VDPA_H */ diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c b/drivers/vdpa/sfc/sfc_vdpa_ops.c index 6401d4e16f..afa6b7e8ef 100644 --- a/drivers/vdpa/sfc/sfc_vdpa_ops.c +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.c @@ -577,7 +577,7 @@ sfc_vdpa_notify_ctrl(void *arg) if (ops_data == NULL) return NULL; - sfc_vdpa_adapter_lock(ops_data->dev_handle); + sfc_vdpa_adapter_lock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); vid = ops_data->vid; @@ -586,7 +586,7 @@ sfc_vdpa_notify_ctrl(void *arg) "vDPA (%s): Notifier could not get configured", ops_data->vdpa_dev->device->name); - sfc_vdpa_adapter_unlock(ops_data->dev_handle); + sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); return NULL; } @@ -637,7 +637,7 @@ sfc_vdpa_dev_config(int vid) ops_data->vid = vid; - sfc_vdpa_adapter_lock(ops_data->dev_handle); + sfc_vdpa_adapter_lock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); sfc_vdpa_log_init(ops_data->dev_handle, "configuring"); rc = sfc_vdpa_configure(ops_data); @@ -653,7 +653,7 @@ sfc_vdpa_dev_config(int vid) if (rc != 0) goto fail_vdpa_notify; - sfc_vdpa_adapter_unlock(ops_data->dev_handle); + sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); sfc_vdpa_log_init(ops_data->dev_handle, "done"); @@ -666,7 +666,7 @@ sfc_vdpa_dev_config(int vid) sfc_vdpa_close(ops_data); fail_vdpa_config: - sfc_vdpa_adapter_unlock(ops_data->dev_handle); + sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); return -1; } @@ -688,7 +688,7 @@ sfc_vdpa_dev_close(int vid) return -1; } - sfc_vdpa_adapter_lock(ops_data->dev_handle); + sfc_vdpa_adapter_lock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); if (ops_data->is_notify_thread_started == true) { void *status; ret = pthread_cancel(ops_data->notify_tid); @@ -710,7 +710,7 @@ sfc_vdpa_dev_close(int vid) sfc_vdpa_stop(ops_data); sfc_vdpa_close(ops_data); - sfc_vdpa_adapter_unlock(ops_data->dev_handle); + sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); return 0; } -- 2.39.2