Re: [PATCH v2 03/11] iommu/arm-smmu-v3: Add arm_smmu_drain_queue_for_iopf() helper
From: Pranjal Shrivastava
Date: Wed Jul 29 2026 - 01:21:43 EST
On Tue, Jul 28, 2026 at 03:17:09PM -0700, Nicolin Chen wrote:
> On Tue, Jul 28, 2026 at 09:16:49PM +0000, Pranjal Shrivastava wrote:
> > The following is a unified drain_queue helper, that also attempts to
> > address Sashiko's concerns. This applies on top of my runtime PM v9
> > series [1], please see if it works for you:
> >
> > Subject: [PATCH] iommu/arm-smmu-v3: Add a unified arm_smmu_drain_queue() helper
> >
> > Introduce a unified arm_smmu_drain_queue() helper to replace queue
> > specific polling loops. The helper handles both snapshot-based cohort
> > draining (for IOPF) and full queue draining (required for Runtime PM).
> >
> > The Runtime PM explicitly gates the CMDQ (via CMDQ_PROD_STOP_FLAG) prior
> > to draining, this allows a single, snapshot-based target to natively
> > handle all drain scenarios.
>
> [..]
> > queue_poll_init(smmu, &qp);
> > + qp.wfe = is_cmdq;
>
> The callers of this drain() will be RPM and PRI, either of which
> needs busy-waiting. So, I have added a different drain() helper.
> I run Sashiko locally; it also gives a clean result.
>
Ahh my bad. I meant to set qp.wfe = false, is_cmdq is a rebase remnant...
> Commit:
> https://github.com/nicolinc/iommufd/commit/d10325ff40fd45c476bc98d484d8dd2cdc7fdf95
>
Thanks for sharing this, looks good from the CMDQ side (since we call
this when new CMDQ submissions are gated).
For PRIQ/EVTQ, my only worry was the HW producing more events,
say Device A is detached (we call drain from attach_release) but Device B
(still attached) starts an agressive DMA with multiple PRI requests/evts.
Maybe we should go back to snapshot based polling for that?
Anyway, we can discuss this when the series is posted.
> This will be in my pri-v3 series:
> https://github.com/nicolinc/iommufd/commits/smmuv3_pri-v3
>
> We have too many SMMUv3 under review now. So, I will post it once
> some of them are merged.
>
> Nicolin
Thanks,
Praan