[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240123165829.630276-1-ovidiu.panait@windriver.com>
Date: Tue, 23 Jan 2024 18:58:29 +0200
From: ovidiu.panait@...driver.com
To: linux-kernel@...r.kernel.org, iommu@...ts.linux.dev
Cc: robin.murphy@....com, will@...nel.org, joro@...tes.org, jgg@...pe.ca,
Ovidiu Panait <ovidiu.panait@...driver.com>
Subject: [PATCH] iommu: iommu_group_alloc_default_domain: Fix ops->default_domain codepath
From: Ovidiu Panait <ovidiu.panait@...driver.com>
Since commit [1], FSL_PAMU initialization on t4240rdb board fails
with: "fsl-pamu-domain: pamu_domain_init: Can't register iommu device".
Commit [1] changed the behavior for drivers that set ops->default_domain,
as the function iommu_group_alloc_default_domain() is now called with
"req_type == IOMMU_DOMAIN_IDENTITY", rather than "req_type == 0". This
causes the following EINVAL condition to be hit during FSL_PAMU
initialization:
...
if (ops->default_domain) {
if (req_type)
return ERR_PTR(-EINVAL);
return ops->default_domain;
}
...
To avoid this issue when ops->default_domain != NULL, remove the check for
non-zero req_type and always return the proper default domain, as set in
the driver.
[1] 0f6a90436a57 ("iommu: Do not use IOMMU_DOMAIN_DMA [...]")
Fixes: 0f6a90436a57 ("iommu: Do not use IOMMU_DOMAIN_DMA if CONFIG_IOMMU_DMA is not enabled")
Signed-off-by: Ovidiu Panait <ovidiu.panait@...driver.com>
---
drivers/iommu/iommu.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 68e648b55767..8e79a074e560 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1798,11 +1798,8 @@ iommu_group_alloc_default_domain(struct iommu_group *group, int req_type)
* domain. This should always be either an IDENTITY/BLOCKED/PLATFORM
* domain. Do not use in new drivers.
*/
- if (ops->default_domain) {
- if (req_type)
- return ERR_PTR(-EINVAL);
+ if (ops->default_domain)
return ops->default_domain;
- }
if (req_type)
return __iommu_group_alloc_default_domain(group, req_type);
--
2.34.1
Powered by blists - more mailing lists