From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from va-2-38.ptr.blmpb.com (va-2-38.ptr.blmpb.com [209.127.231.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 668E949365C for ; Sun, 23 Aug 2026 09:26:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.231.38 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787477212; cv=none; b=tFFQI3BMX261rUumRPapWX0rM0yB3xf6fiHKayv3tfS9FHAd/JhsFqsvr2Q66MYZLSQw8apKlm9ioqXc2UJF9/poFWbzvXn4KeTFtJBJYzEHzBKE6bqfUO2MTCf9OhVNMJAfIlyTq0zVkvTQazTBN5X5c9dhKy0KwlucPAEOQvU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787477212; c=relaxed/simple; bh=mFmuc8txXQV1mSCtBgY5fi2jVBmaQsTnfcp0PU4WNA4=; h=Mime-Version:To:Date:Message-Id:Content-Type:Subject: Content-Disposition:Cc:From; b=Qg5wlesV4u2qIkuFuKUebYPsVEc3G2brNwGa21uoZXZxNTW9d7vvKbOBISs9Fyj9QETghszA5g4MN7a9eirB+/xvl914nZCv9cGdT2GbfxIQTx8N1oeBKK+fMsu9y5iOJl8NsjHtASM/8sdwhY/QHH/Kf+PuvTzVMMxtyLpPoeY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=picoheart.com; spf=pass smtp.mailfrom=picoheart.com; dkim=pass (2048-bit key) header.d=picoheart.com header.i=@picoheart.com header.b=pErTlrf0; arc=none smtp.client-ip=209.127.231.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=picoheart.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=picoheart.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=picoheart.com header.i=@picoheart.com header.b="pErTlrf0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2604151535; d=picoheart.com; t=1787477081; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=T2ArGZLXfhkmEHUMH8ojDXGpECLiQ7Phad9SUPlEop8=; b=pErTlrf0uAdA8bRJT1sqjLNDqiKZV+DLKbohni3lqSb/OTBrKVhiTuGWZvZJvcoYha0WmZ yXRsdwtmD68lJhuG5hlHnYYp2wW1lvsCNP4wSHp5jSmwkNQQgnbIYJFzeMpFWLaxq25bcc YdZ2OiGGbb3PM64ZxfNZx7+uB0WGVQZZiFLqDxhpaUnrW5AHnr1IamugY0/Qp0iQvDi222 JMKzCaw73lo5wBtwouQl0h497kVJnRfUnzYC+KAVP9gv3yocwCRM4i9arthvPThyNKKnUl fsNsiLTMSnX5EAPiatM/qdShauK6WMJszPYsxFRYML3NnD+FINpnQ5+a90WQbw== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit To: , , , Date: Sun, 23 Aug 2026 17:24:36 +0800 X-Original-From: Zhaoyu Liu Received: from hostpc ([124.160.26.250]) by smtp.feishu.cn with ESMTPS; Sun, 23 Aug 2026 17:24:39 +0800 X-Lms-Return-Path: Message-Id: Content-Type: text/plain; charset=UTF-8 Subject: [PATCH] iommu/sva: remove iommu_sva_present flag Content-Disposition: inline Cc: , From: "Zhaoyu Liu" 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 --- 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