iommu: apple-dart: Support the ISP DART
Subsystems (2)
v2 cover iommu: apple-dart: Support the ISP DART
The ISP block has 3 linked DARTs with mismatched bypass support. This series adds support for this setup.
(The ISP driver itself is sent as a separate series
https://lore.kernel.org/asahi/[email protected]/T/ )
---
Changes in v2:
- Made comments and code a closer match for each other
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Hector Martin (2):
iommu: apple-dart: Increase MAX_DARTS_PER_DEVICE to 3
iommu: apple-dart: Allow mismatched bypass support
drivers/iommu/apple-dart.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
---
base-commit: dd83757f6e686a2188997cb58b5975f744bb7786
change-id: 20250227-isp-dart-f8369baaecb1
PATCH v2 1/2 iommu: apple-dart: Increase MAX_DARTS_PER_DEVICE to 3
From: Hector Martin <[email protected]>
ISP needs this.
--- drivers/iommu/apple-dart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/apple-dart.c +1 -1
@@ -36,7 +36,7 @@#define DART_MAX_STREAMS 256#define DART_MAX_TTBR 4 -#define MAX_DARTS_PER_DEVICE 2 +#define MAX_DARTS_PER_DEVICE 3/* Common registers */
Signature · 1 line
2.48.1
PATCH v2 2/2 iommu: apple-dart: Allow mismatched bypass support
In reply to Sasha FinkelsteinFrom: Hector Martin <[email protected]>
This is needed by ISP, which has DART0 with bypass and DART1/2 without.
--- drivers/iommu/apple-dart.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/iommu/apple-dart.c +12 -5
@@ -277,6 +277,9 @@ struct apple_dart_domain {* @streams: streams for this device */ struct apple_dart_master_cfg { +/* Intersection of DART capabilitles */ +u32 supports_bypass :1 ; +struct apple_dart_stream_map stream_maps[MAX_DARTS_PER_DEVICE ]; };
@@ -684,7 +687,7 @@ static int apple_dart_attach_dev_identity(struct iommu_domain *domain,struct apple_dart_stream_map *stream_map;int i; -if (!cfg->stream_maps[0 ].dart->supports_bypass) +if (!cfg->supports_bypass)return -EINVAL ;for_each_stream_map (i, cfg, stream_map)
@@ -792,20 +795,24 @@ static int apple_dart_of_xlate(struct device *dev,return -EINVAL ; sid = args->args[0 ]; -if (!cfg) +if (!cfg) { cfg =kzalloc (sizeof (*cfg),GFP_KERNEL ); + +/* Will be ANDed with DART capabilities */ + cfg->supports_bypass = true; + }if (!cfg)return -ENOMEM ;dev_iommu_priv_set (dev, cfg); cfg_dart = cfg->stream_maps[0 ].dart;if (cfg_dart) { -if (cfg_dart->supports_bypass != dart->supports_bypass) -return -EINVAL ;if (cfg_dart->pgsize != dart->pgsize)return -EINVAL ; } + cfg->supports_bypass &= dart->supports_bypass; +for (i =0 ; i <MAX_DARTS_PER_DEVICE ; ++i) {if (cfg->stream_maps[i].dart == dart) {set_bit (sid, cfg->stream_maps[i].sidmap);
@@ -945,7 +952,7 @@ static int apple_dart_def_domain_type(struct device *dev)if (cfg->stream_maps[0 ].dart->pgsize >PAGE_SIZE )return IOMMU_DOMAIN_IDENTITY ; -if (!cfg->stream_maps[0 ].dart->supports_bypass) +if (!cfg->supports_bypass)return IOMMU_DOMAIN_DMA ;return 0 ;
Signature · 1 line
2.48.1
Re: [PATCH v2 2/2] iommu: apple-dart: Allow mismatched bypass support
Quoted 75 lines · Le Fri , Feb 28, 2025 at 05:32:08PM +0100, Sasha Finkelstein via B4 Relay a…
From: Hector Martin <[email protected]>
This is needed by ISP, which has DART0 with bypass and DART1/2 without.
Signed-off-by Hector Martin <[email protected]>Signed-off-by Sasha Finkelstein <[email protected]>--- drivers/iommu/apple-dart.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)drivers/iommu/apple-dart.c +12
-5@@ -277,6 +277,9 @@ struct apple_dart_domain {* @streams: streams for this device */ struct apple_dart_master_cfg { +/* Intersection of DART capabilitles */ +u32 supports_bypass :1 ; +struct apple_dart_stream_map stream_maps[MAX_DARTS_PER_DEVICE ]; };@@ -684,7 +687,7 @@ static int apple_dart_attach_dev_identity(struct iommu_domain *domain,struct apple_dart_stream_map *stream_map;int i; -if (!cfg->stream_maps[0 ].dart->supports_bypass) +if (!cfg->supports_bypass)return -EINVAL ;for_each_stream_map (i, cfg, stream_map)@@ -792,20 +795,24 @@ static int apple_dart_of_xlate(struct device *dev,return -EINVAL ; sid = args->args[0 ]; -if (!cfg) +if (!cfg) { cfg =kzalloc (sizeof (*cfg),GFP_KERNEL ); + +/* Will be ANDed with DART capabilities */ + cfg->supports_bypass = true; + }if (!cfg)return -ENOMEM ;dev_iommu_priv_set (dev, cfg); cfg_dart = cfg->stream_maps[0 ].dart;if (cfg_dart) { -if (cfg_dart->supports_bypass != dart->supports_bypass) -return -EINVAL ;if (cfg_dart->pgsize != dart->pgsize)return -EINVAL ; } + cfg->supports_bypass &= dart->supports_bypass; +for (i =0 ; i <MAX_DARTS_PER_DEVICE ; ++i) {if (cfg->stream_maps[i].dart == dart) {set_bit (sid, cfg->stream_maps[i].sidmap);@@ -945,7 +952,7 @@ static int apple_dart_def_domain_type(struct device *dev)if (cfg->stream_maps[0 ].dart->pgsize >PAGE_SIZE )return IOMMU_DOMAIN_IDENTITY ; -if (!cfg->stream_maps[0 ].dart->supports_bypass) +if (!cfg->supports_bypass)return IOMMU_DOMAIN_DMA ;return 0 ;Signature · 2 lines
-- 2.48.1