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

[PATCH v2 3/3] PCI: bring pci_get_real_pdev() in line with pci_get_pdev()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 11 Aug 2022 12:52:30 +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=ltM3LnypLdKXezODmgDlDlM4OKAb8fvviVm22POdPMg=; b=CQ2XSET7gVPo/oIFb1yHBjvE+GspoLw+IGkaFxPOgYEl9CNgEDhfYXwErcjo4AiIqGOo4R3VWHqc0pJ93dB/JkhtG/pLdFyXLV2ndfbvp+NS++MYwTD34Y4MlFzVggD1pdBD/wX0Zc2b+RQVP8DXuUEkb1gi4cbCVImEc4uCrjyMlJI5cVvPUCkxgI75Jf+SDkufjNIZgINTBSPulGhrOnFs0Di7y5y5DikHKtozj7eOauwHY0cXGO5ESigcPvECHuxqu9NMh5BMWalO9JECeuVkO0J5z5+FI+EtfqGretewRbG0P1q+zm1WuhNmCWTILhddGpRxIRiz+fNNBcEI+Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hFTHwFhqaQc0LOo0OQJQqWGAbQI3CilsU1n8TnS5mEK7w7V3J8Gj3gqL/W6aDzA5j/3qtdhRtopeXNPNfbLiANndaNo61EIror9rfMgBLjZP0g0eAGIG5FWbjyOCX/syVR0QfaCR164NxotNR/rqMsBys2c7HmxcvtZ+UeRqJXBiX1vTJTDfhBFYGOfMHweOQqDC8vjfA0vEo/o68/QEJrLTnCD1aZPZaue0iR/R5wdqEUBcoTd+I5ON2biJSTNJV9fOY7jS1RZDQttFhl5Zj+JbD7OjWA1oFjB2LpT0nOa3b3GyrdW2lNaSN2cVJsMmsY/X4X7EDrmMj2hqowuMhA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Rahul Singh <Rahul.Singh@xxxxxxx>
  • Delivery-date: Thu, 11 Aug 2022 10:52:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Fold the three parameters into a single pci_sbdf_t one.

No functional change intended, despite the "(8 - stride)" ->
"stride" replacement (not really sure why it was written the more
complicated way originally).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: New.

--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -639,8 +639,7 @@ static void cf_check parse_ppr_log_entry
     struct pci_dev *pdev;
 
     pcidevs_lock();
-    pdev = pci_get_real_pdev(iommu->seg, PCI_BUS(device_id),
-                             PCI_DEVFN(device_id));
+    pdev = pci_get_real_pdev(PCI_SBDF(iommu->seg, device_id));
     pcidevs_unlock();
 
     if ( pdev )
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -576,20 +576,18 @@ int __init pci_ro_device(int seg, int bu
     return 0;
 }
 
-struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn)
+struct pci_dev *pci_get_real_pdev(pci_sbdf_t sbdf)
 {
     struct pci_dev *pdev;
     int stride;
 
-    if ( seg < 0 || bus < 0 || devfn < 0 )
-        return NULL;
-
-    for ( pdev = pci_get_pdev(NULL, PCI_SBDF(seg, bus, devfn)), stride = 4;
+    for ( pdev = pci_get_pdev(NULL, sbdf), stride = 4;
           !pdev && stride; stride >>= 1 )
     {
-        if ( !(devfn & (8 - stride)) )
+        if ( !(sbdf.devfn & stride) )
             continue;
-        pdev = pci_get_pdev(NULL, PCI_SBDF(seg, bus, devfn & ~(8 - stride)));
+        sbdf.devfn &= ~stride;
+        pdev = pci_get_pdev(NULL, sbdf);
         if ( pdev && stride != pdev->phantom_stride )
             pdev = NULL;
     }
@@ -1074,7 +1072,7 @@ void pci_check_disable_device(u16 seg, u
     u16 cword;
 
     pcidevs_lock();
-    pdev = pci_get_real_pdev(seg, bus, devfn);
+    pdev = pci_get_real_pdev(PCI_SBDF(seg, bus, devfn));
     if ( pdev )
     {
         if ( now < pdev->fault.time ||
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -178,7 +178,7 @@ int pci_remove_device(u16 seg, u8 bus, u
 int pci_ro_device(int seg, int bus, int devfn);
 int pci_hide_device(unsigned int seg, unsigned int bus, unsigned int devfn);
 struct pci_dev *pci_get_pdev(const struct domain *d, pci_sbdf_t sbdf);
-struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn);
+struct pci_dev *pci_get_real_pdev(pci_sbdf_t sbdf);
 void pci_check_disable_device(u16 seg, u8 bus, u8 devfn);
 
 uint8_t pci_conf_read8(pci_sbdf_t sbdf, unsigned int reg);




 


Rackspace

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