* [PATCH] iommu/amd: Remove iommu_group_mutex_assert() from amd_iommu_clear_gcr3()
@ 2026-08-14 10:40 Vasant Hegde
2026-08-17 13:51 ` Jason Gunthorpe
2026-09-07 12:28 ` Jörg Rödel
0 siblings, 2 replies; 3+ messages in thread
From: Vasant Hegde @ 2026-08-14 10:40 UTC (permalink / raw)
To: iommu, joro
Cc: will, robin.murphy, suravee.suthikulpanit, Vasant Hegde, Max Zhen,
Liang Wendy
amd_iommu_clear_gcr3() is called from sva_mn_release() during the
mmu_notifier release path to detach a PASIDs when a process exits.
This path does not hold the iommu group mutex, since it is invoked
asynchronously from mm teardown context rather than through the normal
IOMMU group/attach APIs.
As a result, the iommu_group_mutex_assert() check in
amd_iommu_clear_gcr3() logs a kernel warning.
[62863.761300] ------------[ cut here ]------------
[62863.761320] WARNING: drivers/iommu/iommu.c:1361 at iommu_group_mutex_assert+0x3a/0x50, CPU#14: kworker/14:2/621
...
[62863.761706] <TASK>
[62863.761712] amd_iommu_clear_gcr3+0x1e/0x50
[62863.761724] sva_mn_release+0x68/0xd0
[62863.761739] __mmu_notifier_release+0xb9/0x2d0
[62863.761763] exit_mmap+0x427/0x460
[62863.761836] __mmput+0x41/0x120
[62863.761844] mmput_async_fn+0x15/0x20
[62863.761852] process_one_work+0x22e/0x780
[62863.761876] worker_thread+0x1b5/0x380
[62863.761892] kthread+0x10d/0x150
[62863.761913] ret_from_fork+0x346/0x3c0
[62863.761930] ret_from_fork_asm+0x1a/0x30
[62863.761964] </TASK>
Remove the iommu_group_mutex_assert() call from
amd_iommu_clear_gcr3(), since PASID teardown via the mmu_notifier
release path is a legitimate caller that does not and need not hold
the group mutex.
Fixes: 1af95763e0a3 ("iommu/amd: Initial SVA support for AMD IOMMU")
Reported-by: Max Zhen <max.zhen@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Tested-by: Liang Wendy <Wendy.Liang@amd.com>
---
drivers/iommu/amd/iommu.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 29dc18d3d22e..1fe99fb98793 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2063,8 +2063,6 @@ int amd_iommu_clear_gcr3(struct iommu_dev_data *dev_data, ioasid_t pasid)
struct gcr3_tbl_info *gcr3_info = &dev_data->gcr3_info;
int ret;
- iommu_group_mutex_assert(dev_data->dev);
-
ret = update_gcr3(dev_data, pasid, 0, false);
if (ret)
return ret;
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/amd: Remove iommu_group_mutex_assert() from amd_iommu_clear_gcr3()
2026-08-14 10:40 [PATCH] iommu/amd: Remove iommu_group_mutex_assert() from amd_iommu_clear_gcr3() Vasant Hegde
@ 2026-08-17 13:51 ` Jason Gunthorpe
2026-09-07 12:28 ` Jörg Rödel
1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2026-08-17 13:51 UTC (permalink / raw)
To: Vasant Hegde
Cc: iommu, joro, will, robin.murphy, suravee.suthikulpanit, Max Zhen,
Liang Wendy
On Fri, Aug 14, 2026 at 10:40:29AM +0000, Vasant Hegde wrote:
> Remove the iommu_group_mutex_assert() call from
> amd_iommu_clear_gcr3(), since PASID teardown via the mmu_notifier
> release path is a legitimate caller that does not and need not hold
> the group mutex.
Why doesn't it?
Right below this line is:
gcr3_info->pasid_cnt--;
Which certainly needs the lock.
In the ARM driver this async release notifier was pretty tricky to
lock properly. It just updates the equivilent to the GCR3 entry to
make it disabled and doesn't touch anything else. This is locked in a
way so that concurrent domain detach doesn't face any races.
AMD should have the same basic design here too.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/amd: Remove iommu_group_mutex_assert() from amd_iommu_clear_gcr3()
2026-08-14 10:40 [PATCH] iommu/amd: Remove iommu_group_mutex_assert() from amd_iommu_clear_gcr3() Vasant Hegde
2026-08-17 13:51 ` Jason Gunthorpe
@ 2026-09-07 12:28 ` Jörg Rödel
1 sibling, 0 replies; 3+ messages in thread
From: Jörg Rödel @ 2026-09-07 12:28 UTC (permalink / raw)
To: Vasant Hegde
Cc: iommu, will, robin.murphy, suravee.suthikulpanit, Max Zhen,
Liang Wendy
On Fri, Aug 14, 2026 at 10:40:29AM +0000, Vasant Hegde wrote:
> Remove the iommu_group_mutex_assert() call from
> amd_iommu_clear_gcr3(), since PASID teardown via the mmu_notifier
> release path is a legitimate caller that does not and need not hold
> the group mutex.
Jason is right, there is a race around pasid_cnt. Either make that atomic, or,
since it is never read, remove it.
-Joerg
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-07 12:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 10:40 [PATCH] iommu/amd: Remove iommu_group_mutex_assert() from amd_iommu_clear_gcr3() Vasant Hegde
2026-08-17 13:51 ` Jason Gunthorpe
2026-09-07 12:28 ` Jörg Rödel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.