Subject: Re: [PATCH v8 09/12] iommu/arm-smmu-v3: Implement pm_runtime & system sleep ops

From: Pranjal Shrivastava <[email-masked]>
Date: Tue, 2 Jun 2026 12:12:16 +0000

On Mon, Jun 01, 2026 at 10:25:41PM -0700, Daniel Mentz wrote:
> On Mon, Jun 1, 2026 at 2:59 PM Pranjal Shrivastava <[email-masked]> wrote:
> 
> > +       /* Drain the CMDQs */
> > +       ret = arm_smmu_drain_queues(smmu);
> > +       if (ret)
> > +               dev_warn(smmu->dev, "failed to drain queues, forcing suspend\n");
> 
> Can arm_smmu_drain_queues() be called after cmdq->lock is 0? I think
> that way we can be sure that no other thread updates smmu->cmdq.q.cons
>

Hmm.. that wouldn't work for impl-specific CMDQs as we STOP and drain
them together in a single function.. maybe I'll factor out setting the
STOP_FLAG on impl-specific queues as another impl_op, gate the queues
first, wait for lock == 0 and then drain_queues?

> > +
> > +       /* Wait for cmdq->lock == 0 to ensure last CMDQ_CONS_REG is written */
> > +       timeout = ARM_SMMU_SUSPEND_TIMEOUT_US;
> > +       while (atomic_read(&cmdq->lock) != 0 && --timeout)
> > +               udelay(1);
> > +
> > +       /* Timing out here implies misconfigured Runtime PM or broken devlinks */
> > +       if (!timeout)
> > +               dev_err(smmu->dev, "cmdq lock != 0, forcing suspend. Polling CPUs may fault.\n");

Thanks,
Praan