Skip to content

Commit 4000aa2

Browse files
marcanjannau
authored andcommitted
iommu: apple-dart: Allow mismatched bypass support
This is needed by ISP, which has DART0 with bypass and DART1/2 without. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 22cd73f commit 4000aa2

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ struct apple_dart_domain {
293293
* @streams: streams for this device
294294
*/
295295
struct apple_dart_master_cfg {
296+
/* Union of DART capabilitles */
297+
u32 supports_bypass : 1;
298+
296299
struct apple_dart_stream_map stream_maps[MAX_DARTS_PER_DEVICE];
297300
};
298301

@@ -887,7 +890,7 @@ static int apple_dart_attach_dev_identity(struct iommu_domain *domain,
887890
struct apple_dart_stream_map *stream_map;
888891
int i;
889892

890-
if (!cfg->stream_maps[0].dart->supports_bypass)
893+
if (!cfg->supports_bypass)
891894
return -EINVAL;
892895

893896
if (cfg->stream_maps[0].dart->locked)
@@ -1018,20 +1021,25 @@ static int apple_dart_of_xlate(struct device *dev,
10181021
return -EINVAL;
10191022
sid = args->args[0];
10201023

1021-
if (!cfg)
1024+
if (!cfg) {
10221025
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
1026+
1027+
/* Will be ANDed with DART capabilities */
1028+
cfg->supports_bypass = true;
1029+
}
10231030
if (!cfg)
10241031
return -ENOMEM;
10251032
dev_iommu_priv_set(dev, cfg);
10261033

10271034
cfg_dart = cfg->stream_maps[0].dart;
10281035
if (cfg_dart) {
1029-
if (cfg_dart->supports_bypass != dart->supports_bypass)
1030-
return -EINVAL;
10311036
if (cfg_dart->pgsize != dart->pgsize)
10321037
return -EINVAL;
10331038
}
10341039

1040+
if (!dart->supports_bypass)
1041+
cfg->supports_bypass = false;
1042+
10351043
for (i = 0; i < MAX_DARTS_PER_DEVICE; ++i) {
10361044
if (cfg->stream_maps[i].dart == dart) {
10371045
set_bit(sid, cfg->stream_maps[i].sidmap);
@@ -1171,7 +1179,7 @@ static int apple_dart_def_domain_type(struct device *dev)
11711179

11721180
if (cfg->stream_maps[0].dart->pgsize > PAGE_SIZE)
11731181
return IOMMU_DOMAIN_IDENTITY;
1174-
if (!cfg->stream_maps[0].dart->supports_bypass)
1182+
if (!cfg->supports_bypass)
11751183
return IOMMU_DOMAIN_DMA;
11761184
if (cfg->stream_maps[0].dart->locked)
11771185
return IOMMU_DOMAIN_DMA;

0 commit comments

Comments
 (0)