[PATCH 01/22] iommu/amd: Make amd_iommu_completion_wait() non-static

Suravee Suthikulpanit
2026-03-30T08:42:50Z

This will be reused in a new iommufd.c file for nested translation.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
drivers/iommu/amd/amd_iommu.h | 1 +
drivers/iommu/amd/iommu.c | 26 ++++++++++++--------------
2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h
index 02f10922f70b..7308c6f1835c 100644
--- a/drivers/iommu/amd/amd_iommu.h
+++ b/drivers/iommu/amd/amd_iommu.h
@@ -197,6 +197,7 @@ void amd_iommu_set_dte_v1(struct iommu_dev_data *dev_data,
void amd_iommu_update_dte(struct amd_iommu *iommu,
struct iommu_dev_data *dev_data,
struct dev_table_entry *new);
+int amd_iommu_completion_wait(struct amd_iommu *iommu);

static inline void
amd_iommu_make_clear_dte(struct iommu_dev_data *dev_data, struct dev_table_entry *new)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 7e724f5675f4..ffa65a97ba86 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -90,8 +90,6 @@ static int amd_iommu_set_dirty_tracking(struct iommu_domain *domain,

static void clone_aliases(struct amd_iommu *iommu, struct device *dev);

-static int iommu_completion_wait(struct amd_iommu *iommu);
-
/****************************************************************************
*
* Helper functions
@@ -216,7 +214,7 @@ void amd_iommu_update_dte(struct amd_iommu *iommu,
update_dte256(iommu, dev_data, new);
clone_aliases(iommu, dev_data->dev);
device_flush_dte(dev_data);
- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);
}

static void get_dte256(struct amd_iommu *iommu, struct iommu_dev_data *dev_data,
@@ -1443,7 +1441,7 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
* This function queues a completion wait command into the command
* buffer of an IOMMU
*/
-static int iommu_completion_wait(struct amd_iommu *iommu)
+int amd_iommu_completion_wait(struct amd_iommu *iommu)
{
struct iommu_cmd cmd;
unsigned long flags;
@@ -1481,7 +1479,7 @@ static void domain_flush_complete(struct protection_domain *domain)
* We need to wait for completion of all commands.
*/
xa_for_each(&domain->iommu_array, i, pdom_iommu_info)
- iommu_completion_wait(pdom_iommu_info->iommu);
+ amd_iommu_completion_wait(pdom_iommu_info->iommu);
}

static int iommu_flush_dte(struct amd_iommu *iommu, u16 devid)
@@ -1499,7 +1497,7 @@ static void iommu_flush_dte_sync(struct amd_iommu *iommu, u16 devid)

ret = iommu_flush_dte(iommu, devid);
if (!ret)
- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);
}

static void amd_iommu_flush_dte_all(struct amd_iommu *iommu)
@@ -1510,7 +1508,7 @@ static void amd_iommu_flush_dte_all(struct amd_iommu *iommu)
for (devid = 0; devid <= last_bdf; ++devid)
iommu_flush_dte(iommu, devid);

- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);
}

/*
@@ -1529,7 +1527,7 @@ static void amd_iommu_flush_tlb_all(struct amd_iommu *iommu)
iommu_queue_command(iommu, &cmd);
}

- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);
}

static void amd_iommu_flush_tlb_domid(struct amd_iommu *iommu, u32 dom_id)
@@ -1540,7 +1538,7 @@ static void amd_iommu_flush_tlb_domid(struct amd_iommu *iommu, u32 dom_id)
dom_id, IOMMU_NO_PASID, false);
iommu_queue_command(iommu, &cmd);

- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);
}

static int iommu_flush_pages_v1_hdom_ids(struct protection_domain *pdom, u64 address, size_t size)
@@ -1576,7 +1574,7 @@ static void amd_iommu_flush_all(struct amd_iommu *iommu)
build_inv_all(&cmd);

iommu_queue_command(iommu, &cmd);
- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);
}

static void iommu_flush_irt(struct amd_iommu *iommu, u16 devid)
@@ -1599,7 +1597,7 @@ static void amd_iommu_flush_irt_all(struct amd_iommu *iommu)
for (devid = 0; devid <= last_bdf; devid++)
iommu_flush_irt(iommu, devid);

- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);
}

void amd_iommu_flush_all_caches(struct amd_iommu *iommu)
@@ -1835,7 +1833,7 @@ void amd_iommu_dev_flush_pasid_pages(struct iommu_dev_data *dev_data,
if (dev_data->ats_enabled)
device_flush_iotlb(dev_data, address, size, pasid, true);

- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);
}

static void dev_flush_pasid_all(struct iommu_dev_data *dev_data,
@@ -2488,7 +2486,7 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
goto out_err;
}

- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);

if (FEATURE_NUM_INT_REMAP_SUP_2K(amd_iommu_efr2))
dev_data->max_irqs = MAX_IRQS_PER_TABLE_2K;
@@ -3354,7 +3352,7 @@ static struct irq_remap_table *alloc_irq_table(struct amd_iommu *iommu,
set_remap_table_entry(iommu, alias, table);

out_wait:
- iommu_completion_wait(iommu);
+ amd_iommu_completion_wait(iommu);

out_unlock:
spin_unlock_irqrestore(&iommu_table_lock, flags);
--
2.34.1