Skip to contentSkip to conversation

pciback: Make PV PCI Hotplug Work with BACKEND_PASS Option

PATCH New Yosuke Iwamatsu 1 participant 1 message Mar 26, 2008 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pciback: Make PV PCI Hotplug Work with BACKEND_PASS Option

Hi there,

This patch makes it possible to attach/detach passthrough pci devices to/from pv domains, when pciback is compiled with CONFIG_XEN_PCIDEV_BACKEND_PASS option.

With BACKEND_PASS options, the virtual device name is the same as the physical device name and multiple pci roots may be exposed to the guest. In this patch, adding new pci roots is supported by publishing new xenstore root-% nodes when new pci devices are attached. However, removing pci roots is not supported because implementing such 'pci root hot-removal' would add much complication.
If a pci root becomes childless as the result of pci-detach, retaining it would be harmless.

Regards,
-----------------------
Yosuke Iwamatsu
NEC Corporation

# HG changeset patch
# User [email protected]
# Date 1206519257 -32400
# Node ID 37f041c10fcb81d3ff9b0d4d226dadbb8b74b7e3
# Parent 14b9877742337506d1885d21763c31fe465b5512
pciback: Make PV PCI hotplug work with CONFIG_XEN_PCIDEV_BACKEND_PASS

drivers/xen/pciback/passthrough.c +8 -2
diff -r 14b987774233 -r 37f041c10fcb drivers/xen/pciback/passthrough.c
@@ -47,6 +47,8 @@ int pciback_add_pci_dev(struct pciback_d
 	struct passthrough_dev_data *dev_data = pdev->pci_dev_data;
 	struct pci_dev_entry *dev_entry;
 	unsigned long flags;
+	unsigned int domain, bus, devfn;
+	int err;
 
 	dev_entry = kmalloc(sizeof(*dev_entry), GFP_KERNEL);
 	if (!dev_entry)
@@ -57,9 +59,13 @@ int pciback_add_pci_dev(struct pciback_d
 	list_add_tail(&dev_entry->list, &dev_data->dev_list);
 	spin_unlock_irqrestore(&dev_data->lock, flags);
 
-	/* TODO: Publish virtual domain:bus:slot.func here. */
+	/* Publish this device. */
+	domain = (unsigned int)pci_domain_nr(dev->bus);
+	bus = (unsigned int)dev->bus->number;
+	devfn = dev->devfn;
+	err = publish_cb(pdev, domain, bus, devfn, devid);
 
-	return 0;
+	return err;
 }
 
 void pciback_release_pci_dev(struct pciback_device *pdev, struct pci_dev *dev)
drivers/xen/pciback/xenbus.c +12 -8
diff -r 14b987774233 -r 37f041c10fcb drivers/xen/pciback/xenbus.c
@@ -348,7 +348,6 @@ static int pciback_reconfigure(struct pc
 			substate = XenbusStateUnknown;
 
 		switch (substate) {
-		/* case XenbusStateUnknown: */
 		case XenbusStateInitialising:
 			dev_dbg(&pdev->xdev->dev, "Attaching dev-%d ...\n", i);
 
@@ -382,10 +381,14 @@ static int pciback_reconfigure(struct pc
 			if (err)
 				goto out;
 
-			/* TODO: if we are to support multiple pci roots
-			 * (CONFIG_XEN_PCIDEV_BACKEND_PASS), publish newly
-			 * added root here.
-			 */
+			/* Publish pci roots. */
+			err = pciback_publish_pci_roots(pdev, pciback_publish_pci_root);
+			if (err) {
+				xenbus_dev_fatal(pdev->xdev, err,
+						 "Error while publish PCI root"
+						 "buses for frontend");
+				goto out;
+			}
 
 			err = xenbus_printf(XBT_NIL, pdev->xdev->nodename,
 					    state_str, "%d",
@@ -431,10 +434,11 @@ static int pciback_reconfigure(struct pc
 			if(err)
 				goto out;
 
-			/* TODO: if we are to support multiple pci roots
-			 * (CONFIG_XEN_PCIDEV_BACKEND_PASS), remove unnecessary
-			 * root here.
+			/* TODO: If at some point we implement support for pci
+			 * root hot-remove on pcifront side, we'll need to
+			 * remove unnecessary xenstore nodes of pci roots here.
 			 */
+
 			break;
 
 		default:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel