Skip to content

Commit 1bd410d

Browse files
committed
iommu/dart: Use virtual memory ttbr entries in apple_dart_cfg
Locked DARTs can not modify ttbr entries. To ensure atomic updates of PTEs in the L1 table the DART driver will copy entries to the preallocated L1 table. This requires access to io-pgtable-dart's tables. For all other DARTs this moves virt_to_phys() calls into the DART driver. Signed-off-by: Janne Grunau <[email protected]>
1 parent f96d12f commit 1bd410d

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,10 @@ apple_dart_setup_translation(struct apple_dart_domain *domain,
583583
struct io_pgtable_cfg *pgtbl_cfg =
584584
&io_pgtable_ops_to_pgtable(domain->pgtbl_ops)->cfg;
585585

586-
for (i = 0; i < pgtbl_cfg->apple_dart_cfg.n_ttbrs; ++i)
587-
apple_dart_hw_set_ttbr(stream_map, i,
588-
pgtbl_cfg->apple_dart_cfg.ttbr[i]);
586+
for (i = 0; i < pgtbl_cfg->apple_dart_cfg.n_ttbrs; ++i) {
587+
u64 ttbr = virt_to_phys(pgtbl_cfg->apple_dart_cfg.ttbr[i]);
588+
apple_dart_hw_set_ttbr(stream_map, i, ttbr);
589+
}
589590
for (; i < stream_map->dart->hw->ttbr_count; ++i)
590591
apple_dart_hw_clear_ttbr(stream_map, i);
591592

drivers/iommu/io-pgtable-dart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)
435435
iommu_alloc_pages_sz(GFP_KERNEL, DART_GRANULE(data));
436436
if (!data->pgd[i])
437437
goto out_free_data;
438-
cfg->apple_dart_cfg.ttbr[i] = virt_to_phys(data->pgd[i]);
438+
cfg->apple_dart_cfg.ttbr[i] = data->pgd[i];
439439
}
440440

441441
return &data->iop;

include/linux/io-pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct io_pgtable_cfg {
178178
} arm_mali_lpae_cfg;
179179

180180
struct {
181-
u64 ttbr[4];
181+
void *ttbr[4];
182182
u32 n_ttbrs;
183183
u32 n_levels;
184184
} apple_dart_cfg;

0 commit comments

Comments
 (0)