Skip to contentSkip to conversation

iommu/arm-smmu-v3: Disable implementations during devm teardown

PATCH Applied Wentao Guan 4 participants 8 messages Sep 10 – Sep 16 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/arm-smmu-v3: Disable implementations during devm teardown

The Tegra241 CMDQV teardown fix moved VINTF hardware deinitialization into the implementation device_disable() callback. However, its stable backport preceded the conversion to devm teardown and could only invoke the callback from the shutdown path.

Now that arm_smmu_disable_action() manages normal teardown, invoke the implementation callback there while the command queue is still alive. This prevents the subsequent implementation remove action from releasing resources while the CMDQV hardware remains active.

After ("iommu/arm-smmu-v3: Manage teardown with devm") merged in stable, now keep the shutdown path consistent with mainline, where disabling the base SMMU is sufficient.

It is a fix for stable tree commit to aligned with mainline, so no upstream commit id here.

Fixes 5994617e09ee ("iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown")
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +2 -2
index c993e101fab3a..ea908afb0da9d 100644
@@ -4789,6 +4789,8 @@ static void arm_smmu_disable_action(void *data)
 {
 	struct arm_smmu_device *smmu = data;
 
+	if (smmu->impl_ops && smmu->impl_ops->device_disable)
+		smmu->impl_ops->device_disable(smmu);
 	arm_smmu_device_disable(smmu);
 }
 
@@ -5621,8 +5623,6 @@ static void arm_smmu_device_shutdown(struct platform_device *pdev)
 {
 	struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
 
-	if (smmu->impl_ops && smmu->impl_ops->device_disable)
-		smmu->impl_ops->device_disable(smmu);
 	arm_smmu_device_disable(smmu);
 }
 
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 4 lines

The Tegra241 CMDQV teardown fix moved VINTF hardware deinitialization into the implementation device_disable() callback. However, its stable backport preceded the conversion to devm teardown and could only invoke the callback from the shutdown path.

This is a stable-only change for 7.2.y with no upstream commit to point at. Since it has no Reviewed-by or Acked-by from an arm-smmu-v3 or tegra241-cmdqv maintainer, we need that before queuing a stable-only fix.

Could you get a maintainer ack for this?

Signature · 2 lines
Thanks,
Sasha
Reviewed-by on v1 1/1
#2 lore raw
In reply to Wentao Guan
Quoted 56 lines

-----Original Message-----
From: Wentao Guan <[email protected]>
Sent: 10 September 2026 07:54
To: [email protected]; Jason Gunthorpe <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Shameer Kolothum Thodi <[email protected]>; Wentao Guan <[email protected]>
Subject: [PATCH 7.2.y] iommu/arm-smmu-v3: Disable implementations during devm teardown

External email: Use caution opening links or attachments

The Tegra241 CMDQV teardown fix moved VINTF hardware deinitialization into the implementation device_disable() callback. However, its stable backport preceded the conversion to devm teardown and could only invoke the callback from the shutdown path.

Now that arm_smmu_disable_action() manages normal teardown, invoke the implementation callback there while the command queue is still alive. This prevents the subsequent implementation remove action from releasing resources while the CMDQV hardware remains active.

After ("iommu/arm-smmu-v3: Manage teardown with devm") merged in stable,
now keep the shutdown path consistent with mainline, where disabling the base SMMU is sufficient.

It is a fix for stable tree commit to aligned with mainline, so no upstream commit id here.

Fixes 5994617e09ee ("iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free

on teardown")

---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +2 -0
index c993e101fab3a..ea908afb0da9d 100644
@@ -4789,6 +4789,8 @@ static void arm_smmu_disable_action(void *data)
 {
        struct arm_smmu_device *smmu = data;
 
+       if (smmu->impl_ops && smmu->impl_ops->device_disable)
+               smmu->impl_ops->device_disable(smmu);
        arm_smmu_device_disable(smmu);
 }
 

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c static void arm_smmu_device_shutdown(struct · line 5628

Quoted 8 lines
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0 -2
@@ -5621,8 +5623,6 @@ static void arm_smmu_device_shutdown(struct
 platform_device *pdev)
 {
        struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
 
-       if (smmu->impl_ops && smmu->impl_ops->device_disable)
-               smmu->impl_ops->device_disable(smmu);
        arm_smmu_device_disable(smmu);
 }

LGTM;

Thanks,
Shameer

Acked-by on v1 1/1
#3 lore raw
In reply to Wentao Guan
Quoted 4 lines · Wentao Guan

The Tegra241 CMDQV teardown fix moved VINTF hardware deinitialization into the implementation device_disable() callback. However, its stable backport preceded the conversion to devm teardown and could only invoke the callback from the shutdown path.

Hmm, it did...

[correct in mainline]
git log --oneline v7.3-rc1 drivers/iommu/arm/arm-smmu-v3/
...
9ff145a25c5c8 iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown 2bd22a0d40503 iommu/arm-smmu-v3: Manage teardown with devm
...

[inverted in two trees]
git log --oneline v7.2.5 drivers/iommu/arm/arm-smmu-v3/
...
78fd5a2d65f35 iommu/arm-smmu-v3: Manage teardown with devm f9b7375db3b36 iommu/arm-smmu-v3: Add HAFT support for SVA 5994617e09ee6 iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown
...

git log --oneline v6.18.51 drivers/iommu/arm/arm-smmu-v3/
...
2235eafda9b3d iommu/arm-smmu-v3: Manage teardown with devm d903d99ffd22b iommu/tegra241-cmdqv: Reject a vSID wider than the SID_MATCH field d2ab08437e913 iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown
...

[missing cmdqv fix]
git log --oneline v6.12.109 -33 drivers/iommu/arm/arm-smmu-v3/
...
981686f413776 iommu/arm-smmu-v3: Manage teardown with devm
...

Patch itself looks good to me for v7.2 stable and v6.8 longterm.

But v6.12 longterm might need some extra fix, Sasha?

Quoted 9 lines

Now that arm_smmu_disable_action() manages normal teardown, invoke the implementation callback there while the command queue is still alive. This prevents the subsequent implementation remove action from releasing resources while the CMDQV hardware remains active.

After ("iommu/arm-smmu-v3: Manage teardown with devm") merged in stable, now keep the shutdown path consistent with mainline, where disabling the base SMMU is sufficient.

Quoted 5 lines

It is a fix for stable tree commit to aligned with mainline, so no upstream commit id here.

Fixes 5994617e09ee ("iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown")
maintainer Applied
#4 lore raw
Quoted 1 line

Patch itself looks good to me for v7.2 stable and v6.8 longterm.

Queued for 6.18, thanks.

Quoted 1 line

But v6.12 longterm might need some extra fix, Sasha?

It does, but a different one. 6.12 has the devm teardown conversion and never got 9ff145a25c5c ("iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown") at all, so what it is missing is that commit rather than this ordering fixup. It does not apply to 6.12 as-is either, because the tegra241_cmdqv_destroy_vintf_user() hunk has no counterpart there.

Could one of you send an adapted 6.12.y version with that hunk dropped?

Signature · 2 lines
Thanks,
Sasha
#5 lore raw
Quoted 6 lines · Sasha Levin
Quoted 1 line

Patch itself looks good to me for v7.2 stable and v6.8 longterm.

Queued for 6.18, thanks.

Quoted 1 line

But v6.12 longterm might need some extra fix, Sasha?

Quoted 7 lines

It does, but a different one. 6.12 has the devm teardown conversion and never got 9ff145a25c5c ("iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown") at all, so what it is missing is that commit rather than this ordering fixup. It does not apply to 6.12 as-is either, because the tegra241_cmdqv_destroy_vintf_user() hunk has no counterpart there.

Could one of you send an adapted 6.12.y version with that hunk dropped?

Shameer, would you mind helping backport your patch onto 6.12.y?

Thanks
Nicolin

#6 lore raw
Quoted 28 lines

-----Original Message-----
From: Nicolin Chen <[email protected]>
Sent: 15 September 2026 18:10
To: Sasha Levin <[email protected]>; Shameer Kolothum Thodi <[email protected]>
Cc: Wentao Guan <[email protected]>; Jason Gunthorpe <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 7.2.y] iommu/arm-smmu-v3: Disable implementations during devm teardown

Quoted 14 lines · Sasha Levin
Quoted 1 line

Patch itself looks good to me for v7.2 stable and v6.8 longterm.

Queued for 6.18, thanks.

Quoted 1 line

But v6.12 longterm might need some extra fix, Sasha?

It does, but a different one. 6.12 has the devm teardown conversion and never got 9ff145a25c5c ("iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on
teardown") at all, so what it is missing is that commit rather than this ordering fixup. It does not apply to 6.12 as-is either, because the
tegra241_cmdqv_destroy_vintf_user() hunk has no counterpart there.

Quoted 3 lines
Quoted 1 line

Could one of you send an adapted 6.12.y version with that hunk dropped?

Shameer, would you mind helping backport your patch onto 6.12.y?

Sure, I will take a look.

Thanks,
Shameer

maintainer Applied
#7 lore raw
In reply to Wentao Guan
Quoted 7 lines

Now that arm_smmu_disable_action() manages normal teardown, invoke the implementation callback there while the command queue is still alive. This prevents the subsequent implementation remove action from releasing resources while the CMDQV hardware remains active.

Fixes 5994617e09ee ("iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown")

Queued for 7.2, thanks.

Signature · 2 lines
Thanks,
Sasha