Skip to content

Commit 1f58553

Browse files
ssuthiku-amdjoergroedel
authored andcommitted
iommu/amd: Convert to using amd_io_pgtable
Make use of the new struct amd_io_pgtable in preparation to remove the struct domain_pgtable. Signed-off-by: Suravee Suthikulpanit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent d2272ec commit 1f58553

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

drivers/iommu/amd/amd_iommu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern void amd_iommu_domain_direct_map(struct iommu_domain *dom);
5656
extern int amd_iommu_domain_enable_v2(struct iommu_domain *dom, int pasids);
5757
extern int amd_iommu_flush_page(struct iommu_domain *dom, u32 pasid,
5858
u64 address);
59+
extern void amd_iommu_update_and_flush_device_table(struct protection_domain *domain);
5960
extern int amd_iommu_flush_tlb(struct iommu_domain *dom, u32 pasid);
6061
extern int amd_iommu_domain_set_gcr3(struct iommu_domain *dom, u32 pasid,
6162
unsigned long cr3);

drivers/iommu/amd/iommu.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ struct kmem_cache *amd_iommu_irq_cache;
8888

8989
static void update_domain(struct protection_domain *domain);
9090
static void detach_device(struct device *dev);
91-
static void update_and_flush_device_table(struct protection_domain *domain,
92-
struct domain_pgtable *pgtable);
9391

9492
/****************************************************************************
9593
*
@@ -1501,7 +1499,7 @@ static bool increase_address_space(struct protection_domain *domain,
15011499

15021500
pgtable.root = pte;
15031501
pgtable.mode += 1;
1504-
update_and_flush_device_table(domain, &pgtable);
1502+
amd_iommu_update_and_flush_device_table(domain);
15051503
domain_flush_complete(domain);
15061504

15071505
/*
@@ -1876,17 +1874,16 @@ static void free_gcr3_table(struct protection_domain *domain)
18761874
}
18771875

18781876
static void set_dte_entry(u16 devid, struct protection_domain *domain,
1879-
struct domain_pgtable *pgtable,
18801877
bool ats, bool ppr)
18811878
{
18821879
u64 pte_root = 0;
18831880
u64 flags = 0;
18841881
u32 old_domid;
18851882

1886-
if (pgtable->mode != PAGE_MODE_NONE)
1887-
pte_root = iommu_virt_to_phys(pgtable->root);
1883+
if (domain->iop.mode != PAGE_MODE_NONE)
1884+
pte_root = iommu_virt_to_phys(domain->iop.root);
18881885

1889-
pte_root |= (pgtable->mode & DEV_ENTRY_MODE_MASK)
1886+
pte_root |= (domain->iop.mode & DEV_ENTRY_MODE_MASK)
18901887
<< DEV_ENTRY_MODE_SHIFT;
18911888
pte_root |= DTE_FLAG_IR | DTE_FLAG_IW | DTE_FLAG_V | DTE_FLAG_TV;
18921889

@@ -1976,7 +1973,7 @@ static void do_attach(struct iommu_dev_data *dev_data,
19761973

19771974
/* Update device table */
19781975
amd_iommu_domain_get_pgtable(domain, &pgtable);
1979-
set_dte_entry(dev_data->devid, domain, &pgtable,
1976+
set_dte_entry(dev_data->devid, domain,
19801977
ats, dev_data->iommu_v2);
19811978
clone_aliases(dev_data->pdev);
19821979

@@ -2283,22 +2280,20 @@ static int amd_iommu_domain_get_attr(struct iommu_domain *domain,
22832280
*
22842281
*****************************************************************************/
22852282

2286-
static void update_device_table(struct protection_domain *domain,
2287-
struct domain_pgtable *pgtable)
2283+
static void update_device_table(struct protection_domain *domain)
22882284
{
22892285
struct iommu_dev_data *dev_data;
22902286

22912287
list_for_each_entry(dev_data, &domain->dev_list, list) {
2292-
set_dte_entry(dev_data->devid, domain, pgtable,
2288+
set_dte_entry(dev_data->devid, domain,
22932289
dev_data->ats.enabled, dev_data->iommu_v2);
22942290
clone_aliases(dev_data->pdev);
22952291
}
22962292
}
22972293

2298-
static void update_and_flush_device_table(struct protection_domain *domain,
2299-
struct domain_pgtable *pgtable)
2294+
void amd_iommu_update_and_flush_device_table(struct protection_domain *domain)
23002295
{
2301-
update_device_table(domain, pgtable);
2296+
update_device_table(domain);
23022297
domain_flush_devices(domain);
23032298
}
23042299

@@ -2308,7 +2303,7 @@ static void update_domain(struct protection_domain *domain)
23082303

23092304
/* Update device table */
23102305
amd_iommu_domain_get_pgtable(domain, &pgtable);
2311-
update_and_flush_device_table(domain, &pgtable);
2306+
amd_iommu_update_and_flush_device_table(domain);
23122307

23132308
/* Flush domain TLB(s) and wait for completion */
23142309
domain_flush_tlb_pde(domain);

0 commit comments

Comments
 (0)