Re: [PATCH v6 10/24] iommu/amd: Pass iommu to device_flush_dte()

From: Vasant Hegde

Date: Mon Oct 19 2026 - 15:57:35 EST




On 9/30/2026 2:53 PM, Suravee Suthikulpanit wrote:
> Take struct amd_iommu explicitly so DTE invalidation is issued on the
> same IOMMU instance used to program the DTE. Also, flush each device in
> amd_iommu_change_top() immediately after updating its DTE.
>
> Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
> ---
> drivers/iommu/amd/iommu.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index dfb9268f3c4e..a45044e1d423 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -76,7 +76,7 @@ static void set_dte_entry(struct amd_iommu *iommu,
> struct iommu_dev_data *dev_data,
> phys_addr_t top_paddr, unsigned int top_level);
>
> -static int device_flush_dte(struct iommu_dev_data *dev_data);
> +static int device_flush_dte(struct amd_iommu *iommu, struct iommu_dev_data *dev_data);
>
> static void amd_iommu_change_top(struct pt_iommu *iommu_table,
> phys_addr_t top_paddr, unsigned int top_level);
> @@ -218,7 +218,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);
> + device_flush_dte(iommu, dev_data);
> iommu_completion_wait(iommu);
> }
>
> @@ -1824,9 +1824,8 @@ static int device_flush_dte_alias(struct pci_dev *pdev, u16 alias, void *data)
> /*
> * Command send function for invalidating a device table entry
> */
> -static int device_flush_dte(struct iommu_dev_data *dev_data)
> +static int device_flush_dte(struct amd_iommu *iommu, struct iommu_dev_data *dev_data)
> {
> - struct amd_iommu *iommu = get_amd_iommu_from_dev_data(dev_data);
> struct pci_dev *pdev = NULL;
> struct amd_iommu_pci_seg *pci_seg;
> u16 alias;
> @@ -2795,11 +2794,9 @@ static void amd_iommu_change_top(struct pt_iommu *iommu_table,
> /* Update the HW references with the new level and top ptr */
> set_dte_entry(iommu, dev_data, top_paddr, top_level);
> clone_aliases(iommu, dev_data->dev);
> + device_flush_dte(iommu, dev_data);

May be an existing issue.

set_dte_entry -> amd_iommu_update_dte() already handles clone_aliases and dte_flush.

-Vasant