From patchwork Tue Jan 10 02:54:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 41275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2517804wrt; Mon, 9 Jan 2023 19:06:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXsVamCA7Mkr4mxx3IQfqvpCZTHtRx57rC/y0ywQmmbcHVHq20hytuC740DJtO980x8tjbXO X-Received: by 2002:a05:6a21:1507:b0:ac:1cf0:61e2 with SMTP id nq7-20020a056a21150700b000ac1cf061e2mr90592131pzb.3.1673319971575; Mon, 09 Jan 2023 19:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673319971; cv=none; d=google.com; s=arc-20160816; b=hHMbcBCxHOappoazhF62gvpsAij5wSGwGmX5/JRKISdRAaFikfusNnuMO09nOMFR2r x98BOM44PAxqDM6e1TZnszxzGVStcFhrJo0SGaytZ15zhQJxy4hsDPIEx/rGmTsbfVVo 5LHi5q6tCvezUYjMOHkyVkXqS/lHh90/rz0C1knEorp1tk6RHavaaxIidtAXDpQqYzcl jK6nyW/rr9/LIwQXHlYO772j1RjRBMcRb92m6UizLD7chiCZWVywDoyeZPK+euqPUEvq 5OiuUOW5IJwNSBt0fdimcvypoTcD9ARuJPj7O1dTJo4/mW8AOsQpe7ulchdzt+QmGKbX M4QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=isqzNEwGkjxjZ++nYNxX/n9hFV04T7c9g9TA58GJbI0=; b=ssiTNf4hRB3EEXVIjT5kTCZ3YxwAVZnfENOV79igp7rcFWqgKX3dy1mnK/I2LPyegK J54p40KkfvHK5M1OpzfZV7cpM9Yp0AxmHMzbOo7i/lDkmMRgaKBb/TSMNIf6fYkoZlIF rioPJOQrTVTiCBh63t6zS/m7cA2HvgeudbZIA3/nEFz41S7moYA8MbDEUNEByYc3FmgH 9mIu1yLG/zuZYRIPm+/hxdlOVs9vaeFihmvzyChu6Qyy0Dg+KaQgZCQyd0pqnxUZORlE zB8iCLKa+cW4dGRaoYP/EwOfX7PDTwrXbyAq6o/bcrK4r8PCaGjXFDRhf8kHqNklNh/0 zhyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FmfvwiOY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 139-20020a630791000000b004976cc1f412si10683450pgh.288.2023.01.09.19.05.58; Mon, 09 Jan 2023 19:06:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FmfvwiOY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230365AbjAJDCy (ORCPT + 99 others); Mon, 9 Jan 2023 22:02:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235803AbjAJDCm (ORCPT ); Mon, 9 Jan 2023 22:02:42 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64F2A10FEE for ; Mon, 9 Jan 2023 19:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673319761; x=1704855761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UR5WZP9Av4XTBD2BfO5VWRKQ4DlrRvmKTgHn9rKCd1w=; b=FmfvwiOYYvRjGJMu/hFxksfuFnyc1bYd3zR90v883gvCs2NwQz88JS00 mi/8jumfOflCfyJ6NwbMf4fIqj1RYNyOTc1hX3cnk5W+UKo1zn+3S4Nky EPEEWM5Hic7VE0kLRWHns3jtkxjFLTP+vYDHsAJnt87ZoOwiW3Z8g9MMZ VL+/2Ha4qOwzyoX/0JLCZA6OFrOlFYTdLqmgfAiVX6ybv/ZuCk0Hs6PWV kpdE1+TFeR6JXXBJiOoCEX53o3d4UzjCqXvq9dl948W84bL7x5S7pbNMU TNfv+uG6ALuv4uvPUH9hT0Q69IpmQ+dWVJSgnjpW1Jp3OhNXoXfjKIMB+ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="324289201" X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="324289201" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 19:02:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="830842002" X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="830842002" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga005.jf.intel.com with ESMTP; 09 Jan 2023 19:02:33 -0800 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Will Deacon , Robin Murphy , Jean-Philippe Brucker Cc: Suravee Suthikulpanit , Vasant Hegde , 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 v5 5/5] iommu: Remove detach_dev callback Date: Tue, 10 Jan 2023 10:54:08 +0800 Message-Id: <20230110025408.667767-6-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230110025408.667767-1-baolu.lu@linux.intel.com> References: <20230110025408.667767-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754603162740076492?= X-GMAIL-MSGID: =?utf-8?q?1754603162740076492?= 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- include/linux/iommu.h | 2 -- include/trace/events/iommu.h | 7 ------- drivers/iommu/iommu-traces.c | 1 - drivers/iommu/iommu.c | 36 ++++-------------------------------- 4 files changed, 4 insertions(+), 42 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); 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) ); -DEFINE_EVENT(iommu_device_event, detach_device_from_domain, - - TP_PROTO(struct device *dev), - - TP_ARGS(dev) -); - TRACE_EVENT(map, 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); /* iommu_device_event */ EXPORT_TRACEPOINT_SYMBOL_GPL(attach_device_to_domain); -EXPORT_TRACEPOINT_SYMBOL_GPL(detach_device_from_domain); /* iommu_map_unmap */ EXPORT_TRACEPOINT_SYMBOL_GPL(map); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 85ae20c8ff5e..9135540d7d59 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; } -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); -static int iommu_group_do_detach_device(struct device *dev, void *data) -{ - struct iommu_domain *domain = 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 = dev_iommu_ops(dev); @@ -2184,25 +2168,13 @@ static int __iommu_group_set_domain(struct iommu_group *group, return 0; /* - * 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, so set_platform_dma() + * op will never be called. Otherwise the NULL domain represents some * platform specific behavior. */ if (!new_domain) { - struct group_device *grp_dev; - - grp_dev = list_first_entry(&group->devices, - struct group_device, list); - - if (dev_iommu_ops(grp_dev->dev)->set_platform_dma_ops) - __iommu_group_for_each_dev(group, NULL, - iommu_group_do_set_platform_dma); - else if (group->domain->ops->detach_dev) - __iommu_group_for_each_dev(group, group->domain, - iommu_group_do_detach_device); - else - WARN_ON_ONCE(1); - + __iommu_group_for_each_dev(group, NULL, + iommu_group_do_set_platform_dma); group->domain = NULL; return 0; }