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

Re: [PATCH v3 2/4] xen/pci: convert pci_find_*cap* to pci_sbdf_t


  • To: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 22 Aug 2023 14:53:25 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AW33a4gSbvOY3I2Cu/stQ74P9tsFG1s7Qcrsxxj+CXI=; b=BHaS/VpqDIyIgVdLCSJM6fulwTbazbuXZwoDsvYM9iBusn67bjfTJcTqutbjf1v0khIeyOd26BkdXpipSamKJCOWuaIGbtPpJ8ZsBobA7OExk+bD277SMZcPQHMPFEFqgyzB56oZMGwJ4U6vakeEkFk20CzikoCmONTnM1cSaXiUZaM3tQl8XVjIOW/T6NVUfx8R1MAoYOfWC95ciBucyxnGdeG0syiPkEzW2UL6SIvvN+w17WRgZnzTcde3PjatbStz72hkmz22csHoDQ6eK2x2ivNKU3w4rgmGSmgYz18o1lFtZJ/Zvh6tlQEIif+/OANCLUwf2AE+Tci6eg3Sdg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mAu4J20mkb2TLVfrKYgDFrfQhA+wuAJ0FK5MoRIg3TQU/Y1w62+KvqP3NhvtdoKwziECNs4FNJaqGwuP7x/uMuY10bwH+SYxPBfn9Liyd4vjdwhnWEYKFbTDaXcu5qInvIHJqpRUiqcg+bVTTlhR9SUtlAsdRB7Gdfk5X3opYtAiA4xUTfPa3TqYqqbnLfbBCmCvwmX0JRfPiOCIAxyFHEOvTlewuHh1wItvQsnQzx9YYZIf9dmydB/CTRn8xpCcxFSmHf7t+NiZT3fzwsfeKBGBLhk/QMOcC+RbQrQD4g84uSyvvR7DPI+I5NocNdxYrnzmWw+zUlDbtsF7f5clGQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 22 Aug 2023 12:54:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.08.2023 03:29, Stewart Hildebrand wrote:
> @@ -291,12 +291,9 @@ static void msi_set_enable(struct pci_dev *dev, int 
> enable)
>  static void msix_set_enable(struct pci_dev *dev, int enable)
>  {
>      int pos;
> -    u16 control, seg = dev->seg;
> -    u8 bus = dev->bus;
> -    u8 slot = PCI_SLOT(dev->devfn);
> -    u8 func = PCI_FUNC(dev->devfn);
> +    u16 control;

As you touch such places, it would be nice to also switch to uint16_t at
the same time. (Similarly when you touch "pos" declarations anyway,
converting them to unsigned int when they're wrongly plain int would also
be nice.)

> @@ -318,17 +315,12 @@ static bool msi_set_mask_bit(struct irq_desc *desc, 
> bool host, bool guest)
>  {
>      struct msi_desc *entry = desc->msi_desc;
>      struct pci_dev *pdev;
> -    u16 seg, control;
> -    u8 bus, slot, func;
> +    u16 control;
>      bool flag = host || guest, maskall;
>  
>      ASSERT(spin_is_locked(&desc->lock));
>      BUG_ON(!entry || !entry->dev);
>      pdev = entry->dev;
> -    seg = pdev->seg;
> -    bus = pdev->bus;
> -    slot = PCI_SLOT(pdev->devfn);
> -    func = PCI_FUNC(pdev->devfn);
>      switch ( entry->msi_attrib.type )
>      {
>      case PCI_CAP_ID_MSI:

You don't further alter the function, so this looks like an unrelated
(but still desirable for at least Misra) change.

> @@ -685,8 +674,8 @@ static u64 read_pci_mem_bar(u16 seg, u8 bus, u8 slot, u8 
> func, u8 bir, int vf)
>      {
>          struct pci_dev *pdev = pci_get_pdev(NULL,
>                                              PCI_SBDF(seg, bus, slot, func));

With this, ...

> -        unsigned int pos = pci_find_ext_capability(seg, bus,
> -                                                   PCI_DEVFN(slot, func),
> +        unsigned int pos = pci_find_ext_capability(PCI_SBDF(seg, bus, slot,
> +                                                            func),
>                                                     PCI_EXT_CAP_ID_SRIOV);

... please use pdev->sbdf here. Albeit I guess some further re-arrangement
is wanted here, to eliminate all of those PCI_SBDF() (and then also dealing
with the otherwise necessary NULL check). IOW perhaps fine the way you have
it, and then to be subject to a follow-on change.

> --- a/xen/include/xen/pci.h
> +++ b/xen/include/xen/pci.h
> @@ -193,11 +193,10 @@ int pci_mmcfg_read(unsigned int seg, unsigned int bus,
>                     unsigned int devfn, int reg, int len, u32 *value);
>  int pci_mmcfg_write(unsigned int seg, unsigned int bus,
>                      unsigned int devfn, int reg, int len, u32 value);
> -int pci_find_cap_offset(u16 seg, u8 bus, u8 dev, u8 func, u8 cap);
> -int pci_find_next_cap(u16 seg, u8 bus, unsigned int devfn, u8 pos, int cap);
> -int pci_find_ext_capability(int seg, int bus, int devfn, int cap);
> -int pci_find_next_ext_capability(int seg, int bus, int devfn, int start,
> -                                 int cap);
> +int pci_find_cap_offset(pci_sbdf_t sbdf, u8 cap);
> +int pci_find_next_cap(pci_sbdf_t sbdf, u8 pos, int cap);
> +int pci_find_ext_capability(pci_sbdf_t sbdf, int cap);
> +int pci_find_next_ext_capability(pci_sbdf_t sbdf, int start, int cap);

The remaining types want converting, too: Neither fixed-width nor plain int
are appropriate here. (It's a few too many type adjustments to make, for me
to offer doing so while committing.)

Jan



 


Rackspace

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