None of the callers of arm_smmu_cmdq_batch_submit() cares about the batch
after a submission. So, it'll be certainly safe to nuke the cmds->num, at
least upon a successful one. This will ease a bit a wrapper function, for
the new arm_smmu_invs structure.
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 2a8b46b948f05..cccf8f52ee0d5 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -974,11 +974,17 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu,
cmds->num++;
}
+/* Clears cmds->num after a successful submission */
static int arm_smmu_cmdq_batch_submit(struct arm_smmu_device *smmu,
struct arm_smmu_cmdq_batch *cmds)
{
- return arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds,
- cmds->num, true);
+ int ret;
+
+ ret = arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds,
+ cmds->num, true);
+ if (!ret)
+ cmds->num = 0;
+ return ret;
}
static void arm_smmu_page_response(struct device *dev, struct iopf_fault *unused,
--
2.43.0
On Mon, Sep 08, 2025 at 04:26:55PM -0700, Nicolin Chen wrote: > None of the callers of arm_smmu_cmdq_batch_submit() cares about the batch > after a submission. So, it'll be certainly safe to nuke the cmds->num, at > least upon a successful one. This will ease a bit a wrapper function, for > the new arm_smmu_invs structure. This was added when arm_smmu_cmdq_batch_submit() was needed by a new arm_smmu_invs helper that used it at a few places. But after a few rounds of rework, I found that there is only one call now. I will drop this patch. Thanks Nicolin
On 9/9/25 09:26, Nicolin Chen wrote:
> None of the callers of arm_smmu_cmdq_batch_submit() cares about the batch
> after a submission. So, it'll be certainly safe to nuke the cmds->num, at
> least upon a successful one. This will ease a bit a wrapper function, for
> the new arm_smmu_invs structure.
>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 2a8b46b948f05..cccf8f52ee0d5 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -974,11 +974,17 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu,
> cmds->num++;
> }
>
> +/* Clears cmds->num after a successful submission */
> static int arm_smmu_cmdq_batch_submit(struct arm_smmu_device *smmu,
> struct arm_smmu_cmdq_batch *cmds)
> {
Nit: arm_smmu_cmdq_batch_submit_clear()?
> - return arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds,
> - cmds->num, true);
> + int ret;
> +
> + ret = arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmdq, cmds->cmds,
> + cmds->num, true);
> + if (!ret)
> + cmds->num = 0;
> + return ret;
> }
>
> static void arm_smmu_page_response(struct device *dev, struct iopf_fault *unused,
Acked-by: Balbir Singh <balbirs@nvidia.com>
Balbir
On Tue, Sep 09, 2025 at 01:16:11PM +1000, Balbir Singh wrote:
> On 9/9/25 09:26, Nicolin Chen wrote:
> > None of the callers of arm_smmu_cmdq_batch_submit() cares about the batch
> > after a submission. So, it'll be certainly safe to nuke the cmds->num, at
> > least upon a successful one. This will ease a bit a wrapper function, for
> > the new arm_smmu_invs structure.
> >
> > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> > ---
> > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > index 2a8b46b948f05..cccf8f52ee0d5 100644
> > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > @@ -974,11 +974,17 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu,
> > cmds->num++;
> > }
> >
> > +/* Clears cmds->num after a successful submission */
> > static int arm_smmu_cmdq_batch_submit(struct arm_smmu_device *smmu,
> > struct arm_smmu_cmdq_batch *cmds)
> > {
>
> Nit: arm_smmu_cmdq_batch_submit_clear()?
Probably not. There is no particular point in highlighting it in
the function name, as there is no use case wanting an uncleared
version.
Thanks
Nicolin
On 9/9/25 15:42, Nicolin Chen wrote:
> On Tue, Sep 09, 2025 at 01:16:11PM +1000, Balbir Singh wrote:
>> On 9/9/25 09:26, Nicolin Chen wrote:
>>> None of the callers of arm_smmu_cmdq_batch_submit() cares about the batch
>>> after a submission. So, it'll be certainly safe to nuke the cmds->num, at
>>> least upon a successful one. This will ease a bit a wrapper function, for
>>> the new arm_smmu_invs structure.
>>>
>>> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
>>> ---
>>> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++++++++--
>>> 1 file changed, 8 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>> index 2a8b46b948f05..cccf8f52ee0d5 100644
>>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
>>> @@ -974,11 +974,17 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu,
>>> cmds->num++;
>>> }
>>>
>>> +/* Clears cmds->num after a successful submission */
>>> static int arm_smmu_cmdq_batch_submit(struct arm_smmu_device *smmu,
>>> struct arm_smmu_cmdq_batch *cmds)
>>> {
>>
>> Nit: arm_smmu_cmdq_batch_submit_clear()?
>
> Probably not. There is no particular point in highlighting it in
> the function name, as there is no use case wanting an uncleared
> version.
I did not suggest we need an uncleared version, I suggested the change
in name to highlight that the function has a side-effect of clearing
the cmds->num
Thanks,
Balbir
On Wed, Sep 10, 2025 at 08:49:52AM +1000, Balbir Singh wrote:
> On 9/9/25 15:42, Nicolin Chen wrote:
> > On Tue, Sep 09, 2025 at 01:16:11PM +1000, Balbir Singh wrote:
> >> On 9/9/25 09:26, Nicolin Chen wrote:
> >>> None of the callers of arm_smmu_cmdq_batch_submit() cares about the batch
> >>> after a submission. So, it'll be certainly safe to nuke the cmds->num, at
> >>> least upon a successful one. This will ease a bit a wrapper function, for
> >>> the new arm_smmu_invs structure.
> >>>
> >>> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> >>> ---
> >>> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++++++++--
> >>> 1 file changed, 8 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >>> index 2a8b46b948f05..cccf8f52ee0d5 100644
> >>> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >>> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> >>> @@ -974,11 +974,17 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu,
> >>> cmds->num++;
> >>> }
> >>>
> >>> +/* Clears cmds->num after a successful submission */
> >>> static int arm_smmu_cmdq_batch_submit(struct arm_smmu_device *smmu,
> >>> struct arm_smmu_cmdq_batch *cmds)
> >>> {
> >>
> >> Nit: arm_smmu_cmdq_batch_submit_clear()?
> >
> > Probably not. There is no particular point in highlighting it in
> > the function name, as there is no use case wanting an uncleared
> > version.
>
> I did not suggest we need an uncleared version, I suggested the change
> in name to highlight that the function has a side-effect of clearing
> the cmds->num
No caller cares about the "side effect"...
Nicolin
© 2016 - 2026 Red Hat, Inc.