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

Vasant Hegde <[email protected]>
Newsgroups dev.linux.lists.iommu,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

On 7/27/2026 6:58 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 <[email protected]>
> Signed-off-by: Suravee Suthikulpanit <[email protected]>
> ---
>  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 e5d26d6d4715..1bc232553c71 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);
> @@ -213,7 +213,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);
>  	amd_iommu_completion_wait(iommu);
>  }
>  
> @@ -1716,9 +1716,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;
> @@ -2685,11 +2684,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);
>  	}
>  
> -	list_for_each_entry(dev_data, &pdom->dev_list, list)
> -		device_flush_dte(dev_data);
> -
>  	domain_flush_complete(pdom);

May be just replace all these w/ amd_iommu_update_dte()?


-Vasant
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.