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

Nicolin Chen nicolinc at nvidia.com
Fri Sep 4 17:54:43 PDT 2026


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



More information about the linux-arm-kernel mailing list