* [PATCH v3 00/21] iommu: Refactoring domain allocation interface
@ 2024-06-10 8:55 Lu Baolu
2024-06-10 8:55 ` [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface Lu Baolu
` (22 more replies)
0 siblings, 23 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
The IOMMU subsystem has undergone some changes, including the removal
of iommu_ops from the bus structure. Consequently, the existing domain
allocation interface, which relies on a bus type argument, is no longer
relevant:
struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
This series is designed to refactor the use of this interface. It
proposes a new interface iommu_paging_domain_alloc() to replace
iommu_domain_alloc(). This interface is for allocating iommu paging
domains for kernel drivers. It takes a device pointer as a parameter,
which better reflects the current design of the IOMMU subsystem.
The majority of device drivers currently using iommu_domain_alloc() do
so to allocate a domain for a specific device and then attach that
domain to the device. These cases can be straightforwardly migrated to
the new interface.
The drm/tegra driver is a bit different in that the device pointer
passed to the helper, which allocates the iommu domain, is not the one
that will be used for the kernel DMA API. Move the existing logic in
iommu_domain_alloc() into the driver to ensure it works as intended.
Now that all consumers of iommu_domain_alloc() have switched to the new
interface, we can finally remove iommu_domain_alloc(). This removal
paves the way for the IOMMU subsystem to support multiple iommu drivers.
Additionally, the individual iommu driver implementation for domain
allocation could also be simplified, as there will always be a valid
device pointer passed along the path.
The whole series is also available on GitHub:
https://github.com/LuBaolu/intel-iommu/commits/iommu-domain-allocation-refactor-v3
Change log:
v3:
- Remove the proposed iommu_user_domain_alloc() interface.
v2: https://lore.kernel.org/linux-iommu/20240604015134.164206-1-baolu.lu@linux.intel.com/
- Drop the vt-d patches which implement paging domain support from this
series. I will post them in a separate series later.
- Convert all drivers that call iommu_domain_alloc() to use the new
interface and remove iommu_domain_alloc() from the tree.
- For the drm/msm driver, make the code compatible with the no-IOMMU
case.
- Various cleanups and refinements.
v1: https://lore.kernel.org/linux-iommu/20240529053250.91284-1-baolu.lu@linux.intel.com/
Lu Baolu (20):
iommu: Add iommu_paging_domain_alloc() interface
iommufd: Use iommu_paging_domain_alloc()
vfio/type1: Use iommu_paging_domain_alloc()
vhost-vdpa: Use iommu_paging_domain_alloc()
drm/msm: Use iommu_paging_domain_alloc()
drm/nouveau/tegra: Use iommu_paging_domain_alloc()
gpu: host1x: Use iommu_paging_domain_alloc()
media: nvidia: tegra: Use iommu_paging_domain_alloc()
media: venus: firmware: Use iommu_paging_domain_alloc()
wifi: ath10k: Use iommu_paging_domain_alloc()
wifi: ath11k: Use iommu_paging_domain_alloc()
remoteproc: Use iommu_paging_domain_alloc()
soc/fsl/qbman: Use iommu_paging_domain_alloc()
RDMA/usnic: Use iommu_paging_domain_alloc()
iommu/vt-d: Add helper to allocate paging domain
ARM: dma-mapping: Use iommu_paging_domain_alloc()
drm/rockchip: Use iommu_paging_domain_alloc()
drm/tegra: Remove call to iommu_domain_alloc()
iommu: Remove iommu_present()
iommu: Remove iommu_domain_alloc()
Robin Murphy (1):
ARM: dma-mapping: Pass device to arm_iommu_create_mapping()
include/linux/iommu.h | 12 +--
arch/arm/include/asm/dma-iommu.h | 2 +-
arch/arm/mm/dma-mapping.c | 12 +--
drivers/gpu/drm/exynos/exynos_drm_dma.c | 2 +-
drivers/gpu/drm/msm/msm_iommu.c | 7 +-
.../drm/nouveau/nvkm/engine/device/tegra.c | 4 +-
drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 10 ++-
drivers/gpu/drm/tegra/drm.c | 34 ++++++--
drivers/gpu/host1x/dev.c | 7 +-
drivers/infiniband/hw/usnic/usnic_uiom.c | 6 +-
drivers/iommu/intel/iommu.c | 87 +++++++++++++++++--
drivers/iommu/iommu.c | 63 +++-----------
drivers/iommu/iommufd/hw_pagetable.c | 7 +-
drivers/iommu/ipmmu-vmsa.c | 3 +-
drivers/iommu/mtk_iommu_v1.c | 3 +-
.../media/platform/nvidia/tegra-vde/iommu.c | 7 +-
drivers/media/platform/qcom/venus/firmware.c | 6 +-
drivers/media/platform/ti/omap3isp/isp.c | 2 +-
drivers/net/wireless/ath/ath10k/snoc.c | 6 +-
drivers/net/wireless/ath/ath11k/ahb.c | 6 +-
drivers/remoteproc/remoteproc_core.c | 6 +-
drivers/soc/fsl/qbman/qman_portal.c | 5 +-
drivers/vfio/vfio_iommu_type1.c | 7 +-
drivers/vhost/vdpa.c | 14 ++-
24 files changed, 183 insertions(+), 135 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:20 ` Jason Gunthorpe
2024-06-27 7:10 ` Vasant Hegde
2024-06-10 8:55 ` [PATCH v3 02/21] iommufd: Use iommu_paging_domain_alloc() Lu Baolu
` (21 subsequent siblings)
22 siblings, 2 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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 7bc8dff7cf6d..46f1348f1f0a 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_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);
@@ -1086,6 +1087,11 @@ static inline struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus
return NULL;
}
+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 9df7cc75c1bc..e03c71a34347 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2016,6 +2016,10 @@ static int __iommu_domain_alloc_dev(struct device *dev, void *data)
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 = NULL;
@@ -2032,6 +2036,22 @@ struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
}
EXPORT_SYMBOL_GPL(iommu_domain_alloc);
+/**
+ * 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. Return
+ * 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_UNMANAGED);
+}
+EXPORT_SYMBOL_GPL(iommu_paging_domain_alloc);
+
void iommu_domain_free(struct iommu_domain *domain)
{
if (domain->type == IOMMU_DOMAIN_SVA)
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 02/21] iommufd: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
2024-06-10 8:55 ` [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:21 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 03/21] vfio/type1: " Lu Baolu
` (20 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
If the iommu driver doesn't implement its domain_alloc_user callback,
iommufd_hwpt_paging_alloc() rolls back to allocate an iommu paging domain.
Replace iommu_domain_alloc() with iommu_user_domain_alloc() to pass the
device pointer along the path.
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/iommu/iommufd/hw_pagetable.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c
index 33d142f8057d..cbddfa3ca95a 100644
--- a/drivers/iommu/iommufd/hw_pagetable.c
+++ b/drivers/iommu/iommufd/hw_pagetable.c
@@ -137,9 +137,10 @@ iommufd_hwpt_paging_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
}
hwpt->domain->owner = ops;
} else {
- hwpt->domain = iommu_domain_alloc(idev->dev->bus);
- if (!hwpt->domain) {
- rc = -ENOMEM;
+ hwpt->domain = iommu_paging_domain_alloc(idev->dev);
+ if (IS_ERR(hwpt->domain)) {
+ rc = PTR_ERR(hwpt->domain);
+ hwpt->domain = NULL;
goto out_abort;
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 03/21] vfio/type1: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
2024-06-10 8:55 ` [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface Lu Baolu
2024-06-10 8:55 ` [PATCH v3 02/21] iommufd: Use iommu_paging_domain_alloc() Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:21 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 04/21] vhost-vdpa: " Lu Baolu
` (19 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
Replace iommu_domain_alloc() with iommu_paging_domain_alloc().
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
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_type1.c
index 3a0218171cfa..0960699e7554 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 = data;
- *domain = iommu_domain_alloc(dev->bus);
+ *domain = iommu_paging_domain_alloc(dev);
return 1; /* Don't iterate */
}
@@ -2192,11 +2192,12 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
* us a representative device for the IOMMU API call. We don't actually
* want to iterate beyond the first device (if any).
*/
- ret = -EIO;
iommu_group_for_each_dev(iommu_group, &domain->domain,
vfio_iommu_domain_alloc);
- if (!domain->domain)
+ if (IS_ERR(domain->domain)) {
+ ret = PTR_ERR(domain->domain);
goto out_free_domain;
+ }
if (iommu->nesting) {
ret = iommu_enable_nesting(domain->domain);
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (2 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 03/21] vfio/type1: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:27 ` Jason Gunthorpe
2024-07-03 16:32 ` Michael S. Tsirkin
2024-06-10 8:55 ` [PATCH v3 05/21] drm/msm: " Lu Baolu
` (18 subsequent siblings)
22 siblings, 2 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
Replace iommu_domain_alloc() with iommu_paging_domain_alloc().
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
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..e31ec9ebc4ce 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -1312,26 +1312,24 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
struct vdpa_device *vdpa = v->vdpa;
const struct vdpa_config_ops *ops = vdpa->config;
struct device *dma_dev = vdpa_get_dma_dev(vdpa);
- const struct bus_type *bus;
int ret;
/* Device want to do DMA by itself */
if (ops->set_map || ops->dma_map)
return 0;
- bus = 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 capable\n");
return -ENOTSUPP;
}
- v->domain = iommu_domain_alloc(bus);
- if (!v->domain)
- return -EIO;
+ v->domain = iommu_paging_domain_alloc(dma_dev);
+ if (IS_ERR(v->domain)) {
+ ret = PTR_ERR(v->domain);
+ v->domain = NULL;
+ return ret;
+ }
ret = iommu_attach_device(v->domain, dma_dev);
if (ret)
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 05/21] drm/msm: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (3 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 04/21] vhost-vdpa: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-10 8:55 ` [PATCH v3 06/21] drm/nouveau/tegra: " Lu Baolu
` (17 subsequent siblings)
22 siblings, 0 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu, Dmitry Baryshkov
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 <baolu.lu@linux.intel.com>
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
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_iommu.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, unsigned long quirks)
struct msm_iommu *iommu;
int ret;
- domain = iommu_domain_alloc(dev->bus);
- if (!domain)
+ if (!device_iommu_mapped(dev))
return NULL;
+ domain = iommu_paging_domain_alloc(dev);
+ if (IS_ERR(domain))
+ return ERR_CAST(domain);
+
iommu_set_pgtable_quirks(domain, quirks);
iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 06/21] drm/nouveau/tegra: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (4 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 05/21] drm/msm: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-10 8:55 ` [PATCH v3 07/21] gpu: host1x: " Lu Baolu
` (16 subsequent siblings)
22 siblings, 0 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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/gpu/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);
if (device_iommu_mapped(dev)) {
- tdev->iommu.domain = iommu_domain_alloc(&platform_bus_type);
- if (!tdev->iommu.domain)
+ tdev->iommu.domain = iommu_paging_domain_alloc(dev);
+ if (IS_ERR(tdev->iommu.domain))
goto error;
/*
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 07/21] gpu: host1x: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (5 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 06/21] drm/nouveau/tegra: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:30 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 08/21] media: nvidia: tegra: " Lu Baolu
` (15 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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;
- host->domain = iommu_domain_alloc(&platform_bus_type);
- if (!host->domain) {
- err = -ENOMEM;
+ host->domain = iommu_paging_domain_alloc(host->dev);
+ if (IS_ERR(host->domain)) {
+ err = PTR_ERR(host->domain);
+ host->domain = NULL;
goto put_cache;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 08/21] media: nvidia: tegra: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (6 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 07/21] gpu: host1x: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:31 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 09/21] media: venus: firmware: " Lu Baolu
` (14 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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/media/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 = iommu_domain_alloc(&platform_bus_type);
- if (!vde->domain) {
- err = -ENOMEM;
+ vde->domain = iommu_paging_domain_alloc(dev);
+ if (IS_ERR(vde->domain)) {
+ err = PTR_ERR(vde->domain);
+ vde->domain = NULL;
goto put_group;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 09/21] media: venus: firmware: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (7 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 08/21] media: nvidia: tegra: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:32 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 10/21] wifi: ath10k: " Lu Baolu
` (13 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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/platform/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)
core->fw.dev = &pdev->dev;
- iommu_dom = iommu_domain_alloc(&platform_bus_type);
- if (!iommu_dom) {
+ iommu_dom = iommu_paging_domain_alloc(core->fw.dev);
+ if (IS_ERR(iommu_dom)) {
dev_err(core->fw.dev, "Failed to allocate iommu domain\n");
- ret = -ENOMEM;
+ ret = PTR_ERR(iommu_dom);
goto err_unregister;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 10/21] wifi: ath10k: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (8 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 09/21] media: venus: firmware: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:37 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 11/21] wifi: ath11k: " Lu Baolu
` (12 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
---
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)
ar_snoc->fw.dev = &pdev->dev;
- iommu_dom = iommu_domain_alloc(&platform_bus_type);
- if (!iommu_dom) {
+ iommu_dom = iommu_paging_domain_alloc(ar_snoc->fw.dev);
+ if (IS_ERR(iommu_dom)) {
ath10k_err(ar, "failed to allocate iommu domain\n");
- ret = -ENOMEM;
+ ret = PTR_ERR(iommu_dom);
goto err_unregister;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 11/21] wifi: ath11k: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (9 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 10/21] wifi: ath10k: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:38 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 12/21] remoteproc: " Lu Baolu
` (11 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
---
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/ath/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 ath11k_base *ab)
ab_ahb->fw.dev = &pdev->dev;
- iommu_dom = iommu_domain_alloc(&platform_bus_type);
- if (!iommu_dom) {
+ iommu_dom = iommu_paging_domain_alloc(ab_ahb->fw.dev);
+ if (IS_ERR(iommu_dom)) {
ath11k_err(ab, "failed to allocate iommu domain\n");
- ret = -ENOMEM;
+ ret = PTR_ERR(iommu_dom);
goto err_unregister;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 12/21] remoteproc: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (10 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 11/21] wifi: ath11k: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:38 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 13/21] soc/fsl/qbman: " Lu Baolu
` (10 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
drivers/remoteproc/remoteproc_core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_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;
}
- domain = iommu_domain_alloc(dev->bus);
- if (!domain) {
+ domain = iommu_paging_domain_alloc(dev);
+ if (IS_ERR(domain)) {
dev_err(dev, "can't alloc iommu domain\n");
- return -ENOMEM;
+ return PTR_ERR(domain);
}
iommu_set_fault_handler(domain, rproc_iommu_fault, rproc);
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 13/21] soc/fsl/qbman: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (11 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 12/21] remoteproc: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 14:39 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 14/21] RDMA/usnic: " Lu Baolu
` (9 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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/qman_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 = pcfg->dev;
int ret;
- pcfg->iommu_domain = iommu_domain_alloc(&platform_bus_type);
- if (!pcfg->iommu_domain) {
+ pcfg->iommu_domain = iommu_paging_domain_alloc(dev);
+ if (IS_ERR(pcfg->iommu_domain)) {
dev_err(dev, "%s(): iommu_domain_alloc() failed", __func__);
+ pcfg->iommu_domain = NULL;
goto no_iommu;
}
ret = fsl_pamu_configure_l1_stash(pcfg->iommu_domain, cpu);
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 14/21] RDMA/usnic: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (12 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 13/21] soc/fsl/qbman: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-10 8:55 ` [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain Lu Baolu
` (8 subsequent siblings)
22 siblings, 0 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu, Jason Gunthorpe
usnic_uiom_alloc_pd() allocates a paging domain for a given device.
In this case, iommu_domain_alloc(dev->bus) is equivalent to
iommu_paging_domain_alloc(dev). Replace it as iommu_domain_alloc()
has been deprecated.
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Acked-by: Jason Gunthorpe <jgg@nvidia.com>
---
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 device *dev)
if (!pd)
return ERR_PTR(-ENOMEM);
- pd->domain = domain = iommu_domain_alloc(dev->bus);
- if (!domain) {
+ pd->domain = domain = 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);
}
iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL);
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (13 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 14/21] RDMA/usnic: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 15:12 ` Jason Gunthorpe
2024-06-28 5:42 ` Yi Liu
2024-06-10 8:55 ` [PATCH v3 16/21] ARM: dma-mapping: Pass device to arm_iommu_create_mapping() Lu Baolu
` (7 subsequent siblings)
22 siblings, 2 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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 = {
}
};
+static int iommu_superpage_capability(struct intel_iommu *iommu, bool first_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 first_stage)
+{
+ struct device_domain_info *info = dev_iommu_priv_get(dev);
+ struct intel_iommu *iommu = info->iommu;
+ struct dmar_domain *domain;
+ int addr_width;
+
+ domain = 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 = dev_to_node(dev);
+ domain->has_iotlb_device = info->ats_enabled;
+ domain->use_first_level = first_stage;
+
+ /* calculate the address width */
+ addr_width = agaw_to_width(iommu->agaw);
+ if (addr_width > cap_mgaw(iommu->cap))
+ addr_width = cap_mgaw(iommu->cap);
+ domain->gaw = addr_width;
+ domain->agaw = iommu->agaw;
+ domain->max_addr = __DOMAIN_MAX_ADDR(addr_width);
+
+ /* iommu memory access coherency */
+ domain->iommu_coherency = iommu_paging_structure_coherency(iommu);
+
+ /* pagesize bitmap */
+ domain->domain.pgsize_bitmap = SZ_4K;
+ domain->iommu_superpage = iommu_superpage_capability(iommu, first_stage);
+ domain->domain.pgsize_bitmap |= 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 = true;
+ domain->domain.geometry.aperture_start = 0;
+ if (first_stage)
+ domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw - 1);
+ else
+ domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw);
+
+ /* always allocate the top pgd */
+ domain->pgd = 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, u32 flags,
if (user_data || (dirty_tracking && !ssads_supported(iommu)))
return ERR_PTR(-EOPNOTSUPP);
- /*
- * domain_alloc_user op needs to fully initialize a domain before
- * return, so uses iommu_domain_alloc() here for simple.
- */
- domain = iommu_domain_alloc(dev->bus);
- if (!domain)
- return ERR_PTR(-ENOMEM);
-
- dmar_domain = to_dmar_domain(domain);
+ /* Do not use first stage for user domain translation. */
+ dmar_domain = paging_domain_alloc(dev, false);
+ if (IS_ERR(dmar_domain))
+ return ERR_CAST(dmar_domain);
+ domain = &dmar_domain->domain;
if (nested_parent) {
dmar_domain->nested_parent = true;
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 16/21] ARM: dma-mapping: Pass device to arm_iommu_create_mapping()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (14 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-10 8:55 ` [PATCH v3 17/21] ARM: dma-mapping: Use iommu_paging_domain_alloc() Lu Baolu
` (6 subsequent siblings)
22 siblings, 0 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
From: Robin Murphy <robin.murphy@arm.com>
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 <robin.murphy@arm.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
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-iommu.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 {
};
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);
void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping);
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 = {
/**
* 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 = {
* 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 = size >> PAGE_SHIFT;
unsigned int bitmap_size = 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)
spin_lock_init(&mapping->lock);
- mapping->domain = iommu_domain_alloc(bus);
+ mapping->domain = iommu_domain_alloc(dev->bus);
if (!mapping->domain)
goto err4;
@@ -1718,7 +1718,7 @@ static void arm_setup_iommu_dma_ops(struct device *dev)
dma_base = dma_range_map_min(dev->dma_range_map);
size = dma_range_map_max(dev->dma_range_map) - dma_base;
}
- mapping = arm_iommu_create_mapping(dev->bus, dma_base, size);
+ mapping = 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/exynos/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, struct device *dev,
void *mapping = NULL;
if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
- mapping = arm_iommu_create_mapping(&platform_bus_type,
+ mapping = arm_iommu_create_mapping(dev,
EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE);
else if (IS_ENABLED(CONFIG_IOMMU_DMA))
mapping = 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;
- mapping = arm_iommu_create_mapping(&platform_bus_type,
- SZ_1G, SZ_2G);
+ mapping = 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 = 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 *dev,
mtk_mapping = data->mapping;
if (!mtk_mapping) {
/* MTK iommu support 4GB iova address space. */
- mtk_mapping = arm_iommu_create_mapping(&platform_bus_type,
- 0, 1ULL << 32);
+ mtk_mapping = arm_iommu_create_mapping(dev, 0, 1ULL << 32);
if (IS_ERR(mtk_mapping))
return PTR_ERR(mtk_mapping);
diff --git a/drivers/media/platform/ti/omap3isp/isp.c b/drivers/media/platform/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 = arm_iommu_create_mapping(&platform_bus_type, SZ_1G, SZ_2G);
+ mapping = 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);
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 17/21] ARM: dma-mapping: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (15 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 16/21] ARM: dma-mapping: Pass device to arm_iommu_create_mapping() Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 15:13 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 18/21] drm/rockchip: " Lu Baolu
` (5 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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_addr_t base, u64 size)
spin_lock_init(&mapping->lock);
- mapping->domain = iommu_domain_alloc(dev->bus);
- if (!mapping->domain)
+ mapping->domain = iommu_paging_domain_alloc(dev);
+ if (IS_ERR(mapping->domain)) {
+ err = PTR_ERR(mapping->domain);
goto err4;
+ }
kref_init(&mapping->kref);
return mapping;
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 18/21] drm/rockchip: Use iommu_paging_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (16 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 17/21] ARM: dma-mapping: Use iommu_paging_domain_alloc() Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 15:14 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 19/21] drm/tegra: Remove call to iommu_domain_alloc() Lu Baolu
` (4 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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 = drm_dev->dev_private;
struct iommu_domain_geometry *geometry;
u64 start, end;
+ int ret;
if (IS_ERR_OR_NULL(private->iommu_dev))
return 0;
- private->domain = iommu_domain_alloc(private->iommu_dev->bus);
- if (!private->domain)
- return -ENOMEM;
+ private->domain = iommu_paging_domain_alloc(private->iommu_dev);
+ if (IS_ERR(private->domain)) {
+ ret = PTR_ERR(private->domain);
+ private->domain = NULL;
+ return ret;
+ }
geometry = &private->domain->geometry;
start = geometry->aperture_start;
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 19/21] drm/tegra: Remove call to iommu_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (17 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 18/21] drm/rockchip: " Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-10 8:55 ` [PATCH v3 20/21] iommu: Remove iommu_present() Lu Baolu
` (3 subsequent siblings)
22 siblings, 0 replies; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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_device *dev)
return domain != NULL;
}
+static int iommu_mapped_device(struct device *dev, void *data)
+{
+ struct device **iommu_dev = data;
+
+ if (!device_iommu_mapped(dev))
+ return 0;
+
+ *iommu_dev = 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 *dev)
goto put;
}
- if (host1x_drm_wants_iommu(dev) && iommu_present(&platform_bus_type)) {
- tegra->domain = iommu_domain_alloc(&platform_bus_type);
- if (!tegra->domain) {
- err = -ENOMEM;
- goto free;
+ if (host1x_drm_wants_iommu(dev)) {
+ struct device *iommu_dev = NULL;
+
+ bus_for_each_dev(&platform_bus_type, NULL, &iommu_dev, iommu_mapped_device);
+ if (iommu_dev) {
+ tegra->domain = iommu_paging_domain_alloc(iommu_dev);
+ if (IS_ERR(tegra->domain)) {
+ err = PTR_ERR(tegra->domain);
+ goto free;
+ }
+
+ err = iova_cache_get();
+ if (err < 0)
+ goto domain;
}
-
- err = iova_cache_get();
- if (err < 0)
- goto domain;
}
mutex_init(&tegra->clients_lock);
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 20/21] iommu: Remove iommu_present()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (18 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 19/21] drm/tegra: Remove call to iommu_domain_alloc() Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 15:14 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 21/21] iommu: Remove iommu_domain_alloc() Lu Baolu
` (2 subsequent siblings)
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
The iommu_present() interface is no longer used in the tree anymore.
Remove it to avoid dead code.
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
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 46f1348f1f0a..ba0b27afc256 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)
}
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);
@@ -1072,11 +1071,6 @@ struct iommu_iotlb_gather {};
struct iommu_dirty_bitmap {};
struct iommu_dirty_ops {};
-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 e03c71a34347..c7ebdf96e4bc 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;
}
-/**
- * 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 to do
- * with whatever device you are ultimately interested in.
- */
-bool iommu_present(const struct bus_type *bus)
-{
- bool ret = false;
-
- for (int i = 0; i < ARRAY_SIZE(iommu_buses); i++) {
- if (iommu_buses[i] == bus) {
- spin_lock(&iommu_device_lock);
- ret = !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
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH v3 21/21] iommu: Remove iommu_domain_alloc()
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (19 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 20/21] iommu: Remove iommu_present() Lu Baolu
@ 2024-06-10 8:55 ` Lu Baolu
2024-06-19 15:14 ` Jason Gunthorpe
2024-06-19 14:37 ` [PATCH v3 00/21] iommu: Refactoring domain allocation interface Jason Gunthorpe
2024-07-04 14:18 ` Will Deacon
22 siblings, 1 reply; 50+ messages in thread
From: Lu Baolu @ 2024-06-10 8:55 UTC (permalink / raw)
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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel, Lu Baolu
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 <baolu.lu@linux.intel.com>
---
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 ba0b27afc256..bff6e7e81fa3 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_paging_domain_alloc(struct device *dev);
extern void iommu_domain_free(struct iommu_domain *domain);
extern int iommu_attach_device(struct iommu_domain *domain,
@@ -1076,11 +1075,6 @@ static inline bool device_iommu_capable(struct device *dev, enum iommu_cap cap)
return false;
}
-static inline struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
-{
- return NULL;
-}
-
static inline struct iommu_domain *iommu_paging_domain_alloc(struct device *dev)
{
return ERR_PTR(-ENODEV);
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index c7ebdf96e4bc..8212fed27e18 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);
}
-static int __iommu_domain_alloc_dev(struct device *dev, void *data)
-{
- const struct iommu_ops **ops = data;
-
- if (!dev_has_iommu(dev))
- return 0;
-
- if (WARN_ONCE(*ops && *ops != 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 for this to work, sorry!\n",
- dev_bus_name(dev)))
- return -EBUSY;
-
- *ops = 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 = NULL;
- int err = bus_for_each_dev(bus, NULL, &ops, __iommu_domain_alloc_dev);
- struct iommu_domain *domain;
-
- if (err || !ops)
- return NULL;
-
- domain = __iommu_domain_alloc(ops, NULL, IOMMU_DOMAIN_UNMANAGED);
- if (IS_ERR(domain))
- return NULL;
- return domain;
-}
-EXPORT_SYMBOL_GPL(iommu_domain_alloc);
-
/**
* iommu_paging_domain_alloc() - Allocate a paging domain
* @dev: device for which the domain is allocated
--
2.34.1
^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface
2024-06-10 8:55 ` [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface Lu Baolu
@ 2024-06-19 14:20 ` Jason Gunthorpe
2024-06-27 7:10 ` Vasant Hegde
1 sibling, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:20 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:35PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> include/linux/iommu.h | 6 ++++++
> drivers/iommu/iommu.c | 20 ++++++++++++++++++++
> 2 files changed, 26 insertions(+)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 02/21] iommufd: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 02/21] iommufd: Use iommu_paging_domain_alloc() Lu Baolu
@ 2024-06-19 14:21 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:21 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:36PM +0800, Lu Baolu wrote:
> If the iommu driver doesn't implement its domain_alloc_user callback,
> iommufd_hwpt_paging_alloc() rolls back to allocate an iommu paging domain.
> Replace iommu_domain_alloc() with iommu_user_domain_alloc() to pass the
> device pointer along the path.
>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
> drivers/iommu/iommufd/hw_pagetable.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 03/21] vfio/type1: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 03/21] vfio/type1: " Lu Baolu
@ 2024-06-19 14:21 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:21 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:37PM +0800, Lu Baolu wrote:
> Replace iommu_domain_alloc() with iommu_paging_domain_alloc().
>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
> drivers/vfio/vfio_iommu_type1.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 04/21] vhost-vdpa: " Lu Baolu
@ 2024-06-19 14:27 ` Jason Gunthorpe
2024-07-03 16:32 ` Michael S. Tsirkin
1 sibling, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:27 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:38PM +0800, Lu Baolu wrote:
> Replace iommu_domain_alloc() with iommu_paging_domain_alloc().
>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
> drivers/vhost/vdpa.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 07/21] gpu: host1x: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 07/21] gpu: host1x: " Lu Baolu
@ 2024-06-19 14:30 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:30 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:41PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> drivers/gpu/host1x/dev.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 08/21] media: nvidia: tegra: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 08/21] media: nvidia: tegra: " Lu Baolu
@ 2024-06-19 14:31 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:31 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:42PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> drivers/media/platform/nvidia/tegra-vde/iommu.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 09/21] media: venus: firmware: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 09/21] media: venus: firmware: " Lu Baolu
@ 2024-06-19 14:32 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:32 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:43PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> drivers/media/platform/qcom/venus/firmware.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 00/21] iommu: Refactoring domain allocation interface
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (20 preceding siblings ...)
2024-06-10 8:55 ` [PATCH v3 21/21] iommu: Remove iommu_domain_alloc() Lu Baolu
@ 2024-06-19 14:37 ` Jason Gunthorpe
2024-07-04 14:18 ` Will Deacon
22 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:37 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:34PM +0800, Lu Baolu wrote:
> Lu Baolu (20):
> iommu: Add iommu_paging_domain_alloc() interface
> iommufd: Use iommu_paging_domain_alloc()
> vfio/type1: Use iommu_paging_domain_alloc()
> drm/msm: Use iommu_paging_domain_alloc()
> wifi: ath10k: Use iommu_paging_domain_alloc()
> wifi: ath11k: Use iommu_paging_domain_alloc()
> RDMA/usnic: Use iommu_paging_domain_alloc()
Joerg, can you pick at least the above patches for this cycle?
Hopefully more will get tags and can go as well.
If you want to try for more tags on the rest I suggest Lu can send
patches to the subsystem trees and hope the maintainers merge them. At
v6.11-rc5 we declare the remainder unmaintained and you take anything
that hasn't been merged so we can finish the iommu core work.
Thanks,
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 10/21] wifi: ath10k: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 10/21] wifi: ath10k: " Lu Baolu
@ 2024-06-19 14:37 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:37 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:44PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> ---
> drivers/net/wireless/ath/ath10k/snoc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 11/21] wifi: ath11k: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 11/21] wifi: ath11k: " Lu Baolu
@ 2024-06-19 14:38 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:38 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:45PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> ---
> drivers/net/wireless/ath/ath11k/ahb.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 12/21] remoteproc: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 12/21] remoteproc: " Lu Baolu
@ 2024-06-19 14:38 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:38 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:46PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> drivers/remoteproc/remoteproc_core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 13/21] soc/fsl/qbman: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 13/21] soc/fsl/qbman: " Lu Baolu
@ 2024-06-19 14:39 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 14:39 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:47PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> drivers/soc/fsl/qbman/qman_portal.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain
2024-06-10 8:55 ` [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain Lu Baolu
@ 2024-06-19 15:12 ` Jason Gunthorpe
2024-06-20 1:14 ` Baolu Lu
2024-06-28 5:42 ` Yi Liu
1 sibling, 1 reply; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 15:12 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:49PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> drivers/iommu/intel/iommu.c | 87 +++++++++++++++++++++++++++++++++----
> 1 file changed, 78 insertions(+), 9 deletions(-)
It seems Ok, but I have some small thoughts
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> 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 = {
> }
> };
>
> +static int iommu_superpage_capability(struct intel_iommu *iommu, bool first_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 first_stage)
> +{
> + struct device_domain_info *info = dev_iommu_priv_get(dev);
> + struct intel_iommu *iommu = info->iommu;
> + struct dmar_domain *domain;
> + int addr_width;
> +
> + domain = 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);
You should probably split more, with an 'alloc struct dmar_domain'
function that can be used by SVA and others too.
> + domain->nid = dev_to_node(dev);
> + domain->has_iotlb_device = info->ats_enabled;
> + domain->use_first_level = first_stage;
> +
> + /* calculate the address width */
> + addr_width = agaw_to_width(iommu->agaw);
> + if (addr_width > cap_mgaw(iommu->cap))
> + addr_width = cap_mgaw(iommu->cap);
> + domain->gaw = addr_width;
> + domain->agaw = iommu->agaw;
> + domain->max_addr = __DOMAIN_MAX_ADDR(addr_width);
> +
> + /* iommu memory access coherency */
> + domain->iommu_coherency = iommu_paging_structure_coherency(iommu);
> +
> + /* pagesize bitmap */
> + domain->domain.pgsize_bitmap = SZ_4K;
> + domain->iommu_superpage = iommu_superpage_capability(iommu, first_stage);
> + domain->domain.pgsize_bitmap |= domain_super_pgsize_bitmap(domain);
Then some of this stuff is really just paging only. Like
SVA/identity/etc don't have pgszie and other things.
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 17/21] ARM: dma-mapping: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 17/21] ARM: dma-mapping: Use iommu_paging_domain_alloc() Lu Baolu
@ 2024-06-19 15:13 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 15:13 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:51PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> arch/arm/mm/dma-mapping.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 18/21] drm/rockchip: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 18/21] drm/rockchip: " Lu Baolu
@ 2024-06-19 15:14 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 15:14 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:52PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 20/21] iommu: Remove iommu_present()
2024-06-10 8:55 ` [PATCH v3 20/21] iommu: Remove iommu_present() Lu Baolu
@ 2024-06-19 15:14 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 15:14 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:54PM +0800, Lu Baolu wrote:
> The iommu_present() interface is no longer used in the tree anymore.
> Remove it to avoid dead code.
>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
> include/linux/iommu.h | 6 ------
> drivers/iommu/iommu.c | 25 -------------------------
> 2 files changed, 31 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 21/21] iommu: Remove iommu_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 21/21] iommu: Remove iommu_domain_alloc() Lu Baolu
@ 2024-06-19 15:14 ` Jason Gunthorpe
0 siblings, 0 replies; 50+ messages in thread
From: Jason Gunthorpe @ 2024-06-19 15:14 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian, Yi Liu,
David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:55PM +0800, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> include/linux/iommu.h | 6 ------
> drivers/iommu/iommu.c | 36 ------------------------------------
> 2 files changed, 42 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain
2024-06-19 15:12 ` Jason Gunthorpe
@ 2024-06-20 1:14 ` Baolu Lu
0 siblings, 0 replies; 50+ messages in thread
From: Baolu Lu @ 2024-06-20 1:14 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: baolu.lu, Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian,
Yi Liu, David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On 6/19/24 11:12 PM, Jason Gunthorpe wrote:
> On Mon, Jun 10, 2024 at 04:55:49PM +0800, Lu Baolu wrote:
>> 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<baolu.lu@linux.intel.com>
>> ---
>> drivers/iommu/intel/iommu.c | 87 +++++++++++++++++++++++++++++++++----
>> 1 file changed, 78 insertions(+), 9 deletions(-)
> It seems Ok, but I have some small thoughts
>
> Reviewed-by: Jason Gunthorpe<jgg@nvidia.com>
>
>> 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 = {
>> }
>> };
>>
>> +static int iommu_superpage_capability(struct intel_iommu *iommu, bool first_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 first_stage)
>> +{
>> + struct device_domain_info *info = dev_iommu_priv_get(dev);
>> + struct intel_iommu *iommu = info->iommu;
>> + struct dmar_domain *domain;
>> + int addr_width;
>> +
>> + domain = 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);
> You should probably split more, with an 'alloc struct dmar_domain'
> function that can be used by SVA and others too.
>
>> + domain->nid = dev_to_node(dev);
>> + domain->has_iotlb_device = info->ats_enabled;
>> + domain->use_first_level = first_stage;
>> +
>> + /* calculate the address width */
>> + addr_width = agaw_to_width(iommu->agaw);
>> + if (addr_width > cap_mgaw(iommu->cap))
>> + addr_width = cap_mgaw(iommu->cap);
>> + domain->gaw = addr_width;
>> + domain->agaw = iommu->agaw;
>> + domain->max_addr = __DOMAIN_MAX_ADDR(addr_width);
>> +
>> + /* iommu memory access coherency */
>> + domain->iommu_coherency = iommu_paging_structure_coherency(iommu);
>> +
>> + /* pagesize bitmap */
>> + domain->domain.pgsize_bitmap = SZ_4K;
>> + domain->iommu_superpage = iommu_superpage_capability(iommu, first_stage);
>> + domain->domain.pgsize_bitmap |= domain_super_pgsize_bitmap(domain);
> Then some of this stuff is really just paging only. Like
> SVA/identity/etc don't have pgszie and other things.
Yeah, good suggestion. I could do this in this series if it needs a new
version or in my next series which will add domain_alloc_paging for the
intel driver.
Best regards,
baolu
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface
2024-06-10 8:55 ` [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface Lu Baolu
2024-06-19 14:20 ` Jason Gunthorpe
@ 2024-06-27 7:10 ` Vasant Hegde
1 sibling, 0 replies; 50+ messages in thread
From: Vasant Hegde @ 2024-06-27 7:10 UTC (permalink / raw)
To: Lu Baolu, 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, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On 6/10/2024 2:25 PM, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
> ---
> 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 7bc8dff7cf6d..46f1348f1f0a 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_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);
> @@ -1086,6 +1087,11 @@ static inline struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus
> return NULL;
> }
>
> +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 9df7cc75c1bc..e03c71a34347 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -2016,6 +2016,10 @@ static int __iommu_domain_alloc_dev(struct device *dev, void *data)
> 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 = NULL;
> @@ -2032,6 +2036,22 @@ struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
> }
> EXPORT_SYMBOL_GPL(iommu_domain_alloc);
>
> +/**
> + * 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. Return
> + * 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_UNMANAGED);
> +}
> +EXPORT_SYMBOL_GPL(iommu_paging_domain_alloc);
> +
> void iommu_domain_free(struct iommu_domain *domain)
> {
> if (domain->type == IOMMU_DOMAIN_SVA)
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain
2024-06-10 8:55 ` [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain Lu Baolu
2024-06-19 15:12 ` Jason Gunthorpe
@ 2024-06-28 5:42 ` Yi Liu
2024-06-28 8:29 ` Baolu Lu
1 sibling, 1 reply; 50+ messages in thread
From: Yi Liu @ 2024-06-28 5:42 UTC (permalink / raw)
To: Lu Baolu, Joerg Roedel, Will Deacon, Robin Murphy,
Jason Gunthorpe, Kevin Tian
Cc: David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, mst, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On 2024/6/10 16:55, Lu Baolu wrote:
> 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 <baolu.lu@linux.intel.com>
> ---
> 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 = {
> }
> };
>
> +static int iommu_superpage_capability(struct intel_iommu *iommu, bool first_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 first_stage)
> +{
> + struct device_domain_info *info = dev_iommu_priv_get(dev);
> + struct intel_iommu *iommu = info->iommu;
> + struct dmar_domain *domain;
> + int addr_width;
> +
> + domain = 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 = dev_to_node(dev);
> + domain->has_iotlb_device = info->ats_enabled;
> + domain->use_first_level = first_stage;
> +
> + /* calculate the address width */
> + addr_width = agaw_to_width(iommu->agaw);
> + if (addr_width > cap_mgaw(iommu->cap))
> + addr_width = cap_mgaw(iommu->cap);
> + domain->gaw = addr_width;
> + domain->agaw = iommu->agaw;
> + domain->max_addr = __DOMAIN_MAX_ADDR(addr_width);
> +
> + /* iommu memory access coherency */
> + domain->iommu_coherency = iommu_paging_structure_coherency(iommu);
> +
> + /* pagesize bitmap */
> + domain->domain.pgsize_bitmap = SZ_4K;
> + domain->iommu_superpage = iommu_superpage_capability(iommu, first_stage);
> + domain->domain.pgsize_bitmap |= 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 = true;
> + domain->domain.geometry.aperture_start = 0;
> + if (first_stage)
> + domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw - 1);
> + else
> + domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw);
> +
> + /* always allocate the top pgd */
> + domain->pgd = 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, u32 flags,
> if (user_data || (dirty_tracking && !ssads_supported(iommu)))
> return ERR_PTR(-EOPNOTSUPP);
>
> - /*
> - * domain_alloc_user op needs to fully initialize a domain before
> - * return, so uses iommu_domain_alloc() here for simple.
> - */
> - domain = iommu_domain_alloc(dev->bus);
> - if (!domain)
> - return ERR_PTR(-ENOMEM);
> -
> - dmar_domain = to_dmar_domain(domain);
> + /* Do not use first stage for user domain translation. */
> + dmar_domain = paging_domain_alloc(dev, false);
this is not an apple-to-apple replacement yet. You need to set the type,
owner and domain->ops as well.
> + if (IS_ERR(dmar_domain))
> + return ERR_CAST(dmar_domain);
> + domain = &dmar_domain->domain;
>
> if (nested_parent) {
> dmar_domain->nested_parent = true;
--
Regards,
Yi Liu
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain
2024-06-28 5:42 ` Yi Liu
@ 2024-06-28 8:29 ` Baolu Lu
0 siblings, 0 replies; 50+ messages in thread
From: Baolu Lu @ 2024-06-28 8:29 UTC (permalink / raw)
To: Yi Liu, Joerg Roedel, Will Deacon, Robin Murphy, Jason Gunthorpe,
Kevin Tian
Cc: baolu.lu, David Airlie, Daniel Vetter, Kalle Valo,
Bjorn Andersson, Mathieu Poirier, Alex Williamson, mst,
Jason Wang, Thierry Reding, Jonathan Hunter, Mikko Perttunen,
Jeff Johnson, ath10k, ath11k, iommu, dri-devel, linux-kernel
On 2024/6/28 13:42, Yi Liu wrote:
> On 2024/6/10 16:55, Lu Baolu wrote:
>> 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 <baolu.lu@linux.intel.com>
>> ---
>> 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 = {
>> }
>> };
>> +static int iommu_superpage_capability(struct intel_iommu *iommu, bool
>> first_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 first_stage)
>> +{
>> + struct device_domain_info *info = dev_iommu_priv_get(dev);
>> + struct intel_iommu *iommu = info->iommu;
>> + struct dmar_domain *domain;
>> + int addr_width;
>> +
>> + domain = 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 = dev_to_node(dev);
>> + domain->has_iotlb_device = info->ats_enabled;
>> + domain->use_first_level = first_stage;
>> +
>> + /* calculate the address width */
>> + addr_width = agaw_to_width(iommu->agaw);
>> + if (addr_width > cap_mgaw(iommu->cap))
>> + addr_width = cap_mgaw(iommu->cap);
>> + domain->gaw = addr_width;
>> + domain->agaw = iommu->agaw;
>> + domain->max_addr = __DOMAIN_MAX_ADDR(addr_width);
>> +
>> + /* iommu memory access coherency */
>> + domain->iommu_coherency = iommu_paging_structure_coherency(iommu);
>> +
>> + /* pagesize bitmap */
>> + domain->domain.pgsize_bitmap = SZ_4K;
>> + domain->iommu_superpage = iommu_superpage_capability(iommu,
>> first_stage);
>> + domain->domain.pgsize_bitmap |= 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 = true;
>> + domain->domain.geometry.aperture_start = 0;
>> + if (first_stage)
>> + domain->domain.geometry.aperture_end =
>> __DOMAIN_MAX_ADDR(domain->gaw - 1);
>> + else
>> + domain->domain.geometry.aperture_end =
>> __DOMAIN_MAX_ADDR(domain->gaw);
>> +
>> + /* always allocate the top pgd */
>> + domain->pgd = 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, u32 flags,
>> if (user_data || (dirty_tracking && !ssads_supported(iommu)))
>> return ERR_PTR(-EOPNOTSUPP);
>> - /*
>> - * domain_alloc_user op needs to fully initialize a domain before
>> - * return, so uses iommu_domain_alloc() here for simple.
>> - */
>> - domain = iommu_domain_alloc(dev->bus);
>> - if (!domain)
>> - return ERR_PTR(-ENOMEM);
>> -
>> - dmar_domain = to_dmar_domain(domain);
>> + /* Do not use first stage for user domain translation. */
>> + dmar_domain = paging_domain_alloc(dev, false);
>
> this is not an apple-to-apple replacement yet. You need to set the type,
> owner and domain->ops as well.
Yes. You are right. I will add below lines.
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index d51f840715e5..c5d9c2283977 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3732,6 +3732,9 @@ intel_iommu_domain_alloc_user(struct device *dev,
u32 flags,
if (IS_ERR(dmar_domain))
return ERR_CAST(dmar_domain);
domain = &dmar_domain->domain;
+ domain->type = IOMMU_DOMAIN_UNMANAGED;
+ domain->owner = &intel_iommu_ops;
+ domain->ops = intel_iommu_ops.default_domain_ops;
if (nested_parent) {
dmar_domain->nested_parent = true;
Best regards,
baolu
^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH v3 04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
2024-06-10 8:55 ` [PATCH v3 04/21] vhost-vdpa: " Lu Baolu
2024-06-19 14:27 ` Jason Gunthorpe
@ 2024-07-03 16:32 ` Michael S. Tsirkin
2024-07-04 13:53 ` Will Deacon
1 sibling, 1 reply; 50+ messages in thread
From: Michael S. Tsirkin @ 2024-07-03 16:32 UTC (permalink / raw)
To: Lu Baolu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, Jason Gunthorpe,
Kevin Tian, Yi Liu, David Airlie, Daniel Vetter, Kalle Valo,
Bjorn Andersson, Mathieu Poirier, Alex Williamson, Jason Wang,
Thierry Reding, Jonathan Hunter, Mikko Perttunen, Jeff Johnson,
ath10k, ath11k, iommu, dri-devel, linux-kernel
On Mon, Jun 10, 2024 at 04:55:38PM +0800, Lu Baolu wrote:
> Replace iommu_domain_alloc() with iommu_paging_domain_alloc().
>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
I assume it's merged with the rest of the stuff, right?
> ---
> 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..e31ec9ebc4ce 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -1312,26 +1312,24 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
> struct vdpa_device *vdpa = v->vdpa;
> const struct vdpa_config_ops *ops = vdpa->config;
> struct device *dma_dev = vdpa_get_dma_dev(vdpa);
> - const struct bus_type *bus;
> int ret;
>
> /* Device want to do DMA by itself */
> if (ops->set_map || ops->dma_map)
> return 0;
>
> - bus = 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 capable\n");
> return -ENOTSUPP;
> }
>
> - v->domain = iommu_domain_alloc(bus);
> - if (!v->domain)
> - return -EIO;
> + v->domain = iommu_paging_domain_alloc(dma_dev);
> + if (IS_ERR(v->domain)) {
> + ret = PTR_ERR(v->domain);
> + v->domain = NULL;
> + return ret;
> + }
>
> ret = iommu_attach_device(v->domain, dma_dev);
> if (ret)
> --
> 2.34.1
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
2024-07-03 16:32 ` Michael S. Tsirkin
@ 2024-07-04 13:53 ` Will Deacon
0 siblings, 0 replies; 50+ messages in thread
From: Will Deacon @ 2024-07-04 13:53 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Lu Baolu, Joerg Roedel, Robin Murphy, Jason Gunthorpe, Kevin Tian,
Yi Liu, David Airlie, Daniel Vetter, Kalle Valo, Bjorn Andersson,
Mathieu Poirier, Alex Williamson, Jason Wang, Thierry Reding,
Jonathan Hunter, Mikko Perttunen, Jeff Johnson, ath10k, ath11k,
iommu, dri-devel, linux-kernel
On Wed, Jul 03, 2024 at 12:32:06PM -0400, Michael S. Tsirkin wrote:
> On Mon, Jun 10, 2024 at 04:55:38PM +0800, Lu Baolu wrote:
> > Replace iommu_domain_alloc() with iommu_paging_domain_alloc().
> >
> > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
>
> I assume it's merged with the rest of the stuff, right?
Sure, I can grab this one in the iommu tree. It has to go along with
the patch adding iommu_paging_domain_alloc() anyway.
Will
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 00/21] iommu: Refactoring domain allocation interface
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
` (21 preceding siblings ...)
2024-06-19 14:37 ` [PATCH v3 00/21] iommu: Refactoring domain allocation interface Jason Gunthorpe
@ 2024-07-04 14:18 ` Will Deacon
2024-07-04 14:24 ` Baolu Lu
2024-07-08 16:34 ` Jason Gunthorpe
22 siblings, 2 replies; 50+ messages in thread
From: Will Deacon @ 2024-07-04 14:18 UTC (permalink / raw)
To: Joerg Roedel, Robin Murphy, Jason Gunthorpe, Kevin Tian, Lu Baolu
Cc: catalin.marinas, kernel-team, Will Deacon, Yi Liu, David Airlie,
Daniel Vetter, Kalle Valo, Bjorn Andersson, Mathieu Poirier,
Alex Williamson, mst, Jason Wang, Thierry Reding, Jonathan Hunter,
Mikko Perttunen, Jeff Johnson, ath10k, ath11k, iommu, dri-devel,
linux-kernel
On Mon, 10 Jun 2024 16:55:34 +0800, Lu Baolu wrote:
> The IOMMU subsystem has undergone some changes, including the removal
> of iommu_ops from the bus structure. Consequently, the existing domain
> allocation interface, which relies on a bus type argument, is no longer
> relevant:
>
> struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
>
> [...]
Applied a few of these to iommu (iommufd/paging-domain-alloc), thanks!
[01/21] iommu: Add iommu_paging_domain_alloc() interface
https://git.kernel.org/iommu/c/a27bf2743cb8
[02/21] iommufd: Use iommu_paging_domain_alloc()
https://git.kernel.org/iommu/c/26a581606fab
[03/21] vfio/type1: Use iommu_paging_domain_alloc()
https://git.kernel.org/iommu/c/60ffc4501722
[04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
https://git.kernel.org/iommu/c/9c159f6de1ae
[05/21] drm/msm: Use iommu_paging_domain_alloc()
https://git.kernel.org/iommu/c/45acf35af200
[10/21] wifi: ath10k: Use iommu_paging_domain_alloc()
https://git.kernel.org/iommu/c/d5b7485588df
[11/21] wifi: ath11k: Use iommu_paging_domain_alloc()
https://git.kernel.org/iommu/c/ef50d41fbf1c
[14/21] RDMA/usnic: Use iommu_paging_domain_alloc()
https://git.kernel.org/iommu/c/3b10f25704be
[15/21] iommu/vt-d: Add helper to allocate paging domain
https://git.kernel.org/iommu/c/9e9ba576c259
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 00/21] iommu: Refactoring domain allocation interface
2024-07-04 14:18 ` Will Deacon
@ 2024-07-04 14:24 ` Baolu Lu
2024-07-04 14:34 ` Will Deacon
2024-07-08 16:34 ` Jason Gunthorpe
1 sibling, 1 reply; 50+ messages in thread
From: Baolu Lu @ 2024-07-04 14:24 UTC (permalink / raw)
To: Will Deacon, Joerg Roedel, Robin Murphy, Jason Gunthorpe,
Kevin Tian
Cc: baolu.lu, catalin.marinas, kernel-team, Yi Liu, David Airlie,
Daniel Vetter, Kalle Valo, Bjorn Andersson, Mathieu Poirier,
Alex Williamson, mst, Jason Wang, Thierry Reding, Jonathan Hunter,
Mikko Perttunen, Jeff Johnson, ath10k, ath11k, iommu, dri-devel,
linux-kernel
On 2024/7/4 22:18, Will Deacon wrote:
> On Mon, 10 Jun 2024 16:55:34 +0800, Lu Baolu wrote:
>> The IOMMU subsystem has undergone some changes, including the removal
>> of iommu_ops from the bus structure. Consequently, the existing domain
>> allocation interface, which relies on a bus type argument, is no longer
>> relevant:
>>
>> struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
>>
>> [...]
> Applied a few of these to iommu (iommufd/paging-domain-alloc), thanks!
>
> [01/21] iommu: Add iommu_paging_domain_alloc() interface
> https://git.kernel.org/iommu/c/a27bf2743cb8
> [02/21] iommufd: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/26a581606fab
> [03/21] vfio/type1: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/60ffc4501722
> [04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/9c159f6de1ae
> [05/21] drm/msm: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/45acf35af200
>
> [10/21] wifi: ath10k: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/d5b7485588df
> [11/21] wifi: ath11k: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/ef50d41fbf1c
>
> [14/21] RDMA/usnic: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/3b10f25704be
> [15/21] iommu/vt-d: Add helper to allocate paging domain
> https://git.kernel.org/iommu/c/9e9ba576c259
Will, the patch [15/21] has already been included in my VT-d update pull
request. I have also addressed Yi's comment in that patch. So can you
please remove it from this branch?
Thanks,
baolu
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 00/21] iommu: Refactoring domain allocation interface
2024-07-04 14:24 ` Baolu Lu
@ 2024-07-04 14:34 ` Will Deacon
0 siblings, 0 replies; 50+ messages in thread
From: Will Deacon @ 2024-07-04 14:34 UTC (permalink / raw)
To: Baolu Lu
Cc: Joerg Roedel, Robin Murphy, Jason Gunthorpe, Kevin Tian,
catalin.marinas, kernel-team, Yi Liu, David Airlie, Daniel Vetter,
Kalle Valo, Bjorn Andersson, Mathieu Poirier, Alex Williamson,
mst, Jason Wang, Thierry Reding, Jonathan Hunter, Mikko Perttunen,
Jeff Johnson, ath10k, ath11k, iommu, dri-devel, linux-kernel
On Thu, Jul 04, 2024 at 10:24:52PM +0800, Baolu Lu wrote:
> On 2024/7/4 22:18, Will Deacon wrote:
> > On Mon, 10 Jun 2024 16:55:34 +0800, Lu Baolu wrote:
> > > The IOMMU subsystem has undergone some changes, including the removal
> > > of iommu_ops from the bus structure. Consequently, the existing domain
> > > allocation interface, which relies on a bus type argument, is no longer
> > > relevant:
> > >
> > > struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
> > >
> > > [...]
> > Applied a few of these to iommu (iommufd/paging-domain-alloc), thanks!
> >
> > [01/21] iommu: Add iommu_paging_domain_alloc() interface
> > https://git.kernel.org/iommu/c/a27bf2743cb8
> > [02/21] iommufd: Use iommu_paging_domain_alloc()
> > https://git.kernel.org/iommu/c/26a581606fab
> > [03/21] vfio/type1: Use iommu_paging_domain_alloc()
> > https://git.kernel.org/iommu/c/60ffc4501722
> > [04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
> > https://git.kernel.org/iommu/c/9c159f6de1ae
> > [05/21] drm/msm: Use iommu_paging_domain_alloc()
> > https://git.kernel.org/iommu/c/45acf35af200
> >
> > [10/21] wifi: ath10k: Use iommu_paging_domain_alloc()
> > https://git.kernel.org/iommu/c/d5b7485588df
> > [11/21] wifi: ath11k: Use iommu_paging_domain_alloc()
> > https://git.kernel.org/iommu/c/ef50d41fbf1c
> >
> > [14/21] RDMA/usnic: Use iommu_paging_domain_alloc()
> > https://git.kernel.org/iommu/c/3b10f25704be
> > [15/21] iommu/vt-d: Add helper to allocate paging domain
> > https://git.kernel.org/iommu/c/9e9ba576c259
>
> Will, the patch [15/21] has already been included in my VT-d update pull
> request. I have also addressed Yi's comment in that patch. So can you
> please remove it from this branch?
Heh, was just about to say the same thing as I noticed when I was
re-creating 'next'. Yes, I'll drop it now. Since it's on the end, the
other SHAs will remain the same.
Sorry about that,
Will
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 00/21] iommu: Refactoring domain allocation interface
2024-07-04 14:18 ` Will Deacon
2024-07-04 14:24 ` Baolu Lu
@ 2024-07-08 16:34 ` Jason Gunthorpe
2024-07-09 2:10 ` Baolu Lu
1 sibling, 1 reply; 50+ messages in thread
From: Jason Gunthorpe @ 2024-07-08 16:34 UTC (permalink / raw)
To: Will Deacon
Cc: Joerg Roedel, Robin Murphy, Kevin Tian, Lu Baolu, catalin.marinas,
kernel-team, Yi Liu, David Airlie, Daniel Vetter, Kalle Valo,
Bjorn Andersson, Mathieu Poirier, Alex Williamson, mst,
Jason Wang, Thierry Reding, Jonathan Hunter, Mikko Perttunen,
Jeff Johnson, ath10k, ath11k, iommu, dri-devel, linux-kernel
On Thu, Jul 04, 2024 at 03:18:56PM +0100, Will Deacon wrote:
> On Mon, 10 Jun 2024 16:55:34 +0800, Lu Baolu wrote:
> > The IOMMU subsystem has undergone some changes, including the removal
> > of iommu_ops from the bus structure. Consequently, the existing domain
> > allocation interface, which relies on a bus type argument, is no longer
> > relevant:
> >
> > struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
> >
> > [...]
>
> Applied a few of these to iommu (iommufd/paging-domain-alloc), thanks!
>
> [01/21] iommu: Add iommu_paging_domain_alloc() interface
> https://git.kernel.org/iommu/c/a27bf2743cb8
> [02/21] iommufd: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/26a581606fab
> [03/21] vfio/type1: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/60ffc4501722
> [04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/9c159f6de1ae
> [05/21] drm/msm: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/45acf35af200
>
> [10/21] wifi: ath10k: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/d5b7485588df
> [11/21] wifi: ath11k: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/ef50d41fbf1c
>
> [14/21] RDMA/usnic: Use iommu_paging_domain_alloc()
> https://git.kernel.org/iommu/c/3b10f25704be
> [15/21] iommu/vt-d: Add helper to allocate paging domain
> https://git.kernel.org/iommu/c/9e9ba576c259
Great, Lu can you please split the remaining by subsystem and try to
get them to go through subsystem trees? Joerg can take the leftovers
at rc6/7 or something like that so we can finish this.
I think this is enough that Intel and AMD could now assert that dev is
non-null?
Jason
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH v3 00/21] iommu: Refactoring domain allocation interface
2024-07-08 16:34 ` Jason Gunthorpe
@ 2024-07-09 2:10 ` Baolu Lu
0 siblings, 0 replies; 50+ messages in thread
From: Baolu Lu @ 2024-07-09 2:10 UTC (permalink / raw)
To: Jason Gunthorpe, Will Deacon
Cc: baolu.lu, Joerg Roedel, Robin Murphy, Kevin Tian, catalin.marinas,
kernel-team, Yi Liu, David Airlie, Daniel Vetter, Kalle Valo,
Bjorn Andersson, Mathieu Poirier, Alex Williamson, mst,
Jason Wang, Thierry Reding, Jonathan Hunter, Mikko Perttunen,
Jeff Johnson, ath10k, ath11k, iommu, dri-devel, linux-kernel
On 7/9/24 12:34 AM, Jason Gunthorpe wrote:
> On Thu, Jul 04, 2024 at 03:18:56PM +0100, Will Deacon wrote:
>> On Mon, 10 Jun 2024 16:55:34 +0800, Lu Baolu wrote:
>>> The IOMMU subsystem has undergone some changes, including the removal
>>> of iommu_ops from the bus structure. Consequently, the existing domain
>>> allocation interface, which relies on a bus type argument, is no longer
>>> relevant:
>>>
>>> struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
>>>
>>> [...]
>> Applied a few of these to iommu (iommufd/paging-domain-alloc), thanks!
>>
>> [01/21] iommu: Add iommu_paging_domain_alloc() interface
>> https://git.kernel.org/iommu/c/a27bf2743cb8
>> [02/21] iommufd: Use iommu_paging_domain_alloc()
>> https://git.kernel.org/iommu/c/26a581606fab
>> [03/21] vfio/type1: Use iommu_paging_domain_alloc()
>> https://git.kernel.org/iommu/c/60ffc4501722
>> [04/21] vhost-vdpa: Use iommu_paging_domain_alloc()
>> https://git.kernel.org/iommu/c/9c159f6de1ae
>> [05/21] drm/msm: Use iommu_paging_domain_alloc()
>> https://git.kernel.org/iommu/c/45acf35af200
>>
>> [10/21] wifi: ath10k: Use iommu_paging_domain_alloc()
>> https://git.kernel.org/iommu/c/d5b7485588df
>> [11/21] wifi: ath11k: Use iommu_paging_domain_alloc()
>> https://git.kernel.org/iommu/c/ef50d41fbf1c
>>
>> [14/21] RDMA/usnic: Use iommu_paging_domain_alloc()
>> https://git.kernel.org/iommu/c/3b10f25704be
>> [15/21] iommu/vt-d: Add helper to allocate paging domain
>> https://git.kernel.org/iommu/c/9e9ba576c259
> Great, Lu can you please split the remaining by subsystem and try to
> get them to go through subsystem trees? Joerg can take the leftovers
> at rc6/7 or something like that so we can finish this.
Yes, sure. I guess I need to wait until 6.11-rc1 is out. It's a bit late
in the cycle for the subsystem trees to accept brand new changes.
> I think this is enough that Intel and AMD could now assert that dev is
> non-null?
Yes.
Thanks,
baolu
^ permalink raw reply [flat|nested] 50+ messages in thread
end of thread, other threads:[~2024-07-09 2:13 UTC | newest]
Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-10 8:55 [PATCH v3 00/21] iommu: Refactoring domain allocation interface Lu Baolu
2024-06-10 8:55 ` [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface Lu Baolu
2024-06-19 14:20 ` Jason Gunthorpe
2024-06-27 7:10 ` Vasant Hegde
2024-06-10 8:55 ` [PATCH v3 02/21] iommufd: Use iommu_paging_domain_alloc() Lu Baolu
2024-06-19 14:21 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 03/21] vfio/type1: " Lu Baolu
2024-06-19 14:21 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 04/21] vhost-vdpa: " Lu Baolu
2024-06-19 14:27 ` Jason Gunthorpe
2024-07-03 16:32 ` Michael S. Tsirkin
2024-07-04 13:53 ` Will Deacon
2024-06-10 8:55 ` [PATCH v3 05/21] drm/msm: " Lu Baolu
2024-06-10 8:55 ` [PATCH v3 06/21] drm/nouveau/tegra: " Lu Baolu
2024-06-10 8:55 ` [PATCH v3 07/21] gpu: host1x: " Lu Baolu
2024-06-19 14:30 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 08/21] media: nvidia: tegra: " Lu Baolu
2024-06-19 14:31 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 09/21] media: venus: firmware: " Lu Baolu
2024-06-19 14:32 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 10/21] wifi: ath10k: " Lu Baolu
2024-06-19 14:37 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 11/21] wifi: ath11k: " Lu Baolu
2024-06-19 14:38 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 12/21] remoteproc: " Lu Baolu
2024-06-19 14:38 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 13/21] soc/fsl/qbman: " Lu Baolu
2024-06-19 14:39 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 14/21] RDMA/usnic: " Lu Baolu
2024-06-10 8:55 ` [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain Lu Baolu
2024-06-19 15:12 ` Jason Gunthorpe
2024-06-20 1:14 ` Baolu Lu
2024-06-28 5:42 ` Yi Liu
2024-06-28 8:29 ` Baolu Lu
2024-06-10 8:55 ` [PATCH v3 16/21] ARM: dma-mapping: Pass device to arm_iommu_create_mapping() Lu Baolu
2024-06-10 8:55 ` [PATCH v3 17/21] ARM: dma-mapping: Use iommu_paging_domain_alloc() Lu Baolu
2024-06-19 15:13 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 18/21] drm/rockchip: " Lu Baolu
2024-06-19 15:14 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 19/21] drm/tegra: Remove call to iommu_domain_alloc() Lu Baolu
2024-06-10 8:55 ` [PATCH v3 20/21] iommu: Remove iommu_present() Lu Baolu
2024-06-19 15:14 ` Jason Gunthorpe
2024-06-10 8:55 ` [PATCH v3 21/21] iommu: Remove iommu_domain_alloc() Lu Baolu
2024-06-19 15:14 ` Jason Gunthorpe
2024-06-19 14:37 ` [PATCH v3 00/21] iommu: Refactoring domain allocation interface Jason Gunthorpe
2024-07-04 14:18 ` Will Deacon
2024-07-04 14:24 ` Baolu Lu
2024-07-04 14:34 ` Will Deacon
2024-07-08 16:34 ` Jason Gunthorpe
2024-07-09 2:10 ` Baolu Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox