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

[PATCH v3 15/18] pci: Allow ommiting func when parsing with parse_pci_sbdf()



Allow parsing PCI SBDF with the function part omitted (i.e XXXX:YY:ZZ),
in such case, the parsed PCI function is zero.

Then use pci_sbdf_t variant of parse_pci() in parse_phantom_dev().

Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
 xen/drivers/passthrough/pci.c | 10 +++++-----
 xen/drivers/pci/pci.c         | 12 ++++--------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 621537f3cc..69c529459c 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -148,7 +148,7 @@ static unsigned int nr_phantom_devs;
 static int __init cf_check parse_phantom_dev(const char *str)
 {
     const char *s;
-    unsigned int seg, bus, slot;
+    pci_sbdf_t sbdf;
     struct phantom_dev phantom;
 
     if ( !*str )
@@ -156,13 +156,13 @@ static int __init cf_check parse_phantom_dev(const char 
*str)
     if ( nr_phantom_devs >= ARRAY_SIZE(phantom_devs) )
         return -E2BIG;
 
-    s = parse_pci(str, &seg, &bus, &slot, NULL);
+    s = parse_pci(str, &sbdf);
     if ( !s || *s != ',' )
         return -EINVAL;
 
-    phantom.seg = seg;
-    phantom.bus = bus;
-    phantom.slot = slot;
+    phantom.seg = sbdf.seg;
+    phantom.bus = sbdf.bus;
+    phantom.slot = sbdf.dev;
 
     switch ( phantom.stride = simple_strtol(s + 1, &s, 0) )
     {
diff --git a/xen/drivers/pci/pci.c b/xen/drivers/pci/pci.c
index 743e2fd263..793545ae49 100644
--- a/xen/drivers/pci/pci.c
+++ b/xen/drivers/pci/pci.c
@@ -164,7 +164,7 @@ const char *__init parse_pci_split_seg(const char *s, 
unsigned int *seg_p,
                                  unsigned int *bus_p, unsigned int *dev_p,
                                  unsigned int *func_p, bool *def_seg)
 {
-    unsigned long seg = simple_strtoul(s, &s, 16), bus, dev, func;
+    unsigned long seg = simple_strtoul(s, &s, 16), bus, dev, func = 0;
 
     if ( *s != ':' )
         return NULL;
@@ -179,14 +179,10 @@ const char *__init parse_pci_split_seg(const char *s, 
unsigned int *seg_p,
         seg = 0;
         *def_seg = true;
     }
-    if ( func_p )
-    {
-        if ( *s != '.' )
-            return NULL;
+
+    if ( func_p && *s == '.' )
         func = simple_strtoul(s + 1, &s, 0);
-    }
-    else
-        func = 0;
+
     if ( seg != (seg_p ? (u16)seg : 0) ||
          bus != PCI_BUS(PCI_BDF(bus, 0)) ||
          dev != PCI_SLOT(PCI_DEVFN(dev, 0)) ||
-- 
2.54.0



--
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®.