* [PATCH] iommu/sva: remove iommu_sva_present flag
@ 2026-08-23 9:24 Zhaoyu Liu
2026-08-27 13:10 ` Jason Gunthorpe
2026-09-02 1:37 ` Baolu Lu
0 siblings, 2 replies; 4+ messages in thread
From: Zhaoyu Liu @ 2026-08-23 9:24 UTC (permalink / raw)
To: joro, will, robin.murphy, baolu.lu; +Cc: iommu, linux-kernel
The global iommu_sva_present bool merely mirrors
!list_empty(&iommu_sva_mms) under the same mutex. Remove it and rely
on list_for_each_entry to handle the empty list case, which is a no-op.
Signed-off-by: Zhaoyu Liu <liuzhaoyu.zackary@picoheart.com>
---
drivers/iommu/iommu-sva.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c
index 9742cb593577..9827cb804363 100644
--- a/drivers/iommu/iommu-sva.c
+++ b/drivers/iommu/iommu-sva.c
@@ -11,7 +11,6 @@
#include "iommu-priv.h"
static DEFINE_MUTEX(iommu_sva_lock);
-static bool iommu_sva_present;
static LIST_HEAD(iommu_sva_mms);
static struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
struct mm_struct *mm);
@@ -137,11 +136,9 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
goto out_free_domain;
domain->users = 1;
- if (list_empty(&iommu_mm->sva_domains)) {
- if (list_empty(&iommu_sva_mms))
- iommu_sva_present = true;
+ if (list_empty(&iommu_mm->sva_domains))
list_add(&iommu_mm->mm_list_elm, &iommu_sva_mms);
- }
+
list_add(&domain->next, &iommu_mm->sva_domains);
out:
refcount_set(&handle->users, 1);
@@ -182,11 +179,8 @@ void iommu_sva_unbind_device(struct iommu_sva *handle)
iommu_detach_device_pasid(domain, dev, iommu_mm->pasid);
if (--domain->users == 0) {
list_del(&domain->next);
- if (list_empty(&iommu_mm->sva_domains)) {
+ if (list_empty(&iommu_mm->sva_domains))
list_del(&iommu_mm->mm_list_elm);
- if (list_empty(&iommu_sva_mms))
- iommu_sva_present = false;
- }
iommu_domain_free(domain);
}
@@ -334,8 +328,6 @@ void iommu_sva_invalidate_kva_range(unsigned long start, unsigned long end)
struct iommu_mm_data *iommu_mm;
guard(mutex)(&iommu_sva_lock);
- if (!iommu_sva_present)
- return;
list_for_each_entry(iommu_mm, &iommu_sva_mms, mm_list_elm)
mmu_notifier_arch_invalidate_secondary_tlbs(iommu_mm->mm, start, end);
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] iommu/sva: remove iommu_sva_present flag
2026-08-23 9:24 [PATCH] iommu/sva: remove iommu_sva_present flag Zhaoyu Liu
@ 2026-08-27 13:10 ` Jason Gunthorpe
2026-09-01 8:21 ` Zhaoyu Liu
2026-09-02 1:37 ` Baolu Lu
1 sibling, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2026-08-27 13:10 UTC (permalink / raw)
To: Zhaoyu Liu; +Cc: joro, will, robin.murphy, baolu.lu, iommu, linux-kernel
On Sun, Aug 23, 2026 at 05:24:36PM +0800, Zhaoyu Liu wrote:
> The global iommu_sva_present bool merely mirrors
> !list_empty(&iommu_sva_mms) under the same mutex. Remove it and rely
> on list_for_each_entry to handle the empty list case, which is a no-op.
>
> Signed-off-by: Zhaoyu Liu <liuzhaoyu.zackary@picoheart.com>
> ---
> drivers/iommu/iommu-sva.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/sva: remove iommu_sva_present flag
2026-08-27 13:10 ` Jason Gunthorpe
@ 2026-09-01 8:21 ` Zhaoyu Liu
0 siblings, 0 replies; 4+ messages in thread
From: Zhaoyu Liu @ 2026-09-01 8:21 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: joro, will, robin.murphy, baolu.lu, iommu, linux-kernel
Thank you, Jason.
Hi joro, will, robin, baolu,
could you help merge this patch?
Thanks,
zackary
On Thu, Aug 27, 2026 at 10:10:25AM -0300, Jason Gunthorpe wrote:
> On Sun, Aug 23, 2026 at 05:24:36PM +0800, Zhaoyu Liu wrote:
> > The global iommu_sva_present bool merely mirrors
> > !list_empty(&iommu_sva_mms) under the same mutex. Remove it and rely
> > on list_for_each_entry to handle the empty list case, which is a no-op.
> >
> > Signed-off-by: Zhaoyu Liu <liuzhaoyu.zackary@picoheart.com>
> > ---
> > drivers/iommu/iommu-sva.c | 14 +++-----------
> > 1 file changed, 3 insertions(+), 11 deletions(-)
>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
>
> Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/sva: remove iommu_sva_present flag
2026-08-23 9:24 [PATCH] iommu/sva: remove iommu_sva_present flag Zhaoyu Liu
2026-08-27 13:10 ` Jason Gunthorpe
@ 2026-09-02 1:37 ` Baolu Lu
1 sibling, 0 replies; 4+ messages in thread
From: Baolu Lu @ 2026-09-02 1:37 UTC (permalink / raw)
To: Zhaoyu Liu, joro, will, robin.murphy; +Cc: baolu.lu, iommu, linux-kernel
On 8/23/2026 5:24 PM, Zhaoyu Liu wrote:
> The global iommu_sva_present bool merely mirrors
> !list_empty(&iommu_sva_mms) under the same mutex. Remove it and rely
> on list_for_each_entry to handle the empty list case, which is a no-op.
>
> Signed-off-by: Zhaoyu Liu<liuzhaoyu.zackary@picoheart.com>
> ---
> drivers/iommu/iommu-sva.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-02 1:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-23 9:24 [PATCH] iommu/sva: remove iommu_sva_present flag Zhaoyu Liu
2026-08-27 13:10 ` Jason Gunthorpe
2026-09-01 8:21 ` Zhaoyu Liu
2026-09-02 1:37 ` Baolu Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®