patches for DPDK stable branches
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Hemant Agrawal <hemant.agrawal@nxp.com>
Cc: thomas@monjalon.net, dev@dpdk.org, stephen@networkplumber.org,
	 stable@dpdk.org
Subject: Re: [PATCH 1/2] bus/dpaa: fix lock condition during error handling
Date: Wed, 13 Nov 2024 17:48:25 +0100	[thread overview]
Message-ID: <CAJFAV8yzFz0aTW02ddNed52-+TRQmxEaSJ5PcL6nq6K2B5ZSNA@mail.gmail.com> (raw)
In-Reply-To: <20241113161455.2649551-1-hemant.agrawal@nxp.com>

Hello Hemant,

On Wed, Nov 13, 2024 at 5:15 PM Hemant Agrawal <hemant.agrawal@nxp.com> wrote:
>
> The error handling is missing FQ unlock code.
> Detected by pvr-studio
> Bug 89-93: very suspicious synchronization
> The analyzer issued a pack of V1020 warnings that a resource
> might remain blocked.
>
> Fixes: c47ff048b99a ("bus/dpaa: add QMAN driver core routines")
> Cc: stable@dpdk.org
>
> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

The fix looks good to me.

To avoid regressions on this topic, could you look into enabling clang
thread safety check?

I suppose that FQLOCK and FQUNLOCK always come in pairs (seems a safe
assumption), so enabling should be something like:

$ git diff --cached
diff --git a/drivers/bus/dpaa/base/qbman/qman.c
b/drivers/bus/dpaa/base/qbman/qman.c
index 9c90ee25a6..48f181c004 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -27,18 +27,8 @@
  * protection (and indeed, attempting to nest irq-protection doesn't work, as
  * the "irq en/disable" machinery isn't recursive...).
  */
-#define FQLOCK(fq) \
-       do { \
-               struct qman_fq *__fq478 = (fq); \
-               if (fq_isset(__fq478, QMAN_FQ_FLAG_LOCKED)) \
-                       spin_lock(&__fq478->fqlock); \
-       } while (0)
-#define FQUNLOCK(fq) \
-       do { \
-               struct qman_fq *__fq478 = (fq); \
-               if (fq_isset(__fq478, QMAN_FQ_FLAG_LOCKED)) \
-                       spin_unlock(&__fq478->fqlock); \
-       } while (0)
+#define FQLOCK(fq) fq_lock(fq)
+#define FQUNLOCK(fq) fq_unlock(fq)

 static qman_cb_free_mbuf qman_free_mbuf_cb;

@@ -57,6 +47,22 @@ static inline int fq_isset(struct qman_fq *fq, u32 mask)
        return fq->flags & mask;
 }

+static inline void fq_lock(struct qman_fq *fq)
+       __rte_exclusive_lock_function(&fq->fqlock)
+       __rte_no_thread_safety_analysis
+{
+       if (fq_isset(fq, QMAN_FQ_FLAG_LOCKED))
+               spin_lock(&fq->fqlock);
+}
+
+static inline void fq_unlock(struct qman_fq *fq)
+       __rte_unlock_function(&fq->fqlock)
+       __rte_no_thread_safety_analysis
+{
+       if (fq_isset(fq, QMAN_FQ_FLAG_LOCKED))
+               spin_unlock(&fq->fqlock);
+}
+
 static inline int fq_isclear(struct qman_fq *fq, u32 mask)
 {
        return !(fq->flags & mask);
diff --git a/drivers/bus/dpaa/meson.build b/drivers/bus/dpaa/meson.build
index 114e0a2265..5506f2bffc 100644
--- a/drivers/bus/dpaa/meson.build
+++ b/drivers/bus/dpaa/meson.build
@@ -29,5 +29,3 @@ if cc.has_argument('-Wno-pointer-arith')
 endif

 includes += include_directories('include', 'base/qbman')
-
-annotate_locks = false


-- 
David Marchand


  parent reply	other threads:[~2024-11-13 16:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-13 16:14 Hemant Agrawal
2024-11-13 16:14 ` [PATCH 2/2] examples/l2fwd-event: fix spinlock handling Hemant Agrawal
2024-11-13 16:48 ` David Marchand [this message]
2024-11-14  7:45   ` [PATCH 1/2] bus/dpaa: fix lock condition during error handling Hemant Agrawal
2024-11-14  7:44 ` [PATCH v2 1/3] " Hemant Agrawal
2024-11-14  7:44   ` [PATCH v2 2/3] examples/l2fwd-event: fix spinlock handling Hemant Agrawal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJFAV8yzFz0aTW02ddNed52-+TRQmxEaSJ5PcL6nq6K2B5ZSNA@mail.gmail.com \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).