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

[Xen-changelog] [xen-unstable] xl: fix PCI resource parsing



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1275030648 -3600
# Node ID 64133c49e8df2e9cc902c73bbe5b370f83a8f888
# Parent  489d7b631686a8b7948fe8dc06a240e186ece59c
xl: fix PCI resource parsing

The parsing of PCI resources has two problems:

   1. it assumes devices are 32-bits, whereas the fields in the
      "resources" file can have full 64-bit values
   2. it only parses the first resource because the format string is
      missing a \n

Fix both of these up, which allows my Intel 82574L to work with MSI-X.

However, this should probably be using a PCI access library rather
than rummaging around in /sys/bus/pci...

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
 tools/libxl/libxl.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff -r 489d7b631686 -r 64133c49e8df tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri May 28 08:09:38 2010 +0100
+++ b/tools/libxl/libxl.c       Fri May 28 08:10:48 2010 +0100
@@ -2268,7 +2268,7 @@ int libxl_device_pci_add(struct libxl_ct
         char *sysfs_path = libxl_sprintf(ctx, 
SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->domain,
                                          pcidev->bus, pcidev->dev, 
pcidev->func);
         FILE *f = fopen(sysfs_path, "r");
-        unsigned int start = 0, end = 0, flags = 0, size = 0;
+        unsigned long long start = 0, end = 0, flags = 0, size = 0;
         int irq = 0;
         int i;
 
@@ -2277,14 +2277,14 @@ int libxl_device_pci_add(struct libxl_ct
             return -1;
         }
         for (i = 0; i < PROC_PCI_NUM_RESOURCES; i++) {
-            if (fscanf(f, "0x%x 0x%x 0x%x", &start, &end, &flags) != 3)
+            if (fscanf(f, "0x%llx 0x%llx 0x%llx\n", &start, &end, &flags) != 3)
                 continue;
             size = end - start + 1;
             if (start) {
                 if (flags & PCI_BAR_IO) {
                     rc = xc_domain_ioport_permission(ctx->xch, domid, start, 
size, 1);
                     if (rc < 0)
-                        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Error: 
xc_domain_ioport_permission error 0x%x/0x%x", start, size);
+                        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "Error: 
xc_domain_ioport_permission error 0x%llx/0x%llx", start, size);
                 } else {
                     rc = xc_domain_iomem_permission(ctx->xch, domid, 
start>>XC_PAGE_SHIFT,
                                                     
(size+(XC_PAGE_SIZE-1))>>XC_PAGE_SHIFT, 1);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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