From: Adrian Hunter <adrian.hunter@intel.com>
To: "David Nyström" <david.nystrom@est.tech>, "Frank Li" <Frank.li@nxp.com>
Cc: <alexandre.belloni@bootlin.com>, <linux-i3c@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/8] i3c: master: Serialize i3c_set_hotjoin() with the maintenance lock
Date: Wed, 13 May 2026 08:01:02 +0300 [thread overview]
Message-ID: <571f1f5e-544e-4c1b-8ed1-4ddf6bfa9493@intel.com> (raw)
In-Reply-To: <e43cf38f-7878-b112-930a-0f9d3e34a842@est.tech>
On 12/05/2026 22:42, David Nyström wrote:
>
>
> On Tue, 12 May 2026, Frank Li wrote:
>
>> On Tue, May 12, 2026 at 03:17:26PM +0300, Adrian Hunter wrote:
>>> i3c_set_hotjoin() dispatches the controller's enable_hotjoin() or
>>> disable_hotjoin() op and updates master->hotjoin under
>>> i3c_bus_normaluse_lock(). That lock is a read-side acquisition of
>>> bus->lock (down_read()), so it does not exclude concurrent callers.
>>>
>>> The hotjoin sysfs attribute can be opened multiple times, and writes
>>> through different opens are not serialized. Two concurrent writers
>>> to "hotjoin" can therefore race in i3c_set_hotjoin(), with the
>>> controller op and the master->hotjoin store from one call interleaving
>>> with the other. The hardware enable/disable state and the value reported
>>> by hotjoin_show() can end up out of sync.
>>>
>>> Take i3c_bus_maintenance_lock() instead. Toggling Hot Join enable
>>> changes bus state and is conceptually a maintenance operation, so the
>>> write-side acquisition of bus->lock is the appropriate lock and
>>> serializes concurrent callers against each other and against other
>>> maintenance operations.
>>
>> It should be bug fix, add fix tag here.
>
> Agreed, Fixes: "i3c: master: Add sysfs option to rescan bus via entdaa"
> Is this series headed for 7.1-rc3 ? if not, its probably wise to revert the sysfs addition from 7.1-rc
"i3c: master: Add sysfs option to rescan bus via entdaa" added "do_daa".
"hotjoin" is a different sysfs attribute.
>
>> Frank
>>>
>>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>>> ---
>>> drivers/i3c/master.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
>>> index ab11e2d79aab..38ffc8713167 100644
>>> --- a/drivers/i3c/master.c
>>> +++ b/drivers/i3c/master.c
>>> @@ -649,7 +649,7 @@ static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable)
>>> return ret;
>>> }
>>>
>>> - i3c_bus_normaluse_lock(&master->bus);
>>> + i3c_bus_maintenance_lock(&master->bus);
>>>
>>> if (enable)
>>> ret = master->ops->enable_hotjoin(master);
>>> @@ -659,7 +659,7 @@ static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable)
>>> if (!ret)
>>> master->hotjoin = enable;
>>>
>>> - i3c_bus_normaluse_unlock(&master->bus);
>>> + i3c_bus_maintenance_unlock(&master->bus);
>>>
>>> if ((enable && ret) || (!enable && !ret) || master->rpm_ibi_allowed)
>>> i3c_master_rpm_put(master);
>>> --
>>> 2.51.0
>>>
>>
>> --
>> linux-i3c mailing list
>> linux-i3c@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-i3c
>>
next prev parent reply other threads:[~2026-05-13 5:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 12:17 [PATCH 0/8] i3c: Hot-Join improvements and MIPI HCI Hot-Join support Adrian Hunter
2026-05-12 12:17 ` [PATCH 1/8] i3c: master: Make hot-join workqueue freezable to block hot-join during suspend Adrian Hunter
2026-05-12 16:09 ` Frank Li
2026-05-12 12:17 ` [PATCH 2/8] i3c: master: Serialize i3c_set_hotjoin() with the maintenance lock Adrian Hunter
2026-05-12 16:11 ` Frank Li
2026-05-12 19:42 ` David Nyström
2026-05-13 5:01 ` Adrian Hunter [this message]
2026-05-13 10:21 ` David Nyström
2026-05-13 5:09 ` Adrian Hunter
2026-05-12 12:17 ` [PATCH 3/8] i3c: master: Consolidate Hot-Join DAA work in the core Adrian Hunter
2026-05-12 16:16 ` Frank Li
2026-05-12 12:17 ` [PATCH 4/8] i3c: master: Ensure Hot-Join operations are stopped on shutdown Adrian Hunter
2026-05-12 16:27 ` Frank Li
2026-05-13 5:31 ` Adrian Hunter
2026-05-12 12:17 ` [PATCH 5/8] i3c: dw: Drop redundant Hot-Join cancel_work_sync() in shutdown Adrian Hunter
2026-05-12 16:30 ` Frank Li
2026-05-12 12:17 ` [PATCH 6/8] i3c: master: Defer new-device registration out of DAA caller context Adrian Hunter
2026-05-12 16:39 ` Frank Li
2026-05-13 5:45 ` Adrian Hunter
2026-05-13 10:20 ` David Nyström
2026-05-12 12:17 ` [PATCH 7/8] i3c: master: Export i3c_master_enec_disec_locked() Adrian Hunter
2026-05-12 16:31 ` Frank Li
2026-05-12 12:17 ` [PATCH 8/8] i3c: mipi-i3c-hci: Add Hot-Join support Adrian Hunter
2026-05-12 16:34 ` Frank Li
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=571f1f5e-544e-4c1b-8ed1-4ddf6bfa9493@intel.com \
--to=adrian.hunter@intel.com \
--cc=Frank.li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=david.nystrom@est.tech \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox