All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Xuyang Dong" <dongxuyang@eswincomputing.com>
To: "Brian Masney" <bmasney@redhat.com>
Cc: mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, p.zabel@pengutronix.de,
	huangyifeng@eswincomputing.com, benoit.monin@bootlin.com,
	ningyu@eswincomputing.com, linmin@eswincomputing.com,
	pinkesh.vaghela@einfochips.com
Subject: Re: Re: [PATCH v3 2/3] clk: eswin: Add eic7700 HSP clock driver
Date: Fri, 24 Apr 2026 18:44:49 +0800 (GMT+08:00)	[thread overview]
Message-ID: <4e5c887.5a31.19dbf179fb6.Coremail.dongxuyang@eswincomputing.com> (raw)
In-Reply-To: <aeo8nn-eigzlojWx@redhat.com>

> > 
> > Add driver for the ESWIN EIC7700 high-speed peripherals system
> > clock controller and register an auxiliary device for system
> > reset controller which is named as "hsp-reset".
> > 
> > Signed-off-by: Xuyang Dong <dongxuyang@eswincomputing.com>
> 
> Reviewed-by: Brian Masney <bmasney@redhat.com>
> 
> There's one minor bit I am not sure of.
> 
> > +static void eic7700_hsp_regmap_lock(void *arg)
> > +__acquires(lock_ctx->lock)
> > +{
> > +	struct eic7700_hsp_regmap_lock *const lock_ctx = arg;
> > +	unsigned long flags;
> > +
> > +	spin_lock_irqsave(lock_ctx->lock, flags);
> > +	lock_ctx->flags = flags;
> > +}
> 
> I don't know if the __acquires() is accurate syntax. If it needs to
> be arg, lock_ctx->lock, or ((struct eic7700_hsp_regmap_lock *)arg)->lock.
> 
> It looks like this code is triggered with clang, and I tried compiling
> this driver with:
> 
> make LLVM=1 KCFLAGS="-ferror-limit=10000 -DWARN_CONTEXT_ANALYSIS -Wthread-safety" \
>         drivers/clk/eswin/clk-eic7700-hsp.o
> 
> I also tried with 'make C=2' and I don't see any locking messages from
> this driver.
> 

Hi Brian,

Thanks for the feedback. I did some research based on your comments.

lock_ctx is a local variable declared inside the function body. It is not 
in scope at the attribute site. The attribute expands to 
__attribute__((acquire_capability(lock_ctx->lock))), and since lock_ctx 
doesn't exist at the declaration point, clang's analysis cannot resolve it 
and silently drops the annotation. That's why you see no warnings from 
make C=2 or -Wthread-safety.

Why -Wthread-safety produces no output
Two reasons:
  1. The lock_ctx->lock expression is unresolvable at the attribute site, 
  so clang drops the annotation silently — no acquire/release tracking, 
  no warnings.                                                                        
  2. Even if the expression were resolvable, spinlock_t in this driver is 
  a plain pointer field (spinlock_t *lock) accessed through a void * 
  callback — the analysis can't track lock state through that indirection.              

The closest correct expression would be:
__acquires(((struct eic7700_hsp_regmap_lock *)arg)->lock) 
But that also won't work: arg is void *, and clang's thread-safety 
analysis is type-based. It can't trace through a void pointer cast to 
determine which spinlock_t instance is being acquired. The analysis 
would still silently ignore it.

For void * regmap callbacks, there is no clean way to make __acquires() 
work, because the lock is always hidden behind the opaque pointer. 
The annotations should be dropped.

Based on the above analysis, I suggest removing the annotations entirely. 
However, I'd like to hear your thoughts on this approach.

Best regards,
Xuyang Dong

  reply	other threads:[~2026-04-24 10:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23  9:09 [PATCH v3 0/3] Add driver support for ESWIN EIC7700 HSP clock and reset generator Xuyang Dong
2026-04-23  9:10 ` [PATCH v3 1/3] dt-bindings: clock: Add ESWIN eic7700 " dongxuyang
2026-04-23  9:11 ` [PATCH v3 2/3] clk: eswin: Add eic7700 HSP clock driver dongxuyang
2026-04-23 15:37   ` Brian Masney
2026-04-24 10:44     ` Xuyang Dong [this message]
2026-04-24 11:15       ` Brian Masney
2026-04-28  0:21         ` Stephen Boyd
2026-04-28  9:21           ` Xuyang Dong
2026-04-28 13:39             ` Brian Masney
2026-04-29  1:51             ` Stephen Boyd
2026-04-29  9:38               ` Xuyang Dong
2026-04-29 13:54                 ` Brian Masney
2026-04-30  5:58                   ` Xuyang Dong
2026-04-30 22:51                     ` Brian Masney
2026-05-09  2:53                       ` Xuyang Dong
2026-04-23 15:51   ` Benoît Monin
2026-04-23  9:12 ` [PATCH v3 3/3] reset: eswin: Add eic7700 HSP reset driver dongxuyang
2026-04-23 16:09   ` Philipp Zabel

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=4e5c887.5a31.19dbf179fb6.Coremail.dongxuyang@eswincomputing.com \
    --to=dongxuyang@eswincomputing.com \
    --cc=benoit.monin@bootlin.com \
    --cc=bmasney@redhat.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=huangyifeng@eswincomputing.com \
    --cc=krzk+dt@kernel.org \
    --cc=linmin@eswincomputing.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=ningyu@eswincomputing.com \
    --cc=p.zabel@pengutronix.de \
    --cc=pinkesh.vaghela@einfochips.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.