Skip to content

Commit

Permalink
bus/dpaa: enable clang thread safety check for FQ locks
Browse files Browse the repository at this point in the history
Enable "annotate_locks" for compile-time checks by clang.

FQLOCK and FQUNLOCK need to be considered as lock functions
that the clang analyzer can rely on.

Signed-off-by: David Marchand <[email protected]>
Signed-off-by: Hemant Agrawal <[email protected]>
  • Loading branch information
hemantagr authored and tmonjalo committed Nov 18, 2024
1 parent c7c3a32 commit 68508c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 19 additions & 16 deletions drivers/bus/dpaa/base/qbman/qman.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,10 @@
#define FSL_QMAN_POLL_LIMIT 8

/* Lock/unlock frame queues, subject to the "LOCKED" flag. This is about
* inter-processor locking only. Note, FQLOCK() is always called either under a
* local_irq_save() or from interrupt context - hence there's no need for irq
* protection (and indeed, attempting to nest irq-protection doesn't work, as
* the "irq en/disable" machinery isn't recursive...).
* inter-processor locking only.
*/
#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;

Expand All @@ -57,6 +44,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);
Expand Down
2 changes: 0 additions & 2 deletions drivers/bus/dpaa/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ if cc.has_argument('-Wno-pointer-arith')
endif

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

annotate_locks = false

0 comments on commit 68508c1

Please sign in to comment.