Skip to content

Commit bbc70e0

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/dart: Remove the force_bypass variable
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 <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Reviewed-by: Janne Grunau <[email protected]> Acked-by: Sven Peter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 482feb5 commit bbc70e0

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/iommu/apple-dart.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ struct apple_dart_hw {
196196
* @lock: lock for hardware operations involving this dart
197197
* @pgsize: pagesize supported by this DART
198198
* @supports_bypass: indicates if this DART supports bypass mode
199-
* @force_bypass: force bypass mode due to pagesize mismatch?
200199
* @sid2group: maps stream ids to iommu_groups
201200
* @iommu: iommu core device
202201
*/
@@ -217,7 +216,6 @@ struct apple_dart {
217216
u32 pgsize;
218217
u32 num_streams;
219218
u32 supports_bypass : 1;
220-
u32 force_bypass : 1;
221219

222220
struct iommu_group *sid2group[DART_MAX_STREAMS];
223221
struct iommu_device iommu;
@@ -576,6 +574,9 @@ static int apple_dart_finalize_domain(struct apple_dart_domain *dart_domain,
576574
int ret = 0;
577575
int i, j;
578576

577+
if (dart->pgsize > PAGE_SIZE)
578+
return -EINVAL;
579+
579580
mutex_lock(&dart_domain->init_lock);
580581

581582
if (dart_domain->finalized)
@@ -659,9 +660,6 @@ static int apple_dart_attach_dev_paging(struct iommu_domain *domain,
659660
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
660661
struct apple_dart_domain *dart_domain = to_dart_domain(domain);
661662

662-
if (cfg->stream_maps[0].dart->force_bypass)
663-
return -EINVAL;
664-
665663
ret = apple_dart_finalize_domain(dart_domain, cfg);
666664
if (ret)
667665
return ret;
@@ -706,9 +704,6 @@ static int apple_dart_attach_dev_blocked(struct iommu_domain *domain,
706704
struct apple_dart_stream_map *stream_map;
707705
int i;
708706

709-
if (cfg->stream_maps[0].dart->force_bypass)
710-
return -EINVAL;
711-
712707
for_each_stream_map(i, cfg, stream_map)
713708
apple_dart_hw_disable_dma(stream_map);
714709
return 0;
@@ -803,8 +798,6 @@ static int apple_dart_of_xlate(struct device *dev, struct of_phandle_args *args)
803798
if (cfg_dart) {
804799
if (cfg_dart->supports_bypass != dart->supports_bypass)
805800
return -EINVAL;
806-
if (cfg_dart->force_bypass != dart->force_bypass)
807-
return -EINVAL;
808801
if (cfg_dart->pgsize != dart->pgsize)
809802
return -EINVAL;
810803
}
@@ -946,7 +939,7 @@ static int apple_dart_def_domain_type(struct device *dev)
946939
{
947940
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
948941

949-
if (cfg->stream_maps[0].dart->force_bypass)
942+
if (cfg->stream_maps[0].dart->pgsize > PAGE_SIZE)
950943
return IOMMU_DOMAIN_IDENTITY;
951944
if (!cfg->stream_maps[0].dart->supports_bypass)
952945
return IOMMU_DOMAIN_DMA;
@@ -1146,8 +1139,6 @@ static int apple_dart_probe(struct platform_device *pdev)
11461139
goto err_clk_disable;
11471140
}
11481141

1149-
dart->force_bypass = dart->pgsize > PAGE_SIZE;
1150-
11511142
ret = apple_dart_hw_reset(dart);
11521143
if (ret)
11531144
goto err_clk_disable;
@@ -1171,7 +1162,8 @@ static int apple_dart_probe(struct platform_device *pdev)
11711162
dev_info(
11721163
&pdev->dev,
11731164
"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d] initialized\n",
1174-
dart->pgsize, dart->num_streams, dart->supports_bypass, dart->force_bypass);
1165+
dart->pgsize, dart->num_streams, dart->supports_bypass,
1166+
dart->pgsize > PAGE_SIZE);
11751167
return 0;
11761168

11771169
err_sysfs_remove:

0 commit comments

Comments
 (0)