Skip to content

Commit 3bc0102

Browse files
marcanjoergroedel
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 <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Signed-off-by: Sasha Finkelstein <[email protected]> Reviewed-by: Sven Peter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 9d7b779 commit 3bc0102

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/iommu/apple-dart.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ struct apple_dart_domain {
277277
* @streams: streams for this device
278278
*/
279279
struct apple_dart_master_cfg {
280+
/* Intersection of DART capabilitles */
281+
u32 supports_bypass : 1;
282+
280283
struct apple_dart_stream_map stream_maps[MAX_DARTS_PER_DEVICE];
281284
};
282285

@@ -684,7 +687,7 @@ static int apple_dart_attach_dev_identity(struct iommu_domain *domain,
684687
struct apple_dart_stream_map *stream_map;
685688
int i;
686689

687-
if (!cfg->stream_maps[0].dart->supports_bypass)
690+
if (!cfg->supports_bypass)
688691
return -EINVAL;
689692

690693
for_each_stream_map(i, cfg, stream_map)
@@ -792,20 +795,24 @@ static int apple_dart_of_xlate(struct device *dev,
792795
return -EINVAL;
793796
sid = args->args[0];
794797

795-
if (!cfg)
798+
if (!cfg) {
796799
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
800+
801+
/* Will be ANDed with DART capabilities */
802+
cfg->supports_bypass = true;
803+
}
797804
if (!cfg)
798805
return -ENOMEM;
799806
dev_iommu_priv_set(dev, cfg);
800807

801808
cfg_dart = cfg->stream_maps[0].dart;
802809
if (cfg_dart) {
803-
if (cfg_dart->supports_bypass != dart->supports_bypass)
804-
return -EINVAL;
805810
if (cfg_dart->pgsize != dart->pgsize)
806811
return -EINVAL;
807812
}
808813

814+
cfg->supports_bypass &= dart->supports_bypass;
815+
809816
for (i = 0; i < MAX_DARTS_PER_DEVICE; ++i) {
810817
if (cfg->stream_maps[i].dart == dart) {
811818
set_bit(sid, cfg->stream_maps[i].sidmap);
@@ -945,7 +952,7 @@ static int apple_dart_def_domain_type(struct device *dev)
945952

946953
if (cfg->stream_maps[0].dart->pgsize > PAGE_SIZE)
947954
return IOMMU_DOMAIN_IDENTITY;
948-
if (!cfg->stream_maps[0].dart->supports_bypass)
955+
if (!cfg->supports_bypass)
949956
return IOMMU_DOMAIN_DMA;
950957

951958
return 0;

0 commit comments

Comments
 (0)