From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yosuke Iwamatsu Subject: [PATCH] pciback: Make PV PCI Hotplug Work with BACKEND_PASS Option Date: Wed, 26 Mar 2008 18:54:11 +0900 Message-ID: <47EA1D43.4040503@ab.jp.nec.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020705020000010007010001" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------020705020000010007010001 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit 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 --------------020705020000010007010001 Content-Type: all/allfiles; name="pv_pcihp_pass.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pv_pcihp_pass.patch" # HG changeset patch # User y-iwamatsu@ab.jp.nec.com # Date 1206519257 -32400 # Node ID 37f041c10fcb81d3ff9b0d4d226dadbb8b74b7e3 # Parent 14b9877742337506d1885d21763c31fe465b5512 pciback: Make PV PCI hotplug work with CONFIG_XEN_PCIDEV_BACKEND_PASS Signed-off-by: Yosuke Iwamatsu diff -r 14b987774233 -r 37f041c10fcb drivers/xen/pciback/passthrough.c --- a/drivers/xen/pciback/passthrough.c Tue Mar 25 17:54:59 2008 +0000 +++ b/drivers/xen/pciback/passthrough.c Wed Mar 26 17:14:17 2008 +0900 @@ -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) diff -r 14b987774233 -r 37f041c10fcb drivers/xen/pciback/xenbus.c --- a/drivers/xen/pciback/xenbus.c Tue Mar 25 17:54:59 2008 +0000 +++ b/drivers/xen/pciback/xenbus.c Wed Mar 26 17:14:17 2008 +0900 @@ -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: --------------020705020000010007010001 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------020705020000010007010001--