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

[PATCH v2 1/8] driver/pci: Get next capability without passing caps


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jiqian Chen <Jiqian.Chen@xxxxxxx>
  • Date: Wed, 9 Apr 2025 14:45:21 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=/h+KmEfjEwaWP7PdqWTKb6YIL4NuLpnIAIStX4bOq1M=; b=bvrM9A5Une3nPG2cDVpm/GJ9LV45qh6Ll8p3dk4KWg5IjYqbTVBPdsmYhAQoJbcNGhorChI+nLyfHmX+k1Z/L9Zt/Kz99jNJFrZBJ/+pOi72EeaP36/OKDzhlVFbkqYihZErBqfg4G6Zb68VbMx7sZeAJ4wbCt6pFxDkioaT/SuhYouzjpbgt9gGJTF45QYLjAjFcXd+2HJTsjdEEx4yX5CCcNVZeb/2ZekeKt8RkA83ywS2Ui4nUy6zLPUrQm5zeS0QN0iWGqTfCL0SOHp3hoTdxAcRA+jHrIY12zJ4Nzkq6B9yhxtzJGHComtThS+Nsn9N/BiIFu4gALk6jkQzew==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sroPZVeBh84H84JcDGAdlfv6R9TDhayl9n3PPnQz42euOx7LFBxBac4aVL3jWHlffvahXxOfxj4k56SNgUA+1DHtlnQuGAuwUaXREtpiOPfrj8QF3MWJm1n6DYgaq4kFy96hANoyWAspCf8a0Jn5XqF1ZejaD/Q/5Rt/0+pyUbYBqVoSaUwIlbA6025ut+ZmDW203sqOs7g5cgqkdIVFIbASF1f4C6KjpIXhVs14q6ZwHMJ/PuvGpXKXPjzVOPbICDfs/P6FNWICM1yHcOwRMdhKQ3Ag5M/hxzXMExMVfl0mOEPkXPwPZRC2Z37aIc0HyBKU9F2a5wR+2gQtBl5amw==
  • Cc: Huang Rui <ray.huang@xxxxxxx>, Jiqian Chen <Jiqian.Chen@xxxxxxx>, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 09 Apr 2025 06:46:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Modify function pci_find_next_cap_ttl to support returning position
of next capability when array "caps" is empty or size "n" is zero.

That can help caller to get next capability offset if caller just
has a information of current capability offset.

That will be used in a follow-on change.

Signed-off-by: Jiqian Chen <Jiqian.Chen@xxxxxxx>
---
cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
cc: Michal Orzel <michal.orzel@xxxxxxx>
cc: Jan Beulich <jbeulich@xxxxxxxx>
cc: Julien Grall <julien@xxxxxxx>
cc: "Roger Pau Monné" <roger.pau@xxxxxxxxxx>
cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
v1->v2 changes:
new patch

Best regards,
Jiqian Chen.
---
 xen/drivers/pci/pci.c | 6 +++++-
 xen/include/xen/pci.h | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/pci/pci.c b/xen/drivers/pci/pci.c
index edf5b9f7ae9f..ec81d0db6133 100644
--- a/xen/drivers/pci/pci.c
+++ b/xen/drivers/pci/pci.c
@@ -40,7 +40,7 @@ unsigned int pci_find_cap_offset(pci_sbdf_t sbdf, unsigned 
int cap)
 }
 
 unsigned int pci_find_next_cap_ttl(pci_sbdf_t sbdf, unsigned int pos,
-                                   const unsigned int caps[], unsigned int n,
+                                   const unsigned int *caps, unsigned int n,
                                    unsigned int *ttl)
 {
     while ( (*ttl)-- )
@@ -55,6 +55,10 @@ unsigned int pci_find_next_cap_ttl(pci_sbdf_t sbdf, unsigned 
int pos,
 
         if ( id == 0xff )
             break;
+
+        if ( !caps || n == 0 )
+            return pos;
+
         for ( i = 0; i < n; i++ )
         {
             if ( id == caps[i] )
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index ef601966533e..cc84f2cbebfc 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -251,7 +251,7 @@ int pci_mmcfg_write(unsigned int seg, unsigned int bus,
                     unsigned int devfn, int reg, int len, u32 value);
 unsigned int pci_find_cap_offset(pci_sbdf_t sbdf, unsigned int cap);
 unsigned int pci_find_next_cap_ttl(pci_sbdf_t sbdf, unsigned int pos,
-                                   const unsigned int caps[], unsigned int n,
+                                   const unsigned int *caps, unsigned int n,
                                    unsigned int *ttl);
 unsigned int pci_find_next_cap(pci_sbdf_t sbdf, unsigned int pos,
                                unsigned int cap);
-- 
2.34.1




 


Rackspace

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