[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/6] PCI: pass pdev to pci_ats_{device,enabled}()



Hello,

Le 06/01/2026 à 14:51, Jan Beulich a écrit :
> This not only brings both in sync with {en,dis}able_ats_device() but also
> prepares for doing the same to pci_find_{,next_}ext_capability().
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>
> --- a/xen/drivers/passthrough/amd/iommu_cmd.c
> +++ b/xen/drivers/passthrough/amd/iommu_cmd.c
> @@ -285,7 +285,7 @@ void amd_iommu_flush_iotlb(u8 devfn, con
>       if ( !ats_enabled )
>           return;
>
> -    if ( !pci_ats_enabled(pdev->seg, pdev->bus, pdev->devfn) )
> +    if ( !pci_ats_enabled(pdev) )
>           return;
>
>       iommu = find_iommu_for_device(pdev->sbdf);
> --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
> +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
> @@ -121,7 +121,7 @@ static bool use_ats(
>   {
>       return !ivrs_dev->block_ats &&
>              iommu_has_cap(iommu, PCI_CAP_IOTLB_SHIFT) &&
> -           pci_ats_device(iommu->sbdf.seg, pdev->bus, pdev->devfn);
> +           pci_ats_device(pdev);
>   }
>
>   static int __must_check amd_iommu_setup_domain_device(
> @@ -274,8 +274,7 @@ static int __must_check amd_iommu_setup_
>
>       ASSERT(pcidevs_locked());
>
> -    if ( use_ats(pdev, iommu, ivrs_dev) &&
> -         !pci_ats_enabled(iommu->sbdf.seg, bus, pdev->devfn) )
> +    if ( use_ats(pdev, iommu, ivrs_dev) && !pci_ats_enabled(pdev) )
>       {
>           if ( devfn == pdev->devfn )
>               enable_ats_device(pdev, &iommu->ats_devices);
> @@ -418,8 +417,7 @@ static void amd_iommu_disable_domain_dev
>
>       ASSERT(pcidevs_locked());
>
> -    if ( pci_ats_device(iommu->sbdf.seg, bus, pdev->devfn) &&
> -         pci_ats_enabled(iommu->sbdf.seg, bus, pdev->devfn) )
> +    if ( pci_ats_device(pdev) && pci_ats_enabled(pdev) )
>           disable_ats_device(pdev);
>
>       BUG_ON ( iommu->dev_table.buffer == NULL );
> --- a/xen/drivers/passthrough/ats.h
> +++ b/xen/drivers/passthrough/ats.h
> @@ -27,27 +27,25 @@ extern bool ats_enabled;
>   int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list);
>   void disable_ats_device(struct pci_dev *pdev);
>
> -static inline int pci_ats_enabled(int seg, int bus, int devfn)
> +static inline int pci_ats_enabled(const struct pci_dev *pdev)
>   {
>       u32 value;
>       int pos;
>
> -    pos = pci_find_ext_capability(PCI_SBDF(seg, bus, devfn),
> -                                  PCI_EXT_CAP_ID_ATS);
> +    pos = pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS);
>       BUG_ON(!pos);
>
> -    value = pci_conf_read16(PCI_SBDF(seg, bus, devfn), pos + ATS_REG_CTL);
> +    value = pci_conf_read16(pdev->sbdf, pos + ATS_REG_CTL);
>
>       return value & ATS_ENABLE;
>   }
>
> -static inline int pci_ats_device(int seg, int bus, int devfn)
> +static inline int pci_ats_device(const struct pci_dev *pdev)
>   {
>       if ( !ats_enabled )
>           return 0;
>
> -    return pci_find_ext_capability(PCI_SBDF(seg, bus, devfn),
> -                                   PCI_EXT_CAP_ID_ATS);
> +    return pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS);
>   }
>
>   #endif /* DRIVERS__PASSTHROUGH__ATS_H */
>
>

Reviewed-by: Teddy Astie <teddy.astie@xxxxxxxxxx>

Teddy


--
Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.