[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] pciback: notify hypervisor about devices intended to be assigned to guests


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-linux-2.6.18-xen <patchbot@xxxxxxx>
  • Date: Wed, 13 Mar 2013 09:22:02 +0000
  • Delivery-date: Wed, 13 Mar 2013 09:22:11 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1363166084 -3600
# Node ID 93fcadedde4884ead8b206563eba34b780e61db3
# Parent  870ad354925b6e9ace2637a51a5c8b2dd78a9d7e
pciback: notify hypervisor about devices intended to be assigned to guests

For MSI-X capable devices the hypervisor wants to write protect the
MSI-X table and PBA, yet it can't assume that resources have been
assigned to their final values at device enumeration time. Thus have
pciback do that notification, as having the device controlled by it is
a prerequisite to assigning the device to guests anyway.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r 870ad354925b -r 93fcadedde48 drivers/xen/pciback/pci_stub.c
--- a/drivers/xen/pciback/pci_stub.c    Tue Mar 12 17:09:55 2013 +0100
+++ b/drivers/xen/pciback/pci_stub.c    Wed Mar 13 10:14:44 2013 +0100
@@ -14,6 +14,7 @@
 #include <linux/wait.h>
 #include <asm/atomic.h>
 #include <xen/evtchn.h>
+#include <xen/interface/physdev.h>
 #include "pciback.h"
 #include "conf_space.h"
 #include "conf_space_quirks.h"
@@ -82,19 +83,35 @@ static struct pcistub_device *pcistub_de
 static void pcistub_device_release(struct kref *kref)
 {
        struct pcistub_device *psdev;
+       struct pci_dev *dev;
 
        psdev = container_of(kref, struct pcistub_device, kref);
+       dev = psdev->dev;
 
-       dev_dbg(&psdev->dev->dev, "pcistub_device_release\n");
+       dev_dbg(&dev->dev, "pcistub_device_release\n");
+
+       if (pci_find_capability(dev, PCI_CAP_ID_MSIX)) {
+               struct physdev_pci_device ppdev = {
+                       .seg = pci_domain_nr(dev->bus),
+                       .bus = dev->bus->number,
+                       .devfn = dev->devfn
+               };
+               int err = HYPERVISOR_physdev_op(PHYSDEVOP_release_msix,
+                                               &ppdev);
+
+               if (err)
+                       dev_warn(&dev->dev, "MSI-X release failed (%d)\n",
+                                err);
+       }
 
        /* Clean-up the device */
-       pciback_reset_device(psdev->dev);
-       pciback_config_free_dyn_fields(psdev->dev);
-       pciback_config_free_dev(psdev->dev);
-       kfree(pci_get_drvdata(psdev->dev));
-       pci_set_drvdata(psdev->dev, NULL);
+       pciback_reset_device(dev);
+       pciback_config_free_dyn_fields(dev);
+       pciback_config_free_dev(dev);
+       kfree(pci_get_drvdata(dev));
+       pci_set_drvdata(dev, NULL);
 
-       pci_dev_put(psdev->dev);
+       pci_dev_put(dev);
 
        kfree(psdev);
 }
@@ -313,6 +330,19 @@ static int __devinit pcistub_init_device
        if (err)
                goto config_release;
 
+       if (pci_find_capability(dev, PCI_CAP_ID_MSIX)) {
+               struct physdev_pci_device ppdev = {
+                       .seg = pci_domain_nr(dev->bus),
+                       .bus = dev->bus->number,
+                       .devfn = dev->devfn
+               };
+
+               err = HYPERVISOR_physdev_op(PHYSDEVOP_prepare_msix, &ppdev);
+               if (err)
+                       dev_err(&dev->dev, "MSI-X preparation failed (%d)\n",
+                               err);
+       }
+
        /* Now disable the device (this also ensures some private device
         * data is setup before we export)
         */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.