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

Re: [Xen-devel] [GIT PULL] Xen updates



On Wed, 27 Oct 2010, Stefano Stabellini wrote:
> On Wed, 27 Oct 2010, Sander Eikelenboom wrote:
> > Hi Stefano,
> > 
> > About the msi(-x) interrupts:
> > 
> > I have attached the output of:
> > 
> > - Xen serial log
> > - xm info
> > - dmesg
> > - lspci
> > 
> > Dom0 kernel is latest Pull from Linus (commit 
> > 12ba8d1e9262ce81a695795410bd9ee5c9407ba1 which all ready includes pull from 
> > Jeremy) and pulled Stefano's tree on top of that.
> > For both eth0 and xhci controller it can't enable msi(-x)
> 
> can you please try this new branch?
> 
> git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git 
> 2.6.36-rc8-initial-domain-v8
> 

I should add that the problem was that I forgot to include
drivers/xen/pci.c in my series (I was using an old testbox with no msis).

This is the commit that fixes it, it is the result of few commits on
Jeremy's pvops tree squashed together a cleaned up a bit.

---

commit 8cd3c8d3c59c3d349c91108a8b0016c5a6aaf46d
Author: Weidong Han <weidong.han@xxxxxxxxx>
Date:   Wed Oct 27 17:55:04 2010 +0100

    xen: register xen pci notifier
    
    Register the notifier to handle hot-plug devices and SR-IOV devices
    for Xen hypervisor. When a device is hot added or removed, it adds
    or removes it to Xen via hypercalls.
    
    Signed-off-by: Weidong Han <weidong.han@xxxxxxxxx>
    Signed-off-by: Qing He <qing.he@xxxxxxxxx>
    Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index b978645..a572a45 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_XENFS)           += xenfs/
 obj-$(CONFIG_XEN_SYS_HYPERVISOR)       += sys-hypervisor.o
 obj-$(CONFIG_XEN_PLATFORM_PCI) += platform-pci.o
 obj-$(CONFIG_SWIOTLB_XEN)      += swiotlb-xen.o
+obj-$(CONFIG_PCI)              += pci.o
diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c
new file mode 100644
index 0000000..7701741
--- /dev/null
+++ b/drivers/xen/pci.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2009, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Author: Weidong Han <weidong.han@xxxxxxxxx>
+ */
+
+#include <linux/pci.h>
+#include <xen/interface/physdev.h>
+#include <xen/interface/xen.h>
+
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+#include "../pci/pci.h"
+
+static int xen_add_device(struct device *dev)
+{
+       int r;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+
+#ifdef CONFIG_PCI_IOV
+       if (pci_dev->is_virtfn) {
+               struct physdev_manage_pci_ext manage_pci_ext = {
+                       .bus            = pci_dev->bus->number,
+                       .devfn          = pci_dev->devfn,
+                       .is_virtfn      = 1,
+                       .physfn.bus     = pci_dev->physfn->bus->number,
+                       .physfn.devfn   = pci_dev->physfn->devfn,
+               };
+
+               r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add_ext,
+                       &manage_pci_ext);
+       } else
+#endif
+       if (pci_ari_enabled(pci_dev->bus) && PCI_SLOT(pci_dev->devfn)) {
+               struct physdev_manage_pci_ext manage_pci_ext = {
+                       .bus            = pci_dev->bus->number,
+                       .devfn          = pci_dev->devfn,
+                       .is_extfn       = 1,
+               };
+
+               r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add_ext,
+                       &manage_pci_ext);
+       } else {
+               struct physdev_manage_pci manage_pci = {
+                       .bus    = pci_dev->bus->number,
+                       .devfn  = pci_dev->devfn,
+               };
+
+               r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add,
+                       &manage_pci);
+       }
+
+       return r;
+}
+
+static int xen_remove_device(struct device *dev)
+{
+       int r;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       struct physdev_manage_pci manage_pci;
+
+       manage_pci.bus = pci_dev->bus->number;
+       manage_pci.devfn = pci_dev->devfn;
+
+       r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove,
+               &manage_pci);
+
+       return r;
+}
+
+static int xen_pci_notifier(struct notifier_block *nb,
+                           unsigned long action, void *data)
+{
+       struct device *dev = data;
+       int r = 0;
+
+       switch (action) {
+       case BUS_NOTIFY_ADD_DEVICE:
+               r = xen_add_device(dev);
+               break;
+       case BUS_NOTIFY_DEL_DEVICE:
+               r = xen_remove_device(dev);
+               break;
+       default:
+               break;
+       }
+
+       return r;
+}
+
+struct notifier_block device_nb = {
+       .notifier_call = xen_pci_notifier,
+};
+
+static int __init register_xen_pci_notifier(void)
+{
+       if (!xen_pv_domain())
+               return 0;
+
+       return bus_register_notifier(&pci_bus_type, &device_nb);
+}
+
+arch_initcall(register_xen_pci_notifier);
diff --git a/include/xen/interface/physdev.h b/include/xen/interface/physdev.h
index a85d76c..2b2c66c 100644
--- a/include/xen/interface/physdev.h
+++ b/include/xen/interface/physdev.h
@@ -136,6 +136,27 @@ struct physdev_unmap_pirq {
     int pirq;
 };
 
+#define PHYSDEVOP_manage_pci_add       15
+#define PHYSDEVOP_manage_pci_remove    16
+struct physdev_manage_pci {
+       /* IN */
+       uint8_t bus;
+       uint8_t devfn;
+};
+
+#define PHYSDEVOP_manage_pci_add_ext   20
+struct physdev_manage_pci_ext {
+       /* IN */
+       uint8_t bus;
+       uint8_t devfn;
+       unsigned is_extfn;
+       unsigned is_virtfn;
+       struct {
+               uint8_t bus;
+               uint8_t devfn;
+       } physfn;
+};
+
 /*
  * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
  * hypercall since 0x00030202.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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