Skip to content

Commit 119b2b2

Browse files
committed
iommu/amd: Do not flush Device Table in iommu_map_page()
The flush of the Device Table Entries for the domain has already happened in increase_address_space(), if necessary. Do no flush them again in iommu_map_page(). Signed-off-by: Joerg Roedel <[email protected]> Tested-by: Qian Cai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 19c6978 commit 119b2b2

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,15 +1446,18 @@ static bool increase_address_space(struct protection_domain *domain,
14461446
{
14471447
struct domain_pgtable pgtable;
14481448
unsigned long flags;
1449-
bool ret = false;
1449+
bool ret = true;
14501450
u64 *pte, root;
14511451

14521452
spin_lock_irqsave(&domain->lock, flags);
14531453

14541454
amd_iommu_domain_get_pgtable(domain, &pgtable);
14551455

1456-
if (address <= PM_LEVEL_SIZE(pgtable.mode) ||
1457-
WARN_ON_ONCE(pgtable.mode == PAGE_MODE_6_LEVEL))
1456+
if (address <= PM_LEVEL_SIZE(pgtable.mode))
1457+
goto out;
1458+
1459+
ret = false;
1460+
if (WARN_ON_ONCE(pgtable.mode == PAGE_MODE_6_LEVEL))
14581461
goto out;
14591462

14601463
pte = (void *)get_zeroed_page(gfp);
@@ -1499,19 +1502,15 @@ static u64 *alloc_pte(struct protection_domain *domain,
14991502
amd_iommu_domain_get_pgtable(domain, &pgtable);
15001503

15011504
while (address > PM_LEVEL_SIZE(pgtable.mode)) {
1502-
bool upd = increase_address_space(domain, address, gfp);
1503-
1504-
/* Read new values to check if update was successful */
1505-
amd_iommu_domain_get_pgtable(domain, &pgtable);
1506-
15071505
/*
15081506
* Return an error if there is no memory to update the
15091507
* page-table.
15101508
*/
1511-
if (!upd && (address > PM_LEVEL_SIZE(pgtable.mode)))
1509+
if (!increase_address_space(domain, address, gfp))
15121510
return NULL;
15131511

1514-
*updated = *updated || upd;
1512+
/* Read new values to check if update was successful */
1513+
amd_iommu_domain_get_pgtable(domain, &pgtable);
15151514
}
15161515

15171516

@@ -1719,7 +1718,13 @@ static int iommu_map_page(struct protection_domain *dom,
17191718
unsigned long flags;
17201719

17211720
spin_lock_irqsave(&dom->lock, flags);
1722-
update_domain(dom);
1721+
/*
1722+
* Flush domain TLB(s) and wait for completion. Any Device-Table
1723+
* Updates and flushing already happened in
1724+
* increase_address_space().
1725+
*/
1726+
domain_flush_tlb_pde(dom);
1727+
domain_flush_complete(dom);
17231728
spin_unlock_irqrestore(&dom->lock, flags);
17241729
}
17251730

0 commit comments

Comments
 (0)