From nobody Tue Sep 16 10:58:58 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6973CC4708E for ; Wed, 4 Jan 2023 13:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239403AbjADNMO (ORCPT ); Wed, 4 Jan 2023 08:12:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239445AbjADNLG (ORCPT ); Wed, 4 Jan 2023 08:11:06 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A4CC3E0FA for ; Wed, 4 Jan 2023 05:09:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672837754; x=1704373754; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6JspMSxf4tOO5N5gZs/+2wzcZApAr4SYcbdCKphs0Zg=; b=hgZ3FoRPHtl0CywouVL0CTVU3nF7zVOAUxzcBfOytbH9zGfPZqjhjTR1 r+EUA25Oj/2Qj/czO+G1OjzdTX/VK2zgPlNOsuVznTiQtq0i97byRtRN/ 3LTQgv6VDXX4oyJTlA/4uhdT23WSQNFA9GPrm//kiNo9af1kdeK8usYoD Y/oJGTYeHXj9dkOTQzQ2tT9uNQGWw+1J+MDdJJclffK+OLw0lJ3jkAiIb utgMbF7I3HosGcLNUE8z7pRuftTdykT6sG8Gtd/bj4Nv/yj73RtzTxDGw 4mkaup7QPR04k2URRW7pa+lGY+DZRT/B7U4Gm6pSFtDSKTY+uaxUqGWvU A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="320640359" X-IronPort-AV: E=Sophos;i="5.96,300,1665471600"; d="scan'208";a="320640359" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2023 05:07:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="797529492" X-IronPort-AV: E=Sophos;i="5.96,299,1665471600"; d="scan'208";a="797529492" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 04 Jan 2023 05:07:20 -0800 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Will Deacon , Robin Murphy , Jean-Philippe Brucker Cc: Suravee Suthikulpanit , Hector Martin , Sven Peter , Rob Clark , Marek Szyprowski , Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Yong Wu , Matthias Brugger , Heiko Stuebner , Matthew Rosato , Orson Zhai , Baolin Wang , Chunyan Zhang , Chen-Yu Tsai , Thierry Reding , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v4 19/19] iommu: Remove detach_dev callback Date: Wed, 4 Jan 2023 20:57:25 +0800 Message-Id: <20230104125725.271850-20-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104125725.271850-1-baolu.lu@linux.intel.com> References: <20230104125725.271850-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The detach_dev callback of domain ops is not called in the IOMMU core. Remove this callback to avoid dead code. The trace event for detaching domain from device is removed accordingly. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- include/linux/iommu.h | 2 -- include/trace/events/iommu.h | 7 ------- drivers/iommu/iommu-traces.c | 1 - drivers/iommu/iommu.c | 29 +++++------------------------ 4 files changed, 5 insertions(+), 34 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 0d10566b3cb2..a8063f26ff69 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -299,7 +299,6 @@ struct iommu_ops { * * EBUSY - device is attached to a domain and cannot be changed * * ENODEV - device specific errors, not able to be attached * * - treated as ENODEV by the caller. Use is discouraged - * @detach_dev: detach an iommu domain from a device * @set_dev_pasid: set an iommu domain to a pasid of device * @map: map a physically contiguous memory region to an iommu domain * @map_pages: map a physically contiguous set of pages of the same size to @@ -320,7 +319,6 @@ struct iommu_ops { */ struct iommu_domain_ops { int (*attach_dev)(struct iommu_domain *domain, struct device *dev); - void (*detach_dev)(struct iommu_domain *domain, struct device *dev); int (*set_dev_pasid)(struct iommu_domain *domain, struct device *dev, ioasid_t pasid); =20 diff --git a/include/trace/events/iommu.h b/include/trace/events/iommu.h index 29096fe12623..70743db1fb75 100644 --- a/include/trace/events/iommu.h +++ b/include/trace/events/iommu.h @@ -76,13 +76,6 @@ DEFINE_EVENT(iommu_device_event, attach_device_to_domain, TP_ARGS(dev) ); =20 -DEFINE_EVENT(iommu_device_event, detach_device_from_domain, - - TP_PROTO(struct device *dev), - - TP_ARGS(dev) -); - TRACE_EVENT(map, =20 TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size), diff --git a/drivers/iommu/iommu-traces.c b/drivers/iommu/iommu-traces.c index 1e9ca7789de1..23416bf76df9 100644 --- a/drivers/iommu/iommu-traces.c +++ b/drivers/iommu/iommu-traces.c @@ -18,7 +18,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(remove_device_from_group); =20 /* iommu_device_event */ EXPORT_TRACEPOINT_SYMBOL_GPL(attach_device_to_domain); -EXPORT_TRACEPOINT_SYMBOL_GPL(detach_device_from_domain); =20 /* iommu_map_unmap */ EXPORT_TRACEPOINT_SYMBOL_GPL(map); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index c7bd8663f1f5..d2b3210170a8 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2045,13 +2045,6 @@ int iommu_deferred_attach(struct device *dev, struct= iommu_domain *domain) return 0; } =20 -static void __iommu_detach_device(struct iommu_domain *domain, - struct device *dev) -{ - domain->ops->detach_dev(domain, dev); - trace_detach_device_from_domain(dev); -} - void iommu_detach_device(struct iommu_domain *domain, struct device *dev) { struct iommu_group *group; @@ -2156,15 +2149,6 @@ int iommu_attach_group(struct iommu_domain *domain, = struct iommu_group *group) } EXPORT_SYMBOL_GPL(iommu_attach_group); =20 -static int iommu_group_do_detach_device(struct device *dev, void *data) -{ - struct iommu_domain *domain =3D data; - - __iommu_detach_device(domain, dev); - - return 0; -} - static int iommu_group_do_set_platform_dma(struct device *dev, void *data) { const struct iommu_ops *ops =3D dev_iommu_ops(dev); @@ -2185,19 +2169,16 @@ static int __iommu_group_set_domain(struct iommu_gr= oup *group, return 0; =20 /* - * New drivers should support default domains and so the detach_dev() op - * will never be called. Otherwise the NULL domain represents some + * New drivers should support default domains and so set_platform_dma() + * op will never be called. Otherwise the NULL domain represents some * platform specific behavior. */ if (!new_domain) { ret =3D __iommu_group_for_each_dev(group, NULL, iommu_group_do_set_platform_dma); - if (ret) { - if (WARN_ON(!group->domain->ops->detach_dev)) - return -EINVAL; - __iommu_group_for_each_dev(group, group->domain, - iommu_group_do_detach_device); - } + if (ret) + return ret; + group->domain =3D NULL; return 0; } --=20 2.34.1