From: Frank Li <Frank.li@oss.nxp.com>
To: Sam Agazaryan <samagazaryan@google.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-i3c@lists.infradead.org, Frank Li <Frank.Li@nxp.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>,
Ravindra Yashvant Shinde <ravindra.yashvant.shinde@nxp.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 1/2] i3c: master: Drain IBI slot pool before freeing
Date: Wed, 2 Dec 2026 15:14:05 -0500 [thread overview]
Message-ID: <axB8DSq2bdYF4ANK@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20261202022502.3661797-2-samagazaryan@google.com>
On Wed, Dec 02, 2026 at 02:25:01AM +0000, Sam Agazaryan wrote:
Remove RFC
> When DAA re-adds a device that is already known, as on a Hot-Join after
> a target reset, __i3c_master_add_i3c_dev_locked() clears
> olddev->ibi->enabled before calling i3c_dev_free_ibi_locked(). That
> skips the wait for pending IBIs, so the controller frees its IBI pool
> while slot work is still queued or running on dev->ibi->wq. The handler
> then recycles its slot through the controller, whose per-device IBI
> data is already gone:
>
> Internal error: Oops: 0000000096000004 [#1] SMP
> Workqueue: 10-20a0168000f i3c_master_handle_ibi
> pc : hci_dma_recycle_ibi_slot+0x1c/0x38
> lr : i3c_hci_recycle_ibi_slot+0x2c/0x40
> Call trace:
> hci_dma_recycle_ibi_slot+0x1c/0x38 (P)
> i3c_hci_recycle_ibi_slot+0x2c/0x40
> i3c_master_handle_ibi+0x78/0xe0
> process_one_work+0x154/0x3b0
> worker_thread+0x28c/0x3a0
>
> Make the pool safe to free with slots in flight. Each slot now records
> its pool, and i3c_master_queue_ibi() records the IBI info and device the
> handler needs, so i3c_master_handle_ibi() no longer uses slot->dev and
> returns the slot straight to its pool. i3c_generic_ibi_free_pool() stops
> handing out slots and cancels work that has not started. If IBIs were
> ever queued, it frees the pool from a work item on the same ordered
> workqueue, which runs after any handler still in progress.
>
> This assumes every slot passed to i3c_master_queue_ibi() comes from a
> generic IBI pool, which is true for all in-tree drivers.
>
> Fixes: 9fd00df05e81 ("i3c: master: handle IBIs in order they came")
> Fixes: 36faa04ce3d9 ("i3c: master: Remove i3c_dev_disable_ibi_locked(olddev) on device hotjoin")
> Signed-off-by: Sam Agazaryan <samagazaryan@google.com>
> ---
> drivers/i3c/master.c | 149 +++++++++++++++++++++++++++++++++----------
> 1 file changed, 116 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 01e05bad8661..75c44c45bd08 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -3619,6 +3619,26 @@ static void i3c_master_unregister_i3c_devs(struct i3c_master_controller *master)
> /* Approximate time for IBI handler to run */
> #define I3C_WAKEUP_PROCESSING_TIME_MS 100
>
> +struct i3c_generic_ibi_slot {
> + struct list_head node;
> + struct i3c_ibi_slot base;
> + struct i3c_generic_ibi_pool *pool;
> + struct i3c_device_ibi_info *ibi;
> + struct i3c_device *i3cdev;
> +};
> +
> +struct i3c_generic_ibi_pool {
> + spinlock_t lock;
> + unsigned int num_slots;
> + bool stopping;
> + struct workqueue_struct *wq;
> + struct work_struct free_work;
> + void *payload_buf;
> + struct list_head free_slots;
> + struct list_head pending;
> + struct i3c_generic_ibi_slot slots[] __counted_by(num_slots);
> +};
> +
Use prepare patch move i3c_generic_ibi_pool to here
> /**
> * i3c_master_queue_ibi() - Queue an IBI
> * @dev: the device this IBI is coming from
> @@ -3629,14 +3649,32 @@ static void i3c_master_unregister_i3c_devs(struct i3c_master_controller *master)
> */
> void i3c_master_queue_ibi(struct i3c_dev_desc *dev, struct i3c_ibi_slot *slot)
> {
> - if (!dev->ibi || !slot)
> + struct i3c_generic_ibi_slot *gslot;
> + struct i3c_generic_ibi_pool *pool;
> + unsigned long flags;
> +
> + if (!slot)
> return;
>
> + gslot = container_of(slot, struct i3c_generic_ibi_slot, base);
> + pool = gslot->pool;
> +
> + spin_lock_irqsave(&pool->lock, flags);
Usu auto cleanup guard()
Frank
next prev parent reply other threads:[~2026-12-02 20:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:25 [PATCH RFC 0/2] i3c: master: Fix IBI teardown when DAA re-adds a device Sam Agazaryan
2026-12-02 2:25 ` [PATCH RFC 1/2] i3c: master: Drain IBI slot pool before freeing Sam Agazaryan
2026-12-02 20:14 ` Frank Li [this message]
2026-12-02 2:25 ` [PATCH RFC 2/2] i3c: master: Preserve IBI workqueue across DAA Sam Agazaryan
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=axB8DSq2bdYF4ANK@lizhi-Precision-Tower-5810 \
--to=frank.li@oss.nxp.com \
--cc=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 \
--cc=ravindra.yashvant.shinde@nxp.com \
--cc=samagazaryan@google.com \
--cc=zbigniew.lukwinski@linux.intel.com \
/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
all inboxes | Powered by JetHome®