Commit 482feb5c authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Joerg Roedel

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: default avatarJanne Grunau <j@jannau.net>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Acked-by: default avatarSven Peter <sven@svenpeter.dev>
Link: https://lore.kernel.org/r/8-v2-bff223cf6409+282-dart_paging_jgg@nvidia.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 9c3ef90c
...@@ -568,10 +568,9 @@ apple_dart_setup_translation(struct apple_dart_domain *domain, ...@@ -568,10 +568,9 @@ apple_dart_setup_translation(struct apple_dart_domain *domain,
stream_map->dart->hw->invalidate_tlb(stream_map); stream_map->dart->hw->invalidate_tlb(stream_map);
} }
static int apple_dart_finalize_domain(struct iommu_domain *domain, static int apple_dart_finalize_domain(struct apple_dart_domain *dart_domain,
struct apple_dart_master_cfg *cfg) struct apple_dart_master_cfg *cfg)
{ {
struct apple_dart_domain *dart_domain = to_dart_domain(domain);
struct apple_dart *dart = cfg->stream_maps[0].dart; struct apple_dart *dart = cfg->stream_maps[0].dart;
struct io_pgtable_cfg pgtbl_cfg; struct io_pgtable_cfg pgtbl_cfg;
int ret = 0; int ret = 0;
...@@ -597,17 +596,18 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain, ...@@ -597,17 +596,18 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,
.iommu_dev = dart->dev, .iommu_dev = dart->dev,
}; };
dart_domain->pgtbl_ops = dart_domain->pgtbl_ops = alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg,
alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, domain); &dart_domain->domain);
if (!dart_domain->pgtbl_ops) { if (!dart_domain->pgtbl_ops) {
ret = -ENOMEM; ret = -ENOMEM;
goto done; goto done;
} }
domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap; dart_domain->domain.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
domain->geometry.aperture_start = 0; dart_domain->domain.geometry.aperture_start = 0;
domain->geometry.aperture_end = (dma_addr_t)DMA_BIT_MASK(dart->ias); dart_domain->domain.geometry.aperture_end =
domain->geometry.force_aperture = true; (dma_addr_t)DMA_BIT_MASK(dart->ias);
dart_domain->domain.geometry.force_aperture = true;
dart_domain->finalized = true; dart_domain->finalized = true;
...@@ -662,7 +662,7 @@ static int apple_dart_attach_dev_paging(struct iommu_domain *domain, ...@@ -662,7 +662,7 @@ static int apple_dart_attach_dev_paging(struct iommu_domain *domain,
if (cfg->stream_maps[0].dart->force_bypass) if (cfg->stream_maps[0].dart->force_bypass)
return -EINVAL; return -EINVAL;
ret = apple_dart_finalize_domain(domain, cfg); ret = apple_dart_finalize_domain(dart_domain, cfg);
if (ret) if (ret)
return ret; return ret;
...@@ -758,6 +758,16 @@ static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev) ...@@ -758,6 +758,16 @@ static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev)
mutex_init(&dart_domain->init_lock); mutex_init(&dart_domain->init_lock);
if (dev) {
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
int ret;
ret = apple_dart_finalize_domain(dart_domain, cfg);
if (ret) {
kfree(dart_domain);
return ERR_PTR(ret);
}
}
return &dart_domain->domain; return &dart_domain->domain;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment