From patchwork Thu Mar 9 07:53:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 66647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp158456wrd; Thu, 9 Mar 2023 00:00:48 -0800 (PST) X-Google-Smtp-Source: AK7set+iXbXP4k1tqD8QCVkxWP/CYJsBj8/Xkni1OYaRvnvT+aIcL44EApevmihkKzEG67NIYUw9 X-Received: by 2002:a05:6a21:3281:b0:cc:c69b:f7e5 with SMTP id yt1-20020a056a21328100b000ccc69bf7e5mr23780340pzb.9.1678348848540; Thu, 09 Mar 2023 00:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678348848; cv=none; d=google.com; s=arc-20160816; b=Kv7638RE0k1JzZRRHEdDnddJHsdF69EWO2bm0sbmIjL0t7LD6Jt3o+KRJqds3LzMxV ekB8fzyjdA8l8QjcJPbhaBvQdHtGbOyRU+raOPGyd5S6KGJC2ZMtw6Nj6/fiAktri6Hq BvKUchII0rlYjo8uI7C3pFyRe2U0omGq4wVQ751mo41t1DqzF2Yk/HVdnzDV5UWVQ4nl aZikErdHLkzrJYc1/XpX0z6NYbL1i3raZTeucEMh+/ZdULzRGbHdBOWSx8P39v75tCx/ xat0gpwn61SweSrrHHb0r4TIXXnknUKxH1ojDSsxXj8yo94m9ShUWKlqB2a+FAD/2GdS /cPQ== 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=MVqXLmp1N6GD2KsnuMgUV0TH+jN4oe8eHWvANQpJetw=; b=wiEK7o1rTA/DT/M9kipkB/00gsriZNB0Vv7YGAs3XpS6Smp7kKAebOHnLuK26kqWZ2 q+43zxqLmPsohsedQ5d4biC+x2/KrHWPrVS/Dd7+LEyt2c6FHjhtoskDnCsRg0hIE3Ot /SrH3niNkp0C4AyIoi1F2pSS+prWuejQjIckpLDSI66YU/ZFCFcKDl6ZDOGh19krFzex 1nRDBvJz/Hd44w3XN1o7D8braIGF2rOLU+xhvEq7aJ08Ut3KgqRR1dtiBU17qQjCsWU1 GDdUFqwRs1z1NFykb5VMmQpzddHNA9R8012tve+hr2HX1nbk43y+1Ot3Qif98xHA4DzQ 8BHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z8kSTJ07; 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 m21-20020a656a15000000b00503a029385asi17773575pgu.849.2023.03.09.00.00.33; Thu, 09 Mar 2023 00:00:48 -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=Z8kSTJ07; 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 S230209AbjCIHyu (ORCPT + 99 others); Thu, 9 Mar 2023 02:54:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbjCIHy0 (ORCPT ); Thu, 9 Mar 2023 02:54:26 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 305B0DCA7D; Wed, 8 Mar 2023 23:54:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678348443; x=1709884443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9puZucPj6fLkrWz4CurcGtcInzi+r97NtNBrr/RGepA=; b=Z8kSTJ07SglkAH7mh7QBm4FdAvoyIcXwN3H0j4hkgbyZxlBClQtM7Agc gB+/+VBpkv7qKTNY6Y8YPPgixp4jHscEVYzllTa0izkvEr4CbOMKhEwnN 3xHVjm+t1b4nwbaYMDAe/9A38gstPPrSu4zZWyXhvslUTsRSKwhaQW4hd 7bSCDhI5ansqzRTmL/8orpm+rwg+BMQynyorktBUgG9L8+xztghJHGiX4 LaipAIp72+qVnH3zH6ZwR7T5NhflkqYmFxy4Xn85bzPXou1OUaJbbRasR yfMemBWSiHXTGmbRy3CA1TU5aSrTgiNAGiY1m/cLkMNfoTVjFWvphFV/b A==; X-IronPort-AV: E=McAfee;i="6500,9779,10643"; a="422652835" X-IronPort-AV: E=Sophos;i="5.98,245,1673942400"; d="scan'208";a="422652835" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2023 23:54:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10643"; a="851432742" X-IronPort-AV: E=Sophos;i="5.98,245,1673942400"; d="scan'208";a="851432742" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orsmga005.jf.intel.com with ESMTP; 08 Mar 2023 23:54:01 -0800 From: Yi Liu To: joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.com, baolu.lu@linux.intel.com Cc: cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com, shameerali.kolothum.thodi@huawei.com, lulu@redhat.com, suravee.suthikulpanit@amd.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 1/4] iommu: Move dev_iommu_ops() to private header Date: Wed, 8 Mar 2023 23:53:55 -0800 Message-Id: <20230309075358.571567-2-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309075358.571567-1-yi.l.liu@intel.com> References: <20230309075358.571567-1-yi.l.liu@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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?1759876322124817362?= X-GMAIL-MSGID: =?utf-8?q?1759876322124817362?= dev_iommu_ops() is essentially only used in iommu subsystem, so move to a private header to avoid being abused by other drivers. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Yi Liu Reviewed-by: Lu Baolu --- drivers/iommu/iommu-priv.h | 11 +++++++++++ drivers/iommu/iommu.c | 2 ++ include/linux/iommu.h | 11 ----------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/iommu-priv.h b/drivers/iommu/iommu-priv.h index 7c8011bfd153..a6e694f59f64 100644 --- a/drivers/iommu/iommu-priv.h +++ b/drivers/iommu/iommu-priv.h @@ -4,6 +4,17 @@ #include +static inline const struct iommu_ops *dev_iommu_ops(struct device *dev) +{ + /* + * Assume that valid ops must be installed if iommu_probe_device() + * has succeeded. The device ops are essentially for internal use + * within the IOMMU subsystem itself, so we should be able to trust + * ourselves not to misuse the helper. + */ + return dev->iommu->iommu_dev->ops; +} + int iommu_group_replace_domain(struct iommu_group *group, struct iommu_domain *new_domain); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index fd8fe2cd7303..437476c36de5 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -37,6 +37,8 @@ #include "iommu-sva.h" +#include "iommu-priv.h" + static struct kset *iommu_group_kset; static DEFINE_IDA(iommu_group_ida); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 6595454d4f48..7202d8ece343 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -444,17 +444,6 @@ static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather) }; } -static inline const struct iommu_ops *dev_iommu_ops(struct device *dev) -{ - /* - * Assume that valid ops must be installed if iommu_probe_device() - * has succeeded. The device ops are essentially for internal use - * within the IOMMU subsystem itself, so we should be able to trust - * ourselves not to misuse the helper. - */ - return dev->iommu->iommu_dev->ops; -} - extern int bus_iommu_probe(struct bus_type *bus); extern bool iommu_present(struct bus_type *bus); extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap);