Skip to content

Commit 964877d

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Make amd_iommu_domain_flush_complete() static
AMD driver uses amd_iommu_domain_flush_complete() function to make sure IOMMU processed invalidation commands before proceeding. Ideally this should be called from functions which updates DTE/invalidates caches. There is no need to call this function explicitly. This patches makes below changes : - Rename amd_iommu_domain_flush_complete() -> domain_flush_complete() and make it as static function. - Rearrage domain_flush_complete() to avoid forward declaration. - Update amd_iommu_update_and_flush_device_table() to call domain_flush_complete(). Signed-off-by: Vasant Hegde <[email protected]> Reviewed-by: Suravee Suthikulpanit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 845bd6a commit 964877d

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

drivers/iommu/amd/amd_iommu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ void amd_iommu_flush_all_caches(struct amd_iommu *iommu);
8888
void amd_iommu_update_and_flush_device_table(struct protection_domain *domain);
8989
void amd_iommu_domain_update(struct protection_domain *domain);
9090
void amd_iommu_dev_update_dte(struct iommu_dev_data *dev_data, bool set);
91-
void amd_iommu_domain_flush_complete(struct protection_domain *domain);
9291
void amd_iommu_domain_flush_pages(struct protection_domain *domain,
9392
u64 address, size_t size);
9493
void amd_iommu_dev_flush_pasid_pages(struct iommu_dev_data *dev_data,

drivers/iommu/amd/io_pgtable.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ static bool increase_address_space(struct protection_domain *domain,
175175
domain->iop.root = pte;
176176
domain->iop.mode += 1;
177177
amd_iommu_update_and_flush_device_table(domain);
178-
amd_iommu_domain_flush_complete(domain);
179178

180179
/*
181180
* Device Table needs to be updated and flushed before the new root can

drivers/iommu/amd/iommu.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,22 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
12491249
return ret;
12501250
}
12511251

1252+
static void domain_flush_complete(struct protection_domain *domain)
1253+
{
1254+
int i;
1255+
1256+
for (i = 0; i < amd_iommu_get_num_iommus(); ++i) {
1257+
if (domain && !domain->dev_iommu[i])
1258+
continue;
1259+
1260+
/*
1261+
* Devices of this domain are behind this IOMMU
1262+
* We need to wait for completion of all commands.
1263+
*/
1264+
iommu_completion_wait(amd_iommus[i]);
1265+
}
1266+
}
1267+
12521268
static int iommu_flush_dte(struct amd_iommu *iommu, u16 devid)
12531269
{
12541270
struct iommu_cmd cmd;
@@ -1485,7 +1501,7 @@ void amd_iommu_domain_flush_pages(struct protection_domain *domain,
14851501
__domain_flush_pages(domain, address, size);
14861502

14871503
/* Wait until IOMMU TLB and all device IOTLB flushes are complete */
1488-
amd_iommu_domain_flush_complete(domain);
1504+
domain_flush_complete(domain);
14891505

14901506
return;
14911507
}
@@ -1525,7 +1541,7 @@ void amd_iommu_domain_flush_pages(struct protection_domain *domain,
15251541
}
15261542

15271543
/* Wait until IOMMU TLB and all device IOTLB flushes are complete */
1528-
amd_iommu_domain_flush_complete(domain);
1544+
domain_flush_complete(domain);
15291545
}
15301546

15311547
/* Flush the whole IO/TLB for a given protection domain - including PDE */
@@ -1558,22 +1574,6 @@ static void dev_flush_pasid_all(struct iommu_dev_data *dev_data,
15581574
CMD_INV_IOMMU_ALL_PAGES_ADDRESS, pasid);
15591575
}
15601576

1561-
void amd_iommu_domain_flush_complete(struct protection_domain *domain)
1562-
{
1563-
int i;
1564-
1565-
for (i = 0; i < amd_iommu_get_num_iommus(); ++i) {
1566-
if (domain && !domain->dev_iommu[i])
1567-
continue;
1568-
1569-
/*
1570-
* Devices of this domain are behind this IOMMU
1571-
* We need to wait for completion of all commands.
1572-
*/
1573-
iommu_completion_wait(amd_iommus[i]);
1574-
}
1575-
}
1576-
15771577
/* Flush the not present cache if it exists */
15781578
static void domain_flush_np_cache(struct protection_domain *domain,
15791579
dma_addr_t iova, size_t size)
@@ -1615,6 +1615,7 @@ void amd_iommu_update_and_flush_device_table(struct protection_domain *domain)
16151615
{
16161616
update_device_table(domain);
16171617
domain_flush_devices(domain);
1618+
domain_flush_complete(domain);
16181619
}
16191620

16201621
void amd_iommu_domain_update(struct protection_domain *domain)

0 commit comments

Comments
 (0)