[PATCH 2/9] iommu/arm-smmu-v3: Use the HW arm_smmu_cmd in cmdq selection functions
Jason Gunthorpe
jgg at nvidia.com
Fri May 8 08:54:32 PDT 2026
On Fri, May 08, 2026 at 07:47:45AM +0000, Pranjal Shrivastava wrote:
> On Fri, May 01, 2026 at 11:29:11AM -0300, Jason Gunthorpe wrote:
> > Start removing the use of struct arm_smmu_cmdq_ent, starting at the
> > lower levels of the call chain. Change the functions that determine what
> > cmdq to issue the batch to into using struct arm_smmu_cmd directly.
> >
> > Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>
> > ---
> > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 47 ++++++++++++-------
> > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 8 ++--
> > .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 8 ++--
> > 3 files changed, 38 insertions(+), 25 deletions(-)
>
> [...]
>
> > index = cmds->num * CMDQ_ENT_DWORDS;
> > - if (unlikely(arm_smmu_cmdq_build_cmd(&cmds->cmds[index], cmd))) {
> > - dev_warn(smmu->dev, "ignoring unknown CMDQ opcode 0x%x\n",
> > - cmd->opcode);
> > - return;
> > - }
> > -
> > + memcpy(&cmds->cmds[index], cmd.data, sizeof(cmd.data));
> > cmds->num++;
> > }
>
> The memcpy is a temporary step and goes way in Patch 4.
To be clear patch 4 still has the memcpy:
- index = cmds->num * CMDQ_ENT_DWORDS;
- memcpy(&cmds->cmds[index], cmd.data, sizeof(cmd.data));
- cmds->num++;
+ cmds->cmds[cmds->num++] = cmd;
^^^^^^^^^^^
The compiler just builds it.
The flow evolution is:
Now:
struct arm_smmu_cmdq_ent (stack) -> arm_smmu_cmdq_build_cmd (batch) -> memcpy (queue)
Here:
struct arm_smmu_cmdq_ent (stack) -> arm_smmu_cmdq_build_cmd (stack) -> memcpy (batch) -> memcpy (queue)
Done:
struct arm_smmu_cmd (stack) -> memcpy (batch) -> memcpy (queue)
So the net result is the same before/after this series, we just carry
an extra stack copy till the last patch.
Thanks,
Jason
More information about the linux-arm-kernel
mailing list