From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FD3A13D606 for ; Tue, 4 Jun 2024 01:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466042; cv=none; b=JxV2PWF632bNB0ag+jxEVtK4FGX4oimJlNmjBiBKQT1Yr/LWlRVwjuQaouUEbt8AKvReuPKT1wA3BdGLvD+QP7YZF/YOiHfZvRm5YEcDKqpzrlCjyovqOOmhKNFDbVQ8FmY9Q7dAZK2RPTdTog9UjZtsX6DFvbD7I+kQDPEZ9XQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466042; c=relaxed/simple; bh=WX+m07wt3DtPAOjU2K7TAng/knQriugPLDZHnttGpjU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PvBZSi+bFGeI1lkm42cFUC+F/+FDJg61THprQoG5c2xJ4KE9fhmxAttmrXd/Z0nYxgBe3mc6/zZHRAgfSCQBCeBsiBoWDokO+A7AAk2SYXxxxVUP+/C1NKmbhdWQLXvEmMHsDQ2QGLXlZQagrC6z8FQrRb9C99js1Urbxwm7Xc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BU589C/v; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BU589C/v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466039; x=1749002039; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WX+m07wt3DtPAOjU2K7TAng/knQriugPLDZHnttGpjU=; b=BU589C/vPAOoNBvrH6WC6U9I2pgPi/J23NzGoZfq/0DuF6GERug4w++U eKdMh+8JZbEm0nqrKQ29GdkuGR+fmJJt26m3B/FtZ5FLeP/S+8nvPG4tF Wv/VXfGfaAP/tnbLnr/iUoQfNgFVIYeXLeUMeqN2LBvGTeKFiblRMUS3Z 2KiCMhxuhwc7c9vyopxPzT50lCkj01FMmi1VvYlBXitgVu41wRR2Iyqth pkT4otcdDdMMowIqIv7ZovZM95mKSUWhgMKrEXedbd7pe1WcSPXG81ZOf 6SGbd1MKwXRmN3ngEqi26BMbc5VEndmB6fZxAU0II1m08BNF2IsSMM6p8 Q==; X-CSE-ConnectionGUID: nBHNzNsHQlyakN2ojrCNFw== X-CSE-MsgGUID: 9VFrthX7Q2SUIjB+tzS1eA== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25384832" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25384832" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:53:59 -0700 X-CSE-ConnectionGUID: H2d7q3d/ToWaibEpldtEew== X-CSE-MsgGUID: e4akGPgXS7ya4weofPLdUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661779" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:53:54 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 01/22] iommu: Add iommu_user_domain_alloc() interface Date: Tue, 4 Jun 2024 09:51:13 +0800 Message-Id: <20240604015134.164206-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit <909f4abd1097> ("iommu: Add new iommu op to create domains owned by userspace") added a dedicated iommu op to allocate a user domain. While IOMMUFD has already made use of this callback, other frameworks like vfio/type1 and vDPA still use the paging domain allocation interface. Add a new interface named iommu_user_domain_alloc(), which indicates the allocation of a domain for device DMA managed by user space driver. All device passthrough frameworks could use this interface for their domain allocation. Although it is expected that all iommu drivers could implement their own domain_alloc_user ops, most drivers haven't implemented it yet. Rollback to the paging domain allocation interface if the iommu driver hasn't implemented this op yet. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 6 ++++++ drivers/iommu/iommu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 7bc8dff7cf6d..6648b2415474 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -780,6 +780,7 @@ extern bool iommu_present(const struct bus_type *bus); extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap); extern bool iommu_group_has_isolated_msi(struct iommu_group *group); extern struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus); +struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags= ); extern void iommu_domain_free(struct iommu_domain *domain); extern int iommu_attach_device(struct iommu_domain *domain, struct device *dev); @@ -1086,6 +1087,11 @@ static inline struct iommu_domain *iommu_domain_allo= c(const struct bus_type *bus return NULL; } =20 +static inline struct iommu_domain *iommu_user_domain_alloc(struct device *= dev, u32 flags) +{ + return ERR_PTR(-ENODEV); +} + static inline void iommu_domain_free(struct iommu_domain *domain) { } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 9df7cc75c1bc..f1416892ef8e 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2032,6 +2032,48 @@ struct iommu_domain *iommu_domain_alloc(const struct= bus_type *bus) } EXPORT_SYMBOL_GPL(iommu_domain_alloc); =20 +/** + * iommu_user_domain_alloc() - Allocate a user domain + * @dev: device for which the domain is allocated + * @flags: iommufd_hwpt_alloc_flags defined in uapi/linux/iommufd.h + * + * Allocate a user domain which will be managed by a userspace driver. Ret= urn + * allocated domain if successful, or a ERR pointer for failure. + */ +struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags) +{ + struct iommu_domain *domain; + const struct iommu_ops *ops; + + if (!dev_has_iommu(dev)) + return ERR_PTR(-ENODEV); + + ops =3D dev_iommu_ops(dev); + if (ops->domain_alloc_user) { + domain =3D ops->domain_alloc_user(dev, flags, NULL, NULL); + if (IS_ERR(domain)) + return domain; + + domain->type =3D IOMMU_DOMAIN_UNMANAGED; + domain->owner =3D ops; + domain->pgsize_bitmap =3D ops->pgsize_bitmap; + domain->ops =3D ops->default_domain_ops; + + return domain; + } + + /* + * The iommu driver doesn't support domain_alloc_user callback. + * Rollback to a UNMANAGED paging domain which doesn't support + * the allocation flags. + */ + if (flags) + return ERR_PTR(-EOPNOTSUPP); + + return __iommu_domain_alloc(ops, dev, IOMMU_DOMAIN_UNMANAGED); +} +EXPORT_SYMBOL_GPL(iommu_user_domain_alloc); + void iommu_domain_free(struct iommu_domain *domain) { if (domain->type =3D=3D IOMMU_DOMAIN_SVA) --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40AE513D8B5 for ; Tue, 4 Jun 2024 01:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466045; cv=none; b=DCb04MsAnw+UFiYr3ZaFMSEMrvgimB6K0KbhCz+nOZgMJymPJmqTLynoRyQpXuvEf0d3exOyE40vU1W3og3F1wBJ8HBr/FheEwdxXBjIRah3WYPjRkmwUMZIaegR35ODvlJWnlCVMzsSH2BvU4/a3B6w+d3PAh1FAyWR6ggRHkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466045; c=relaxed/simple; bh=i2g4o4FMSNI6vy56g2mVccrM+MuXNKNyXwoqmECaK9M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sEC2yR72Z4SzLDLe8KsHy2tZ13IiyYt4rHDQHDXbSJ0outr+UQi7A3KmzOtpzuoV+onTYik9sOcrdh1culjQo4UL68DDcwP33AOqAHs8/Ixb1FyAsJSCb9M5Sfs7L5OjeYVCipjhREi7oa0IaPkSe2D2nu0t98s2OZ3iTNFF4nw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MGomGvjh; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MGomGvjh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466044; x=1749002044; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i2g4o4FMSNI6vy56g2mVccrM+MuXNKNyXwoqmECaK9M=; b=MGomGvjh19dTkPR0w1aBpGbXedA+oPSkuq190ZKphcsIsv7LtWHsbPZg CrbBz91rhpz2nCsFCd9MJBd8AfOhkQZOxFtZ6cFBh7xvFSBnx6+UkL5m8 Ygifn6WgLQ7EyDVUrXtmnVLkanpi8h5nRpw5KvEQYi3WclSbzuxkj/4oS x0sEMDl0jjIl2XYdb2RSdvbOY72jCGTn29vSaDdpT3t0nBi49j2/7COVL JcVhHTi4Xd9hOIi/H/HUUk0s7AjjRpuxgXEsbyCltfaUd6WDF0YFP3vFf UMU1fenTMFsbzJiqYoZhk73i8Dh/g7J9wN8KsPWc6/X7JYrh1KNxF3pW9 g==; X-CSE-ConnectionGUID: nQy0yVThRnqFgnPUIfjyow== X-CSE-MsgGUID: mGGZEsAsR8iou0dmLkWgYw== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25384855" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25384855" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:04 -0700 X-CSE-ConnectionGUID: cJdjhM31QJCIcg5kz7jpwA== X-CSE-MsgGUID: PJKNfxZORvC21A1XdJMlrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661791" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:53:59 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 02/22] iommufd: Use iommu_user_domain_alloc() Date: Tue, 4 Jun 2024 09:51:14 +0800 Message-Id: <20240604015134.164206-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace iommu_domain_alloc() with iommu_user_domain_alloc(). Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/hw_pagetable.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/h= w_pagetable.c index 33d142f8057d..ada05fccb36a 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -127,21 +127,11 @@ iommufd_hwpt_paging_alloc(struct iommufd_ctx *ictx, s= truct iommufd_ioas *ioas, hwpt_paging->ioas =3D ioas; hwpt_paging->nest_parent =3D flags & IOMMU_HWPT_ALLOC_NEST_PARENT; =20 - if (ops->domain_alloc_user) { - hwpt->domain =3D ops->domain_alloc_user(idev->dev, flags, NULL, - user_data); - if (IS_ERR(hwpt->domain)) { - rc =3D PTR_ERR(hwpt->domain); - hwpt->domain =3D NULL; - goto out_abort; - } - hwpt->domain->owner =3D ops; - } else { - hwpt->domain =3D iommu_domain_alloc(idev->dev->bus); - if (!hwpt->domain) { - rc =3D -ENOMEM; - goto out_abort; - } + hwpt->domain =3D iommu_user_domain_alloc(idev->dev, flags); + if (IS_ERR(hwpt->domain)) { + rc =3D PTR_ERR(hwpt->domain); + hwpt->domain =3D NULL; + goto out_abort; } =20 /* --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CD7B13D51C for ; Tue, 4 Jun 2024 01:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466050; cv=none; b=M+cWtoNKaGKZXEVMaBKsNZidR9C377TdBt9uyJbuKqOIdjqqFc9eAuar9uRV9bdx29T9FH1HgPm1c4B4IO6EsL0o/ZmGGMH7qyuKVg5OAsYhUk78GzfO54Xitzfujaf+I/ePtfCBVkPfEQ/iJx/drRsmN8ahGrbcC1pLoVZW/EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466050; c=relaxed/simple; bh=Ku98pK7UgGN8K4Vqi8YCUxqt/MmWDBRD7GnhYQUhVEg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oCSBaDNU8z6tDhotkcDUQZ7kwE0GvY4SgDO8M0w/uivdtIi9SAWg8Gui0EsjiYlX4TdY2q4qle1ipO2Cbrb42ZQRTXuvXQXCefebqFg2Z8DoOvjzSpnwwZoGkomk37fJc7c+ljwkgAjYilsSrDU6ebTJzIT8CVxhpggL8eNSNkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Tu0ikfkQ; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Tu0ikfkQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466049; x=1749002049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ku98pK7UgGN8K4Vqi8YCUxqt/MmWDBRD7GnhYQUhVEg=; b=Tu0ikfkQj4Vspfm9oTzKBauZYeBpaWgaTBVCjKiJpUWr4nKIhDgir9Mk xXn5nzQVqn6Yx8mLhxdnFx4hud9Kj7FUq3OY82T5SKSgyHS+gCVX1x3F/ wWIfjuiUFoX/1SqBty6VTVXG+NZAP40xAxRlZvO3PNFMVFZbvRoxE0ZeI DUSUEqCw+VzCB7NMem9zu5rCLm1hFBP6XhoJkhACsxv5rGRm5OL4q5ZOP eGSprL73B7U16TFK9nwA1vBZXOz2FRWy/D3CUosxgxeLaPEY1kdZUwh8m xFOt8rpqa22oJ/g5X8CK4hDDrlxpCWsT15UuK4HxJ1fiusP7MeLLMSAQw A==; X-CSE-ConnectionGUID: grN7K4CYS0mb3imHrqX85A== X-CSE-MsgGUID: LTamHuYASwiI02Vucy1eXA== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25384876" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25384876" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:09 -0700 X-CSE-ConnectionGUID: 3OptiiBcRb6wogYJZJBjmw== X-CSE-MsgGUID: 7UBZgbTGTcmFgOeAWR9vHQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661800" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:04 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 03/22] vfio/type1: Use iommu_user_domain_alloc() Date: Tue, 4 Jun 2024 09:51:15 +0800 Message-Id: <20240604015134.164206-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace iommu_domain_alloc() with iommu_user_domain_alloc(). Signed-off-by: Lu Baolu --- drivers/vfio/vfio_iommu_type1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type= 1.c index 3a0218171cfa..1d553f7f7c26 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -2135,7 +2135,7 @@ static int vfio_iommu_domain_alloc(struct device *dev= , void *data) { struct iommu_domain **domain =3D data; =20 - *domain =3D iommu_domain_alloc(dev->bus); + *domain =3D iommu_user_domain_alloc(dev, 0); return 1; /* Don't iterate */ } =20 @@ -2192,11 +2192,12 @@ static int vfio_iommu_type1_attach_group(void *iomm= u_data, * us a representative device for the IOMMU API call. We don't actually * want to iterate beyond the first device (if any). */ - ret =3D -EIO; iommu_group_for_each_dev(iommu_group, &domain->domain, vfio_iommu_domain_alloc); - if (!domain->domain) + if (IS_ERR(domain->domain)) { + ret =3D PTR_ERR(domain->domain); goto out_free_domain; + } =20 if (iommu->nesting) { ret =3D iommu_enable_nesting(domain->domain); --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D3E413D60F for ; Tue, 4 Jun 2024 01:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466055; cv=none; b=NvmsWbE/uKBAgmgTDTaTA8JiJDMu+em6DLlmaucifW/cMEdTCvF1DJcMfLfPDqhEZ9yyCpoY4r/jd1P862+171itjJ3mWU7ZEKaMSQTEOAsm+hXfcvsQ8gs/AxsPKGLjqzqAc6P8PYVLhqIW++S4GRBqxj13jUtk2uqkO7PygWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466055; c=relaxed/simple; bh=Ixvg9rthHQ++gOUcIGxznMoJ6JJhVf/NaGpaKm7M1Do=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QgTIRiZxgZCvtZsFcLgbYrn8D2IeIu5SZ7nIya2u6R2GCPGOT3Tsm28sPBRRi/e+CyJ+70RHUS1W2Uv9fkyCFWfY7Ykjawx8jzoDIEEkgz/iV1Us1jIyicP5zI2Q5taZQtBSmY9iNEaC5TFIxY+dKixuGJTQ9GuKn5Pv+Wa/FJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MT+2+YF4; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MT+2+YF4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466054; x=1749002054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ixvg9rthHQ++gOUcIGxznMoJ6JJhVf/NaGpaKm7M1Do=; b=MT+2+YF4SMqVj6Sy/ez9WCNzn3AlfeCLNbowDOFZ8J23qhkwsR5OZQ48 NxnIsQTwKeFyD2SqcQ59uitu3D7tO96+oUuF+ONSSIWOaKybE9ycbz2Yy 2FRAhPQTpJcgC6zSV6FNwewdausXJzBWHqLkmeiAu7YdjADDwAQkOYVwg gcxtGwoaZ61BHtD98Z3sVND16qz2LE5tkROwIo0IcJH3kPP7dDBkR61Mq JKtXZx/Nir7YCGvB1yNuoU//23naCa/wRJGJgI9o7jrvYk+h3v1jvMhjP YmHDCAajG9whKeXw2op2QRMyPL+qbafJTLySYvCXGcq2mhcXPcGCV5p+s A==; X-CSE-ConnectionGUID: YRtrSYPSQZmXhMwecD2adw== X-CSE-MsgGUID: 2h0wEOF5RzCbGqDRieuRIg== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25384900" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25384900" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:14 -0700 X-CSE-ConnectionGUID: KgtWwSTbSBOJFgVEw2AV7w== X-CSE-MsgGUID: 8LxxIA6KQxawSj81m3DOyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661817" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:10 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 04/22] vhost-vdpa: Use iommu_user_domain_alloc() Date: Tue, 4 Jun 2024 09:51:16 +0800 Message-Id: <20240604015134.164206-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace iommu_domain_alloc() with iommu_user_domain_alloc(). Signed-off-by: Lu Baolu --- drivers/vhost/vdpa.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 63a53680a85c..d15673cb05f2 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -1312,26 +1312,24 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdp= a *v) struct vdpa_device *vdpa =3D v->vdpa; const struct vdpa_config_ops *ops =3D vdpa->config; struct device *dma_dev =3D vdpa_get_dma_dev(vdpa); - const struct bus_type *bus; int ret; =20 /* Device want to do DMA by itself */ if (ops->set_map || ops->dma_map) return 0; =20 - bus =3D dma_dev->bus; - if (!bus) - return -EFAULT; - if (!device_iommu_capable(dma_dev, IOMMU_CAP_CACHE_COHERENCY)) { dev_warn_once(&v->dev, "Failed to allocate domain, device is not IOMMU cache coherent ca= pable\n"); return -ENOTSUPP; } =20 - v->domain =3D iommu_domain_alloc(bus); - if (!v->domain) - return -EIO; + v->domain =3D iommu_user_domain_alloc(dma_dev, 0); + if (IS_ERR(v->domain)) { + ret =3D PTR_ERR(v->domain); + v->domain =3D NULL; + return ret; + } =20 ret =3D iommu_attach_device(v->domain, dma_dev); if (ret) --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62DCA13D60F for ; Tue, 4 Jun 2024 01:54:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466060; cv=none; b=th1K8330KvmPd9DV6xsHX207ko3JJEKtvWFJNg4uOEYpVP9el1dD2bSF7NtgA2PvddgZCjOlDR3m3tppIqJjMBCDdgLxiwxcAfDUJCVRvTzve4EA5JbSCNo4j+gL4S3pOaudEHcXLP65bR6/oxM8WEoy2+nojatMXnUBkWc4Czc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466060; c=relaxed/simple; bh=xf05GvXEO+I215J3GQWK9zqCkzSYPhbVb/+Tz/JkYCQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tTYL90y8l9Q36NdyChDmj+c9iTpT6X/XE3TtlyEfS+3/ot2S3EM8SB/14Q0EvyWOPRc8S08Kuwl4S80OEaH0rWO0qDIPg4zyT98FBsRMv/gWMMxLiDsajqiRwyI+hf+eMHudDP2Y3SiikGy8SBFNUM3xuxYq1F0IeZzLlH0gavI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YNFU8r09; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YNFU8r09" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466059; x=1749002059; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xf05GvXEO+I215J3GQWK9zqCkzSYPhbVb/+Tz/JkYCQ=; b=YNFU8r096BP5eDpFKO4OW1JwI75Mqry21pp3shGBWCg3Axv5BTZih8a4 oeY/kEGDsoasMOUio1Pc/NfeqPVGqsE6mRe87dIuKlFLVvFgqEIhGfddZ EvkVZoMkVk3x1BRaegcs3CE6VeQY8dNkpcpt180sJ8tvV7JdJg4Wz5j8x GKpIFaIr1vU6VlLtLTyIHRP9dRiE+PYYK+e3Xu2d+7Ge6bWutLVlkY0OB RPCoYwjkwf+jqgJC4ZAy+5dqWmLtt56OLm4wTM+QHcOz/SbsU3+xosaLH Eu+ixg4X8prp3JdbSfTVJbAmsL4JZM6dUF4/1/tNjzJVj8HfP9IBtDkMt g==; X-CSE-ConnectionGUID: w3UhSEiFReWlc9/8aafCKg== X-CSE-MsgGUID: n5vJTVaNTciITRH9DRisWw== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25384922" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25384922" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:19 -0700 X-CSE-ConnectionGUID: tnO3brn5RtKaOeayj/FeKQ== X-CSE-MsgGUID: JOqcCzIaQuu78m9RMY08Xw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661828" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:15 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 05/22] iommu: Add iommu_paging_domain_alloc() interface Date: Tue, 4 Jun 2024 09:51:17 +0800 Message-Id: <20240604015134.164206-6-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit <17de3f5fdd35> ("iommu: Retire bus ops") removes iommu ops from bus. The iommu subsystem no longer relies on bus for operations. So the bus parameter in iommu_domain_alloc() is no longer relevant. Add a new interface named iommu_paging_domain_alloc(), which explicitly indicates the allocation of a paging domain for DMA managed by a kernel driver. The new interface takes a device pointer as its parameter, that better aligns with the current iommu subsystem. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 6 ++++++ drivers/iommu/iommu.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 6648b2415474..16401de7802d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -781,6 +781,7 @@ extern bool device_iommu_capable(struct device *dev, en= um iommu_cap cap); extern bool iommu_group_has_isolated_msi(struct iommu_group *group); extern struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus); struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags= ); +struct iommu_domain *iommu_paging_domain_alloc(struct device *dev); extern void iommu_domain_free(struct iommu_domain *domain); extern int iommu_attach_device(struct iommu_domain *domain, struct device *dev); @@ -1092,6 +1093,11 @@ static inline struct iommu_domain *iommu_user_domain= _alloc(struct device *dev, u return ERR_PTR(-ENODEV); } =20 +static inline struct iommu_domain *iommu_paging_domain_alloc(struct device= *dev) +{ + return ERR_PTR(-ENODEV); +} + static inline void iommu_domain_free(struct iommu_domain *domain) { } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f1416892ef8e..7df4a021b040 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2016,6 +2016,10 @@ static int __iommu_domain_alloc_dev(struct device *d= ev, void *data) return 0; } =20 +/* + * The iommu ops in bus has been retired. Do not use this interface in + * new drivers. + */ struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus) { const struct iommu_ops *ops =3D NULL; @@ -2074,6 +2078,22 @@ struct iommu_domain *iommu_user_domain_alloc(struct = device *dev, u32 flags) } EXPORT_SYMBOL_GPL(iommu_user_domain_alloc); =20 +/** + * iommu_paging_domain_alloc() - Allocate a paging domain + * @dev: device for which the domain is allocated + * + * Allocate a paging domain which will be managed by a kernel driver. Retu= rn + * allocated domain if successful, or a ERR pointer for failure. + */ +struct iommu_domain *iommu_paging_domain_alloc(struct device *dev) +{ + if (!dev_has_iommu(dev)) + return ERR_PTR(-ENODEV); + + return __iommu_domain_alloc(dev_iommu_ops(dev), dev, IOMMU_DOMAIN_UNMANAG= ED); +} +EXPORT_SYMBOL_GPL(iommu_paging_domain_alloc); + void iommu_domain_free(struct iommu_domain *domain) { if (domain->type =3D=3D IOMMU_DOMAIN_SVA) --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77F0F13D60F for ; Tue, 4 Jun 2024 01:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466065; cv=none; b=EK0swBMOC87XV5F9fO3eK7zC+RH0bDvW+G978fmT4BB+3OoRbeZ8EsXt1S8hKz9mWBENIdhpu4hyRZjpbZSFciTOOdBtcRs6Xf00gSk3IUyIXfdpUy1lfMmAY4hA5Gsqe6ciRrvMOTXQAKGGRuK+lPndC2+PKCUHopCRKGlSDTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466065; c=relaxed/simple; bh=Y8tmajavNhEb2U4e54gDZyZwgTBk84qW7m36BoQgWp0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iHyuqylaIueHfDwnlDzPlRjE+yevMOxjPPgF1IzeDVm5Xy5Mswimbyf1YrVFpE6B21ZUR6l9vxlDrusAaL6liw34hg0/hFi29yosHN8WUJ49td2mBL+7+0vG6c53CB2ESE6AlGKb7GiBbxqn2ivl5ik8axQjNvGUaCdAD1ZDRt4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KXuCHG+6; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KXuCHG+6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466064; x=1749002064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y8tmajavNhEb2U4e54gDZyZwgTBk84qW7m36BoQgWp0=; b=KXuCHG+6IJBSBfhb4lOgwBoN7SwhyImuy8jyE4bXjBMgDqJoJLnX3p4q jApEFRn2Yh72q+HpDC6exNXVOaZpnGbPLkkBi9wVmKiIB43Lj5lxwSjRg s6KVIVw2D0ySS1C29IdIfEm+S8dUNav+7zPwAhci7YintSgEhayX3hH0Y NiRp0f/dOClAyQVTqx6Nt8JtZm5+gIDUqlxau8wvVxmmASQymyHhs3ASR N8svGxf1tjM3YH734EhcihiTR+flRgSSPoRmVYALknQGV+jAd8RdZgDm4 p9I32TCEJJPI9p/O8lqPPCVpYl6uQ9wKG6sGhs1ZrvHf8lsBD1NZhcLbI Q==; X-CSE-ConnectionGUID: 0QS0fvMqTCiOyJ1KismtCg== X-CSE-MsgGUID: W8jDsbOaSxOB53vb2HUVAg== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25384950" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25384950" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:24 -0700 X-CSE-ConnectionGUID: q82kEK5bRvekjrNhIFC1Zw== X-CSE-MsgGUID: CmxBK1IlQW2p11gUJOibRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661843" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:20 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 06/22] drm/msm: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:18 +0800 Message-Id: <20240604015134.164206-7-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The domain allocated in msm_iommu_new() is for the @dev. Replace iommu_domain_alloc() with iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu Acked-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iomm= u.c index d5512037c38b..2a94e82316f9 100644 --- a/drivers/gpu/drm/msm/msm_iommu.c +++ b/drivers/gpu/drm/msm/msm_iommu.c @@ -407,10 +407,13 @@ struct msm_mmu *msm_iommu_new(struct device *dev, uns= igned long quirks) struct msm_iommu *iommu; int ret; =20 - domain =3D iommu_domain_alloc(dev->bus); - if (!domain) + if (!device_iommu_mapped(dev)) return NULL; =20 + domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(domain)) + return ERR_CAST(domain); + iommu_set_pgtable_quirks(domain, quirks); =20 iommu =3D kzalloc(sizeof(*iommu), GFP_KERNEL); --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8056713D889 for ; Tue, 4 Jun 2024 01:54:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466070; cv=none; b=I0YCt4GZf2vBrGiIzwPXpWzgkWpgDEbGg7w5nl7ye48a0stz4+QHM9Av4J4tlL9md7d/ax8baxuB1qgzAo552vOMT1u3ZlgahoGOdC8Z3pSx46M1loZmUoYgUd5dFUpRVEvnQ5KlZonRAcdSl0Ylv5VQl0RwogerfwCDtHE6zo0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466070; c=relaxed/simple; bh=GbpYXxZBS+r4Y0EiK3BFmXVZKaFfLeJ2IAlI0t0Upno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EOvMxK2FrY2nz1kPU4PAcRXq/beUv985v40vrcOVHdVrDS9ns8tMaz29Vjtci3sHSgeBPPIUkZJdiLH5NwzIflCryHZl8Ll/4ckL0jOSNT5K+/GHeB8brqNX+aDU47vWJ8gwNIrF7G3R6lpb5iHSC+iajw8pYtzr1+IQuR7wSLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Knq+jsgG; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Knq+jsgG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466069; x=1749002069; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GbpYXxZBS+r4Y0EiK3BFmXVZKaFfLeJ2IAlI0t0Upno=; b=Knq+jsgG4xMPmNKhDliI/BnsXKIVvkC+YjH9fLmnSz5LoxrLzSoh0WxX 6Nsf38vjwbM1TQv8PMFFABjaRddOPkXG18XkFr9RvvtL5BnLWAT+/xTff L5DF2EoQyXSHHg7IdBCGSagCHKygIv8EaOZ9JzMu0Yu1lcj7FhTHyWkUA gGcYEsd9fpYEUy5zzXpB4iaTyyDStCAOmS7giJa/AzKBFV8LmVt6ef5eU 5z/LbNH+fgR0Va60PwLvWL5fnqtJtyHJPEgzmDgNwXirgzbhfRowhpjUb 3g0DBJRRX4/5a/rF2WnW7YF38D3Y/GilHxet/kuc80oN0+DcKETPr6fLe g==; X-CSE-ConnectionGUID: ZjYk3wZsRVqugSpsYWZsig== X-CSE-MsgGUID: XVefv/QtTtqNZdkL8SR79w== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25384969" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25384969" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:29 -0700 X-CSE-ConnectionGUID: szQ8yndbQgaTpYGWEJJX9g== X-CSE-MsgGUID: 5NNfCBxmSl2dOFakvCmPOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661857" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:25 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 07/22] drm/nouveau/tegra: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:19 +0800 Message-Id: <20240604015134.164206-8-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In nvkm_device_tegra_probe_iommu(), a paging domain is allocated for @dev and attached to it on success. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/g= pu/drm/nouveau/nvkm/engine/device/tegra.c index 87caa4a72921..763c4c2925f9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c @@ -120,8 +120,8 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra = *tdev) mutex_init(&tdev->iommu.mutex); =20 if (device_iommu_mapped(dev)) { - tdev->iommu.domain =3D iommu_domain_alloc(&platform_bus_type); - if (!tdev->iommu.domain) + tdev->iommu.domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(tdev->iommu.domain)) goto error; =20 /* --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 772B214036F for ; Tue, 4 Jun 2024 01:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466075; cv=none; b=cJeZeZe2ttBsRyYFm7cKN4Kp80MjYfryC3bLrWsvOIbR6xjR8Vyr9fYCvum3VH6PaSFIliN+Lrbe+qLqJ4DW/+DYMkG7B5cp2uRjJzTV21a8tOahTgZ2N1bMPO1FzE441ldvGxCjHtDiFz1oHuVoJhWAzQAI0HBLAmB8NRrTyN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466075; c=relaxed/simple; bh=3intrfdlq62sPZGdllNzLo1Ahf/WR8/6yPI2eqBXYY8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V2xmhus0sServqArbWoUN9M1A7A6qHWmTkO4HTENt3ffHZCiPJaKD1sFpyfpS/DtC7WckFBfUIjWhI00p618FBJZuwj4l/NHICuQ62ZFz9+AsAnbbA7GVjnlNz5/NYgZVSu29wMbYBdKe5M8jpEuX3OkqUquKaKsIr9O4W5amsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Boy63i1q; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Boy63i1q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466074; x=1749002074; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3intrfdlq62sPZGdllNzLo1Ahf/WR8/6yPI2eqBXYY8=; b=Boy63i1qpGgOm0rPIKOHlFR1n2jlCGnXcZfG0oDQxT3MuN3vjNP9jTqC 5/HhFviImC/lgEr91+RICIUY7z1T82omT8c8GxuxP8V2jXsSrhDkaaHMB CPJi+QVVZMky5z/2GMcx1k5fnIjaSTFk1Rxi0AQOuFex2m3wuLigvLMoV +mv9hjM7CKk+HeFt72k6GyLRjkutugpsXtJg1XQ4iQ+dT2fz4TvKLd/QD lmx7W/9/s8e03OJ2x6xBB14UUi7+htnZhnge+FdBARUYkTLBwkCTDdefo tYL7i3YHQUbGb6j1AdONwQun91x03EdEY9AUg3O6m5gsQukG7CZvCJHZ5 w==; X-CSE-ConnectionGUID: czkmwpmPTpKKO+KLu5Zg4w== X-CSE-MsgGUID: m9mR97BEQ0e+aXDUCSkFlg== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25384983" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25384983" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:34 -0700 X-CSE-ConnectionGUID: z1Bd9oYQTbCgJn8uWSeXAQ== X-CSE-MsgGUID: gJw4bU42SyyJ0W4xw8ZCEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661869" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:30 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 08/22] gpu: host1x: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:20 +0800 Message-Id: <20240604015134.164206-9-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An iommu domain is allocated in host1x_iommu_attach() and is attached to host->dev. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/gpu/host1x/dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 3a0aaa68ac8d..f86a6b12f24a 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -404,9 +404,10 @@ static struct iommu_domain *host1x_iommu_attach(struct= host1x *host) if (err < 0) goto put_group; =20 - host->domain =3D iommu_domain_alloc(&platform_bus_type); - if (!host->domain) { - err =3D -ENOMEM; + host->domain =3D iommu_paging_domain_alloc(host->dev); + if (IS_ERR(host->domain)) { + err =3D PTR_ERR(host->domain); + host->domain =3D NULL; goto put_cache; } =20 --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F83713D8B2 for ; Tue, 4 Jun 2024 01:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466080; cv=none; b=VM6QLq4nMKvv12m3KUU2YRiQqrsEVos1CENxdMAfVZegvXIHvTX5nVREuqk8PV/7vYaD6yuCURrktaHMshGRH4scHZuhSAdV7UiW3g/3e1FO/1kjtmEWGYk2YO4gT3mouKuISskQvOn/zInOBAlJMr70EvG00BWgMCAkbOHbHTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466080; c=relaxed/simple; bh=gcVUdhVM6KwB99b7OFzWjZ/BBZdHQiOtwXYtd2+KA+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u4lSDFm76w/aElTaaPOfEmClptmmNkqZe4c1SnqksqREXxoB7S2sR4lOVjRK/n0Ttl1zXXRf9IedsBQFeE539HJNJkzSAXWspQAf1U9zPDuBe4cm/iOA99YRTbB55ZExWhexvG/ySp7r/JUSMvTQ8fZtgdk3n+BtbaXKxagPYk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FL5gpbHm; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FL5gpbHm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466079; x=1749002079; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gcVUdhVM6KwB99b7OFzWjZ/BBZdHQiOtwXYtd2+KA+I=; b=FL5gpbHmswqWlvgbMoIZUAg3aC7e4NA6gaMdEiJ3zfBKvNsz4q/X9qT8 P2/o8X04zhfy3PcLQKIGtO+4kSrvyFMXnFPDhcrU8kPxf4saGljctvqSB yGhPtA3ikr/noNfTuNWjNaFZrs6rdYKDYGXUKSsVLUwKz+aATQwUOHR// fg6uDTsKrG3wzjgv8KS++rbZWd/OEOs5/WWgMkd3Cfk/G/wy7ThbZAHIo 9nuJJzAqF0ox+v2neVI6Qx2GT2Zs04Wip5hsYx7MB0B7rbMLNJTsZt4VL 5hEXtilWyIA5qvb6va3gKhUq8M8v2LyJXWfgqBLqt9ZPvxz9HyUAbQYC0 w==; X-CSE-ConnectionGUID: otzPST2pQdiStmDDaB1LrQ== X-CSE-MsgGUID: Lpts8uLORXSyje8V+nCtGA== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385002" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385002" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:39 -0700 X-CSE-ConnectionGUID: DnPnbKhAQ6KevfMrXwRsWg== X-CSE-MsgGUID: pW7vflF4TpC0dcW3FuGODA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661878" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:35 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 09/22] media: nvidia: tegra: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:21 +0800 Message-Id: <20240604015134.164206-10-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An iommu domain is allocated in tegra_vde_iommu_init() and is attached to vde->dev. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/media/platform/nvidia/tegra-vde/iommu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/nvidia/tegra-vde/iommu.c b/drivers/medi= a/platform/nvidia/tegra-vde/iommu.c index 5521ed3e465f..b1d9d841d944 100644 --- a/drivers/media/platform/nvidia/tegra-vde/iommu.c +++ b/drivers/media/platform/nvidia/tegra-vde/iommu.c @@ -78,9 +78,10 @@ int tegra_vde_iommu_init(struct tegra_vde *vde) arm_iommu_release_mapping(mapping); } #endif - vde->domain =3D iommu_domain_alloc(&platform_bus_type); - if (!vde->domain) { - err =3D -ENOMEM; + vde->domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(vde->domain)) { + err =3D PTR_ERR(vde->domain); + vde->domain =3D NULL; goto put_group; } =20 --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B83D513D2BA for ; Tue, 4 Jun 2024 01:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466087; cv=none; b=k9qTmd1zOZ6XZf/GT6cImMe4l+s1tG6cK0kWsXvLX6hFbzpqirFji9saxEmEdeSzGBhKKkfN+gt71WdnzIpVSw3x4H+SOOGo6fzeHjTM83tpMJ36uUCFRpm/600sUZe3cdniDGAJkoAO6wryf9d5W47td8csWRQ9nLaTGolaL4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466087; c=relaxed/simple; bh=sQhpQrDpkr5d6QzI9UDmfi+nhpzVyW1CcaBVDpyFpuE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZG937Y5Nfl4rOB39XnGcdboSQC3NB0hZ1Zt0smooYZmqs/e5lEwJY/DEBGoDJ1ud2EZ+kohQepUztqjzcE+ZgkLiq3gLDWVXVrAkFJ9WPcB9SNKO/yR5H7YUh7sSkRWnmHjFs2ALRjMXOIGqJa2P2bizF8zI1/DHRq8w84MH7mE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jGIF17uH; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jGIF17uH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466084; x=1749002084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sQhpQrDpkr5d6QzI9UDmfi+nhpzVyW1CcaBVDpyFpuE=; b=jGIF17uHdgSogYLbHJLHkYM6fkeJ0WWQThrap59PHoPAO0b8yEfqkbib KCNGMElT4YQrgjSk95cqzgUaaGFmJ4SW+AZpz2ZIlwPY+VMb2rAfYhbez MVm9FiLRScsny/uAc4Fc7A5enM5+XQNQluQZZWKCYIhJaaEznXQXkniXg b6n6+Z07LDBkHDJdAPBHCpCemtLrsPiUZ/NYjYFoGQBraU+B3lYstu2A9 zEDKqkiYfvuGkKVItA3OvNWGkUjrVAVLjX83SK7eKh1CAqh8mM9wLDfK9 Ca21/kAz29HuMFb6rnzOBsQ7rzEViP+qnUVD9SHdf5VLFZmDjQCkEbBhQ w==; X-CSE-ConnectionGUID: JykVb8pKT9eLdAhgs1Jzfg== X-CSE-MsgGUID: /DJejG5GTziaTjpFNgh2tw== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385020" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385020" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:44 -0700 X-CSE-ConnectionGUID: I4TaijsOST+d8oeWfx06Pg== X-CSE-MsgGUID: U/IxZ0NeQJKr3g9XM7QcXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661891" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:40 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 10/22] media: venus: firmware: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:22 +0800 Message-Id: <20240604015134.164206-11-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An iommu domain is allocated in venus_firmware_init() and is attached to core->fw.dev in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/media/platform/qcom/venus/firmware.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/p= latform/qcom/venus/firmware.c index fe7da2b30482..66a18830e66d 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -316,10 +316,10 @@ int venus_firmware_init(struct venus_core *core) =20 core->fw.dev =3D &pdev->dev; =20 - iommu_dom =3D iommu_domain_alloc(&platform_bus_type); - if (!iommu_dom) { + iommu_dom =3D iommu_paging_domain_alloc(core->fw.dev); + if (IS_ERR(iommu_dom)) { dev_err(core->fw.dev, "Failed to allocate iommu domain\n"); - ret =3D -ENOMEM; + ret =3D PTR_ERR(iommu_dom); goto err_unregister; } =20 --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0B081411D9 for ; Tue, 4 Jun 2024 01:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466090; cv=none; b=fVGopIpIBymRbFkcAu2+MgpEJNmxjnoEDsUVfsBX022Ob4Gt/dtv00tPKyKbsqOT+OaRe2OTLXSpOp3fL5Py7Yuw8oXRXARinzvMMHJGPq1DhleTKb6MRRhAqS6sAv9c0MdhLI4+VwyujAz3JJdM3e0YDOOaadtOuZS057VcV6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466090; c=relaxed/simple; bh=kv68qkR9q97yuL81djioGxxqJnKTS0o+E5D+XI6WQks=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V8+p775F5PFJUPOFcfcfcYESmblvAAAZsA5LNIjJJkq+diABllIa6M8X4IU8rOu9fMaQ2SIoYpQJncKoZrac6hUYLXEcyQm83XohZsQbkvaLlOsju1GNJlhv8foFIugQqY/rfr4j2PHFdCg8gdnAd6pcRlX+xAqR256cj7N8Xmw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GZlPlV+z; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GZlPlV+z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466089; x=1749002089; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kv68qkR9q97yuL81djioGxxqJnKTS0o+E5D+XI6WQks=; b=GZlPlV+zsLuUntfY+agB5uIMitJsYCG2VxFoK9wFmFlU9OzScqNMjCSd DsPVUdV8pAQUQLJQgnG16XiPbZPm8cl5Gar9LWtngRpBbKAeYXdY0vYvu ZJiTK5QzgyneUDH4AcaRBc7empueDr09tEnjBLhTvUHl68Becptx1hZza yHvBU9xXa35G83sGDh06WTHaTBfiqobF5DTbXRNy5LYNbsDU1Xv9HCgfO mCqxGeRQrCBkRtytwVvevBlAe/RZ1D3ugHsCI6AIq6jYIwh2LpyH3vBr8 IyOafr8nS594YL9DPZnnwlLn4rQf4neYUTsreEu69j0ZvbjlB83FQ/Msv g==; X-CSE-ConnectionGUID: eZbFXPq7QmW9ogH7VcWYlw== X-CSE-MsgGUID: FANZF1FQRRK3hZLQk+f8lg== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385031" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385031" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:49 -0700 X-CSE-ConnectionGUID: /AzNYxuvQx2xoxMl9BNqEw== X-CSE-MsgGUID: ll0cIefjRU6Vo9+7jOwqfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661900" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:45 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 11/22] ath10k: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:23 +0800 Message-Id: <20240604015134.164206-12-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An iommu domain is allocated in ath10k_fw_init() and is attached to ar_snoc->fw.dev in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath10k/snoc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/= ath/ath10k/snoc.c index 8530550cf5df..0fe47d51013c 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -1635,10 +1635,10 @@ static int ath10k_fw_init(struct ath10k *ar) =20 ar_snoc->fw.dev =3D &pdev->dev; =20 - iommu_dom =3D iommu_domain_alloc(&platform_bus_type); - if (!iommu_dom) { + iommu_dom =3D iommu_paging_domain_alloc(ar_snoc->fw.dev); + if (IS_ERR(iommu_dom)) { ath10k_err(ar, "failed to allocate iommu domain\n"); - ret =3D -ENOMEM; + ret =3D PTR_ERR(iommu_dom); goto err_unregister; } =20 --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A15F91411D9 for ; Tue, 4 Jun 2024 01:54:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466095; cv=none; b=qF4PXMQ4TpUEJ6SMvYD+GQKX+mVXa1jQ3WMvkSzlhYz6A37qq2D1YvA8NtrE20HO1eir5ZSV2Kh5zMf5Yk54sG9uVbXtMh1i2t0yaRlakTNyzBE1eRuJ3hWvqy6DC4ESYPeCWUu62E3uwSK4pDrXzgZUoi1DK6prphTMa9k1Iis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466095; c=relaxed/simple; bh=b4g7oPuUpFCf7ehXVGbGAAANzK1lpGoRJJpR32Cbgc4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H+pB1b/4Nm2JZ15TzeoFMOYTycLCbPJ5PcZEgvffrYg8Soa0Ai8ukHZegb8eyPOnI24lPCsC4X695cBWa7Z+T4I+WeABrrqggPVBs1lGdIRbMmn0y8GIy5lZ48SEbgBQXYg6jOIgKzrpHh6TlBDL+ZZRZaDFhO7Geu4DI0UsI+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bE2t4oR1; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bE2t4oR1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466094; x=1749002094; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b4g7oPuUpFCf7ehXVGbGAAANzK1lpGoRJJpR32Cbgc4=; b=bE2t4oR1SXKURPiz1Dsdxe0KQsjSDDW/MIuOMpgWNpM8h+I3a4ciWn3m N/yPzNc6yJ0vb2Z4VfEcLEPYrxoGpxMCoHQzeJbt2oN9lpT3dmPp4XLWA N5MKjIvDShvDwxxfDV2N3oQDCrckZtapmhofcTGNE12yrUE1Mfc69L6eN bMIALIWH8+tlKZUKrjzliktBt9y4Wqq1TfNuVft4V6YqgtUc8JRRzqCCr wDMPO+YPLWjQVjl7GMAEFkCqpAhVHgHvlR7D68hKzl1wWt/er4sgDvNdE U9x28K2EQLJdqeGBEReodVBqRi3GJaZFQcJCs3AkFbYnlrUUhFBJeeOpQ w==; X-CSE-ConnectionGUID: Knvb5Fc7Qlqk8uLovWBSVQ== X-CSE-MsgGUID: 6ud5bYqJREeh6jX++cLQ8A== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385045" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385045" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:54 -0700 X-CSE-ConnectionGUID: DQ0egUMjQGSEUpZ0ZFVhjw== X-CSE-MsgGUID: 2DpNSy0/Tymi8iHi2D3nuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661916" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:50 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 12/22] wifi: ath11k: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:24 +0800 Message-Id: <20240604015134.164206-13-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An iommu domain is allocated in ath11k_ahb_fw_resources_init() and is attached to ab_ahb->fw.dev in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath11k/ahb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/a= th/ath11k/ahb.c index ca0f17ddebba..a469647719f9 100644 --- a/drivers/net/wireless/ath/ath11k/ahb.c +++ b/drivers/net/wireless/ath/ath11k/ahb.c @@ -1001,10 +1001,10 @@ static int ath11k_ahb_fw_resources_init(struct ath1= 1k_base *ab) =20 ab_ahb->fw.dev =3D &pdev->dev; =20 - iommu_dom =3D iommu_domain_alloc(&platform_bus_type); - if (!iommu_dom) { + iommu_dom =3D iommu_paging_domain_alloc(ab_ahb->fw.dev); + if (IS_ERR(iommu_dom)) { ath11k_err(ab, "failed to allocate iommu domain\n"); - ret =3D -ENOMEM; + ret =3D PTR_ERR(iommu_dom); goto err_unregister; } =20 --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A861013DDCB for ; Tue, 4 Jun 2024 01:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466101; cv=none; b=OX4F15ifZTOND5rUZL/CiFr/cgmqHG2gNwto+kMV/8kbpupv1ehZRkWxN6IERf1i4WIqhAiLaIWzm1RECmGcZ7FfdgGxInl925GZxwfF3OJuHIYAiZ393z66PAn0w7eC+V+x0Ux7B0+bgXHaDOdq6Irgt8Vy6VjbZmIW07hwWrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466101; c=relaxed/simple; bh=kDJcZN33ntEvZZurzXrpsoEVgCNzk8vicnqImPO/kUg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DZ+SdhRYcX5cV11I1T9zXXK/6lPleF9F0VdkOz5Wx5SmswCWAZ0wgmpbHPItz0iAvhzwNNWsk35tBMk5vKNiDt5nOinNiO7Et8O20f/gRaIWOGnC34DasEUTEL9hRR0GXuvz/KVsIMnpkaXPkpUMNK2LmtciTTYnaPVnekaHzE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=APiSe0HP; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="APiSe0HP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466099; x=1749002099; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kDJcZN33ntEvZZurzXrpsoEVgCNzk8vicnqImPO/kUg=; b=APiSe0HPdgjUnddTUsw28Gc4DXVU22j8kfMMfCW9/3BP6aX/p3AOfKqP oajH8D9R5usOEwWQZkL7OiW5LnfRpq+NdR+H9Ss4YWMOOZE02YkAVGhO+ SwErEEoS8mZugV5pArY9PMIFqPgWA38af1xir3lm8DTvUD6tSVxXiSu51 eivKRxCS8Zx7UXo7ZSe9H6qZEr4j71fr9BFHInseMbovaQoMPIQJyLyIa Vkm003/yzIJsfnjHroIxTB/k3aMxjhcXWL+CmHycKDuMMVYF5Ulq1i9jJ n/moAoBhDVTqf6PZc5dP0YoxaSdVFEIpc92cqktSmU+giyi7vWAMKTlho A==; X-CSE-ConnectionGUID: 826e4rhHTLK5PplLF2S04g== X-CSE-MsgGUID: f4X4OnsTS4uItyQbA072Pw== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385057" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385057" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:54:59 -0700 X-CSE-ConnectionGUID: DTyXmmBOQmCNwsou/DMlhQ== X-CSE-MsgGUID: 1cbIuYNgSouRWqxQ9G8H1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661929" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:54:55 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 13/22] remoteproc: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:25 +0800 Message-Id: <20240604015134.164206-14-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An iommu domain is allocated in rproc_enable_iommu() and is attached to rproc->dev.parent in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/remoteproc/remoteproc_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remo= teproc_core.c index f276956f2c5c..eb66f78ec8b7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -109,10 +109,10 @@ static int rproc_enable_iommu(struct rproc *rproc) return 0; } =20 - domain =3D iommu_domain_alloc(dev->bus); - if (!domain) { + domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(domain)) { dev_err(dev, "can't alloc iommu domain\n"); - return -ENOMEM; + return PTR_ERR(domain); } =20 iommu_set_fault_handler(domain, rproc_iommu_fault, rproc); --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F275413E020 for ; Tue, 4 Jun 2024 01:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466106; cv=none; b=rjh3nVf4t4lcMB3172ELGNJm9RjuwFPvAwTnt/nTT0CCgFbbsw40OJt9UmLd9vmVMCXWA7cMIivxHoMyKfu1QAqTslQtrh5vC7JIDw0qrgMNcyX84vCUZQrJwrO1Z778SN2n2x/xNM+g3k+PjzstpFvBKVDwtasXxW6aC4cpS1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466106; c=relaxed/simple; bh=sM71nWFg3cNfoT7YtYLr4iW7aTMKAR3F9pN2mUDECnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MuYOGswq4HHTJCZaYFohW2n8lSNmj0BzeRTZJFMysFlnQcFY/KYj1p6MLLIgyFEtyim+Yjy0DXYa/ix69YgzdJhpa55NsacObT9wXrr13z44/65E8s9K9vgle6LWe+q9jQnuXlVSwYdxku0R4/P+iqpAtoAdd6SI+KbxPqYkUNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZDUzqcIQ; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZDUzqcIQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466105; x=1749002105; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sM71nWFg3cNfoT7YtYLr4iW7aTMKAR3F9pN2mUDECnk=; b=ZDUzqcIQBbDNSST6JwZUsLzcU9juCPB4/pYyMT9S5NULFPPHwcm8G58g YjEhHyMJ8JvyAeg5jTYHN9YeShuatM6zMrY+w3cRyjJoZLTbmDsnBOmqD DSx63CSPVGtmeSGX3vXlR3FfUZ3qWjVp3SeBjM0XnDcIHM+bTE0mjtk13 HSILhsRAkQo670FKXN/ETXqe7MMMus9D7iaxcy45A0z5ksS1WmuxxAmUy 3o7L3DgYxn9HiTvAp5awy4KeSyeS4FIY2/l6IstHr/qrNHeHzwoy1/HAP XYY2Q/6DV+LcIoXok9FCRT7XN0NyJ1GCdr+91oUvdzCOD4s0dfjc/0UN3 Q==; X-CSE-ConnectionGUID: DHNEIXi7TaSQMxLICEZYug== X-CSE-MsgGUID: LymqMMA6SaOu+yo889tGYA== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385073" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385073" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:04 -0700 X-CSE-ConnectionGUID: LPeuwZRTQwS7l9EikmKgHA== X-CSE-MsgGUID: FcmlMLbDT6S4m+oC2yOaQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661974" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:00 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 14/22] soc/fsl/qbman: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:26 +0800 Message-Id: <20240604015134.164206-15-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An iommu domain is allocated in portal_set_cpu() and is attached to pcfg->dev in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/soc/fsl/qbman/qman_portal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qm= an_portal.c index e23b60618c1a..456ef5d5c199 100644 --- a/drivers/soc/fsl/qbman/qman_portal.c +++ b/drivers/soc/fsl/qbman/qman_portal.c @@ -48,9 +48,10 @@ static void portal_set_cpu(struct qm_portal_config *pcfg= , int cpu) struct device *dev =3D pcfg->dev; int ret; =20 - pcfg->iommu_domain =3D iommu_domain_alloc(&platform_bus_type); - if (!pcfg->iommu_domain) { + pcfg->iommu_domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(pcfg->iommu_domain)) { dev_err(dev, "%s(): iommu_domain_alloc() failed", __func__); + pcfg->iommu_domain =3D NULL; goto no_iommu; } ret =3D fsl_pamu_configure_l1_stash(pcfg->iommu_domain, cpu); --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E96FB13D602 for ; Tue, 4 Jun 2024 01:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466111; cv=none; b=u3G6WBZgGD0h7iokQRltIMTan8gLRiABTT2lnLeNF+FA7FJaEjg9qU5uBV4OWEn8nEGMktniI/ldDLjBpq1Kzj6DSV58uWrQvQE1KDDm4sTk755lIBvFK/YIoP+Ap9KnhRjxWKSLY0/+4xLrV7l+rlWaWDE0ZHUguHqesJ330zM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466111; c=relaxed/simple; bh=Q9WtpwCC02vx2ybK55ip8mbKEJ1zuaBDftnxsc6ieIQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=qV7c8Li0cNCbBKPMbIL4PoCWJ1fcEb8zm31lo3C+3m38aKwrKXwle7RwF9/d6cHS6VgooBfC0HyoWYrem7pqfWReAzYRHcnXl9uw7hKdM/FSh6444wkB2h2KgBamwadRGV5MT4EdrWDURfKIpNSRlIVYV35gBkMLQmJfxVOWiKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=cv+PDNX1; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cv+PDNX1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466110; x=1749002110; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q9WtpwCC02vx2ybK55ip8mbKEJ1zuaBDftnxsc6ieIQ=; b=cv+PDNX1p09gG2SgUoDWOnhcFPM9qGpbLN4q6zJJ5oob/hIPuVRnPErx lVEbpHFj4ejhgyPqzF5b8QwjniyA8E6zF/V7wjWhoD0fMMGYmwEbBVhdQ Bnn/mtlbz4G1+aYrN4Fl6UCm67/fRZVa92oynCISHgtHpd6TkKqvhrp+H PVVAoPYHNgYxLgUP6ZB8wdO95yOS2ZQReF+8NMvHOBNtFIEUuAHrn7eM4 1I92eboU6jRn/Z0ccP87+KnaniwffSeb5V9+lKE44NoSAc+3Xbir2MmtU K+Ud2qh7GCr1WLLI5JFMakfVv2ZfIlzkQ7ooOsBsoRWS3RtangAkJiewu A==; X-CSE-ConnectionGUID: YSEQt1CJTqafiHOYYSBpVg== X-CSE-MsgGUID: 0NBMZM7jQbWuVCC47KqOUw== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385096" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385096" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:09 -0700 X-CSE-ConnectionGUID: e1r3ChScReqqwQzmKW9O+Q== X-CSE-MsgGUID: hie+PAaPSB6kc851S6gIgQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37661993" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:05 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 15/22] RDMA/usnic: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:27 +0800 Message-Id: <20240604015134.164206-16-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable usnic_uiom_alloc_pd() allocates a paging domain for a given device. In this case, iommu_domain_alloc(dev->bus) is equivalent to=C2=A0 iommu_paging_domain_alloc(dev). Replace it as iommu_domain_alloc() has been deprecated. Signed-off-by: Lu Baolu Acked-by: Jason Gunthorpe --- drivers/infiniband/hw/usnic/usnic_uiom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/= hw/usnic/usnic_uiom.c index 84e0f41e7dfa..f948b76f984d 100644 --- a/drivers/infiniband/hw/usnic/usnic_uiom.c +++ b/drivers/infiniband/hw/usnic/usnic_uiom.c @@ -443,11 +443,11 @@ struct usnic_uiom_pd *usnic_uiom_alloc_pd(struct devi= ce *dev) if (!pd) return ERR_PTR(-ENOMEM); =20 - pd->domain =3D domain =3D iommu_domain_alloc(dev->bus); - if (!domain) { + pd->domain =3D domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(domain)) { usnic_err("Failed to allocate IOMMU domain"); kfree(pd); - return ERR_PTR(-ENOMEM); + return ERR_CAST(domain); } =20 iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL); --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4536613D602 for ; Tue, 4 Jun 2024 01:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466116; cv=none; b=Y7pvPZIgxrjfKapvnXAZdJOX7Pj3KSR5pZQGZb9gs847MB9ZMGZ3S7ZOWS0mrMTj19hGkwDS9fELF58TB6S8fNLurr0pzidfh8zr0W8b3r9CCtFgi6u4SFsZgm5cU+86Xzx1jhhljDb0m8gk/7+zGe6s67wwvtZPcbOgUkmas2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466116; c=relaxed/simple; bh=kAf7SPBLso5zp49wUYubqs0YKzd/lC+tt+i0+MOxu64=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DiQ06789pj5xnrEsOMhEJj6L1WDcPnfLPAYGDopkik9bm4Yl1fm3CRq4E4SzX5xARVUgxGbryBNBkorTctVqnv/S3C31meR5KvNbTJuYhBT3THOD8RHL18xLo0JpwsyOpzG/M/ZA+yxBVdTDZ3CWoU0SFspec+/DHIG5l06QOHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ImMPwOS2; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ImMPwOS2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466115; x=1749002115; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kAf7SPBLso5zp49wUYubqs0YKzd/lC+tt+i0+MOxu64=; b=ImMPwOS2JXbxXm7beN8Z18qt5UlBLtMurMcdggCZURLEbu1jyJloiyQ7 EXmnThg8g+nPmKd42WzMD5XzasLCuFUdSubJYKaiXmoszx2qLb8+LRFiH uJtZavjtHQRvfYc1LcJAgV2wv0KO57VMWdOnvkQ5NaMOE1YWSXl4ICXj+ izBx78JY14YwX6E/lHV01gdQKSAKqmIP2te6mcNQWdLF+navbVk/uL9lq BQqCu7H38gUKfCPaJT5qLn/uSLAg2w7MhpmDdbbnraxdgbyle5VVkOQnS OJ0lseQyrRvoDiIfaGDL9Gu5I29AgbMj+PbyE0Iek/PP/oKH3aoP5VJV+ w==; X-CSE-ConnectionGUID: DTZBXE3mS9iaMVmim/WE+g== X-CSE-MsgGUID: qDrh4lNSRAGsLXXnw5cnaw== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385112" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385112" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:15 -0700 X-CSE-ConnectionGUID: jA42G9WrSPGHTpJhOfsc+w== X-CSE-MsgGUID: pDOu6a06Qr+ncAZQM+PzJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37662017" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:10 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 16/22] iommu/vt-d: Add helper to allocate paging domain Date: Tue, 4 Jun 2024 09:51:28 +0800 Message-Id: <20240604015134.164206-17-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The domain_alloc_user operation is currently implemented by allocating a paging domain using iommu_domain_alloc(). This is because it needs to fully initialize the domain before return. Add a helper to do this to avoid using iommu_domain_alloc(). Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 87 +++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 2e9811bf2a4e..ccde5f5972e4 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3633,6 +3633,79 @@ static struct iommu_domain blocking_domain =3D { } }; =20 +static int iommu_superpage_capability(struct intel_iommu *iommu, bool firs= t_stage) +{ + if (!intel_iommu_superpage) + return 0; + + if (first_stage) + return cap_fl1gp_support(iommu->cap) ? 2 : 1; + + return fls(cap_super_page_val(iommu->cap)); +} + +static struct dmar_domain *paging_domain_alloc(struct device *dev, bool fi= rst_stage) +{ + struct device_domain_info *info =3D dev_iommu_priv_get(dev); + struct intel_iommu *iommu =3D info->iommu; + struct dmar_domain *domain; + int addr_width; + + domain =3D kzalloc(sizeof(*domain), GFP_KERNEL); + if (!domain) + return ERR_PTR(-ENOMEM); + + INIT_LIST_HEAD(&domain->devices); + INIT_LIST_HEAD(&domain->dev_pasids); + INIT_LIST_HEAD(&domain->cache_tags); + spin_lock_init(&domain->lock); + spin_lock_init(&domain->cache_lock); + xa_init(&domain->iommu_array); + + domain->nid =3D dev_to_node(dev); + domain->has_iotlb_device =3D info->ats_enabled; + domain->use_first_level =3D first_stage; + + /* calculate the address width */ + addr_width =3D agaw_to_width(iommu->agaw); + if (addr_width > cap_mgaw(iommu->cap)) + addr_width =3D cap_mgaw(iommu->cap); + domain->gaw =3D addr_width; + domain->agaw =3D iommu->agaw; + domain->max_addr =3D __DOMAIN_MAX_ADDR(addr_width); + + /* iommu memory access coherency */ + domain->iommu_coherency =3D iommu_paging_structure_coherency(iommu); + + /* pagesize bitmap */ + domain->domain.pgsize_bitmap =3D SZ_4K; + domain->iommu_superpage =3D iommu_superpage_capability(iommu, first_stage= ); + domain->domain.pgsize_bitmap |=3D domain_super_pgsize_bitmap(domain); + + /* + * IOVA aperture: First-level translation restricts the input-address + * to a canonical address (i.e., address bits 63:N have the same value + * as address bit [N-1], where N is 48-bits with 4-level paging and + * 57-bits with 5-level paging). Hence, skip bit [N-1]. + */ + domain->domain.geometry.force_aperture =3D true; + domain->domain.geometry.aperture_start =3D 0; + if (first_stage) + domain->domain.geometry.aperture_end =3D __DOMAIN_MAX_ADDR(domain->gaw -= 1); + else + domain->domain.geometry.aperture_end =3D __DOMAIN_MAX_ADDR(domain->gaw); + + /* always allocate the top pgd */ + domain->pgd =3D iommu_alloc_page_node(domain->nid, GFP_KERNEL); + if (!domain->pgd) { + kfree(domain); + return ERR_PTR(-ENOMEM); + } + domain_flush_cache(domain, domain->pgd, PAGE_SIZE); + + return domain; +} + static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) { struct dmar_domain *dmar_domain; @@ -3695,15 +3768,11 @@ intel_iommu_domain_alloc_user(struct device *dev, u= 32 flags, if (user_data || (dirty_tracking && !ssads_supported(iommu))) return ERR_PTR(-EOPNOTSUPP); =20 - /* - * domain_alloc_user op needs to fully initialize a domain before - * return, so uses iommu_domain_alloc() here for simple. - */ - domain =3D iommu_domain_alloc(dev->bus); - if (!domain) - return ERR_PTR(-ENOMEM); - - dmar_domain =3D to_dmar_domain(domain); + /* Do not use first stage for user domain translation. */ + dmar_domain =3D paging_domain_alloc(dev, false); + if (IS_ERR(dmar_domain)) + return ERR_CAST(dmar_domain); + domain =3D &dmar_domain->domain; =20 if (nested_parent) { dmar_domain->nested_parent =3D true; --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA8B313E3F2 for ; Tue, 4 Jun 2024 01:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466122; cv=none; b=mbPJadKzTQLDTaUwn0fXqOakFV+mHOxhlggJ3eovoJ6mRpyVh2t9jibq0YZZY9RtLNgb2Qs8fTdPwpnKk7wFrdA19bHQU+gTKJkkAv4BUe7+QryK0jW9vvEtnnmrFxwm/Wxm/aoKmGUFF0vVIpjdVazgSnbNhsaMRZPlmlKeczE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466122; c=relaxed/simple; bh=KoW/D18MopXUFdHXQ6Q/PnnQkxmmhncr645BE4UuUac=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rqAqX5qHgaK4IrGCi0KBpQg4ielZjaLQ9woFE8CQRt8d6DGOY1kemkN5R2e4gq9DfMSj9DxkDuJux+uAkSowQTRcQFc1PaJmHIwuhW9DTHRaL9mnhFA298gDRiW55M2o3yNvg4tIE4FxzTMgrwKR9+napTPR6UqIj+KSRsS1u28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ur9kay7r; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ur9kay7r" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466121; x=1749002121; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KoW/D18MopXUFdHXQ6Q/PnnQkxmmhncr645BE4UuUac=; b=Ur9kay7rfaWJjRI9ghAIRtAsyFI8Kqli0Ry4WZma/SfRsT3FDFOLYyWv wCvdOcGjE7FHL+MqH/UTDLMTodxNERkLoRH8mkrsmExVMiieZkIhqD8MD 4LLW+8FB5Nm3JCNAzHy/j8uJf+9RkbKH2C+m2qxkVm5Xru0TmTssZTHxk FlR54A/rFW4RRXqdyj0tdGqxlqOpErAaelRYCLpMt4j/lMCxZAD1CbCsK JVQQSmNUSOk29AJ1Kw7v8rgauh/nP+2o20DNH9H++eC7L9/Oa4EbQeuJQ vaLWpgDjqJi3CT/WU/8O4v14l4wqwcnE+JRU9v4nMg2Cc8DegovblY7gQ g==; X-CSE-ConnectionGUID: sZryKuVjRbmzjlgnVwla/w== X-CSE-MsgGUID: fMNI1QwQSOKZE82RgFOd1g== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385138" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385138" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:20 -0700 X-CSE-ConnectionGUID: 8KCAZo9aTm+WGTPkIQjPMQ== X-CSE-MsgGUID: Clo85EuxT/qX1MmOM+MbzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37662033" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:15 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 17/22] ARM: dma-mapping: Pass device to arm_iommu_create_mapping() Date: Tue, 4 Jun 2024 09:51:29 +0800 Message-Id: <20240604015134.164206-18-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Robin Murphy All users of ARM IOMMU mappings create them for a particular device, so change the interface to accept the device rather than forcing a vague indirection through a bus type. This prepares for making a similar change to iommu_domain_alloc() itself. Signed-off-by: Robin Murphy Signed-off-by: Lu Baolu --- arch/arm/include/asm/dma-iommu.h | 2 +- arch/arm/mm/dma-mapping.c | 8 ++++---- drivers/gpu/drm/exynos/exynos_drm_dma.c | 2 +- drivers/iommu/ipmmu-vmsa.c | 3 +-- drivers/iommu/mtk_iommu_v1.c | 3 +-- drivers/media/platform/ti/omap3isp/isp.c | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-io= mmu.h index 82ec1ccf1fee..2ce4c5683e6d 100644 --- a/arch/arm/include/asm/dma-iommu.h +++ b/arch/arm/include/asm/dma-iommu.h @@ -24,7 +24,7 @@ struct dma_iommu_mapping { }; =20 struct dma_iommu_mapping * -arm_iommu_create_mapping(const struct bus_type *bus, dma_addr_t base, u64 = size); +arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size); =20 void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping); =20 diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 5adf1769eee4..52f9c56cc3cb 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1532,7 +1532,7 @@ static const struct dma_map_ops iommu_ops =3D { =20 /** * arm_iommu_create_mapping - * @bus: pointer to the bus holding the client device (for IOMMU calls) + * @dev: pointer to the client device (for IOMMU calls) * @base: start address of the valid IO address space * @size: maximum size of the valid IO address space * @@ -1544,7 +1544,7 @@ static const struct dma_map_ops iommu_ops =3D { * arm_iommu_attach_device function. */ struct dma_iommu_mapping * -arm_iommu_create_mapping(const struct bus_type *bus, dma_addr_t base, u64 = size) +arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size) { unsigned int bits =3D size >> PAGE_SHIFT; unsigned int bitmap_size =3D BITS_TO_LONGS(bits) * sizeof(long); @@ -1585,7 +1585,7 @@ arm_iommu_create_mapping(const struct bus_type *bus, = dma_addr_t base, u64 size) =20 spin_lock_init(&mapping->lock); =20 - mapping->domain =3D iommu_domain_alloc(bus); + mapping->domain =3D iommu_domain_alloc(dev->bus); if (!mapping->domain) goto err4; =20 @@ -1718,7 +1718,7 @@ static void arm_setup_iommu_dma_ops(struct device *de= v) dma_base =3D dma_range_map_min(dev->dma_range_map); size =3D dma_range_map_max(dev->dma_range_map) - dma_base; } - mapping =3D arm_iommu_create_mapping(dev->bus, dma_base, size); + mapping =3D arm_iommu_create_mapping(dev, dma_base, size); if (IS_ERR(mapping)) { pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n", size, dev_name(dev)); diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exyn= os/exynos_drm_dma.c index e2c7373f20c6..6a6761935224 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dma.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c @@ -110,7 +110,7 @@ int exynos_drm_register_dma(struct drm_device *drm, str= uct device *dev, void *mapping =3D NULL; =20 if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) - mapping =3D arm_iommu_create_mapping(&platform_bus_type, + mapping =3D arm_iommu_create_mapping(dev, EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); else if (IS_ENABLED(CONFIG_IOMMU_DMA)) mapping =3D iommu_get_domain_for_dev(priv->dma_dev); diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index b657cc09605f..ff55b8c30712 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -804,8 +804,7 @@ static int ipmmu_init_arm_mapping(struct device *dev) if (!mmu->mapping) { struct dma_iommu_mapping *mapping; =20 - mapping =3D arm_iommu_create_mapping(&platform_bus_type, - SZ_1G, SZ_2G); + mapping =3D arm_iommu_create_mapping(dev, SZ_1G, SZ_2G); if (IS_ERR(mapping)) { dev_err(mmu->dev, "failed to create ARM IOMMU mapping\n"); ret =3D PTR_ERR(mapping); diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index d6e4002200bd..da61df27582d 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -439,8 +439,7 @@ static int mtk_iommu_v1_create_mapping(struct device *d= ev, mtk_mapping =3D data->mapping; if (!mtk_mapping) { /* MTK iommu support 4GB iova address space. */ - mtk_mapping =3D arm_iommu_create_mapping(&platform_bus_type, - 0, 1ULL << 32); + mtk_mapping =3D arm_iommu_create_mapping(dev, 0, 1ULL << 32); if (IS_ERR(mtk_mapping)) return PTR_ERR(mtk_mapping); =20 diff --git a/drivers/media/platform/ti/omap3isp/isp.c b/drivers/media/platf= orm/ti/omap3isp/isp.c index 1cda23244c7b..91101ba88ef0 100644 --- a/drivers/media/platform/ti/omap3isp/isp.c +++ b/drivers/media/platform/ti/omap3isp/isp.c @@ -1965,7 +1965,7 @@ static int isp_attach_iommu(struct isp_device *isp) * Create the ARM mapping, used by the ARM DMA mapping core to allocate * VAs. This will allocate a corresponding IOMMU domain. */ - mapping =3D arm_iommu_create_mapping(&platform_bus_type, SZ_1G, SZ_2G); + mapping =3D arm_iommu_create_mapping(isp->dev, SZ_1G, SZ_2G); if (IS_ERR(mapping)) { dev_err(isp->dev, "failed to create ARM IOMMU mapping\n"); return PTR_ERR(mapping); --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60FD3142645 for ; Tue, 4 Jun 2024 01:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466126; cv=none; b=TI5kYWaq8RKPYGpzGRpwJbcQjsiYn2fjBeivFOzhYS4ejwAe7Xe1XAt0jUADoGtv07LODTyJpttQbHiDrvtZgPq8mUYK5vVP3mHz/goYP1r6tw0W3ZblxfMv69iW2NmRgb+u1v6PHCRB+LOPxKCLOP+f12szTjTs+qEqf5sOo9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466126; c=relaxed/simple; bh=9YhH5rA1b+ID5Xo/cB0X+5j1j2KZOf2zs+wByq5adpQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hfMYeIoevkjh7svtPnvWTcwDToDhmDFEBCCPOZy/A8F9DnHXtUStYz2JXrPqSq64dyjx2zXlsPUU2H2O/DCzhHOjckT70H4ZhF4+Uja/ssr1R/PzV5fccipu38vzsuvVm6NJBQHZVPuSlI+n7B1FPl+mVVpk859Rubaqv8t2SgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Nn7l0nOS; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Nn7l0nOS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466125; x=1749002125; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9YhH5rA1b+ID5Xo/cB0X+5j1j2KZOf2zs+wByq5adpQ=; b=Nn7l0nOSktkuJJtwluKnuA5MVDsA8MaGFRnzT2tU/5W8dCN3Kjq3b8gy O0Msoco0kgrCd+2NnOOaFHjMPl674zrJI8ZGnGTC6c+qukWjMC3jpifwR L4hI2LddPywPwrPTOCcOWEbG9wYoIsjV+at7aF3LrxvOiISWUzuZc7jXa HKCRgdxIyi57TG99mCMTj4255oo/CADnlxL3y8SCOeUO79BO0vA3nQQFB SdaKJC7iCTsozBsMreoDFgWn6AXLZzK3DnaFAHJQt8U5WUF53hFE42/lh 6C/vO7gvibvU/wBDVkcwG0gqXtAHKYzK2it4eeT4CMJUzELe9r1y3dGCE g==; X-CSE-ConnectionGUID: 4wqgtdAMTmeXplMoC/UDYA== X-CSE-MsgGUID: zrIXSETqQq6tq6/YoQYETg== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385159" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385159" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:25 -0700 X-CSE-ConnectionGUID: T4omcRksRbOOdlHyphpw8A== X-CSE-MsgGUID: c7zTJVNbQXuNhzYvb42Urw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37662045" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:21 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 18/22] ARM: dma-mapping: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:30 +0800 Message-Id: <20240604015134.164206-19-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since arm_iommu_create_mapping() now accepts the device, let's replace iommu_domain_alloc() with iommu_paging_domain_alloc() to retire the former. Signed-off-by: Lu Baolu --- arch/arm/mm/dma-mapping.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 52f9c56cc3cb..88c2d68a69c9 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1585,9 +1585,11 @@ arm_iommu_create_mapping(struct device *dev, dma_add= r_t base, u64 size) =20 spin_lock_init(&mapping->lock); =20 - mapping->domain =3D iommu_domain_alloc(dev->bus); - if (!mapping->domain) + mapping->domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(mapping->domain)) { + err =3D PTR_ERR(mapping->domain); goto err4; + } =20 kref_init(&mapping->kref); return mapping; --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55DF213D62A for ; Tue, 4 Jun 2024 01:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466131; cv=none; b=ukAxNOVaG33Spu0XNdtumNB4E4/6pzyWbfEyPvv6mB8ey1zr0J30EKwUo/87McjZ7KJoL55Euq45Dgdb14SqfBXY7Ubg6gcihXky3MW0nuNIHaIl3BvQt7Uq77QU5QlITSHfmkmpz8lXVvNEj+Kpk3NbRHitVa45gCAJUYNuIF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466131; c=relaxed/simple; bh=2RzKLZKa9aMbeh8zX7gRXSDK8Hv/vXOsjqYlhYXqS5Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eQAJUiazOzQHsh+Rq0Eq08452QYWy276TWePS506RYNhJlf65JZezThn6lR1IO+45k2+E1lhzH64R2pgj6f+r2bSZtFrxTi2W3gzC10hn2q9kW9z7mI17T2nUrsoh4pXZ44tCkZeMKBhqFbxTXnfbkmViRpyU1/QlxSYffZhRmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Rlr5wSER; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Rlr5wSER" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466130; x=1749002130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2RzKLZKa9aMbeh8zX7gRXSDK8Hv/vXOsjqYlhYXqS5Y=; b=Rlr5wSERCUw83JfXhbs+Omrm4rtb/+gcPRz0hO3x0ZF1YrKqkerdTWqp gPUnZSeQ9jHmszYUsCdMRN3SGiczN/HLb9XxCU9VITe0pevRHLYHrS4oo WPPTvSYu6cFALpYJR+odRyoHqEcdJlcA7ln367zSMeuguxIYKcVwkS6fp Xfat8PRH9GP4GASsu6Z5Lbd4B3dxU523o3i9Vu181k1V3Tj+IphzybGmY nJYsBmLBHpe6LxTVL9AvGldRTGbO+bznbb7uP5Bmn9463OHxWRY0516a5 9bnXduyqP6NXffabY/pO/vFSiY7oe9jIzkro4n4UqKoOGswyjKGdUDT3B g==; X-CSE-ConnectionGUID: wVJMw0/lSr63AeQwQaK+Rg== X-CSE-MsgGUID: jLwzpc+CRv6v3WxNvmQN0w== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385167" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385167" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:30 -0700 X-CSE-ConnectionGUID: 8Ijzyl4kRVWuMkWYuL3Cgg== X-CSE-MsgGUID: wQRiAP+zTimow0SHenz+fg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37662048" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:26 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 19/22] drm/rockchip: Use iommu_paging_domain_alloc() Date: Tue, 4 Jun 2024 09:51:31 +0800 Message-Id: <20240604015134.164206-20-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit <421be3ee36a4> ("drm/rockchip: Refactor IOMMU initialisation") has refactored rockchip_drm_init_iommu() to pass a device that the domain is allocated for. Replace iommu_domain_alloc() with iommu_paging_domain_alloc() to retire the former. Signed-off-by: Lu Baolu --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/= rockchip/rockchip_drm_drv.c index ab55d7132550..52126ffb9280 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -103,13 +103,17 @@ static int rockchip_drm_init_iommu(struct drm_device = *drm_dev) struct rockchip_drm_private *private =3D drm_dev->dev_private; struct iommu_domain_geometry *geometry; u64 start, end; + int ret; =20 if (IS_ERR_OR_NULL(private->iommu_dev)) return 0; =20 - private->domain =3D iommu_domain_alloc(private->iommu_dev->bus); - if (!private->domain) - return -ENOMEM; + private->domain =3D iommu_paging_domain_alloc(private->iommu_dev); + if (IS_ERR(private->domain)) { + ret =3D PTR_ERR(private->domain); + private->domain =3D NULL; + return ret; + } =20 geometry =3D &private->domain->geometry; start =3D geometry->aperture_start; --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 668B513D62A for ; Tue, 4 Jun 2024 01:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466136; cv=none; b=tb1mioFb/VQMuVqTSCAnCsCy4f+/IedOvOXYXhmpvW6PtLBVv6AN/XJKOVomVfOd0XF2j/uKJy0Zoy/Cc3GI2yBzG0w6gPT3GzbEdvPCZ2nIyeAl2fSs1UFe1GudIWu5cQ7MUeQHUOIvMYACXmc0Z1by3ZPbvzuhzqMDmUCl/jQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466136; c=relaxed/simple; bh=I56l8aUrWEsOdJKWYfI6TJlpnl4t+tX3NQmfYGnyV7M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kpmqPYaiQgdlnNxTG25aODF6YCNqLzD+g3I/FURSVQo9jGG3aeeIaQsTjTbsAyKqxLAmbpzIPQXFaXhzPXyi/JA0Egn5qEJNhhQPe9U6vt8AFjCmnrOZkJHMUTl6yNg7XYQO2DpvGDlLyaabLpO5WQoak2d5H08v0r2N8ofVeSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=H9g6H+yi; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="H9g6H+yi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466135; x=1749002135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I56l8aUrWEsOdJKWYfI6TJlpnl4t+tX3NQmfYGnyV7M=; b=H9g6H+yiPOB+1V2jTkmFFiAiqZ1HzZjoDyd2PhjIe/JuqavYVZ0GBhu2 JsmIY03EuEpCHVbo6AJTitWDqaWaiUgRl3oVy7lT00cGj6v1Z+ilmn5Ip XKfLU/BdQaOxu8qlQI8xDsi1gNnX/4RX9LbYmiGQjQQoSDL86uHamN8ti HaX6rVNghyK4O/oBJgzVU67jQw6Z5BgBjyLENLutHMXU/mMjKnVVKpTCB TSNRMLZX50Ujeb/6/xvkKPHZkrkwzJ2vWMCW4J1Bi2afCZq+35Sj6MP4G jxM2QBOkndyH0gnHyI003e55hC0olphoPqqrRS8Z4yIA58jbuTbwzFG3r Q==; X-CSE-ConnectionGUID: Rl5XRdtuQe6Gg0rZu6FJSg== X-CSE-MsgGUID: S0nU5liwTuKMTdv3NDztmw== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385189" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385189" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:35 -0700 X-CSE-ConnectionGUID: iy5Ha6XGSomqRxRqbU9xMQ== X-CSE-MsgGUID: 0J02TVC8Qyu9oAdvu9xQyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37662052" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:31 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 20/22] drm/tegra: Remove call to iommu_domain_alloc() Date: Tue, 4 Jun 2024 09:51:32 +0800 Message-Id: <20240604015134.164206-21-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit <17de3f5fdd35> ("iommu: Retire bus ops") removes iommu ops from the bus structure. The iommu subsystem no longer relies on bus for operations. So iommu_domain_alloc() interface is no longer relevant. Normally, iommu_paging_domain_alloc() could be a replacement for iommu_domain_alloc() if the caller has the right device for IOMMU API use. Unfortunately, this is not the case for this driver. Iterate the devices on the platform bus and find a suitable device whose device DMA is translated by an IOMMU. Then use this device to allocate an iommu domain. The iommu subsystem prevents domains allocated by one iommu driver from being attached to devices managed by any different iommu driver. Signed-off-by: Lu Baolu --- drivers/gpu/drm/tegra/drm.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 03d1c76aec2d..ee391f859992 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1133,6 +1133,17 @@ static bool host1x_drm_wants_iommu(struct host1x_dev= ice *dev) return domain !=3D NULL; } =20 +static int iommu_mapped_device(struct device *dev, void *data) +{ + struct device **iommu_dev =3D data; + + if (!device_iommu_mapped(dev)) + return 0; + + *iommu_dev =3D dev; + return 1; +} + static int host1x_drm_probe(struct host1x_device *dev) { struct tegra_drm *tegra; @@ -1149,16 +1160,21 @@ static int host1x_drm_probe(struct host1x_device *d= ev) goto put; } =20 - if (host1x_drm_wants_iommu(dev) && iommu_present(&platform_bus_type)) { - tegra->domain =3D iommu_domain_alloc(&platform_bus_type); - if (!tegra->domain) { - err =3D -ENOMEM; - goto free; + if (host1x_drm_wants_iommu(dev)) { + struct device *iommu_dev =3D NULL; + + bus_for_each_dev(&platform_bus_type, NULL, &iommu_dev, iommu_mapped_devi= ce); + if (iommu_dev) { + tegra->domain =3D iommu_paging_domain_alloc(iommu_dev); + if (IS_ERR(tegra->domain)) { + err =3D PTR_ERR(tegra->domain); + goto free; + } + + err =3D iova_cache_get(); + if (err < 0) + goto domain; } - - err =3D iova_cache_get(); - if (err < 0) - goto domain; } =20 mutex_init(&tegra->clients_lock); --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5AC613D636 for ; Tue, 4 Jun 2024 01:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466143; cv=none; b=gaU6+G74LlQ85zUiYx4nooX/otiEKeySrTa/WZQIGGO89+97YtruM6MyV2+K3ljW4bYCTqqCAOX7JJlm2pVuJX73ydvLV4L0FvvrfMxogsK54HimfHUndTvKw5T7L3qigxQciEGHBp2Wrx9lHhKT/QFIMtgd4DKd3rvlzdNoMKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466143; c=relaxed/simple; bh=w7xpZF6zFqfkcvZbi2eydbd2CTcSjXyT/TTFm+mMIv4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qxIRwYkRMZMe1k/yKJeFYakjH8C76MFPgVUYYLo0Ju5Kevga2vh7hVzxl/kpzMDDOKhLKfxOk6mNJOKulg/9vl6KR0ugr85R+yicvv3CgvZRfxtjWmDA0ag/h5/ar/I9oJO/REqOUoy/4/CfYdJOZg7eE1eKpaYYtuXw8oFR4Cc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=A44Ut/5v; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="A44Ut/5v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466142; x=1749002142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w7xpZF6zFqfkcvZbi2eydbd2CTcSjXyT/TTFm+mMIv4=; b=A44Ut/5v5EJQIzV5A+gAJUJuApNZT2i7q1HcSEPGdJaWOFj0nVRxRiAM NQ1yzjoHEjs4GDDOHIRxaJdiOKZou6ZzYKPmipVeh09lSGdDu5qm+mJCH Qeg0INszW3vuJv0sqQFBUhFL672+nK/dvWK0LW+Ifvxd+IisSs+rvouGN vm0srd/YIQnN6g2JceWnn+UPnON01l6xKB/tq5/sfr6IZqI6+4sRY35Hs gxHj3nXNs8YiJ2Z9fRxp0sKhBtq4RKS8fQunWjPO0TfH7+yPtQkjv0IUq MtaxPvgKwAwu55iSh4o49FitjdmGfnTBNwa7qPruEDXrMzxqlA2gUqDo9 Q==; X-CSE-ConnectionGUID: VLlXfY9URiucivWWtApBqw== X-CSE-MsgGUID: eGIgvggKSFSn2TDNJSJa2Q== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385261" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385261" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:40 -0700 X-CSE-ConnectionGUID: UYTWYDDfT0qdTFCeWKMbag== X-CSE-MsgGUID: slPdM7OrRP2pa5uJS4C6wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37662057" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:36 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 21/22] iommu: Remove iommu_present() Date: Tue, 4 Jun 2024 09:51:33 +0800 Message-Id: <20240604015134.164206-22-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The iommu_present() interface is no longer used in the tree anymore. Remove it to avoid dead code. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 6 ------ drivers/iommu/iommu.c | 25 ------------------------- 2 files changed, 31 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 16401de7802d..b0bd16a7768e 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -776,7 +776,6 @@ static inline void iommu_iotlb_gather_init(struct iommu= _iotlb_gather *gather) } =20 extern int bus_iommu_probe(const struct bus_type *bus); -extern bool iommu_present(const struct bus_type *bus); extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap); extern bool iommu_group_has_isolated_msi(struct iommu_group *group); extern struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus); @@ -1073,11 +1072,6 @@ struct iommu_iotlb_gather {}; struct iommu_dirty_bitmap {}; struct iommu_dirty_ops {}; =20 -static inline bool iommu_present(const struct bus_type *bus) -{ - return false; -} - static inline bool device_iommu_capable(struct device *dev, enum iommu_cap= cap) { return false; diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 7df4a021b040..3e4195c28e85 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1846,31 +1846,6 @@ int bus_iommu_probe(const struct bus_type *bus) return 0; } =20 -/** - * iommu_present() - make platform-specific assumptions about an IOMMU - * @bus: bus to check - * - * Do not use this function. You want device_iommu_mapped() instead. - * - * Return: true if some IOMMU is present and aware of devices on the given= bus; - * in general it may not be the only IOMMU, and it may not have anything t= o do - * with whatever device you are ultimately interested in. - */ -bool iommu_present(const struct bus_type *bus) -{ - bool ret =3D false; - - for (int i =3D 0; i < ARRAY_SIZE(iommu_buses); i++) { - if (iommu_buses[i] =3D=3D bus) { - spin_lock(&iommu_device_lock); - ret =3D !list_empty(&iommu_device_list); - spin_unlock(&iommu_device_lock); - } - } - return ret; -} -EXPORT_SYMBOL_GPL(iommu_present); - /** * device_iommu_capable() - check for a general IOMMU capability * @dev: device to which the capability would be relevant, if available --=20 2.34.1 From nobody Sat Feb 7 12:18:11 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99FAE142E68 for ; Tue, 4 Jun 2024 01:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466148; cv=none; b=E0+iHPoy+VAJzqyUwb5BbCMBuaDOeo4T/I8GOWE9Xtv+2MFnpHmN+rAx23ti0dR2OYXkC/PghYLKd59EeWWOUeu4LHRs93wLOC2ZQKSfT9o2JqqwFUinA62XuLseGAGPVGW5iUmIl+oMN/LfdAEuxFjpcxYD/XlnOaElabJmucM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466148; c=relaxed/simple; bh=fB0WT/uFAD/6kyoV4UsQtcUjaYUF0Qf8FTDYMb+l8Rw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dhWqpnzt3ki9yBLaFlovaDp7pd0QWzFTnKpxxhTY18pjcLBo3ftaBaBgLqswyoDs5pKph4QixCN4cRF4aoWe+oBYN8c5ukjcaYIeDMk7wNcQyVdz90wJJcRZttQ4i7u9OtFSfwDwCCOfaNXSoCRKjsMlxDheNai19cqrfxrD6og= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=B4QF+BTW; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="B4QF+BTW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717466145; x=1749002145; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fB0WT/uFAD/6kyoV4UsQtcUjaYUF0Qf8FTDYMb+l8Rw=; b=B4QF+BTWm9Nfsz2hTrk9Cw3jodZzg4BlnldUUepl7FvIgZblkrAOYWWa kXij+QMpmjrvfccOnx7N5SNebe0xM5vxiSePPzID9VNY4061uNL9T9+Kz zZSRfdlhteUtZHblJgGt81+VdaORgyQEGFZU5pykqt5UPUQypIf7fLf+b JosnTe3KTIsX2HVAgxcv1B45rapnKUDtf6WKr4yjTOe/HIsc3qYvJ8Kpo 2sPyn8ZVPfg1AB7drWDjo4QPZFFjo8eQJn37PbQ9Q616nNpuOCtGUNNj0 5OVEKhEeyeNbaJ0hTaoS7e5Ngl5D3PH9D2zJBcOs+ws4Nsvs8ygVXqIn+ A==; X-CSE-ConnectionGUID: 8BYXUwd6QA+VQaxI9Znl+g== X-CSE-MsgGUID: K0xst9fcSs6tsROKL0pfog== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25385283" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="25385283" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 18:55:45 -0700 X-CSE-ConnectionGUID: zu00YDKoTgCrApgAN111bg== X-CSE-MsgGUID: kCjus9/aSU67aafbZZIwFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="37662070" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 03 Jun 2024 18:55:41 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 22/22] iommu: Remove iommu_domain_alloc() Date: Tue, 4 Jun 2024 09:51:34 +0800 Message-Id: <20240604015134.164206-23-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604015134.164206-1-baolu.lu@linux.intel.com> References: <20240604015134.164206-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The iommu_domain_alloc() interface is no longer used in the tree anymore. Remove it to avoid dead code. There is increasing demand for supporting multiple IOMMU drivers, and this is the last bus-based thing standing in the way of that. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 6 ------ drivers/iommu/iommu.c | 36 ------------------------------------ 2 files changed, 42 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index b0bd16a7768e..8b4ce7aa16ac 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -778,7 +778,6 @@ static inline void iommu_iotlb_gather_init(struct iommu= _iotlb_gather *gather) extern int bus_iommu_probe(const struct bus_type *bus); extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap); extern bool iommu_group_has_isolated_msi(struct iommu_group *group); -extern struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus); struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags= ); struct iommu_domain *iommu_paging_domain_alloc(struct device *dev); extern void iommu_domain_free(struct iommu_domain *domain); @@ -1077,11 +1076,6 @@ static inline bool device_iommu_capable(struct devic= e *dev, enum iommu_cap cap) return false; } =20 -static inline struct iommu_domain *iommu_domain_alloc(const struct bus_typ= e *bus) -{ - return NULL; -} - static inline struct iommu_domain *iommu_user_domain_alloc(struct device *= dev, u32 flags) { return ERR_PTR(-ENODEV); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 3e4195c28e85..9ce8bc18485b 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1975,42 +1975,6 @@ __iommu_group_domain_alloc(struct iommu_group *group= , unsigned int type) return __iommu_domain_alloc(dev_iommu_ops(dev), dev, type); } =20 -static int __iommu_domain_alloc_dev(struct device *dev, void *data) -{ - const struct iommu_ops **ops =3D data; - - if (!dev_has_iommu(dev)) - return 0; - - if (WARN_ONCE(*ops && *ops !=3D dev_iommu_ops(dev), - "Multiple IOMMU drivers present for bus %s, which the public IOMMU= API can't fully support yet. You will still need to disable one or more fo= r this to work, sorry!\n", - dev_bus_name(dev))) - return -EBUSY; - - *ops =3D dev_iommu_ops(dev); - return 0; -} - -/* - * The iommu ops in bus has been retired. Do not use this interface in - * new drivers. - */ -struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus) -{ - const struct iommu_ops *ops =3D NULL; - int err =3D bus_for_each_dev(bus, NULL, &ops, __iommu_domain_alloc_dev); - struct iommu_domain *domain; - - if (err || !ops) - return NULL; - - domain =3D __iommu_domain_alloc(ops, NULL, IOMMU_DOMAIN_UNMANAGED); - if (IS_ERR(domain)) - return NULL; - return domain; -} -EXPORT_SYMBOL_GPL(iommu_domain_alloc); - /** * iommu_user_domain_alloc() - Allocate a user domain * @dev: device for which the domain is allocated --=20 2.34.1