From: Jason Gunthorpe <jgg@nvidia.com>
To: Mostafa Saleh <smostafa@google.com>
Cc: iommu@lists.linux.dev, Jonathan Hunter <jonathanh@nvidia.com>,
Joerg Roedel <joro@8bytes.org>,
linux-arm-kernel@lists.infradead.org,
linux-tegra@vger.kernel.org, Robin Murphy <robin.murphy@arm.com>,
Thierry Reding <thierry.reding@kernel.org>,
Krishna Reddy <vdumpa@nvidia.com>, Will Deacon <will@kernel.org>,
David Matlack <dmatlack@google.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
patches@lists.linux.dev, Samiullah Khawaja <skhawaja@google.com>
Subject: Re: [PATCH 2/9] iommu/arm-smmu-v3: Use the HW arm_smmu_cmd in cmdq selection functions
Date: Fri, 8 May 2026 12:49:50 -0300 [thread overview]
Message-ID: <20260508154950.GD9254@nvidia.com> (raw)
In-Reply-To: <afxZmOP6m_Khatj8@google.com>
On Thu, May 07, 2026 at 09:21:28AM +0000, Mostafa Saleh wrote:
> > static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu,
> > struct arm_smmu_cmdq_batch *cmds,
> > - struct arm_smmu_cmdq_ent *cmd)
> > + struct arm_smmu_cmdq_ent *ent)
> > {
> > - bool unsupported_cmd = !arm_smmu_cmdq_supports_cmd(cmds->cmdq, cmd);
> > bool force_sync = (cmds->num == CMDQ_BATCH_ENTRIES - 1) &&
> > (smmu->options & ARM_SMMU_OPT_CMDQ_FORCE_SYNC);
> > + struct arm_smmu_cmd cmd;
> > + bool unsupported_cmd;
> > int index;
> >
> > + if (unlikely(arm_smmu_cmdq_build_cmd(cmd.data, ent))) {
> > + dev_warn(smmu->dev, "ignoring unknown CMDQ opcode 0x%x\n",
> > + ent->opcode);
> > + return;
> > + }
> > +
> > + unsupported_cmd = !arm_smmu_cmdq_supports_cmd(cmds->cmdq, &cmd);
> > if (force_sync || unsupported_cmd) {
> > arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds,
> > cmds->num, true);
> > - arm_smmu_cmdq_batch_init(smmu, cmds, cmd);
> > + arm_smmu_cmdq_batch_init_cmd(smmu, cmds, &cmd);
> > }
> >
> > if (cmds->num == CMDQ_BATCH_ENTRIES) {
> > arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds,
> > cmds->num, false);
> > - arm_smmu_cmdq_batch_init(smmu, cmds, cmd);
> > + arm_smmu_cmdq_batch_init_cmd(smmu, cmds, &cmd);
> > }
> >
> > 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));
>
> Maybe this would be better squashed with other arm_smmu_cmdq_batch
> patch to avoid this memcpy, but no strong opinion.
The memcpy has always been there, previously it was effectively inside
arm_smmu_cmdq_build_cmd(), now it is here. A later patch turns it into
a struct variable assignment which is still a memcpy.
The new thing to avoid is the arm_smmu_cmdq_build_cmd() at the top of
the function, which doesn't go away until the last patch.
This memcpy remains throughout the series since it doesn't try
directly initialize the batch in place.. Fixing that is problematic
because all the cmdq selection logic relies on an already formed
command, so we need to construct one before we even know what array
index it will land in.
Unwinding that would probably require restructing how the batch works,
which I think is probably more trouble than value. I hope to
micro-optimize the tlbi flow by removing the batch entirely
eventually. Then we'd be looking at writing the formed invalidation
command directly into the command queue (avoiding another copy on this
path), however I haven't written this and it may not work out.
Thanks,
Jason
next prev parent reply other threads:[~2026-05-08 15:49 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 14:29 [PATCH 0/9] Remove SMMUv3 struct arm_smmu_cmdq_ent Jason Gunthorpe
2026-05-01 14:29 ` [PATCH 1/9] iommu/arm-smmu-v3: Add struct arm_smmu_cmd to represent the HW format command Jason Gunthorpe
2026-05-06 6:11 ` Nicolin Chen
2026-05-06 23:41 ` Samiullah Khawaja
2026-05-07 9:19 ` Mostafa Saleh
2026-05-08 7:29 ` Pranjal Shrivastava
2026-05-01 14:29 ` [PATCH 2/9] iommu/arm-smmu-v3: Use the HW arm_smmu_cmd in cmdq selection functions Jason Gunthorpe
2026-05-07 9:21 ` Mostafa Saleh
2026-05-08 15:49 ` Jason Gunthorpe [this message]
2026-05-08 7:47 ` Pranjal Shrivastava
2026-05-08 15:54 ` Jason Gunthorpe
2026-05-08 16:58 ` Pranjal Shrivastava
2026-05-01 14:29 ` [PATCH 3/9] iommu/arm-smmu-v3: Use the HW arm_smmu_cmd in cmdq submission functions Jason Gunthorpe
2026-05-07 9:21 ` Mostafa Saleh
2026-05-08 8:27 ` Pranjal Shrivastava
2026-05-08 16:00 ` Jason Gunthorpe
2026-05-08 17:00 ` Pranjal Shrivastava
2026-05-01 14:29 ` [PATCH 4/9] iommu/arm-smmu-v3: Convert arm_smmu_cmdq_batch cmds to struct arm_smmu_cmd Jason Gunthorpe
2026-05-07 9:22 ` Mostafa Saleh
2026-05-08 9:26 ` Pranjal Shrivastava
2026-05-01 14:29 ` [PATCH 5/9] iommu/arm-smmu-v3: Remove CMDQ_OP_CFGI_CD_ALL from arm_smmu_cmdq_build_cmd() Jason Gunthorpe
2026-05-07 9:22 ` Mostafa Saleh
2026-05-08 9:45 ` Pranjal Shrivastava
2026-05-08 16:02 ` Jason Gunthorpe
2026-05-08 17:17 ` Pranjal Shrivastava
2026-05-01 14:29 ` [PATCH 6/9] iommu/arm-smmu-v3: Directly encode simple commands Jason Gunthorpe
2026-05-07 9:22 ` Mostafa Saleh
2026-05-08 11:33 ` Pranjal Shrivastava
2026-05-08 17:37 ` Jason Gunthorpe
2026-05-08 20:09 ` Pranjal Shrivastava
2026-05-08 23:36 ` Jason Gunthorpe
2026-05-10 18:59 ` Pranjal Shrivastava
2026-05-01 14:29 ` [PATCH 7/9] iommu/arm-smmu-v3: Directly encode CMDQ_OP_ATC_INV Jason Gunthorpe
2026-05-07 9:23 ` Mostafa Saleh
2026-05-08 11:46 ` Pranjal Shrivastava
2026-05-09 16:54 ` Jason Gunthorpe
2026-05-11 10:34 ` Pranjal Shrivastava
2026-05-01 14:29 ` [PATCH 8/9] iommu/arm-smmu-v3: Directly encode CMDQ_OP_SYNC Jason Gunthorpe
2026-05-07 9:23 ` Mostafa Saleh
2026-05-08 13:41 ` Pranjal Shrivastava
2026-05-01 14:29 ` [PATCH 9/9] iommu/arm-smmu-v3: Directly encode TLBI commands Jason Gunthorpe
2026-05-07 9:24 ` Mostafa Saleh
2026-05-08 14:00 ` Pranjal Shrivastava
2026-05-07 9:26 ` [PATCH 0/9] Remove SMMUv3 struct arm_smmu_cmdq_ent Mostafa Saleh
2026-05-08 14:03 ` Pranjal Shrivastava
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260508154950.GD9254@nvidia.com \
--to=jgg@nvidia.com \
--cc=dmatlack@google.com \
--cc=iommu@lists.linux.dev \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=patches@lists.linux.dev \
--cc=robin.murphy@arm.com \
--cc=skhawaja@google.com \
--cc=smostafa@google.com \
--cc=thierry.reding@kernel.org \
--cc=vdumpa@nvidia.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox