[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aGVftn+0+DH7Yz7S@e129823.arm.com>
Date: Wed, 2 Jul 2025 17:35:02 +0100
From: Yeoreum Yun <yeoreum.yun@....com>
To: Leo Yan <leo.yan@....com>
Cc: Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach <mike.leach@...aro.org>,
James Clark <james.clark@...aro.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Yabin Cui <yabinc@...gle.com>, Keita Morisaki <keyz@...gle.com>,
Yuanfang Zhang <quic_yuanfang@...cinc.com>,
coresight@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 01/28] coresight: Change device mode to atomic type
Hi,
>
> On Wed, Jul 02, 2025 at 10:49:01AM +0100, Yeoreum Yun wrote:
> > Hi Leo,
> >
> > > {
> > > - return local_cmpxchg(&csdev->mode, CS_MODE_DISABLED, new_mode) ==
> > > - CS_MODE_DISABLED;
> > > + int curr = CS_MODE_DISABLED;
> > > +
> > > + return atomic_try_cmpxchg_acquire(&csdev->mode, &curr, new_mode);
> > > }
> >
> > Just question. why is acquire symentic enough in here?
>
> My understanding is that acquire semantics ensure ordering between
> cmpxchg_acquire() and all memory accesses that follow it. However, it
> does not guarantee that memory accesses appearing before the acquire
> are ordered as well.
>
> This is exactly what we want in the driver. We must ensure to first grab
> an active device mode, then it is safe to proceed later operations (e.g.
> set configurations in driver data and access registers).
>
> > before this change, local_cmpxchg seems to use full_fenced.
>
> Not really. Arm64 has atomic instruction for cmpxchg, it does not use
> full_fenced. It should run into the path of arch_cmpxchg().
No, It local_cmpxchg backend with atomic_cmpxchg() and it seems include
full fenced.
But, you've explained the what i concerned with below diagram clear
CPU0 CPU1
// store csmode in store buffer
atomic_cmpxchg_acquired(csmode)
// couldn't see the contents in store buffer
atomic_read_acquire(csmode);
Send SMP call
,-------------------------------/
v
atomic_cmpxchg_acquired(csmode) ==> Fail to grab another mode
However, I think it would be good to change the atomic_try_cmpxchg()
instead of atomic_cmpxchg_acquired() to prevent redundnat IPI trigger for
observation failure.
Thanks.
--
Sincerely,
Yeoreum Yun
Powered by blists - more mailing lists