]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
vpci: add a priority field to the vPCI register initializer
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 20 Apr 2017 09:27:57 +0000 (10:27 +0100)
committerRoger Pau Monne <roger.pau@citrix.com>
Thu, 20 Apr 2017 14:05:49 +0000 (15:05 +0100)
And mark the capability and header vPCI register initializers as high priority,
so that they are initialized first.

This is needed for MSI-X, since MSI-X needs to know the position of the BARs in
order to perform it's initialization, and in order to mask or enable the
MSI/MSI-X functionality on demand.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Jan Beulich <jbeulich@suse.com>
Andrew Cooper <andrew.cooper3@citrix.com>

tools/tests/vpci/Makefile
xen/drivers/vpci/capabilities.c
xen/drivers/vpci/header.c
xen/drivers/vpci/vpci.c
xen/include/xen/vpci.h

index 7969fcbd8219e7ee98d8146761b5d53047e43dbb..e5edc4f512e9937005e3cd87b953df6103092675 100644 (file)
@@ -31,8 +31,8 @@ vpci.c: $(XEN_ROOT)/xen/drivers/vpci/vpci.c
        # Trick the compiler so it doesn't complain about missing symbols
        sed -e '/#include/d' \
            -e '1s;^;#include "emul.h"\
-                    const vpci_register_init_t __start_vpci_array[1]\;\
-                    const vpci_register_init_t __end_vpci_array[1]\;\
+                    const struct vpci_register_init __start_vpci_array[1]\;\
+                    const struct vpci_register_init __end_vpci_array[1]\;\
                     ;' <$< >$@
 
 rbtree.h: $(XEN_ROOT)/xen/include/xen/rbtree.h
index b2a3326aa75c16da39d4fc9a5285ea4b6ef26271..204355e67334d8525c57e0ba15befdb60596fe8f 100644 (file)
@@ -145,7 +145,7 @@ static int vpci_capabilities_init(struct pci_dev *pdev)
     return 0;
 }
 
-REGISTER_VPCI_INIT(vpci_capabilities_init);
+REGISTER_VPCI_INIT(vpci_capabilities_init, true);
 
 /*
  * Local variables:
index 808888c3298175bce1038a09ce3ab3b8bcb4ae4f..d77d82455fe8c8536187f65e7baf6bc52e44890c 100644 (file)
@@ -256,7 +256,7 @@ static int vpci_init_bars(struct pci_dev *pdev)
     return 0;
 }
 
-REGISTER_VPCI_INIT(vpci_init_bars);
+REGISTER_VPCI_INIT(vpci_init_bars, true);
 
 /*
  * Local variables:
index f4cd04f11d8baa7c00ac4b9adb9434d603b1a22e..9f9abadbdbba8ef5b523279c5c07bc02e770b18b 100644 (file)
@@ -20,7 +20,7 @@
 #include <xen/sched.h>
 #include <xen/vpci.h>
 
-extern const vpci_register_init_t __start_vpci_array[], __end_vpci_array[];
+extern const struct vpci_register_init __start_vpci_array[], __end_vpci_array[];
 #define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
 #define vpci_init __start_vpci_array
 
@@ -42,6 +42,7 @@ struct vpci_register {
 int xen_vpci_add_handlers(struct pci_dev *pdev)
 {
     int i, rc = 0;
+    bool priority = true;
 
     if ( !has_vpci(pdev->domain) )
         return 0;
@@ -52,9 +53,13 @@ int xen_vpci_add_handlers(struct pci_dev *pdev)
 
     pdev->vpci->handlers = RB_ROOT;
 
+ again:
     for ( i = 0; i < NUM_VPCI_INIT; i++ )
     {
-        rc = vpci_init[i](pdev);
+        if ( priority != vpci_init[i].priority )
+            continue;
+
+        rc = vpci_init[i].init(pdev);
         if ( rc )
             break;
     }
@@ -74,6 +79,11 @@ int xen_vpci_add_handlers(struct pci_dev *pdev)
         }
         xfree(pdev->vpci);
     }
+    else if ( priority )
+    {
+        priority = false;
+        goto again;
+    }
 
     return rc;
 }
index 53443f51640d69b2ff4daccc3fa940b9aacd01f0..75564b9d93041f7c62858b3c4ba38270c3feac3c 100644 (file)
@@ -29,8 +29,17 @@ typedef int (*vpci_write_t)(struct pci_dev *pdev, unsigned int reg,
 
 typedef int (*vpci_register_init_t)(struct pci_dev *dev);
 
-#define REGISTER_VPCI_INIT(x) \
-  static const vpci_register_init_t x##_entry __used_section(".data.vpci") = x
+struct vpci_register_init {
+    vpci_register_init_t init;
+    bool priority;
+};
+
+#define REGISTER_VPCI_INIT(f, p)                                        \
+  static const struct vpci_register_init                                \
+                      x##_entry __used_section(".data.vpci") = {        \
+    .init = f,                                                          \
+    .priority = p,                                                      \
+}
 
 /* Add vPCI handlers to device. */
 int xen_vpci_add_handlers(struct pci_dev *dev);