Re: [PATCH v3 04/13] iommu/arm-smmu-v3: Flush in-flight fault work on domain detach

From: Nicolin Chen

Date: Fri Sep 04 2026 - 20:55:44 EST


On Thu, Sep 03, 2026 at 12:18:33PM -0700, Jonathan Cameron wrote:
> > arm_smmu_attach_release() polls the hardware event queue to drain all the
> > in-flight stall events for an old domain that the IOMMU core might free at
> > any moment. However, a drained event is dequeued, yet it is not necessarily
> > handled, and the IOPF work for a handled one can still be running.
> >
> > So, first synchronize_irq() on the evtq and the combined IRQs following the
> > drain, in order to guarantee that every dequeued event has reached the IOPF
> > workqueue, since synchronize_irq() waits for an in-flight IRQ thread. Skip
> > the waits on a timed-out drain though, since a stuck consumer would block
>
> drop the "though" - doesn't read well or add anything.

Done.

> > - if (master->stall_enabled)
> > - arm_smmu_drain_queue(smmu, &smmu->evtq.q, false);
> > + if (master->stall_enabled) {
> > + ret = arm_smmu_drain_queue(smmu, &smmu->evtq.q, false);
> > + /*
> > + * Ensure pending events have reached the IOPF queue, unless
> > + * the drain timed out: a stuck consumer would also block an
> > + * unbounded wait_event() inside the synchronize_irq().
> > + */
> > + if (!ret && smmu->evtq.q.irq)
> > + synchronize_irq(smmu->evtq.q.irq);
> > + /* Pending events might be in the combined_irq handler */
> > + if (!ret && smmu->combined_irq)
> > + synchronize_irq(smmu->combined_irq);
>
> I'd group the two things that happen if we didn't time out.

I folded this in.

@@ -3423,11 +3423,13 @@ void arm_smmu_attach_release(struct arm_smmu_attach_state *state)
* the drain timed out: a stuck consumer would also block an
* unbounded wait_event() inside the synchronize_irq().
*/
- if (!ret && smmu->evtq.q.irq)
- synchronize_irq(smmu->evtq.q.irq);
- /* Pending events might be in the combined_irq handler */
- if (!ret && smmu->combined_irq)
- synchronize_irq(smmu->combined_irq);
+ if (!ret) {
+ if (smmu->evtq.q.irq)
+ synchronize_irq(smmu->evtq.q.irq);
+ /* Pending events might be in the combined_irq handler */
+ if (smmu->combined_irq)
+ synchronize_irq(smmu->combined_irq);
+ }
}

/*

Thanks
Nicolin