Skip to content

Commit cf23ad4

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 38ade95 commit cf23ad4

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
@@ -580,9 +580,10 @@ apple_dart_setup_translation(struct apple_dart_domain *domain,
580580
struct io_pgtable_cfg *pgtbl_cfg =
581581
&io_pgtable_ops_to_pgtable(domain->pgtbl_ops)->cfg;
582582

583-
for (i = 0; i < pgtbl_cfg->apple_dart_cfg.n_ttbrs; ++i)
584-
apple_dart_hw_set_ttbr(stream_map, i,
585-
pgtbl_cfg->apple_dart_cfg.ttbr[i]);
583+
for (i = 0; i < pgtbl_cfg->apple_dart_cfg.n_ttbrs; ++i) {
584+
u64 ttbr = virt_to_phys(pgtbl_cfg->apple_dart_cfg.ttbr[i]);
585+
apple_dart_hw_set_ttbr(stream_map, i, ttbr);
586+
}
586587
for (; i < stream_map->dart->hw->ttbr_count; ++i)
587588
apple_dart_hw_clear_ttbr(stream_map, i);
588589

drivers/iommu/io-pgtable-dart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)
442442
data->pgd[i] = __dart_alloc_pages(DART_GRANULE(data), GFP_KERNEL);
443443
if (!data->pgd[i])
444444
goto out_free_data;
445-
cfg->apple_dart_cfg.ttbr[i] = virt_to_phys(data->pgd[i]);
445+
cfg->apple_dart_cfg.ttbr[i] = data->pgd[i];
446446
}
447447

448448
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
u32 n_levels;
176176
} apple_dart_cfg;

0 commit comments

Comments
 (0)