From nobody Fri May 8 00:09:39 2026 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 728AEC433F5 for ; Mon, 16 May 2022 02:01:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239289AbiEPCBX (ORCPT ); Sun, 15 May 2022 22:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239255AbiEPCBT (ORCPT ); Sun, 15 May 2022 22:01:19 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAFDC12AC4 for ; Sun, 15 May 2022 19:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652666477; x=1684202477; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lw/z1i0cdD3DhbXVRo4EJGfKaM6+wWlycH0aSNhGDhA=; b=m4qAxejcJMjxaFlUPnfEePY/M2yEDyNURj96IAOuo54/YaYGFCulBvbs CXzCiBHyYT1majMJ/GDQXGuBrDybDT6zBKm5oXi07UsQ1SM2JEEVGDi3H IhcWFmlgtjwQZ9QtCNrp2RXpVLvXXgdeS2EBvvl9ueMwdnQuWyRskz2rt c3luQyAdXyRNeQixofqVX8FHlSZfq/vvOdlGO543SgBorH1jqYmEk+1Fw J67UBXJho/0Qo2ZiZt7EbjV16M2anxuypFWzSxmQgT5dAnUCXdqLfso4m vHHar8RgWAQDr/CDHCgfZXZrvAsCdjYDKEjPTd2HAcOy/2K/3ohkP5zWO A==; X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="270658985" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="270658985" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2022 19:01:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="713172159" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 15 May 2022 19:01:14 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker Cc: Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 1/5] iommu: Rename attach_dev to set_dev in domain ops Date: Mon, 16 May 2022 09:57:55 +0800 Message-Id: <20220516015759.2952771-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220516015759.2952771-1-baolu.lu@linux.intel.com> References: <20220516015759.2952771-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 callback of the iommu domain ops is not used in some IOMMU drivers. The detach_dev actually means setting a default domain or a blocking domain to the device. As attach_dev actually acts as setting domain for a device, this renames attach_dev to set_dev to reflect the actual usage. Suggested-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- include/linux/iommu.h | 4 ++-- drivers/iommu/amd/iommu.c | 2 +- drivers/iommu/apple-dart.c | 2 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +- drivers/iommu/arm/arm-smmu/arm-smmu.c | 2 +- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 2 +- drivers/iommu/exynos-iommu.c | 2 +- drivers/iommu/fsl_pamu_domain.c | 2 +- drivers/iommu/intel/iommu.c | 2 +- drivers/iommu/iommu.c | 6 +++--- drivers/iommu/ipmmu-vmsa.c | 2 +- drivers/iommu/msm_iommu.c | 2 +- drivers/iommu/mtk_iommu.c | 2 +- drivers/iommu/mtk_iommu_v1.c | 2 +- drivers/iommu/omap-iommu.c | 2 +- drivers/iommu/rockchip-iommu.c | 2 +- drivers/iommu/s390-iommu.c | 2 +- drivers/iommu/sprd-iommu.c | 2 +- drivers/iommu/sun50i-iommu.c | 2 +- drivers/iommu/tegra-gart.c | 2 +- drivers/iommu/tegra-smmu.c | 2 +- drivers/iommu/virtio-iommu.c | 2 +- 22 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 5e1afe169549..572399ac1d83 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -261,7 +261,7 @@ struct iommu_ops { =20 /** * struct iommu_domain_ops - domain specific operations - * @attach_dev: attach an iommu domain to a device + * @set_dev: set an iommu domain to a device * @detach_dev: detach an iommu domain from a 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 @@ -281,7 +281,7 @@ struct iommu_ops { * @free: Release the domain after use. */ struct iommu_domain_ops { - int (*attach_dev)(struct iommu_domain *domain, struct device *dev); + int (*set_dev)(struct iommu_domain *domain, struct device *dev); void (*detach_dev)(struct iommu_domain *domain, struct device *dev); =20 int (*map)(struct iommu_domain *domain, unsigned long iova, diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 840831d5d2ad..01b8668ef46d 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2285,7 +2285,7 @@ const struct iommu_ops amd_iommu_ops =3D { .pgsize_bitmap =3D AMD_IOMMU_PGSIZES, .def_domain_type =3D amd_iommu_def_domain_type, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D amd_iommu_attach_device, + .set_dev =3D amd_iommu_attach_device, .detach_dev =3D amd_iommu_detach_device, .map =3D amd_iommu_map, .unmap =3D amd_iommu_unmap, diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 8af0242a90d9..a0b7281f1989 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -775,7 +775,7 @@ static const struct iommu_ops apple_dart_iommu_ops =3D { .pgsize_bitmap =3D -1UL, /* Restricted during dart probe */ .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D apple_dart_attach_dev, + .set_dev =3D apple_dart_attach_dev, .detach_dev =3D apple_dart_detach_dev, .map_pages =3D apple_dart_map_pages, .unmap_pages =3D apple_dart_unmap_pages, diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 88817a3376ef..7e7d9e0b7aee 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2859,7 +2859,7 @@ static struct iommu_ops arm_smmu_ops =3D { .pgsize_bitmap =3D -1UL, /* Restricted during device attach */ .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D arm_smmu_attach_dev, + .set_dev =3D arm_smmu_attach_dev, .map_pages =3D arm_smmu_map_pages, .unmap_pages =3D arm_smmu_unmap_pages, .flush_iotlb_all =3D arm_smmu_flush_iotlb_all, diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-= smmu/arm-smmu.c index 2ed3594f384e..c91d12b7e283 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1597,7 +1597,7 @@ static struct iommu_ops arm_smmu_ops =3D { .pgsize_bitmap =3D -1UL, /* Restricted during device attach */ .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D arm_smmu_attach_dev, + .set_dev =3D arm_smmu_attach_dev, .map_pages =3D arm_smmu_map_pages, .unmap_pages =3D arm_smmu_unmap_pages, .flush_iotlb_all =3D arm_smmu_flush_iotlb_all, diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/ar= m-smmu/qcom_iommu.c index 4c077c38fbd6..cf624bd305e0 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -596,7 +596,7 @@ static const struct iommu_ops qcom_iommu_ops =3D { .of_xlate =3D qcom_iommu_of_xlate, .pgsize_bitmap =3D SZ_4K | SZ_64K | SZ_1M | SZ_16M, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D qcom_iommu_attach_dev, + .set_dev =3D qcom_iommu_attach_dev, .detach_dev =3D qcom_iommu_detach_dev, .map =3D qcom_iommu_map, .unmap =3D qcom_iommu_unmap, diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 71f2018e23fe..797348f3440e 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1315,7 +1315,7 @@ static const struct iommu_ops exynos_iommu_ops =3D { .pgsize_bitmap =3D SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, .of_xlate =3D exynos_iommu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D exynos_iommu_attach_device, + .set_dev =3D exynos_iommu_attach_device, .detach_dev =3D exynos_iommu_detach_device, .map =3D exynos_iommu_map, .unmap =3D exynos_iommu_unmap, diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domai= n.c index 94b4589dc67c..7512c8e007e9 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c @@ -458,7 +458,7 @@ static const struct iommu_ops fsl_pamu_ops =3D { .release_device =3D fsl_pamu_release_device, .device_group =3D fsl_pamu_device_group, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D fsl_pamu_attach_device, + .set_dev =3D fsl_pamu_attach_device, .detach_dev =3D fsl_pamu_detach_device, .iova_to_phys =3D fsl_pamu_iova_to_phys, .free =3D fsl_pamu_domain_free, diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index e56b3a4b6998..6abc1fbbd461 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4925,7 +4925,7 @@ const struct iommu_ops intel_iommu_ops =3D { .page_response =3D intel_svm_page_response, #endif .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D intel_iommu_attach_device, + .set_dev =3D intel_iommu_attach_device, .detach_dev =3D intel_iommu_detach_device, .map_pages =3D intel_iommu_map_pages, .unmap_pages =3D intel_iommu_unmap_pages, diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 847ad47a2dfd..8eba26be4363 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1963,10 +1963,10 @@ static int __iommu_attach_device(struct iommu_domai= n *domain, { int ret; =20 - if (unlikely(domain->ops->attach_dev =3D=3D NULL)) + if (unlikely(domain->ops->set_dev =3D=3D NULL)) return -ENODEV; =20 - ret =3D domain->ops->attach_dev(domain, dev); + ret =3D domain->ops->set_dev(domain, dev); if (!ret) trace_attach_device_to_domain(dev); return ret; @@ -2142,7 +2142,7 @@ static int __iommu_group_set_domain(struct iommu_grou= p *group, } =20 /* - * Changing the domain is done by calling attach_dev() on the new + * Changing the domain is done by calling set_dev() on the new * domain. This switch does not have to be atomic and DMA can be * discarded during the transition. DMA must only be able to access * either new_domain or group->domain, never something else. diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 8fdb84b3642b..b361a4cff688 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -877,7 +877,7 @@ static const struct iommu_ops ipmmu_ops =3D { .pgsize_bitmap =3D SZ_1G | SZ_2M | SZ_4K, .of_xlate =3D ipmmu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D ipmmu_attach_device, + .set_dev =3D ipmmu_attach_device, .detach_dev =3D ipmmu_detach_device, .map =3D ipmmu_map, .unmap =3D ipmmu_unmap, diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index f09aedfdd462..569d36840b67 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -682,7 +682,7 @@ static struct iommu_ops msm_iommu_ops =3D { .pgsize_bitmap =3D MSM_IOMMU_PGSIZES, .of_xlate =3D qcom_iommu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D msm_iommu_attach_dev, + .set_dev =3D msm_iommu_attach_dev, .detach_dev =3D msm_iommu_detach_dev, .map =3D msm_iommu_map, .unmap =3D msm_iommu_unmap, diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index bb9dd92c9898..33ec401d40eb 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -937,7 +937,7 @@ static const struct iommu_ops mtk_iommu_ops =3D { .pgsize_bitmap =3D SZ_4K | SZ_64K | SZ_1M | SZ_16M, .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D mtk_iommu_attach_device, + .set_dev =3D mtk_iommu_attach_device, .detach_dev =3D mtk_iommu_detach_device, .map =3D mtk_iommu_map, .unmap =3D mtk_iommu_unmap, diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index e1cb51b9866c..fb55802fb841 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -594,7 +594,7 @@ static const struct iommu_ops mtk_iommu_v1_ops =3D { .pgsize_bitmap =3D ~0UL << MT2701_IOMMU_PAGE_SHIFT, .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D mtk_iommu_v1_attach_device, + .set_dev =3D mtk_iommu_v1_attach_device, .detach_dev =3D mtk_iommu_v1_detach_device, .map =3D mtk_iommu_v1_map, .unmap =3D mtk_iommu_v1_unmap, diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index d9cf2820c02e..6720dcb437a0 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1739,7 +1739,7 @@ static const struct iommu_ops omap_iommu_ops =3D { .device_group =3D omap_iommu_device_group, .pgsize_bitmap =3D OMAP_IOMMU_PGSIZES, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D omap_iommu_attach_dev, + .set_dev =3D omap_iommu_attach_dev, .detach_dev =3D omap_iommu_detach_dev, .map =3D omap_iommu_map, .unmap =3D omap_iommu_unmap, diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index ab57c4b8fade..0a4196c34179 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1193,7 +1193,7 @@ static const struct iommu_ops rk_iommu_ops =3D { .pgsize_bitmap =3D RK_IOMMU_PGSIZE_BITMAP, .of_xlate =3D rk_iommu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D rk_iommu_attach_device, + .set_dev =3D rk_iommu_attach_device, .detach_dev =3D rk_iommu_detach_device, .map =3D rk_iommu_map, .unmap =3D rk_iommu_unmap, diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index 3833e86c6e7b..cde01c72f573 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -368,7 +368,7 @@ static const struct iommu_ops s390_iommu_ops =3D { .device_group =3D generic_device_group, .pgsize_bitmap =3D S390_IOMMU_PGSIZES, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D s390_iommu_attach_device, + .set_dev =3D s390_iommu_attach_device, .detach_dev =3D s390_iommu_detach_device, .map =3D s390_iommu_map, .unmap =3D s390_iommu_unmap, diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index bd409bab6286..45b58845f5f8 100644 --- a/drivers/iommu/sprd-iommu.c +++ b/drivers/iommu/sprd-iommu.c @@ -423,7 +423,7 @@ static const struct iommu_ops sprd_iommu_ops =3D { .pgsize_bitmap =3D ~0UL << SPRD_IOMMU_PAGE_SHIFT, .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D sprd_iommu_attach_device, + .set_dev =3D sprd_iommu_attach_device, .detach_dev =3D sprd_iommu_detach_device, .map =3D sprd_iommu_map, .unmap =3D sprd_iommu_unmap, diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index c54ab477b8fd..041b30463552 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -766,7 +766,7 @@ static const struct iommu_ops sun50i_iommu_ops =3D { .probe_device =3D sun50i_iommu_probe_device, .release_device =3D sun50i_iommu_release_device, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D sun50i_iommu_attach_device, + .set_dev =3D sun50i_iommu_attach_device, .detach_dev =3D sun50i_iommu_detach_device, .flush_iotlb_all =3D sun50i_iommu_flush_iotlb_all, .iotlb_sync =3D sun50i_iommu_iotlb_sync, diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index a6700a40a6f8..f083a9fba4d0 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -278,7 +278,7 @@ static const struct iommu_ops gart_iommu_ops =3D { .pgsize_bitmap =3D GART_IOMMU_PGSIZES, .of_xlate =3D gart_iommu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D gart_iommu_attach_dev, + .set_dev =3D gart_iommu_attach_dev, .detach_dev =3D gart_iommu_detach_dev, .map =3D gart_iommu_map, .unmap =3D gart_iommu_unmap, diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 1fea68e551f1..36e9c2864e3f 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -971,7 +971,7 @@ static const struct iommu_ops tegra_smmu_ops =3D { .of_xlate =3D tegra_smmu_of_xlate, .pgsize_bitmap =3D SZ_4K, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D tegra_smmu_attach_dev, + .set_dev =3D tegra_smmu_attach_dev, .detach_dev =3D tegra_smmu_detach_dev, .map =3D tegra_smmu_map, .unmap =3D tegra_smmu_unmap, diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 25be4b822aa0..ce2bd01806d8 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -1017,7 +1017,7 @@ static struct iommu_ops viommu_ops =3D { .of_xlate =3D viommu_of_xlate, .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { - .attach_dev =3D viommu_attach_dev, + .set_dev =3D viommu_attach_dev, .map =3D viommu_map, .unmap =3D viommu_unmap, .iova_to_phys =3D viommu_iova_to_phys, --=20 2.25.1 From nobody Fri May 8 00:09:39 2026 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 632A8C433EF for ; Mon, 16 May 2022 02:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239304AbiEPCBm (ORCPT ); Sun, 15 May 2022 22:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239300AbiEPCBY (ORCPT ); Sun, 15 May 2022 22:01:24 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFA4012AEB for ; Sun, 15 May 2022 19:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652666481; x=1684202481; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WOENIgdcD7RFAjuMLJnNHsT0/7tXgm6YKuBH2LuazZ4=; b=PIQkUIqY9vx0dQoBXIoyffwhW6GOdUJOyq4lCJap/qMVHYRvkltdIHGo ShK4gSFd9A/ZbtB5Ocf4N7rTXHVQRqeOZSczZR9M9AFVYqn4IYP3v69kI vcwWkUFK+caZ9TetNzZj+GZkFrk7qpfUlkkXnjmhADdqoP8ncqramM0CO s9VrGdMutK4TacdRNeEtLAsHCCoI4Oj1Q1yzA7w6eOTnFgbmPD05j4kN1 RgLPPQh4SBT47iK8eJdYlyrHN9o3L5MUlY8KYsEzXySvsq4rsYEtMjuUS 7oz24LRVcfPZpnrykNsM5frBTxJXW+OjafYOrzWz/x/73Q9Fk13pyd/NF Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="270658990" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="270658990" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2022 19:01:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="713172168" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 15 May 2022 19:01:17 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker Cc: Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 2/5] iommu: Add blocking_domain_ops field in iommu_ops Date: Mon, 16 May 2022 09:57:56 +0800 Message-Id: <20220516015759.2952771-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220516015759.2952771-1-baolu.lu@linux.intel.com> References: <20220516015759.2952771-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" Each IOMMU driver must provide a blocking domain ops. If the hardware supports detaching domain from device, setting blocking domain equals detaching the existing domain from the deivce. Otherwise, an UNMANAGED domain without any mapping will be used instead. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 7 +++++++ drivers/iommu/amd/iommu.c | 12 ++++++++++++ drivers/iommu/apple-dart.c | 12 ++++++++++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 +++ drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 +++ drivers/iommu/arm/arm-smmu/qcom_iommu.c | 12 ++++++++++++ drivers/iommu/exynos-iommu.c | 12 ++++++++++++ drivers/iommu/fsl_pamu_domain.c | 12 ++++++++++++ drivers/iommu/intel/iommu.c | 12 ++++++++++++ drivers/iommu/ipmmu-vmsa.c | 12 ++++++++++++ drivers/iommu/msm_iommu.c | 12 ++++++++++++ drivers/iommu/mtk_iommu.c | 12 ++++++++++++ drivers/iommu/mtk_iommu_v1.c | 12 ++++++++++++ drivers/iommu/omap-iommu.c | 12 ++++++++++++ drivers/iommu/rockchip-iommu.c | 12 ++++++++++++ drivers/iommu/s390-iommu.c | 12 ++++++++++++ drivers/iommu/sprd-iommu.c | 11 +++++++++++ drivers/iommu/sun50i-iommu.c | 12 ++++++++++++ drivers/iommu/tegra-gart.c | 12 ++++++++++++ drivers/iommu/tegra-smmu.c | 12 ++++++++++++ drivers/iommu/virtio-iommu.c | 3 +++ 21 files changed, 219 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 572399ac1d83..5e228aad0ef6 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -216,6 +216,7 @@ struct iommu_iotlb_gather { * - IOMMU_DOMAIN_DMA: must use a dma domain * - 0: use the default setting * @default_domain_ops: the default ops for domains + * @blocking_domain_ops: the blocking ops for domains * @pgsize_bitmap: bitmap of all possible supported page sizes * @owner: Driver module providing these ops */ @@ -255,6 +256,7 @@ struct iommu_ops { int (*def_domain_type)(struct device *dev); =20 const struct iommu_domain_ops *default_domain_ops; + const struct iommu_domain_ops *blocking_domain_ops; unsigned long pgsize_bitmap; struct module *owner; }; @@ -279,6 +281,9 @@ struct iommu_ops { * @enable_nesting: Enable nesting * @set_pgtable_quirks: Set io page table quirks (IO_PGTABLE_QUIRK_*) * @free: Release the domain after use. + * @blocking_domain_detach: iommu hardware support detaching a domain from + * a device, hence setting blocking domain to a device equals to + * detach the existing domain from it. */ struct iommu_domain_ops { int (*set_dev)(struct iommu_domain *domain, struct device *dev); @@ -310,6 +315,8 @@ struct iommu_domain_ops { unsigned long quirks); =20 void (*free)(struct iommu_domain *domain); + + unsigned int blocking_domain_detach:1; }; =20 /** diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 01b8668ef46d..c66713439824 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2272,6 +2272,14 @@ static bool amd_iommu_enforce_cache_coherency(struct= iommu_domain *domain) return true; } =20 +static int amd_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + amd_iommu_detach_device(domain, dev); + + return 0; +} + const struct iommu_ops amd_iommu_ops =3D { .capable =3D amd_iommu_capable, .domain_alloc =3D amd_iommu_domain_alloc, @@ -2295,6 +2303,10 @@ const struct iommu_ops amd_iommu_ops =3D { .iotlb_sync =3D amd_iommu_iotlb_sync, .free =3D amd_iommu_domain_free, .enforce_cache_coherency =3D amd_iommu_enforce_cache_coherency, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D amd_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index a0b7281f1989..3c37762e01ec 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -763,6 +763,14 @@ static void apple_dart_get_resv_regions(struct device = *dev, iommu_dma_get_resv_regions(dev, head); } =20 +static int apple_dart_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + apple_dart_detach_dev(domain, dev); + + return 0; +} + static const struct iommu_ops apple_dart_iommu_ops =3D { .domain_alloc =3D apple_dart_domain_alloc, .probe_device =3D apple_dart_probe_device, @@ -784,6 +792,10 @@ static const struct iommu_ops apple_dart_iommu_ops =3D= { .iotlb_sync_map =3D apple_dart_iotlb_sync_map, .iova_to_phys =3D apple_dart_iova_to_phys, .free =3D apple_dart_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D apple_dart_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 7e7d9e0b7aee..4b0ec5bef63b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2867,6 +2867,9 @@ static struct iommu_ops arm_smmu_ops =3D { .iova_to_phys =3D arm_smmu_iova_to_phys, .enable_nesting =3D arm_smmu_enable_nesting, .free =3D arm_smmu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D arm_smmu_attach_dev, } }; =20 diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-= smmu/arm-smmu.c index c91d12b7e283..0723f7c97763 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1606,6 +1606,9 @@ static struct iommu_ops arm_smmu_ops =3D { .enable_nesting =3D arm_smmu_enable_nesting, .set_pgtable_quirks =3D arm_smmu_set_pgtable_quirks, .free =3D arm_smmu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D arm_smmu_attach_dev, } }; =20 diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/ar= m-smmu/qcom_iommu.c index cf624bd305e0..dee9b5a3a324 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -587,6 +587,14 @@ static int qcom_iommu_of_xlate(struct device *dev, str= uct of_phandle_args *args) return iommu_fwspec_add_ids(dev, &asid, 1); } =20 +static int qcom_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + qcom_iommu_detach_dev(domain, dev); + + return 0; +} + static const struct iommu_ops qcom_iommu_ops =3D { .capable =3D qcom_iommu_capable, .domain_alloc =3D qcom_iommu_domain_alloc, @@ -604,6 +612,10 @@ static const struct iommu_ops qcom_iommu_ops =3D { .iotlb_sync =3D qcom_iommu_iotlb_sync, .iova_to_phys =3D qcom_iommu_iova_to_phys, .free =3D qcom_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D qcom_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 797348f3440e..bbecb9a2a554 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1307,6 +1307,14 @@ static int exynos_iommu_of_xlate(struct device *dev, return 0; } =20 +static int exynos_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + exynos_iommu_detach_device(domain, dev); + + return 0; +} + static const struct iommu_ops exynos_iommu_ops =3D { .domain_alloc =3D exynos_iommu_domain_alloc, .device_group =3D generic_device_group, @@ -1321,6 +1329,10 @@ static const struct iommu_ops exynos_iommu_ops =3D { .unmap =3D exynos_iommu_unmap, .iova_to_phys =3D exynos_iommu_iova_to_phys, .free =3D exynos_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D exynos_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domai= n.c index 7512c8e007e9..92fc320f8c83 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c @@ -451,6 +451,14 @@ static void fsl_pamu_release_device(struct device *dev) { } =20 +static int fsl_pamu_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + fsl_pamu_detach_device(domain, dev); + + return 0; +} + static const struct iommu_ops fsl_pamu_ops =3D { .capable =3D fsl_pamu_capable, .domain_alloc =3D fsl_pamu_domain_alloc, @@ -462,6 +470,10 @@ static const struct iommu_ops fsl_pamu_ops =3D { .detach_dev =3D fsl_pamu_detach_device, .iova_to_phys =3D fsl_pamu_iova_to_phys, .free =3D fsl_pamu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D fsl_pamu_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 6abc1fbbd461..2060e8a540b3 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4904,6 +4904,14 @@ static void intel_iommu_iotlb_sync_map(struct iommu_= domain *domain, } } =20 +static int intel_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + intel_iommu_detach_device(domain, dev); + + return 0; +} + const struct iommu_ops intel_iommu_ops =3D { .capable =3D intel_iommu_capable, .domain_alloc =3D intel_iommu_domain_alloc, @@ -4935,6 +4943,10 @@ const struct iommu_ops intel_iommu_ops =3D { .iova_to_phys =3D intel_iommu_iova_to_phys, .free =3D intel_iommu_domain_free, .enforce_cache_coherency =3D intel_iommu_enforce_cache_coherency, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D intel_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index b361a4cff688..72982d1277c2 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -867,6 +867,14 @@ static struct iommu_group *ipmmu_find_group(struct dev= ice *dev) return group; } =20 +static int ipmmu_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + ipmmu_detach_device(domain, dev); + + return 0; +} + static const struct iommu_ops ipmmu_ops =3D { .domain_alloc =3D ipmmu_domain_alloc, .probe_device =3D ipmmu_probe_device, @@ -885,6 +893,10 @@ static const struct iommu_ops ipmmu_ops =3D { .iotlb_sync =3D ipmmu_iotlb_sync, .iova_to_phys =3D ipmmu_iova_to_phys, .free =3D ipmmu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D ipmmu_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index 569d36840b67..b0471d03db60 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -674,6 +674,14 @@ irqreturn_t msm_iommu_fault_handler(int irq, void *dev= _id) return 0; } =20 +static int msm_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + msm_iommu_detach_dev(domain, dev); + + return 0; +} + static struct iommu_ops msm_iommu_ops =3D { .domain_alloc =3D msm_iommu_domain_alloc, .probe_device =3D msm_iommu_probe_device, @@ -696,6 +704,10 @@ static struct iommu_ops msm_iommu_ops =3D { .iotlb_sync_map =3D msm_iommu_sync_map, .iova_to_phys =3D msm_iommu_iova_to_phys, .free =3D msm_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D msm_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 33ec401d40eb..cc8d80290498 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -926,6 +926,14 @@ static void mtk_iommu_get_resv_regions(struct device *= dev, } } =20 +static int mtk_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + mtk_iommu_detach_device(domain, dev); + + return 0; +} + static const struct iommu_ops mtk_iommu_ops =3D { .domain_alloc =3D mtk_iommu_domain_alloc, .probe_device =3D mtk_iommu_probe_device, @@ -946,6 +954,10 @@ static const struct iommu_ops mtk_iommu_ops =3D { .iotlb_sync_map =3D mtk_iommu_sync_map, .iova_to_phys =3D mtk_iommu_iova_to_phys, .free =3D mtk_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D mtk_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index fb55802fb841..894d2526ba4c 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -584,6 +584,14 @@ static int mtk_iommu_v1_hw_init(const struct mtk_iommu= _v1_data *data) return 0; } =20 +static int mtk_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + mtk_iommu_v1_detach_device(domain, dev); + + return 0; +} + static const struct iommu_ops mtk_iommu_v1_ops =3D { .domain_alloc =3D mtk_iommu_v1_domain_alloc, .probe_device =3D mtk_iommu_v1_probe_device, @@ -600,6 +608,10 @@ static const struct iommu_ops mtk_iommu_v1_ops =3D { .unmap =3D mtk_iommu_v1_unmap, .iova_to_phys =3D mtk_iommu_v1_iova_to_phys, .free =3D mtk_iommu_v1_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D mtk_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 6720dcb437a0..7e6ba6f1218d 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1732,6 +1732,14 @@ static struct iommu_group *omap_iommu_device_group(s= truct device *dev) return group; } =20 +static int omap_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + omap_iommu_detach_dev(domain, dev); + + return 0; +} + static const struct iommu_ops omap_iommu_ops =3D { .domain_alloc =3D omap_iommu_domain_alloc, .probe_device =3D omap_iommu_probe_device, @@ -1745,6 +1753,10 @@ static const struct iommu_ops omap_iommu_ops =3D { .unmap =3D omap_iommu_unmap, .iova_to_phys =3D omap_iommu_iova_to_phys, .free =3D omap_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D omap_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 0a4196c34179..29c803759a0b 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1185,6 +1185,14 @@ static int rk_iommu_of_xlate(struct device *dev, return 0; } =20 +static int rk_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + rk_iommu_detach_device(domain, dev); + + return 0; +} + static const struct iommu_ops rk_iommu_ops =3D { .domain_alloc =3D rk_iommu_domain_alloc, .probe_device =3D rk_iommu_probe_device, @@ -1199,6 +1207,10 @@ static const struct iommu_ops rk_iommu_ops =3D { .unmap =3D rk_iommu_unmap, .iova_to_phys =3D rk_iommu_iova_to_phys, .free =3D rk_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D rk_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index cde01c72f573..a03bff562a44 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -360,6 +360,14 @@ void zpci_destroy_iommu(struct zpci_dev *zdev) iommu_device_sysfs_remove(&zdev->iommu_dev); } =20 +static int s390_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + s390_iommu_detach_device(domain, dev); + + return 0; +} + static const struct iommu_ops s390_iommu_ops =3D { .capable =3D s390_iommu_capable, .domain_alloc =3D s390_domain_alloc, @@ -374,6 +382,10 @@ static const struct iommu_ops s390_iommu_ops =3D { .unmap =3D s390_iommu_unmap, .iova_to_phys =3D s390_iommu_iova_to_phys, .free =3D s390_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D s390_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index 45b58845f5f8..ab62063cee5b 100644 --- a/drivers/iommu/sprd-iommu.c +++ b/drivers/iommu/sprd-iommu.c @@ -413,6 +413,13 @@ static int sprd_iommu_of_xlate(struct device *dev, str= uct of_phandle_args *args) return 0; } =20 +static int sprd_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + sprd_iommu_detach_device(domain, dev); + + return 0; +} =20 static const struct iommu_ops sprd_iommu_ops =3D { .domain_alloc =3D sprd_iommu_domain_alloc, @@ -431,6 +438,10 @@ static const struct iommu_ops sprd_iommu_ops =3D { .iotlb_sync =3D sprd_iommu_sync, .iova_to_phys =3D sprd_iommu_iova_to_phys, .free =3D sprd_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D sprd_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 041b30463552..a51a55ae0634 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -758,6 +758,14 @@ static int sun50i_iommu_of_xlate(struct device *dev, return iommu_fwspec_add_ids(dev, &id, 1); } =20 +static int sun50i_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + sun50i_iommu_detach_device(domain, dev); + + return 0; +} + static const struct iommu_ops sun50i_iommu_ops =3D { .pgsize_bitmap =3D SZ_4K, .device_group =3D sun50i_iommu_device_group, @@ -774,6 +782,10 @@ static const struct iommu_ops sun50i_iommu_ops =3D { .map =3D sun50i_iommu_map, .unmap =3D sun50i_iommu_unmap, .free =3D sun50i_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D sun50i_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index f083a9fba4d0..7e2aef7ae72e 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -270,6 +270,14 @@ static void gart_iommu_sync(struct iommu_domain *domai= n, gart_iommu_sync_map(domain, gather->start, length); } =20 +static int gart_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + gart_iommu_detach_dev(domain, dev); + + return 0; +} + static const struct iommu_ops gart_iommu_ops =3D { .domain_alloc =3D gart_iommu_domain_alloc, .probe_device =3D gart_iommu_probe_device, @@ -286,6 +294,10 @@ static const struct iommu_ops gart_iommu_ops =3D { .iotlb_sync_map =3D gart_iommu_sync_map, .iotlb_sync =3D gart_iommu_sync, .free =3D gart_iommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D gart_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 36e9c2864e3f..fe2c463db230 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -963,6 +963,14 @@ static int tegra_smmu_of_xlate(struct device *dev, return iommu_fwspec_add_ids(dev, &id, 1); } =20 +static int tegra_smmu_blocking_domain_set_dev(struct iommu_domain *domain, + struct device *dev) +{ + tegra_smmu_detach_dev(domain, dev); + + return 0; +} + static const struct iommu_ops tegra_smmu_ops =3D { .domain_alloc =3D tegra_smmu_domain_alloc, .probe_device =3D tegra_smmu_probe_device, @@ -977,6 +985,10 @@ static const struct iommu_ops tegra_smmu_ops =3D { .unmap =3D tegra_smmu_unmap, .iova_to_phys =3D tegra_smmu_iova_to_phys, .free =3D tegra_smmu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D tegra_smmu_blocking_domain_set_dev, + .blocking_domain_detach =3D true, } }; =20 diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index ce2bd01806d8..5054ebaf9654 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -1023,6 +1023,9 @@ static struct iommu_ops viommu_ops =3D { .iova_to_phys =3D viommu_iova_to_phys, .iotlb_sync =3D viommu_iotlb_sync, .free =3D viommu_domain_free, + }, + .blocking_domain_ops =3D &(const struct iommu_domain_ops) { + .set_dev =3D viommu_attach_dev, } }; =20 --=20 2.25.1 From nobody Fri May 8 00:09:39 2026 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 E986BC433EF for ; Mon, 16 May 2022 02:01:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239255AbiEPCBh (ORCPT ); Sun, 15 May 2022 22:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239296AbiEPCB0 (ORCPT ); Sun, 15 May 2022 22:01:26 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B90D312ADC for ; Sun, 15 May 2022 19:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652666484; x=1684202484; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LHhv25RN3InxjHy86FN8zSgjz6xAFhg1jRNzCYo5Vn8=; b=VGZZWW0dZyrNP0ks7Ts0Z/5aQe79+AtW0RR/KMuGddpecxOkbh2tK9Hb JeB+nAs+JpDvbmUPDN6K4mn9DzkTVNLC8YGbb8qVmiX1hFkJI+2foVYwC hR3wnmHbpLNVxYYfmtJ1536Q3hIUpp9sqDDBZ3FWM92/yI+LIYblxOqSG 96olpUgTdJt4pzrpUw069zLXHqJDTBq2X2UeX0SDTl6xvgCm/oCQnF7xB owfPZ50EXWjRtz/hTkEzDmYIfaQPzhFxzmc7t4IpnMSdjJhhNQ/I6wjCc jv/DTMUWanS9xoOiKFhrt6nAy4Jr63MJX+7qLeX6cvitk7gnPAuc6Y5qZ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="270659010" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="270659010" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2022 19:01:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="713172177" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 15 May 2022 19:01:21 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker Cc: Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 3/5] iommu: Make blocking domain static for iommu group Date: Mon, 16 May 2022 09:57:57 +0800 Message-Id: <20220516015759.2952771-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220516015759.2952771-1-baolu.lu@linux.intel.com> References: <20220516015759.2952771-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" This makes the blocking_domain static for an iommu group. It's allocated when the first device joins the group and freed after the last device leaves. Essentially the blocking domain is a dummy domain used to remove the domain from IOMMU's device context. Unfortunately, some IOMMU devices don't provide such capability. In this case, we use an UNMANAGED domain without any mapping instead. Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 85 +++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 31 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 8eba26be4363..dcbc55c9d8d7 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -604,8 +604,6 @@ static void iommu_group_release(struct kobject *kobj) =20 if (group->default_domain) iommu_domain_free(group->default_domain); - if (group->blocking_domain) - iommu_domain_free(group->blocking_domain); =20 kfree(group->name); kfree(group); @@ -854,6 +852,46 @@ static bool iommu_is_attach_deferred(struct device *de= v) return false; } =20 +static int iommu_group_alloc_blocking_domain(struct iommu_group *group, + struct device *dev) +{ + struct iommu_domain *domain; + const struct iommu_ops *iommu_ops =3D dev_iommu_ops(dev); + const struct iommu_domain_ops *ops =3D iommu_ops->blocking_domain_ops; + + if (group->blocking_domain) + return 0; + + if (ops->blocking_domain_detach) { + domain =3D kzalloc(sizeof(*domain), GFP_KERNEL); + if (domain) + domain->type =3D IOMMU_DOMAIN_BLOCKED; + } else { + domain =3D __iommu_domain_alloc(dev->bus, IOMMU_DOMAIN_UNMANAGED); + } + + if (!domain) + return -ENOMEM; + + domain->ops =3D ops; + group->blocking_domain =3D domain; + + return 0; +} + +static void iommu_group_free_blocking_domain(struct iommu_group *group, + struct device *dev) +{ + struct iommu_domain *domain =3D group->blocking_domain; + + if (domain->type =3D=3D IOMMU_DOMAIN_BLOCKED) + kfree(domain); + else + iommu_domain_free(domain); + + group->blocking_domain =3D NULL; +} + /** * iommu_group_add_device - add a device to an iommu group * @group: the group into which to add the device (reference should be hel= d) @@ -867,6 +905,12 @@ int iommu_group_add_device(struct iommu_group *group, = struct device *dev) int ret, i =3D 0; struct group_device *device; =20 + mutex_lock(&group->mutex); + ret =3D iommu_group_alloc_blocking_domain(group, dev); + mutex_unlock(&group->mutex); + if (ret) + return -ENODEV; + device =3D kzalloc(sizeof(*device), GFP_KERNEL); if (!device) return -ENOMEM; @@ -961,6 +1005,8 @@ void iommu_group_remove_device(struct device *dev) break; } } + if (list_empty(&group->devices)) + iommu_group_free_blocking_domain(group, dev); mutex_unlock(&group->mutex); =20 if (!device) @@ -1961,12 +2007,16 @@ static void __iommu_group_set_core_domain(struct io= mmu_group *group) static int __iommu_attach_device(struct iommu_domain *domain, struct device *dev) { + const struct iommu_domain_ops *ops =3D domain->ops; int ret; =20 - if (unlikely(domain->ops->set_dev =3D=3D NULL)) + if (unlikely(ops->set_dev =3D=3D NULL)) return -ENODEV; =20 - ret =3D domain->ops->set_dev(domain, dev); + if (domain->type =3D=3D IOMMU_DOMAIN_BLOCKED) + domain =3D iommu_get_domain_for_dev(dev); + + ret =3D ops->set_dev(domain, dev); if (!ret) trace_attach_device_to_domain(dev); return ret; @@ -3146,29 +3196,6 @@ void iommu_device_unuse_default_domain(struct device= *dev) iommu_group_put(group); } =20 -static int __iommu_group_alloc_blocking_domain(struct iommu_group *group) -{ - struct group_device *dev =3D - list_first_entry(&group->devices, struct group_device, list); - - if (group->blocking_domain) - return 0; - - group->blocking_domain =3D - __iommu_domain_alloc(dev->dev->bus, IOMMU_DOMAIN_BLOCKED); - if (!group->blocking_domain) { - /* - * For drivers that do not yet understand IOMMU_DOMAIN_BLOCKED - * create an empty domain instead. - */ - group->blocking_domain =3D __iommu_domain_alloc( - dev->dev->bus, IOMMU_DOMAIN_UNMANAGED); - if (!group->blocking_domain) - return -EINVAL; - } - return 0; -} - /** * iommu_group_claim_dma_owner() - Set DMA ownership of a group * @group: The group. @@ -3192,10 +3219,6 @@ int iommu_group_claim_dma_owner(struct iommu_group *= group, void *owner) goto unlock_out; } =20 - ret =3D __iommu_group_alloc_blocking_domain(group); - if (ret) - goto unlock_out; - ret =3D __iommu_group_set_domain(group, group->blocking_domain); if (ret) goto unlock_out; --=20 2.25.1 From nobody Fri May 8 00:09:39 2026 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 AB49DC433F5 for ; Mon, 16 May 2022 02:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239321AbiEPCBz (ORCPT ); Sun, 15 May 2022 22:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239284AbiEPCBd (ORCPT ); Sun, 15 May 2022 22:01:33 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43DDE13CC8 for ; Sun, 15 May 2022 19:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652666488; x=1684202488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3Hgd203HC0g1TyuguE1zfaQq4/xIrHOAw15KA4w3UCI=; b=QoL5oRg1QK9im9fU54zVQ6CpArV2ppg8t5DrLYTreMM56e+Wsz/a7tJV OoriwvPrhuMKbLvNWLUbBrbqdRaZ5ucvkj/XpPL0dxgCBGEmXllfl+tH3 R62XSSuwVpjws09MRh2XsZg/nrkoy96M/P4KpiRzFdmxmUrJiyBWEADEa ZOpEXpcY5oed7L+Z+b1EhARtD8WrhnTMkQequYNNiTmHiPPplq3YzBB/N nL+vLMFAI7ujJDIPE3z6GmFiv2QTBQrCGm8KFxl9M+Qr5f7ggEvpE9f+Y JEmHUBejBe6y7uzq8/sTrVElOvrnYSVw1G+jZ/b0a9WbioEHQSkIoj50J A==; X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="270659018" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="270659018" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2022 19:01:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="713172191" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 15 May 2022 19:01:24 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker Cc: Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 4/5] iommu: Use blocking domain for empty domain attaching Date: Mon, 16 May 2022 09:57:58 +0800 Message-Id: <20220516015759.2952771-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220516015759.2952771-1-baolu.lu@linux.intel.com> References: <20220516015759.2952771-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" If a NULL domain is about to set to a device, let's set the blocking domain instead. Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index dcbc55c9d8d7..ba0f427c2823 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2058,16 +2058,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) -{ - if (iommu_is_attach_deferred(dev)) - return; - - 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; @@ -2160,15 +2150,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_set_domain(struct iommu_group *group, struct iommu_domain *new_domain) { @@ -2177,19 +2158,9 @@ static int __iommu_group_set_domain(struct iommu_gro= up *group, if (group->domain =3D=3D new_domain) 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 - * platform specific behavior. - */ - if (!new_domain) { - if (WARN_ON(!group->domain->ops->detach_dev)) - return -EINVAL; - __iommu_group_for_each_dev(group, group->domain, - iommu_group_do_detach_device); - group->domain =3D NULL; - return 0; - } + /* The NULL domain represents some platform specific behavior. */ + if (!new_domain) + new_domain =3D group->blocking_domain; =20 /* * Changing the domain is done by calling set_dev() on the new --=20 2.25.1 From nobody Fri May 8 00:09:39 2026 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 B4DA4C433F5 for ; Mon, 16 May 2022 02:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239340AbiEPCBu (ORCPT ); Sun, 15 May 2022 22:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239307AbiEPCBe (ORCPT ); Sun, 15 May 2022 22:01:34 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C47EF13CE6 for ; Sun, 15 May 2022 19:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652666491; x=1684202491; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hOxaawGZIzuK4xnzeqSxzg8q19xNDedvZWN/kKyU3MY=; b=e65FvvHJ2M53UNIiBr2Tc6lMz5aCIx6O+GwKG02DaB7UrkZP6K78djxb VguH1GSUz7lxJUPViQwUpjY9M3A2wCUD7eDltUOUILtTMPmaFR8DjR5H5 R622j9T+wUjMX0QeagLnk13OZoIqeHdYinNvbTisrmnKU2GeDAgHyNoso EAmD1eZXsUysfGjPsquq26W01R8qfBxlBeXcFNYvTvl8ZSj03n7m53ouU u9nH3ZJczQgTM3IDFIJIAT1hrVYEWrnh/mf8ztpsMSuqWa+R3nktBwt+J 0N+YOVxkELgoMIg0eqhf+CXclR50Xrj9MOJJIn7ZGAoFBp7sKP7yqQDWY A==; X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="270659028" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="270659028" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2022 19:01:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="713172214" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 15 May 2022 19:01:28 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker Cc: Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 5/5] iommu: Remove .detach_dev from iommu domain ops Date: Mon, 16 May 2022 09:57:59 +0800 Message-Id: <20220516015759.2952771-6-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220516015759.2952771-1-baolu.lu@linux.intel.com> References: <20220516015759.2952771-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 is not used anymore. Reomve it to avoid dead code. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 2 -- include/trace/events/iommu.h | 7 ------- drivers/iommu/amd/iommu.c | 1 - drivers/iommu/apple-dart.c | 1 - drivers/iommu/arm/arm-smmu/qcom_iommu.c | 1 - drivers/iommu/exynos-iommu.c | 1 - drivers/iommu/fsl_pamu_domain.c | 1 - drivers/iommu/intel/iommu.c | 1 - drivers/iommu/iommu-traces.c | 1 - drivers/iommu/ipmmu-vmsa.c | 1 - drivers/iommu/msm_iommu.c | 1 - drivers/iommu/mtk_iommu.c | 1 - drivers/iommu/mtk_iommu_v1.c | 1 - drivers/iommu/omap-iommu.c | 1 - drivers/iommu/rockchip-iommu.c | 1 - drivers/iommu/s390-iommu.c | 1 - drivers/iommu/sprd-iommu.c | 1 - drivers/iommu/sun50i-iommu.c | 1 - drivers/iommu/tegra-gart.c | 1 - drivers/iommu/tegra-smmu.c | 1 - 20 files changed, 27 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 5e228aad0ef6..a8c87ebef02d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -264,7 +264,6 @@ struct iommu_ops { /** * struct iommu_domain_ops - domain specific operations * @set_dev: set an iommu domain to a device - * @detach_dev: detach an iommu domain from a 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 * an iommu domain. @@ -287,7 +286,6 @@ struct iommu_ops { */ struct iommu_domain_ops { int (*set_dev)(struct iommu_domain *domain, struct device *dev); - void (*detach_dev)(struct iommu_domain *domain, struct device *dev); =20 int (*map)(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp); 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/amd/iommu.c b/drivers/iommu/amd/iommu.c index c66713439824..9ccf289196be 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2294,7 +2294,6 @@ const struct iommu_ops amd_iommu_ops =3D { .def_domain_type =3D amd_iommu_def_domain_type, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D amd_iommu_attach_device, - .detach_dev =3D amd_iommu_detach_device, .map =3D amd_iommu_map, .unmap =3D amd_iommu_unmap, .iotlb_sync_map =3D amd_iommu_iotlb_sync_map, diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 3c37762e01ec..640f2ebeba0c 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -784,7 +784,6 @@ static const struct iommu_ops apple_dart_iommu_ops =3D { .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D apple_dart_attach_dev, - .detach_dev =3D apple_dart_detach_dev, .map_pages =3D apple_dart_map_pages, .unmap_pages =3D apple_dart_unmap_pages, .flush_iotlb_all =3D apple_dart_flush_iotlb_all, diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/ar= m-smmu/qcom_iommu.c index dee9b5a3a324..b6400458bcdb 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -605,7 +605,6 @@ static const struct iommu_ops qcom_iommu_ops =3D { .pgsize_bitmap =3D SZ_4K | SZ_64K | SZ_1M | SZ_16M, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D qcom_iommu_attach_dev, - .detach_dev =3D qcom_iommu_detach_dev, .map =3D qcom_iommu_map, .unmap =3D qcom_iommu_unmap, .flush_iotlb_all =3D qcom_iommu_flush_iotlb_all, diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index bbecb9a2a554..0ed3ac3f6b28 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1324,7 +1324,6 @@ static const struct iommu_ops exynos_iommu_ops =3D { .of_xlate =3D exynos_iommu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D exynos_iommu_attach_device, - .detach_dev =3D exynos_iommu_detach_device, .map =3D exynos_iommu_map, .unmap =3D exynos_iommu_unmap, .iova_to_phys =3D exynos_iommu_iova_to_phys, diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domai= n.c index 92fc320f8c83..8e32d7942835 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c @@ -467,7 +467,6 @@ static const struct iommu_ops fsl_pamu_ops =3D { .device_group =3D fsl_pamu_device_group, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D fsl_pamu_attach_device, - .detach_dev =3D fsl_pamu_detach_device, .iova_to_phys =3D fsl_pamu_iova_to_phys, .free =3D fsl_pamu_domain_free, }, diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 2060e8a540b3..9b6b3d38de46 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4934,7 +4934,6 @@ const struct iommu_ops intel_iommu_ops =3D { #endif .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D intel_iommu_attach_device, - .detach_dev =3D intel_iommu_detach_device, .map_pages =3D intel_iommu_map_pages, .unmap_pages =3D intel_iommu_unmap_pages, .iotlb_sync_map =3D intel_iommu_iotlb_sync_map, 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/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 72982d1277c2..5803f6175a46 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -886,7 +886,6 @@ static const struct iommu_ops ipmmu_ops =3D { .of_xlate =3D ipmmu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D ipmmu_attach_device, - .detach_dev =3D ipmmu_detach_device, .map =3D ipmmu_map, .unmap =3D ipmmu_unmap, .flush_iotlb_all =3D ipmmu_flush_iotlb_all, diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index b0471d03db60..3f3ce24e1db6 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -691,7 +691,6 @@ static struct iommu_ops msm_iommu_ops =3D { .of_xlate =3D qcom_iommu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D msm_iommu_attach_dev, - .detach_dev =3D msm_iommu_detach_dev, .map =3D msm_iommu_map, .unmap =3D msm_iommu_unmap, /* diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index cc8d80290498..63cb4379314c 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -946,7 +946,6 @@ static const struct iommu_ops mtk_iommu_ops =3D { .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D mtk_iommu_attach_device, - .detach_dev =3D mtk_iommu_detach_device, .map =3D mtk_iommu_map, .unmap =3D mtk_iommu_unmap, .flush_iotlb_all =3D mtk_iommu_flush_iotlb_all, diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 894d2526ba4c..3ffaadcf9a30 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -603,7 +603,6 @@ static const struct iommu_ops mtk_iommu_v1_ops =3D { .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D mtk_iommu_v1_attach_device, - .detach_dev =3D mtk_iommu_v1_detach_device, .map =3D mtk_iommu_v1_map, .unmap =3D mtk_iommu_v1_unmap, .iova_to_phys =3D mtk_iommu_v1_iova_to_phys, diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 7e6ba6f1218d..33ba73be932a 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1748,7 +1748,6 @@ static const struct iommu_ops omap_iommu_ops =3D { .pgsize_bitmap =3D OMAP_IOMMU_PGSIZES, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D omap_iommu_attach_dev, - .detach_dev =3D omap_iommu_detach_dev, .map =3D omap_iommu_map, .unmap =3D omap_iommu_unmap, .iova_to_phys =3D omap_iommu_iova_to_phys, diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 29c803759a0b..3d3baad1bc36 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1202,7 +1202,6 @@ static const struct iommu_ops rk_iommu_ops =3D { .of_xlate =3D rk_iommu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D rk_iommu_attach_device, - .detach_dev =3D rk_iommu_detach_device, .map =3D rk_iommu_map, .unmap =3D rk_iommu_unmap, .iova_to_phys =3D rk_iommu_iova_to_phys, diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index a03bff562a44..e9ad001d086b 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -377,7 +377,6 @@ static const struct iommu_ops s390_iommu_ops =3D { .pgsize_bitmap =3D S390_IOMMU_PGSIZES, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D s390_iommu_attach_device, - .detach_dev =3D s390_iommu_detach_device, .map =3D s390_iommu_map, .unmap =3D s390_iommu_unmap, .iova_to_phys =3D s390_iommu_iova_to_phys, diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index ab62063cee5b..b732cd894725 100644 --- a/drivers/iommu/sprd-iommu.c +++ b/drivers/iommu/sprd-iommu.c @@ -431,7 +431,6 @@ static const struct iommu_ops sprd_iommu_ops =3D { .owner =3D THIS_MODULE, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D sprd_iommu_attach_device, - .detach_dev =3D sprd_iommu_detach_device, .map =3D sprd_iommu_map, .unmap =3D sprd_iommu_unmap, .iotlb_sync_map =3D sprd_iommu_sync_map, diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index a51a55ae0634..12da8e4fdef9 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -775,7 +775,6 @@ static const struct iommu_ops sun50i_iommu_ops =3D { .release_device =3D sun50i_iommu_release_device, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D sun50i_iommu_attach_device, - .detach_dev =3D sun50i_iommu_detach_device, .flush_iotlb_all =3D sun50i_iommu_flush_iotlb_all, .iotlb_sync =3D sun50i_iommu_iotlb_sync, .iova_to_phys =3D sun50i_iommu_iova_to_phys, diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index 7e2aef7ae72e..152a04dd5753 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -287,7 +287,6 @@ static const struct iommu_ops gart_iommu_ops =3D { .of_xlate =3D gart_iommu_of_xlate, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D gart_iommu_attach_dev, - .detach_dev =3D gart_iommu_detach_dev, .map =3D gart_iommu_map, .unmap =3D gart_iommu_unmap, .iova_to_phys =3D gart_iommu_iova_to_phys, diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index fe2c463db230..f35ee4d07a33 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -980,7 +980,6 @@ static const struct iommu_ops tegra_smmu_ops =3D { .pgsize_bitmap =3D SZ_4K, .default_domain_ops =3D &(const struct iommu_domain_ops) { .set_dev =3D tegra_smmu_attach_dev, - .detach_dev =3D tegra_smmu_detach_dev, .map =3D tegra_smmu_map, .unmap =3D tegra_smmu_unmap, .iova_to_phys =3D tegra_smmu_iova_to_phys, --=20 2.25.1