Re: [PATCH v5 3/7] PCI/ATS: Initialize PASID in pci_ats_init()

From: Bjorn Helgaas
Date: Thu Aug 15 2019 - 00:43:33 EST


On Thu, Aug 01, 2019 at 05:06:00PM -0700, sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx wrote:
> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
>
> Currently, PASID Capability checks are repeated across all PASID API's.
> Instead, cache the capability check result in pci_pasid_init() and use
> it in other PASID API's. Also, since PASID is a shared resource between
> PF/VF, initialize PASID features with default values in pci_pasid_init().
>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
> ---
> drivers/pci/ats.c | 74 +++++++++++++++++++++++++++++------------
> include/linux/pci-ats.h | 5 +++
> include/linux/pci.h | 1 +
> 3 files changed, 59 insertions(+), 21 deletions(-)
>

> diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
> index 280be911f190..1f4be27a071d 100644
> --- a/drivers/pci/ats.c
> +++ b/drivers/pci/ats.c
> @@ -30,6 +30,8 @@ void pci_ats_init(struct pci_dev *dev)
> dev->ats_cap = pos;
>
> pci_pri_init(dev);
> +
> + pci_pasid_init(dev);
> }
>
> /**
> @@ -315,6 +317,40 @@ EXPORT_SYMBOL_GPL(pci_reset_pri);
> #endif /* CONFIG_PCI_PRI */
>
> #ifdef CONFIG_PCI_PASID
> +
> +void pci_pasid_init(struct pci_dev *pdev)
> +{
> ...
> +}

> diff --git a/include/linux/pci-ats.h b/include/linux/pci-ats.h
> index 33653d4ca94f..bc7f815d38ff 100644
> --- a/include/linux/pci-ats.h
> +++ b/include/linux/pci-ats.h
> @@ -40,6 +40,7 @@ static inline int pci_reset_pri(struct pci_dev *pdev)
>
> #ifdef CONFIG_PCI_PASID
>
> +void pci_pasid_init(struct pci_dev *pdev);

This also looks like it should be static in ats.c.

> int pci_enable_pasid(struct pci_dev *pdev, int features);
> void pci_disable_pasid(struct pci_dev *pdev);
> void pci_restore_pasid_state(struct pci_dev *pdev);
> @@ -48,6 +49,10 @@ int pci_max_pasids(struct pci_dev *pdev);
>
> #else /* CONFIG_PCI_PASID */
>
> +static inline void pci_pasid_init(struct pci_dev *pdev)
> +{
> +}
> +
> static inline int pci_enable_pasid(struct pci_dev *pdev, int features)
> {
> return -EINVAL;