Skip to content

Commit 482feb5

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()
In many cases the dev argument will now be !NULL so we should use it to finalize the domain at allocation. Make apple_dart_finalize_domain() accept the correct type. Reviewed-by: Janne Grunau <[email protected]> Signed-off-by: Jason Gunthorpe <[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 9c3ef90 commit 482feb5

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

drivers/iommu/apple-dart.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,9 @@ apple_dart_setup_translation(struct apple_dart_domain *domain,
568568
stream_map->dart->hw->invalidate_tlb(stream_map);
569569
}
570570

571-
static int apple_dart_finalize_domain(struct iommu_domain *domain,
571+
static int apple_dart_finalize_domain(struct apple_dart_domain *dart_domain,
572572
struct apple_dart_master_cfg *cfg)
573573
{
574-
struct apple_dart_domain *dart_domain = to_dart_domain(domain);
575574
struct apple_dart *dart = cfg->stream_maps[0].dart;
576575
struct io_pgtable_cfg pgtbl_cfg;
577576
int ret = 0;
@@ -597,17 +596,18 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,
597596
.iommu_dev = dart->dev,
598597
};
599598

600-
dart_domain->pgtbl_ops =
601-
alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, domain);
599+
dart_domain->pgtbl_ops = alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg,
600+
&dart_domain->domain);
602601
if (!dart_domain->pgtbl_ops) {
603602
ret = -ENOMEM;
604603
goto done;
605604
}
606605

607-
domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
608-
domain->geometry.aperture_start = 0;
609-
domain->geometry.aperture_end = (dma_addr_t)DMA_BIT_MASK(dart->ias);
610-
domain->geometry.force_aperture = true;
606+
dart_domain->domain.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
607+
dart_domain->domain.geometry.aperture_start = 0;
608+
dart_domain->domain.geometry.aperture_end =
609+
(dma_addr_t)DMA_BIT_MASK(dart->ias);
610+
dart_domain->domain.geometry.force_aperture = true;
611611

612612
dart_domain->finalized = true;
613613

@@ -662,7 +662,7 @@ static int apple_dart_attach_dev_paging(struct iommu_domain *domain,
662662
if (cfg->stream_maps[0].dart->force_bypass)
663663
return -EINVAL;
664664

665-
ret = apple_dart_finalize_domain(domain, cfg);
665+
ret = apple_dart_finalize_domain(dart_domain, cfg);
666666
if (ret)
667667
return ret;
668668

@@ -758,6 +758,16 @@ static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev)
758758

759759
mutex_init(&dart_domain->init_lock);
760760

761+
if (dev) {
762+
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
763+
int ret;
764+
765+
ret = apple_dart_finalize_domain(dart_domain, cfg);
766+
if (ret) {
767+
kfree(dart_domain);
768+
return ERR_PTR(ret);
769+
}
770+
}
761771
return &dart_domain->domain;
762772
}
763773

0 commit comments

Comments
 (0)