Re: [PATCH v7 1/2] iommu/arm-smmu-v3: Add a cmdq_max_n_shift module parameter

From: Nicolin Chen

Date: Fri Sep 25 2026 - 15:03:46 EST


On Fri, Sep 25, 2026 at 03:15:29PM +0100, Kiryl Shutsemau wrote:
> From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>
>
> The command queue depth comes straight from the maximum the hardware
> advertises in IDR1, which reaches megabytes of coherent DMA per queue.
> A system with several SMMUv3 instances pays that per instance, and the
> Tegra241 CMDQV pays it again for every VCMDQ it preallocates.
>
> Queue depth only bounds how many commands may be in flight before a sync.
> A machine driving a handful of devices, or one with a tight memory budget,
> has no use for the maximum, and no way to say so.
>
> Add cmdq_max_n_shift, a cap on the depth given as the log2 of the entry
> count, the form the hardware itself takes in the LOG2SIZE field of
> CMDQ_BASE. It defaults to the largest depth the driver allocates, so an
> unset parameter changes nothing. Decide the depth in
> arm_smmu_cmdq_max_n_shift(), which applies the parameter to the IDR1
> value, so the queue is allocated at the requested size. The Tegra241 CMDQV
> sizes its VCMDQs from IDR1 itself, so route that through the same helper.
>
> Floor the request at one page worth of entries. Without the floor, a small
> request trips the CMDQ_BATCH_ENTRIES check in arm_smmu_device_hw_probe()
> and the SMMU fails to probe. The floor also costs nothing: coherent DMA is
> page granular, so a shallower queue occupies the same memory as one that
> fills the page.
>
> Assisted-by: LLM
> Reviewed-by: Breno Leitao <leitao@xxxxxxxxxx>
> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>

Reviewed-by: Nicolin Chen <nicolinc@xxxxxxxxxx>
Tested-by: Nicolin Chen <nicolinc@xxxxxxxxxx>