* [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging()
@ 2023-09-27 23:47 Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain Jason Gunthorpe
` (10 more replies)
0 siblings, 11 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
Continue converting drivers to the new interface. Introduce
ops->blocked_domain to hold the global static BLOCKED domain and convert
all drivers supporting BLOCKED to use it.
This makes it trivial for dart and iommufd to convert over to
domain_alloc_paging().
There are six drivers remaining:
drivers/iommu/amd/iommu.c: .domain_alloc = amd_iommu_domain_alloc,
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c: .domain_alloc = arm_smmu_domain_alloc,
drivers/iommu/arm/arm-smmu/arm-smmu.c: .domain_alloc = arm_smmu_domain_alloc,
drivers/iommu/fsl_pamu_domain.c: .domain_alloc = fsl_pamu_domain_alloc,
drivers/iommu/intel/iommu.c: .domain_alloc = intel_iommu_domain_alloc,
drivers/iommu/virtio-iommu.c: .domain_alloc = viommu_domain_alloc,
v2:
- Rebase to Joerg's for-next
- New patch to remove force_bypass, as discussed with Janne
- Move some hunks between patches to accommodate Robin's change to the
attach_dev switch
v1: https://lore.kernel.org/r/0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com
Jason Gunthorpe (9):
iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain
iommu/vt-d: Update the definition of the blocking domain
iommu/vt-d: Use ops->blocked_domain
iommufd: Convert to alloc_domain_paging()
iommu/dart: Use static global identity domains
iommu/dart: Move the blocked domain support to a global static
iommu/dart: Convert to domain_alloc_paging()
iommu/dart: Call apple_dart_finalize_domain() as part of
alloc_paging()
iommu/dart: Remove the force_bypass variable
arch/powerpc/kernel/iommu.c | 9 +-
drivers/iommu/apple-dart.c | 137 ++++++++++++++++++-------------
drivers/iommu/intel/iommu.c | 7 +-
drivers/iommu/iommu.c | 2 +
drivers/iommu/iommufd/selftest.c | 11 +--
include/linux/iommu.h | 3 +
6 files changed, 94 insertions(+), 75 deletions(-)
base-commit: 83653d8508051af13f74905fc3f6c2fa2e59dbee
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 2/9] iommu/vt-d: Update the definition of the blocking domain Jason Gunthorpe
` (9 subsequent siblings)
10 siblings, 1 reply; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
Following the pattern of identity domains, just assign the BLOCKED domain
global statics to a value in ops. Update the core code to use the global
static directly.
Update powerpc to use the new scheme and remove its empty domain_alloc
callback.
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
arch/powerpc/kernel/iommu.c | 9 +--------
drivers/iommu/iommu.c | 2 ++
include/linux/iommu.h | 3 +++
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index d6ad3fde85a212..3c1d10be19c4c7 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -1327,13 +1327,6 @@ static bool spapr_tce_iommu_capable(struct device *dev, enum iommu_cap cap)
return false;
}
-static struct iommu_domain *spapr_tce_iommu_domain_alloc(unsigned int type)
-{
- if (type != IOMMU_DOMAIN_BLOCKED)
- return NULL;
- return &spapr_tce_blocked_domain;
-}
-
static struct iommu_device *spapr_tce_iommu_probe_device(struct device *dev)
{
struct pci_dev *pdev;
@@ -1368,8 +1361,8 @@ static struct iommu_group *spapr_tce_iommu_device_group(struct device *dev)
static const struct iommu_ops spapr_tce_iommu_ops = {
.default_domain = &spapr_tce_platform_domain,
+ .blocked_domain = &spapr_tce_blocked_domain,
.capable = spapr_tce_iommu_capable,
- .domain_alloc = spapr_tce_iommu_domain_alloc,
.probe_device = spapr_tce_iommu_probe_device,
.release_device = spapr_tce_iommu_release_device,
.device_group = spapr_tce_iommu_device_group,
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 1ecac2b5c54f4a..89db35e2c21771 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2074,6 +2074,8 @@ static struct iommu_domain *__iommu_domain_alloc(const struct iommu_ops *ops,
if (alloc_type == IOMMU_DOMAIN_IDENTITY && ops->identity_domain)
return ops->identity_domain;
+ else if (alloc_type == IOMMU_DOMAIN_BLOCKED && ops->blocked_domain)
+ return ops->blocked_domain;
else if (type & __IOMMU_DOMAIN_PAGING && ops->domain_alloc_paging)
domain = ops->domain_alloc_paging(dev);
else if (ops->domain_alloc)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 64bd20142cbed0..e1a4c2c2c34d42 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -265,6 +265,8 @@ struct iommu_iotlb_gather {
* @owner: Driver module providing these ops
* @identity_domain: An always available, always attachable identity
* translation.
+ * @blocked_domain: An always available, always attachable blocking
+ * translation.
* @default_domain: If not NULL this will always be set as the default domain.
* This should be an IDENTITY/BLOCKED/PLATFORM domain.
* Do not use in new drivers.
@@ -303,6 +305,7 @@ struct iommu_ops {
unsigned long pgsize_bitmap;
struct module *owner;
struct iommu_domain *identity_domain;
+ struct iommu_domain *blocked_domain;
struct iommu_domain *default_domain;
};
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 2/9] iommu/vt-d: Update the definition of the blocking domain
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 3/9] iommu/vt-d: Use ops->blocked_domain Jason Gunthorpe
` (8 subsequent siblings)
10 siblings, 1 reply; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
The global static should pre-define the type and the NOP free function can
be now left as NULL.
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/intel/iommu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 3685ba90ec88e8..ba9db95d2f1c5e 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4013,9 +4013,9 @@ static int blocking_domain_attach_dev(struct iommu_domain *domain,
}
static struct iommu_domain blocking_domain = {
+ .type = IOMMU_DOMAIN_BLOCKED,
.ops = &(const struct iommu_domain_ops) {
.attach_dev = blocking_domain_attach_dev,
- .free = intel_iommu_domain_free
}
};
@@ -4060,7 +4060,7 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
static void intel_iommu_domain_free(struct iommu_domain *domain)
{
- if (domain != &si_domain->domain && domain != &blocking_domain)
+ if (domain != &si_domain->domain)
domain_exit(to_dmar_domain(domain));
}
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 3/9] iommu/vt-d: Use ops->blocked_domain
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 2/9] iommu/vt-d: Update the definition of the blocking domain Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 4/9] iommufd: Convert to alloc_domain_paging() Jason Gunthorpe
` (7 subsequent siblings)
10 siblings, 1 reply; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
Trivially migrate to the ops->blocked_domain for the existing global
static.
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/intel/iommu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index ba9db95d2f1c5e..71c12e15ecd7b3 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4025,8 +4025,6 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
struct iommu_domain *domain;
switch (type) {
- case IOMMU_DOMAIN_BLOCKED:
- return &blocking_domain;
case IOMMU_DOMAIN_DMA:
case IOMMU_DOMAIN_UNMANAGED:
dmar_domain = alloc_domain(type);
@@ -4788,6 +4786,7 @@ static void *intel_iommu_hw_info(struct device *dev, u32 *length, u32 *type)
}
const struct iommu_ops intel_iommu_ops = {
+ .blocked_domain = &blocking_domain,
.capable = intel_iommu_capable,
.hw_info = intel_iommu_hw_info,
.domain_alloc = intel_iommu_domain_alloc,
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 4/9] iommufd: Convert to alloc_domain_paging()
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
` (2 preceding siblings ...)
2023-09-27 23:47 ` [PATCH v2 3/9] iommu/vt-d: Use ops->blocked_domain Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-10-09 7:48 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 5/9] iommu/dart: Use static global identity domains Jason Gunthorpe
` (6 subsequent siblings)
10 siblings, 1 reply; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
Move the global static blocked domain to the ops and convert the unmanaged
domain to domain_alloc_paging.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/iommufd/selftest.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index fb981ba97c4e87..ee607984709102 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -141,16 +141,10 @@ static void *mock_domain_hw_info(struct device *dev, u32 *length, u32 *type)
return info;
}
-static struct iommu_domain *mock_domain_alloc(unsigned int iommu_domain_type)
+static struct iommu_domain *mock_domain_alloc_paging(struct device *dev)
{
struct mock_iommu_domain *mock;
- if (iommu_domain_type == IOMMU_DOMAIN_BLOCKED)
- return &mock_blocking_domain;
-
- if (iommu_domain_type != IOMMU_DOMAIN_UNMANAGED)
- return NULL;
-
mock = kzalloc(sizeof(*mock), GFP_KERNEL);
if (!mock)
return NULL;
@@ -295,10 +289,11 @@ static const struct iommu_ops mock_ops = {
* because it is zero.
*/
.default_domain = &mock_blocking_domain,
+ .blocked_domain = &mock_blocking_domain,
.owner = THIS_MODULE,
.pgsize_bitmap = MOCK_IO_PAGE_SIZE,
.hw_info = mock_domain_hw_info,
- .domain_alloc = mock_domain_alloc,
+ .domain_alloc_paging = mock_domain_alloc_paging,
.capable = mock_domain_capable,
.device_group = generic_device_group,
.probe_device = mock_probe_device,
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 5/9] iommu/dart: Use static global identity domains
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
` (3 preceding siblings ...)
2023-09-27 23:47 ` [PATCH v2 4/9] iommufd: Convert to alloc_domain_paging() Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 6/9] iommu/dart: Move the blocked domain support to a global static Jason Gunthorpe
` (5 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
Move to the new static global for identity domains. Move the identity
specific code to apple_dart_attach_dev_identity().
Reviewed-by: Janne Grunau <j@jannau.net>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/apple-dart.c | 39 +++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index 0b892750842746..2c121c525749cf 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -659,11 +659,7 @@ static int apple_dart_attach_dev(struct iommu_domain *domain,
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
struct apple_dart_domain *dart_domain = to_dart_domain(domain);
- if (cfg->stream_maps[0].dart->force_bypass &&
- domain->type != IOMMU_DOMAIN_IDENTITY)
- return -EINVAL;
- if (!cfg->stream_maps[0].dart->supports_bypass &&
- domain->type == IOMMU_DOMAIN_IDENTITY)
+ if (cfg->stream_maps[0].dart->force_bypass)
return -EINVAL;
ret = apple_dart_finalize_domain(domain, cfg);
@@ -683,15 +679,35 @@ static int apple_dart_attach_dev(struct iommu_domain *domain,
for_each_stream_map(i, cfg, stream_map)
apple_dart_hw_disable_dma(stream_map);
break;
- case IOMMU_DOMAIN_IDENTITY:
- for_each_stream_map(i, cfg, stream_map)
- apple_dart_hw_enable_bypass(stream_map);
- break;
}
return ret;
}
+static int apple_dart_attach_dev_identity(struct iommu_domain *domain,
+ struct device *dev)
+{
+ struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
+ struct apple_dart_stream_map *stream_map;
+ int i;
+
+ if (!cfg->stream_maps[0].dart->supports_bypass)
+ return -EINVAL;
+
+ for_each_stream_map(i, cfg, stream_map)
+ apple_dart_hw_enable_bypass(stream_map);
+ return 0;
+}
+
+static const struct iommu_domain_ops apple_dart_identity_ops = {
+ .attach_dev = apple_dart_attach_dev_identity,
+};
+
+static struct iommu_domain apple_dart_identity_domain = {
+ .type = IOMMU_DOMAIN_IDENTITY,
+ .ops = &apple_dart_identity_ops,
+};
+
static struct iommu_device *apple_dart_probe_device(struct device *dev)
{
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
@@ -722,7 +738,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type)
struct apple_dart_domain *dart_domain;
if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED &&
- type != IOMMU_DOMAIN_IDENTITY && type != IOMMU_DOMAIN_BLOCKED)
+ type != IOMMU_DOMAIN_BLOCKED)
return NULL;
dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL);
@@ -732,7 +748,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type)
mutex_init(&dart_domain->init_lock);
/* no need to allocate pgtbl_ops or do any other finalization steps */
- if (type == IOMMU_DOMAIN_IDENTITY || type == IOMMU_DOMAIN_BLOCKED)
+ if (type == IOMMU_DOMAIN_BLOCKED)
dart_domain->finalized = true;
return &dart_domain->domain;
@@ -947,6 +963,7 @@ static void apple_dart_get_resv_regions(struct device *dev,
}
static const struct iommu_ops apple_dart_iommu_ops = {
+ .identity_domain = &apple_dart_identity_domain,
.domain_alloc = apple_dart_domain_alloc,
.probe_device = apple_dart_probe_device,
.release_device = apple_dart_release_device,
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 6/9] iommu/dart: Move the blocked domain support to a global static
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
` (4 preceding siblings ...)
2023-09-27 23:47 ` [PATCH v2 5/9] iommu/dart: Use static global identity domains Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 7/9] iommu/dart: Convert to domain_alloc_paging() Jason Gunthorpe
` (4 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
Move to the new static global for blocked domains. Move the blocked
specific code to apple_dart_attach_dev_blocked().
Reviewed-by: Janne Grunau <j@jannau.net>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/apple-dart.c | 53 +++++++++++++++++++++++---------------
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index 2c121c525749cf..a34812e8c9ea57 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -666,22 +666,13 @@ static int apple_dart_attach_dev(struct iommu_domain *domain,
if (ret)
return ret;
- switch (domain->type) {
- default:
- ret = apple_dart_domain_add_streams(dart_domain, cfg);
- if (ret)
- return ret;
+ ret = apple_dart_domain_add_streams(dart_domain, cfg);
+ if (ret)
+ return ret;
- for_each_stream_map(i, cfg, stream_map)
- apple_dart_setup_translation(dart_domain, stream_map);
- break;
- case IOMMU_DOMAIN_BLOCKED:
- for_each_stream_map(i, cfg, stream_map)
- apple_dart_hw_disable_dma(stream_map);
- break;
- }
-
- return ret;
+ for_each_stream_map(i, cfg, stream_map)
+ apple_dart_setup_translation(dart_domain, stream_map);
+ return 0;
}
static int apple_dart_attach_dev_identity(struct iommu_domain *domain,
@@ -708,6 +699,30 @@ static struct iommu_domain apple_dart_identity_domain = {
.ops = &apple_dart_identity_ops,
};
+static int apple_dart_attach_dev_blocked(struct iommu_domain *domain,
+ struct device *dev)
+{
+ struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
+ struct apple_dart_stream_map *stream_map;
+ int i;
+
+ if (cfg->stream_maps[0].dart->force_bypass)
+ return -EINVAL;
+
+ for_each_stream_map(i, cfg, stream_map)
+ apple_dart_hw_disable_dma(stream_map);
+ return 0;
+}
+
+static const struct iommu_domain_ops apple_dart_blocked_ops = {
+ .attach_dev = apple_dart_attach_dev_blocked,
+};
+
+static struct iommu_domain apple_dart_blocked_domain = {
+ .type = IOMMU_DOMAIN_BLOCKED,
+ .ops = &apple_dart_blocked_ops,
+};
+
static struct iommu_device *apple_dart_probe_device(struct device *dev)
{
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
@@ -737,8 +752,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type)
{
struct apple_dart_domain *dart_domain;
- if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED &&
- type != IOMMU_DOMAIN_BLOCKED)
+ if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED)
return NULL;
dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL);
@@ -747,10 +761,6 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type)
mutex_init(&dart_domain->init_lock);
- /* no need to allocate pgtbl_ops or do any other finalization steps */
- if (type == IOMMU_DOMAIN_BLOCKED)
- dart_domain->finalized = true;
-
return &dart_domain->domain;
}
@@ -964,6 +974,7 @@ static void apple_dart_get_resv_regions(struct device *dev,
static const struct iommu_ops apple_dart_iommu_ops = {
.identity_domain = &apple_dart_identity_domain,
+ .blocked_domain = &apple_dart_blocked_domain,
.domain_alloc = apple_dart_domain_alloc,
.probe_device = apple_dart_probe_device,
.release_device = apple_dart_release_device,
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 7/9] iommu/dart: Convert to domain_alloc_paging()
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
` (5 preceding siblings ...)
2023-09-27 23:47 ` [PATCH v2 6/9] iommu/dart: Move the blocked domain support to a global static Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 8/9] iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging() Jason Gunthorpe
` (3 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
Since the IDENTITY and BLOCKED behaviors were moved to global statics all
that remains is the paging domain. Rename to
apple_dart_attach_dev_paging() and remove the left over type check.
Reviewed-by: Janne Grunau <j@jannau.net>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/apple-dart.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index a34812e8c9ea57..2566cf3111c7c1 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -651,8 +651,8 @@ static int apple_dart_domain_add_streams(struct apple_dart_domain *domain,
true);
}
-static int apple_dart_attach_dev(struct iommu_domain *domain,
- struct device *dev)
+static int apple_dart_attach_dev_paging(struct iommu_domain *domain,
+ struct device *dev)
{
int ret, i;
struct apple_dart_stream_map *stream_map;
@@ -748,13 +748,10 @@ static void apple_dart_release_device(struct device *dev)
kfree(cfg);
}
-static struct iommu_domain *apple_dart_domain_alloc(unsigned int type)
+static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev)
{
struct apple_dart_domain *dart_domain;
- if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED)
- return NULL;
-
dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL);
if (!dart_domain)
return NULL;
@@ -975,7 +972,7 @@ static void apple_dart_get_resv_regions(struct device *dev,
static const struct iommu_ops apple_dart_iommu_ops = {
.identity_domain = &apple_dart_identity_domain,
.blocked_domain = &apple_dart_blocked_domain,
- .domain_alloc = apple_dart_domain_alloc,
+ .domain_alloc_paging = apple_dart_domain_alloc_paging,
.probe_device = apple_dart_probe_device,
.release_device = apple_dart_release_device,
.device_group = apple_dart_device_group,
@@ -985,7 +982,7 @@ static const struct iommu_ops apple_dart_iommu_ops = {
.pgsize_bitmap = -1UL, /* Restricted during dart probe */
.owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
- .attach_dev = apple_dart_attach_dev,
+ .attach_dev = apple_dart_attach_dev_paging,
.map_pages = apple_dart_map_pages,
.unmap_pages = apple_dart_unmap_pages,
.flush_iotlb_all = apple_dart_flush_iotlb_all,
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 8/9] iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
` (6 preceding siblings ...)
2023-09-27 23:47 ` [PATCH v2 7/9] iommu/dart: Convert to domain_alloc_paging() Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 9/9] iommu/dart: Remove the force_bypass variable Jason Gunthorpe
` (2 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
In many cases the dev argument will now be !NULL so we should use it to
finalize the domain at allocation.
Make apple_dart_finalize_domain() accept the correct type.
Reviewed-by: Janne Grunau <j@jannau.net>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/apple-dart.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index 2566cf3111c7c1..126da0d89f0dd4 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -568,10 +568,9 @@ apple_dart_setup_translation(struct apple_dart_domain *domain,
stream_map->dart->hw->invalidate_tlb(stream_map);
}
-static int apple_dart_finalize_domain(struct iommu_domain *domain,
+static int apple_dart_finalize_domain(struct apple_dart_domain *dart_domain,
struct apple_dart_master_cfg *cfg)
{
- struct apple_dart_domain *dart_domain = to_dart_domain(domain);
struct apple_dart *dart = cfg->stream_maps[0].dart;
struct io_pgtable_cfg pgtbl_cfg;
int ret = 0;
@@ -597,17 +596,18 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,
.iommu_dev = dart->dev,
};
- dart_domain->pgtbl_ops =
- alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, domain);
+ dart_domain->pgtbl_ops = alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg,
+ &dart_domain->domain);
if (!dart_domain->pgtbl_ops) {
ret = -ENOMEM;
goto done;
}
- domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
- domain->geometry.aperture_start = 0;
- domain->geometry.aperture_end = (dma_addr_t)DMA_BIT_MASK(dart->ias);
- domain->geometry.force_aperture = true;
+ dart_domain->domain.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
+ dart_domain->domain.geometry.aperture_start = 0;
+ dart_domain->domain.geometry.aperture_end =
+ (dma_addr_t)DMA_BIT_MASK(dart->ias);
+ dart_domain->domain.geometry.force_aperture = true;
dart_domain->finalized = true;
@@ -662,7 +662,7 @@ static int apple_dart_attach_dev_paging(struct iommu_domain *domain,
if (cfg->stream_maps[0].dart->force_bypass)
return -EINVAL;
- ret = apple_dart_finalize_domain(domain, cfg);
+ ret = apple_dart_finalize_domain(dart_domain, cfg);
if (ret)
return ret;
@@ -758,6 +758,16 @@ static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev)
mutex_init(&dart_domain->init_lock);
+ if (dev) {
+ struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
+ int ret;
+
+ ret = apple_dart_finalize_domain(dart_domain, cfg);
+ if (ret) {
+ kfree(dart_domain);
+ return ERR_PTR(ret);
+ }
+ }
return &dart_domain->domain;
}
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 9/9] iommu/dart: Remove the force_bypass variable
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
` (7 preceding siblings ...)
2023-09-27 23:47 ` [PATCH v2 8/9] iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging() Jason Gunthorpe
@ 2023-09-27 23:47 ` Jason Gunthorpe
2023-10-16 11:44 ` Janne Grunau
2023-10-25 15:58 ` [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() jgg
2023-10-26 7:49 ` Joerg Roedel
10 siblings, 1 reply; 19+ messages in thread
From: Jason Gunthorpe @ 2023-09-27 23:47 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Joerg Roedel, Kevin Tian, linux-arm-kernel, linuxppc-dev,
Hector Martin, Michael Ellerman, Nicholas Piggin, Robin Murphy,
Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
This flag just caches if the IO page size is larger than the CPU
PAGE_SIZE. This only needs to be checked in two places so remove the
confusingly named cache.
dart would like to not support paging domains at all if the IO page size
is larger than the CPU page size. In this case we should ideally fail
domain_alloc_paging(), as there is no point in creating a domain that can
never be attached. Move the test into apple_dart_finalize_domain().
The check in apple_dart_mod_streams() will prevent the domain from being
attached to the wrong dart
There is no HW limitation that prevents BLOCKED domains from working,
remove that test.
The check in apple_dart_of_xlate() is redundant since immediately after
the pgsize is checked. Remove it.
Remove the variable.
Suggested-by: Janne Grunau <j@jannau.net>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/apple-dart.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index 126da0d89f0dd4..821b4a3465dfb9 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -196,7 +196,6 @@ struct apple_dart_hw {
* @lock: lock for hardware operations involving this dart
* @pgsize: pagesize supported by this DART
* @supports_bypass: indicates if this DART supports bypass mode
- * @force_bypass: force bypass mode due to pagesize mismatch?
* @sid2group: maps stream ids to iommu_groups
* @iommu: iommu core device
*/
@@ -217,7 +216,6 @@ struct apple_dart {
u32 pgsize;
u32 num_streams;
u32 supports_bypass : 1;
- u32 force_bypass : 1;
struct iommu_group *sid2group[DART_MAX_STREAMS];
struct iommu_device iommu;
@@ -576,6 +574,9 @@ static int apple_dart_finalize_domain(struct apple_dart_domain *dart_domain,
int ret = 0;
int i, j;
+ if (dart->pgsize > PAGE_SIZE)
+ return -EINVAL;
+
mutex_lock(&dart_domain->init_lock);
if (dart_domain->finalized)
@@ -659,9 +660,6 @@ static int apple_dart_attach_dev_paging(struct iommu_domain *domain,
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
struct apple_dart_domain *dart_domain = to_dart_domain(domain);
- if (cfg->stream_maps[0].dart->force_bypass)
- return -EINVAL;
-
ret = apple_dart_finalize_domain(dart_domain, cfg);
if (ret)
return ret;
@@ -706,9 +704,6 @@ static int apple_dart_attach_dev_blocked(struct iommu_domain *domain,
struct apple_dart_stream_map *stream_map;
int i;
- if (cfg->stream_maps[0].dart->force_bypass)
- return -EINVAL;
-
for_each_stream_map(i, cfg, stream_map)
apple_dart_hw_disable_dma(stream_map);
return 0;
@@ -803,8 +798,6 @@ static int apple_dart_of_xlate(struct device *dev, struct of_phandle_args *args)
if (cfg_dart) {
if (cfg_dart->supports_bypass != dart->supports_bypass)
return -EINVAL;
- if (cfg_dart->force_bypass != dart->force_bypass)
- return -EINVAL;
if (cfg_dart->pgsize != dart->pgsize)
return -EINVAL;
}
@@ -946,7 +939,7 @@ static int apple_dart_def_domain_type(struct device *dev)
{
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
- if (cfg->stream_maps[0].dart->force_bypass)
+ if (cfg->stream_maps[0].dart->pgsize > PAGE_SIZE)
return IOMMU_DOMAIN_IDENTITY;
if (!cfg->stream_maps[0].dart->supports_bypass)
return IOMMU_DOMAIN_DMA;
@@ -1146,8 +1139,6 @@ static int apple_dart_probe(struct platform_device *pdev)
goto err_clk_disable;
}
- dart->force_bypass = dart->pgsize > PAGE_SIZE;
-
ret = apple_dart_hw_reset(dart);
if (ret)
goto err_clk_disable;
@@ -1171,7 +1162,8 @@ static int apple_dart_probe(struct platform_device *pdev)
dev_info(
&pdev->dev,
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d] initialized\n",
- dart->pgsize, dart->num_streams, dart->supports_bypass, dart->force_bypass);
+ dart->pgsize, dart->num_streams, dart->supports_bypass,
+ dart->pgsize > PAGE_SIZE);
return 0;
err_sysfs_remove:
--
2.42.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 19+ messages in thread
* RE: [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain
2023-09-27 23:47 ` [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain Jason Gunthorpe
@ 2023-10-09 7:47 ` Tian, Kevin
0 siblings, 0 replies; 19+ messages in thread
From: Tian, Kevin @ 2023-10-09 7:47 UTC (permalink / raw)
To: Jason Gunthorpe, Alyssa Rosenzweig, asahi@lists.linux.dev,
Christophe Leroy, David Woodhouse, iommu@lists.linux.dev,
Joerg Roedel, linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, Hector Martin, Michael Ellerman,
Nicholas Piggin, Robin Murphy, Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Thursday, September 28, 2023 7:48 AM
>
> Following the pattern of identity domains, just assign the BLOCKED domain
> global statics to a value in ops. Update the core code to use the global
> static directly.
>
> Update powerpc to use the new scheme and remove its empty domain_alloc
> callback.
>
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH v2 2/9] iommu/vt-d: Update the definition of the blocking domain
2023-09-27 23:47 ` [PATCH v2 2/9] iommu/vt-d: Update the definition of the blocking domain Jason Gunthorpe
@ 2023-10-09 7:47 ` Tian, Kevin
0 siblings, 0 replies; 19+ messages in thread
From: Tian, Kevin @ 2023-10-09 7:47 UTC (permalink / raw)
To: Jason Gunthorpe, Alyssa Rosenzweig, asahi@lists.linux.dev,
Christophe Leroy, David Woodhouse, iommu@lists.linux.dev,
Joerg Roedel, linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, Hector Martin, Michael Ellerman,
Nicholas Piggin, Robin Murphy, Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Thursday, September 28, 2023 7:48 AM
>
> The global static should pre-define the type and the NOP free function can
> be now left as NULL.
>
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH v2 3/9] iommu/vt-d: Use ops->blocked_domain
2023-09-27 23:47 ` [PATCH v2 3/9] iommu/vt-d: Use ops->blocked_domain Jason Gunthorpe
@ 2023-10-09 7:47 ` Tian, Kevin
0 siblings, 0 replies; 19+ messages in thread
From: Tian, Kevin @ 2023-10-09 7:47 UTC (permalink / raw)
To: Jason Gunthorpe, Alyssa Rosenzweig, asahi@lists.linux.dev,
Christophe Leroy, David Woodhouse, iommu@lists.linux.dev,
Joerg Roedel, linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, Hector Martin, Michael Ellerman,
Nicholas Piggin, Robin Murphy, Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Thursday, September 28, 2023 7:48 AM
>
> Trivially migrate to the ops->blocked_domain for the existing global
> static.
>
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH v2 4/9] iommufd: Convert to alloc_domain_paging()
2023-09-27 23:47 ` [PATCH v2 4/9] iommufd: Convert to alloc_domain_paging() Jason Gunthorpe
@ 2023-10-09 7:48 ` Tian, Kevin
0 siblings, 0 replies; 19+ messages in thread
From: Tian, Kevin @ 2023-10-09 7:48 UTC (permalink / raw)
To: Jason Gunthorpe, Alyssa Rosenzweig, asahi@lists.linux.dev,
Christophe Leroy, David Woodhouse, iommu@lists.linux.dev,
Joerg Roedel, linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, Hector Martin, Michael Ellerman,
Nicholas Piggin, Robin Murphy, Sven Peter, Will Deacon
Cc: Lu Baolu, Janne Grunau
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Thursday, September 28, 2023 7:48 AM
>
> Move the global static blocked domain to the ops and convert the
> unmanaged
> domain to domain_alloc_paging.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 9/9] iommu/dart: Remove the force_bypass variable
2023-09-27 23:47 ` [PATCH v2 9/9] iommu/dart: Remove the force_bypass variable Jason Gunthorpe
@ 2023-10-16 11:44 ` Janne Grunau
0 siblings, 0 replies; 19+ messages in thread
From: Janne Grunau @ 2023-10-16 11:44 UTC (permalink / raw)
To: Jason Gunthorpe, Alyssa Rosenzweig, asahi, Christophe Leroy,
David Woodhouse, iommu, Joerg Roedel, Kevin Tian,
linux-arm-kernel, linuxppc-dev, Hector Martin, Michael Ellerman,
Nicholas Piggin, Robin Murphy, Sven Peter, Will Deacon
Cc: Lu Baolu
Hej,
On Thu, Sep 28, 2023, at 01:47, Jason Gunthorpe wrote:
> This flag just caches if the IO page size is larger than the CPU
> PAGE_SIZE. This only needs to be checked in two places so remove the
> confusingly named cache.
>
> dart would like to not support paging domains at all if the IO page size
> is larger than the CPU page size. In this case we should ideally fail
> domain_alloc_paging(), as there is no point in creating a domain that can
> never be attached. Move the test into apple_dart_finalize_domain().
>
> The check in apple_dart_mod_streams() will prevent the domain from being
> attached to the wrong dart
>
> There is no HW limitation that prevents BLOCKED domains from working,
> remove that test.
>
> The check in apple_dart_of_xlate() is redundant since immediately after
> the pgsize is checked. Remove it.
>
> Remove the variable.
>
> Suggested-by: Janne Grunau <j@jannau.net>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/apple-dart.c | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
> index 126da0d89f0dd4..821b4a3465dfb9 100644
> --- a/drivers/iommu/apple-dart.c
> +++ b/drivers/iommu/apple-dart.c
> @@ -196,7 +196,6 @@ struct apple_dart_hw {
> * @lock: lock for hardware operations involving this dart
> * @pgsize: pagesize supported by this DART
> * @supports_bypass: indicates if this DART supports bypass mode
> - * @force_bypass: force bypass mode due to pagesize mismatch?
> * @sid2group: maps stream ids to iommu_groups
> * @iommu: iommu core device
> */
> @@ -217,7 +216,6 @@ struct apple_dart {
> u32 pgsize;
> u32 num_streams;
> u32 supports_bypass : 1;
> - u32 force_bypass : 1;
>
> struct iommu_group *sid2group[DART_MAX_STREAMS];
> struct iommu_device iommu;
> @@ -576,6 +574,9 @@ static int apple_dart_finalize_domain(struct
> apple_dart_domain *dart_domain,
> int ret = 0;
> int i, j;
>
> + if (dart->pgsize > PAGE_SIZE)
> + return -EINVAL;
> +
> mutex_lock(&dart_domain->init_lock);
>
> if (dart_domain->finalized)
> @@ -659,9 +660,6 @@ static int apple_dart_attach_dev_paging(struct
> iommu_domain *domain,
> struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
> struct apple_dart_domain *dart_domain = to_dart_domain(domain);
>
> - if (cfg->stream_maps[0].dart->force_bypass)
> - return -EINVAL;
> -
> ret = apple_dart_finalize_domain(dart_domain, cfg);
> if (ret)
> return ret;
> @@ -706,9 +704,6 @@ static int apple_dart_attach_dev_blocked(struct
> iommu_domain *domain,
> struct apple_dart_stream_map *stream_map;
> int i;
>
> - if (cfg->stream_maps[0].dart->force_bypass)
> - return -EINVAL;
> -
> for_each_stream_map(i, cfg, stream_map)
> apple_dart_hw_disable_dma(stream_map);
> return 0;
> @@ -803,8 +798,6 @@ static int apple_dart_of_xlate(struct device *dev,
> struct of_phandle_args *args)
> if (cfg_dart) {
> if (cfg_dart->supports_bypass != dart->supports_bypass)
> return -EINVAL;
> - if (cfg_dart->force_bypass != dart->force_bypass)
> - return -EINVAL;
> if (cfg_dart->pgsize != dart->pgsize)
> return -EINVAL;
> }
> @@ -946,7 +939,7 @@ static int apple_dart_def_domain_type(struct device
> *dev)
> {
> struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
>
> - if (cfg->stream_maps[0].dart->force_bypass)
> + if (cfg->stream_maps[0].dart->pgsize > PAGE_SIZE)
> return IOMMU_DOMAIN_IDENTITY;
> if (!cfg->stream_maps[0].dart->supports_bypass)
> return IOMMU_DOMAIN_DMA;
> @@ -1146,8 +1139,6 @@ static int apple_dart_probe(struct platform_device *pdev)
> goto err_clk_disable;
> }
>
> - dart->force_bypass = dart->pgsize > PAGE_SIZE;
> -
> ret = apple_dart_hw_reset(dart);
> if (ret)
> goto err_clk_disable;
> @@ -1171,7 +1162,8 @@ static int apple_dart_probe(struct
> platform_device *pdev)
> dev_info(
> &pdev->dev,
> "DART [pagesize %x, %d streams, bypass support: %d, bypass forced:
> %d] initialized\n",
> - dart->pgsize, dart->num_streams, dart->supports_bypass,
> dart->force_bypass);
> + dart->pgsize, dart->num_streams, dart->supports_bypass,
> + dart->pgsize > PAGE_SIZE);
> return 0;
>
> err_sysfs_remove:
> --
Reviewed-by: Janne Grunau <j@jannau.net>
thanks,
Janne
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging()
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
` (8 preceding siblings ...)
2023-09-27 23:47 ` [PATCH v2 9/9] iommu/dart: Remove the force_bypass variable Jason Gunthorpe
@ 2023-10-25 15:58 ` jgg
2023-10-26 7:49 ` Joerg Roedel
10 siblings, 0 replies; 19+ messages in thread
From: jgg @ 2023-10-25 15:58 UTC (permalink / raw)
To: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Kevin Tian, linux-arm-kernel, linuxppc-dev, Hector Martin,
Michael Ellerman, Nicholas Piggin, Robin Murphy, Sven Peter,
Will Deacon
Cc: Lu Baolu, Janne Grunau
On Wed, Sep 27, 2023 at 08:47:30PM -0300, Jason Gunthorpe wrote:
> Continue converting drivers to the new interface. Introduce
> ops->blocked_domain to hold the global static BLOCKED domain and convert
> all drivers supporting BLOCKED to use it.
>
> This makes it trivial for dart and iommufd to convert over to
> domain_alloc_paging().
>
> There are six drivers remaining:
>
> drivers/iommu/amd/iommu.c: .domain_alloc = amd_iommu_domain_alloc,
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c: .domain_alloc = arm_smmu_domain_alloc,
> drivers/iommu/arm/arm-smmu/arm-smmu.c: .domain_alloc = arm_smmu_domain_alloc,
> drivers/iommu/fsl_pamu_domain.c: .domain_alloc = fsl_pamu_domain_alloc,
> drivers/iommu/intel/iommu.c: .domain_alloc = intel_iommu_domain_alloc,
> drivers/iommu/virtio-iommu.c: .domain_alloc = viommu_domain_alloc,
>
> v2:
> - Rebase to Joerg's for-next
> - New patch to remove force_bypass, as discussed with Janne
> - Move some hunks between patches to accommodate Robin's change to the
> attach_dev switch
> v1: https://lore.kernel.org/r/0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com
>
> Jason Gunthorpe (9):
> iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain
> iommu/vt-d: Update the definition of the blocking domain
> iommu/vt-d: Use ops->blocked_domain
> iommufd: Convert to alloc_domain_paging()
Joerg can you grab these for this cycle please
> iommu/dart: Use static global identity domains
> iommu/dart: Move the blocked domain support to a global static
> iommu/dart: Convert to domain_alloc_paging()
> iommu/dart: Call apple_dart_finalize_domain() as part of
> alloc_paging()
> iommu/dart: Remove the force_bypass variable
I will poke more dart related people to get a tested-by, maybe next
cycle.
The arm patches at least need this
Thanks,
Jason
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging()
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
` (9 preceding siblings ...)
2023-10-25 15:58 ` [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() jgg
@ 2023-10-26 7:49 ` Joerg Roedel
2023-10-26 10:34 ` Sven Peter
10 siblings, 1 reply; 19+ messages in thread
From: Joerg Roedel @ 2023-10-26 7:49 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Alyssa Rosenzweig, asahi, Christophe Leroy, David Woodhouse,
iommu, Kevin Tian, linux-arm-kernel, linuxppc-dev, Hector Martin,
Michael Ellerman, Nicholas Piggin, Robin Murphy, Sven Peter,
Will Deacon, Lu Baolu, Janne Grunau
On Wed, Sep 27, 2023 at 08:47:30PM -0300, Jason Gunthorpe wrote:
> Jason Gunthorpe (9):
> iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain
> iommu/vt-d: Update the definition of the blocking domain
> iommu/vt-d: Use ops->blocked_domain
> iommufd: Convert to alloc_domain_paging()
Applied these 4, the dart patches need reviewed-by/tested-by/acked-by
from one of the Dart maintainers.
Regards,
Joerg
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging()
2023-10-26 7:49 ` Joerg Roedel
@ 2023-10-26 10:34 ` Sven Peter
2023-10-26 14:55 ` Joerg Roedel
0 siblings, 1 reply; 19+ messages in thread
From: Sven Peter @ 2023-10-26 10:34 UTC (permalink / raw)
To: Joerg Roedel
Cc: Jason Gunthorpe, Alyssa Rosenzweig, asahi, Christophe Leroy,
David Woodhouse, iommu, Kevin Tian, linux-arm-kernel,
linuxppc-dev, Hector Martin, Michael Ellerman, Nicholas Piggin,
Robin Murphy, Will Deacon, Lu Baolu, Janne Grunau
>
> On 26. Oct 2023, at 09:49, Joerg Roedel <joro@8bytes.org> wrote:
>
> On Wed, Sep 27, 2023 at 08:47:30PM -0300, Jason Gunthorpe wrote:
>> Jason Gunthorpe (9):
>> iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain
>> iommu/vt-d: Update the definition of the blocking domain
>> iommu/vt-d: Use ops->blocked_domain
>> iommufd: Convert to alloc_domain_paging()
>
> Applied these 4, the dart patches need reviewed-by/tested-by/acked-by
> from one of the Dart maintainers.
Sorry, must’ve missed the series. I took a brief look and this all looks good to me. Given that Janne already reviewed it in detail:
Acked-by: Sven Peter <sven@svenpeter.dev>
Thanks,
Sven
> Regards,
>
> Joerg
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging()
2023-10-26 10:34 ` Sven Peter
@ 2023-10-26 14:55 ` Joerg Roedel
0 siblings, 0 replies; 19+ messages in thread
From: Joerg Roedel @ 2023-10-26 14:55 UTC (permalink / raw)
To: Sven Peter
Cc: Jason Gunthorpe, Alyssa Rosenzweig, asahi, Christophe Leroy,
David Woodhouse, iommu, Kevin Tian, linux-arm-kernel,
linuxppc-dev, Hector Martin, Michael Ellerman, Nicholas Piggin,
Robin Murphy, Will Deacon, Lu Baolu, Janne Grunau
On Thu, Oct 26, 2023 at 12:34:54PM +0200, Sven Peter wrote:
> Acked-by: Sven Peter <sven@svenpeter.dev>
Thanks, the Dart patches are now also applied.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2023-10-26 14:55 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-27 23:47 [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 1/9] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 2/9] iommu/vt-d: Update the definition of the blocking domain Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 3/9] iommu/vt-d: Use ops->blocked_domain Jason Gunthorpe
2023-10-09 7:47 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 4/9] iommufd: Convert to alloc_domain_paging() Jason Gunthorpe
2023-10-09 7:48 ` Tian, Kevin
2023-09-27 23:47 ` [PATCH v2 5/9] iommu/dart: Use static global identity domains Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 6/9] iommu/dart: Move the blocked domain support to a global static Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 7/9] iommu/dart: Convert to domain_alloc_paging() Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 8/9] iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging() Jason Gunthorpe
2023-09-27 23:47 ` [PATCH v2 9/9] iommu/dart: Remove the force_bypass variable Jason Gunthorpe
2023-10-16 11:44 ` Janne Grunau
2023-10-25 15:58 ` [PATCH v2 0/9] iommu: Convert dart & iommufd to the new domain_alloc_paging() jgg
2023-10-26 7:49 ` Joerg Roedel
2023-10-26 10:34 ` Sven Peter
2023-10-26 14:55 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).