Skip to content

Commit c81d3d2

Browse files
jbeulichjgross1
authored andcommitted
xen-pciback: reconfigure also from backend watch handler
When multiple PCI devices get assigned to a guest right at boot, libxl incrementally populates the backend tree. The writes for the first of the devices trigger the backend watch. In turn xen_pcibk_setup_backend() will set the XenBus state to Initialised, at which point no further reconfigures would happen unless a device got hotplugged. Arrange for reconfigure to also get triggered from the backend watch handler. Signed-off-by: Jan Beulich <[email protected]> Cc: [email protected] Reviewed-by: Boris Ostrovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
1 parent 4ba50e7 commit c81d3d2

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

drivers/xen/xen-pciback/xenbus.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ static int xen_pcibk_publish_pci_root(struct xen_pcibk_device *pdev,
359359
return err;
360360
}
361361

362-
static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
362+
static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev,
363+
enum xenbus_state state)
363364
{
364365
int err = 0;
365366
int num_devs;
@@ -373,9 +374,7 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
373374
dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n");
374375

375376
mutex_lock(&pdev->dev_lock);
376-
/* Make sure we only reconfigure once */
377-
if (xenbus_read_driver_state(pdev->xdev->nodename) !=
378-
XenbusStateReconfiguring)
377+
if (xenbus_read_driver_state(pdev->xdev->nodename) != state)
379378
goto out;
380379

381380
err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d",
@@ -500,6 +499,10 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
500499
}
501500
}
502501

502+
if (state != XenbusStateReconfiguring)
503+
/* Make sure we only reconfigure once. */
504+
goto out;
505+
503506
err = xenbus_switch_state(pdev->xdev, XenbusStateReconfigured);
504507
if (err) {
505508
xenbus_dev_fatal(pdev->xdev, err,
@@ -525,7 +528,7 @@ static void xen_pcibk_frontend_changed(struct xenbus_device *xdev,
525528
break;
526529

527530
case XenbusStateReconfiguring:
528-
xen_pcibk_reconfigure(pdev);
531+
xen_pcibk_reconfigure(pdev, XenbusStateReconfiguring);
529532
break;
530533

531534
case XenbusStateConnected:
@@ -664,6 +667,15 @@ static void xen_pcibk_be_watch(struct xenbus_watch *watch,
664667
xen_pcibk_setup_backend(pdev);
665668
break;
666669

670+
case XenbusStateInitialised:
671+
/*
672+
* We typically move to Initialised when the first device was
673+
* added. Hence subsequent devices getting added may need
674+
* reconfiguring.
675+
*/
676+
xen_pcibk_reconfigure(pdev, XenbusStateInitialised);
677+
break;
678+
667679
default:
668680
break;
669681
}

0 commit comments

Comments
 (0)