* [PATCH v4 1/4] remoteproc: Use iommu_paging_domain_alloc()
2024-10-09 4:11 [PATCH v4 0/4] iommu: Refactoring domain allocation interface Lu Baolu
@ 2024-10-09 4:11 ` Lu Baolu
2024-10-09 4:11 ` [PATCH v4 2/4] media: nvidia: tegra: " Lu Baolu
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Lu Baolu @ 2024-10-09 4:11 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,
Lyude Paul, Beleswar Padhi, iommu, linux-kernel, Lu Baolu,
Jason Gunthorpe
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>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Beleswar Padhi <b-padhi@ti.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.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v4 2/4] media: nvidia: tegra: Use iommu_paging_domain_alloc()
2024-10-09 4:11 [PATCH v4 0/4] iommu: Refactoring domain allocation interface Lu Baolu
2024-10-09 4:11 ` [PATCH v4 1/4] remoteproc: Use iommu_paging_domain_alloc() Lu Baolu
@ 2024-10-09 4:11 ` Lu Baolu
2024-10-09 4:11 ` [PATCH v4 3/4] drm/nouveau/tegra: " Lu Baolu
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Lu Baolu @ 2024-10-09 4:11 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,
Lyude Paul, Beleswar Padhi, iommu, linux-kernel, Lu Baolu,
Jason Gunthorpe, Thierry Reding
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>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.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.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v4 3/4] drm/nouveau/tegra: Use iommu_paging_domain_alloc()
2024-10-09 4:11 [PATCH v4 0/4] iommu: Refactoring domain allocation interface Lu Baolu
2024-10-09 4:11 ` [PATCH v4 1/4] remoteproc: Use iommu_paging_domain_alloc() Lu Baolu
2024-10-09 4:11 ` [PATCH v4 2/4] media: nvidia: tegra: " Lu Baolu
@ 2024-10-09 4:11 ` Lu Baolu
2024-10-09 4:11 ` [PATCH v4 4/4] iommu: Remove iommu_domain_alloc() Lu Baolu
2024-10-29 9:05 ` [PATCH v4 0/4] iommu: Refactoring domain allocation interface Joerg Roedel
4 siblings, 0 replies; 6+ messages in thread
From: Lu Baolu @ 2024-10-09 4:11 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,
Lyude Paul, Beleswar Padhi, iommu, linux-kernel, Lu Baolu,
Thierry Reding
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>
Acked-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Lyude Paul <lyude@redhat.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 d1c294f00665..78a83f904bbd 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.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v4 4/4] iommu: Remove iommu_domain_alloc()
2024-10-09 4:11 [PATCH v4 0/4] iommu: Refactoring domain allocation interface Lu Baolu
` (2 preceding siblings ...)
2024-10-09 4:11 ` [PATCH v4 3/4] drm/nouveau/tegra: " Lu Baolu
@ 2024-10-09 4:11 ` Lu Baolu
2024-10-29 9:05 ` [PATCH v4 0/4] iommu: Refactoring domain allocation interface Joerg Roedel
4 siblings, 0 replies; 6+ messages in thread
From: Lu Baolu @ 2024-10-09 4:11 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,
Lyude Paul, Beleswar Padhi, iommu, linux-kernel, Lu Baolu,
Jason Gunthorpe
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>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.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 bd722f473635..6d809f6e6c8d 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -788,7 +788,6 @@ 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);
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,
@@ -1091,11 +1090,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 83c8e617a2c5..521471706400 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1994,42 +1994,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.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v4 0/4] iommu: Refactoring domain allocation interface
2024-10-09 4:11 [PATCH v4 0/4] iommu: Refactoring domain allocation interface Lu Baolu
` (3 preceding siblings ...)
2024-10-09 4:11 ` [PATCH v4 4/4] iommu: Remove iommu_domain_alloc() Lu Baolu
@ 2024-10-29 9:05 ` Joerg Roedel
4 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2024-10-29 9:05 UTC (permalink / raw)
To: Lu Baolu
Cc: Will Deacon, Robin Murphy, Jason Gunthorpe, 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,
Lyude Paul, Beleswar Padhi, iommu, linux-kernel
On Wed, Oct 09, 2024 at 12:11:43PM +0800, Lu Baolu wrote:
> Lu Baolu (4):
> remoteproc: Use iommu_paging_domain_alloc()
> media: nvidia: tegra: Use iommu_paging_domain_alloc()
> drm/nouveau/tegra: Use iommu_paging_domain_alloc()
> iommu: Remove iommu_domain_alloc()
>
> include/linux/iommu.h | 6 ----
> .../drm/nouveau/nvkm/engine/device/tegra.c | 4 +--
> drivers/iommu/iommu.c | 36 -------------------
> .../media/platform/nvidia/tegra-vde/iommu.c | 7 ++--
> drivers/remoteproc/remoteproc_core.c | 6 ++--
> 5 files changed, 9 insertions(+), 50 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread