[PATCH] iommu/amd: Remove iommu_group_mutex_assert() from amd_iommu_clear_gcr3()

Vasant Hegde <[email protected]>
Newsgroups dev.linux.lists.iommu
Message-ID <[email protected]>
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 <[email protected]>
Signed-off-by: Vasant Hegde <[email protected]>
Tested-by: Liang Wendy <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.