From patchwork Wed Jan 4 12:57:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 38915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5138485wrt; Wed, 4 Jan 2023 05:18:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZag2IQHobT5bBSc4uaVYpfEMEdxNZL6U1liEgzY9kNVGSLtQE5pvwY/ir9VskHNM/QROG X-Received: by 2002:a05:6402:2217:b0:48b:c8de:9d15 with SMTP id cq23-20020a056402221700b0048bc8de9d15mr13672038edb.1.1672838297006; Wed, 04 Jan 2023 05:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672838296; cv=none; d=google.com; s=arc-20160816; b=pGy/XbWfN7Bu5je3vWJZW1B/QVRhIcFrbxx6VEcrEREyw1eptkE6VGhc7ai8B9g2lu BTkuR37RMikUkUmneztRERBjnFspntYEBgE5HlpU4nEK8o+4wac6Xt5milrZ7chlXArL ST9Jsh7Sh0xq5mpQq6DHI94dCHY+IGz+q7Fp2m9H3QmmwZnlTFDrRTS+IPWmWPAMFoaq Gbz5ZzuLtvwH9ZWITUERRbSlpsl/YbvtumIjgAvxo4BSEw6ZKKEpQeKMO8B/DzX3xUy1 yjT40U3awcTBpMN4/wi6al30PPeAmclb7NE3cKOPI2iE8DUaOV/s6fM7j94ahywuXlQQ /41w== 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=1XAnlxGMe2AZzMEqKYNKOyK9ehx0FlucnEt6lHR78b8=; b=MSNNSZOHH3cJpMO8jleOGN5QWcbX9j4d6G4vWHoCez9QJi5ZzW3sLXJiNOLqTwEG7S bdM6Rdqv28pbGedNM+sE1ugk/8SE1LsChSliSqrElKd3wvBYb2c+OKhVVS0p8o85dMy0 hvEFmJkIWV9a2xvn4Lg/p3SPRq+k21jq/dsd9TPMA4NWG7Y4QUb+cbRAMMTsbVHmMbXj eQL2i1/iXPWfdg1O8Hog6wC/RIFNZE3EOZIVhlXU4OyIgpy3yeNGGcnX1fFC2eaBQAf4 160YZIZImu10SUJ5cqG8rfRmbH2oannqtap0pGDpG5zJEI0oWmaF81/s1wpDwixPfDU0 GiLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hgZ3FoRP; 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 z11-20020a056402274b00b0045c93142111si34922511edd.70.2023.01.04.05.17.53; Wed, 04 Jan 2023 05:18:16 -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=hgZ3FoRP; 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 S239392AbjADNMM (ORCPT + 99 others); Wed, 4 Jan 2023 08:12:12 -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 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,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?1754098089819937345?= X-GMAIL-MSGID: =?utf-8?q?1754098089819937345?= 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); 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 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; } -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); @@ -2185,19 +2169,16 @@ 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 and so set_platform_dma() + * op will never be called. Otherwise the NULL domain represents some * platform specific behavior. */ if (!new_domain) { ret = __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 = NULL; return 0; }