]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
pcifront: fix multiple initialization bug
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 23 Nov 2009 07:14:33 +0000 (07:14 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 23 Nov 2009 07:14:33 +0000 (07:14 +0000)
Now that we have pcifront_watches to dynamically initialize pcifront
we don't need a call to init_pcifront in pcilib and pcifront_scan
anymore; we should just wait for the frontend to connect to the
backend instead.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
pcifront.c

index ed402a8a194fefd0baa1b4a029d54da6418a4edb..718abf1d7384b401e8ae220e636a181c0e0a98d2 100644 (file)
@@ -276,15 +276,24 @@ void pcifront_scan(struct pcifront_dev *dev, void (*func)(unsigned int domain, u
 {
     char *path;
     int i, n, len;
-    char *s, *msg;
+    char *s, *msg = NULL, *err = NULL;
     unsigned int domain, bus, slot, fun;
 
     if (!dev)
         dev = pcidev;
-    if (!dev)
-        dev = init_pcifront(NULL);
-    if (!dev)
-        return;
+    if (!dev) {
+        xenbus_event_queue events = NULL;
+        char *fe_state = "device/pci/0/state";
+        xenbus_watch_path_token(XBT_NIL, fe_state, fe_state, &events);
+        while ((err = xenbus_read(XBT_NIL, fe_state, &msg)) != NULL || msg[0] != '4') {
+            free(msg);
+            free(err);
+            printk("pcifront_scan: waiting for pcifront to become ready\n");
+            xenbus_wait_for_watch(&events);
+        }
+        xenbus_unwatch_path_token(XBT_NIL, fe_state, fe_state);
+        dev = pcidev;
+    }
 
     len = strlen(dev->backend) + 1 + 5 + 10 + 1;
     path = (char *) malloc(len);