Skip to content

Commit a373a2c

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 <j@jannau.net>
1 parent c6287fe commit a373a2c

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
@@ -563,9 +563,10 @@ apple_dart_setup_translation(struct apple_dart_domain *domain,
563563
struct io_pgtable_cfg *pgtbl_cfg =
564564
&io_pgtable_ops_to_pgtable(domain->pgtbl_ops)->cfg;
565565

566-
for (i = 0; i < pgtbl_cfg->apple_dart_cfg.n_ttbrs; ++i)
567-
apple_dart_hw_set_ttbr(stream_map, i,
568-
pgtbl_cfg->apple_dart_cfg.ttbr[i]);
566+
for (i = 0; i < pgtbl_cfg->apple_dart_cfg.n_ttbrs; ++i) {
567+
u64 ttbr = virt_to_phys(pgtbl_cfg->apple_dart_cfg.ttbr[i]);
568+
apple_dart_hw_set_ttbr(stream_map, i, ttbr);
569+
}
569570
for (; i < stream_map->dart->hw->ttbr_count; ++i)
570571
apple_dart_hw_clear_ttbr(stream_map, i);
571572

drivers/iommu/io-pgtable-dart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)
416416
data->pgd[i] = __dart_alloc_pages(DART_GRANULE(data), GFP_KERNEL);
417417
if (!data->pgd[i])
418418
goto out_free_data;
419-
cfg->apple_dart_cfg.ttbr[i] = virt_to_phys(data->pgd[i]);
419+
cfg->apple_dart_cfg.ttbr[i] = data->pgd[i];
420420
}
421421

422422
return &data->iop;

include/linux/io-pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct io_pgtable_cfg {
170170
} arm_mali_lpae_cfg;
171171

172172
struct {
173-
u64 ttbr[4];
173+
void *ttbr[4];
174174
u32 n_ttbrs;
175175
} apple_dart_cfg;
176176

0 commit comments

Comments
 (0)