Skip to content

Commit 2c535dd

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Make domain_flush_pages as global function
- Rename domain_flush_pages() -> amd_iommu_domain_flush_pages() and make it as global function. - Rename amd_iommu_domain_flush_tlb_pde() -> amd_iommu_domain_flush_all() and make it as static. - Convert v1 page table (io_pgtble.c) to use amd_iommu_domain_flush_pages(). Signed-off-by: Vasant Hegde <vasant.hegde@amd.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20231122090215.6191-9-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 8d004ac commit 2c535dd

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

drivers/iommu/amd/amd_iommu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ void amd_iommu_flush_all_caches(struct amd_iommu *iommu);
6161
void amd_iommu_update_and_flush_device_table(struct protection_domain *domain);
6262
void amd_iommu_domain_update(struct protection_domain *domain);
6363
void amd_iommu_domain_flush_complete(struct protection_domain *domain);
64-
void amd_iommu_domain_flush_tlb_pde(struct protection_domain *domain);
64+
void amd_iommu_domain_flush_pages(struct protection_domain *domain,
65+
u64 address, size_t size);
6566
int amd_iommu_flush_tlb(struct iommu_domain *dom, u32 pasid);
6667
int amd_iommu_domain_set_gcr3(struct iommu_domain *dom, u32 pasid,
6768
unsigned long cr3);

drivers/iommu/amd/io_pgtable.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ static int iommu_v1_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
369369
bool updated = false;
370370
u64 __pte, *pte;
371371
int ret, i, count;
372+
size_t size = pgcount << __ffs(pgsize);
373+
unsigned long o_iova = iova;
372374

373375
BUG_ON(!IS_ALIGNED(iova, pgsize));
374376
BUG_ON(!IS_ALIGNED(paddr, pgsize));
@@ -424,7 +426,7 @@ static int iommu_v1_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
424426
* Updates and flushing already happened in
425427
* increase_address_space().
426428
*/
427-
amd_iommu_domain_flush_tlb_pde(dom);
429+
amd_iommu_domain_flush_pages(dom, o_iova, size);
428430
spin_unlock_irqrestore(&dom->lock, flags);
429431
}
430432

drivers/iommu/amd/iommu.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,8 +1484,8 @@ static void __domain_flush_pages(struct protection_domain *domain,
14841484
WARN_ON(ret);
14851485
}
14861486

1487-
static void domain_flush_pages(struct protection_domain *domain,
1488-
u64 address, size_t size)
1487+
void amd_iommu_domain_flush_pages(struct protection_domain *domain,
1488+
u64 address, size_t size)
14891489
{
14901490
if (likely(!amd_iommu_np_cache)) {
14911491
__domain_flush_pages(domain, address, size);
@@ -1535,9 +1535,10 @@ static void domain_flush_pages(struct protection_domain *domain,
15351535
}
15361536

15371537
/* Flush the whole IO/TLB for a given protection domain - including PDE */
1538-
void amd_iommu_domain_flush_tlb_pde(struct protection_domain *domain)
1538+
static void amd_iommu_domain_flush_all(struct protection_domain *domain)
15391539
{
1540-
domain_flush_pages(domain, 0, CMD_INV_IOMMU_ALL_PAGES_ADDRESS);
1540+
amd_iommu_domain_flush_pages(domain, 0,
1541+
CMD_INV_IOMMU_ALL_PAGES_ADDRESS);
15411542
}
15421543

15431544
void amd_iommu_domain_flush_complete(struct protection_domain *domain)
@@ -1564,7 +1565,7 @@ static void domain_flush_np_cache(struct protection_domain *domain,
15641565
unsigned long flags;
15651566

15661567
spin_lock_irqsave(&domain->lock, flags);
1567-
domain_flush_pages(domain, iova, size);
1568+
amd_iommu_domain_flush_pages(domain, iova, size);
15681569
spin_unlock_irqrestore(&domain->lock, flags);
15691570
}
15701571
}
@@ -1843,7 +1844,7 @@ static void do_detach(struct iommu_dev_data *dev_data)
18431844
device_flush_dte(dev_data);
18441845

18451846
/* Flush IOTLB and wait for the flushes to finish */
1846-
amd_iommu_domain_flush_tlb_pde(domain);
1847+
amd_iommu_domain_flush_all(domain);
18471848

18481849
/* decrease reference counters - needs to happen after the flushes */
18491850
domain->dev_iommu[iommu->index] -= 1;
@@ -2020,7 +2021,7 @@ void amd_iommu_domain_update(struct protection_domain *domain)
20202021
amd_iommu_update_and_flush_device_table(domain);
20212022

20222023
/* Flush domain TLB(s) and wait for completion */
2023-
amd_iommu_domain_flush_tlb_pde(domain);
2024+
amd_iommu_domain_flush_all(domain);
20242025
}
20252026

20262027
/*****************************************************************************
@@ -2454,7 +2455,7 @@ static int amd_iommu_set_dirty_tracking(struct iommu_domain *domain,
24542455

24552456
/* Flush IOTLB to mark IOPTE dirty on the next translation(s) */
24562457
if (domain_flush)
2457-
amd_iommu_domain_flush_tlb_pde(pdomain);
2458+
amd_iommu_domain_flush_all(pdomain);
24582459

24592460
pdomain->dirty_tracking = enable;
24602461
spin_unlock_irqrestore(&pdomain->lock, flags);
@@ -2558,7 +2559,7 @@ static void amd_iommu_flush_iotlb_all(struct iommu_domain *domain)
25582559
unsigned long flags;
25592560

25602561
spin_lock_irqsave(&dom->lock, flags);
2561-
amd_iommu_domain_flush_tlb_pde(dom);
2562+
amd_iommu_domain_flush_all(dom);
25622563
spin_unlock_irqrestore(&dom->lock, flags);
25632564
}
25642565

@@ -2569,7 +2570,8 @@ static void amd_iommu_iotlb_sync(struct iommu_domain *domain,
25692570
unsigned long flags;
25702571

25712572
spin_lock_irqsave(&dom->lock, flags);
2572-
domain_flush_pages(dom, gather->start, gather->end - gather->start + 1);
2573+
amd_iommu_domain_flush_pages(dom, gather->start,
2574+
gather->end - gather->start + 1);
25732575
spin_unlock_irqrestore(&dom->lock, flags);
25742576
}
25752577

0 commit comments

Comments
 (0)