The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: alexandre.belloni@bootlin.com, linux-i3c@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/8] i3c: master: Ensure Hot-Join operations are stopped on shutdown
Date: Tue, 12 May 2026 12:27:53 -0400	[thread overview]
Message-ID: <agNVCdZ93XwtBHjB@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260512121732.406009-5-adrian.hunter@intel.com>

On Tue, May 12, 2026 at 03:17:28PM +0300, Adrian Hunter wrote:
> System shutdown invokes each device's bus shutdown callback to quiesce
> hardware, but the I3C bus type does not currently implement one.  As a
> result, on shutdown the controller's Hot-Join work and any in-flight
> i3c_master_do_daa() can keep running (or be newly triggered) while the
> rest of the system is being torn down.
>
> A similar window exists at i3c_master_unregister() time: cancel_work_sync()
> on hj_work prevents queued work from completing, but does not stop a
> fresh Hot-Join IBI from re-queueing the worker, nor a concurrent sysfs
> writer from toggling Hot-Join via i3c_set_hotjoin().
>
> Introduce a single "shutting down" gate in the I3C core, set under the
> bus maintenance lock so it is observed by any in-progress DAA path
> before pending work is cancelled.  Install an i3c_bus_type shutdown
> callback that engages this gate for master devices during system
> shutdown, and use the same gate in i3c_master_unregister() so both
> paths get identical guarantees.
>
> Once the gate is engaged, the Hot-Join worker, i3c_master_do_daa_ext()
> and i3c_set_hotjoin() all bail out cleanly, so Hot-Join IBIs that race
> with shutdown become no-ops, direct DAA callers see -ENODEV, and sysfs
> writers can no longer re-enable Hot-Join through ops->enable_hotjoin()
> while the controller is going away.
>
> No functional change for the steady-state runtime path; the new checks
> only take effect once the controller has been marked as shutting down.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  drivers/i3c/master.c       | 52 +++++++++++++++++++++++++++-----------
>  include/linux/i3c/master.h |  2 ++
>  2 files changed, 39 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index cdb5cb2aa65d..a59c4b744b36 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -368,14 +368,6 @@ static void i3c_device_remove(struct device *dev)
>  		driver->remove(i3cdev);
>  }
>
> -const struct bus_type i3c_bus_type = {
> -	.name = "i3c",
> -	.match = i3c_device_match,
> -	.probe = i3c_device_probe,
> -	.remove = i3c_device_remove,
> -};
> -EXPORT_SYMBOL_GPL(i3c_bus_type);
> -

why need move this tunk?

>  static enum i3c_addr_slot_status
>  i3c_bus_get_addr_slot_status_mask(struct i3c_bus *bus, u16 addr, u32 mask)
>  {
> @@ -637,7 +629,8 @@ static void i3c_master_hj_work_fn(struct work_struct *work)
>  {
>  	struct i3c_master_controller *master = container_of(work, typeof(*master), hj_work);
>
> -	i3c_master_do_daa(master);
> +	if (!master->shutting_down)
> +		i3c_master_do_daa(master);
>  }
>
>  static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable)
> @@ -658,7 +651,9 @@ static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable)
>
>  	i3c_bus_maintenance_lock(&master->bus);

later, consider change to use cleanup, so
	if (master->shutting_down)
		return -ENODEV

	and avoid use else if branch.

but this change is okay for now.

Frank

  reply	other threads:[~2026-05-12 16:28 UTC|newest]

Thread overview: 18+ 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-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 [this message]
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-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=agNVCdZ93XwtBHjB@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=adrian.hunter@intel.com \
    --cc=alexandre.belloni@bootlin.com \
    --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