WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] Hook Linux's PCI probe and remove cal

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] Hook Linux's PCI probe and remove callbacks
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 04 Jul 2008 16:20:20 -0700
Delivery-date: Fri, 04 Jul 2008 16:21:08 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1215190507 -3600
# Node ID bb937c2f73823cbf636e6245e9aaf9d703b90da9
# Parent  a2e385815f36b67e1542834f7ca0b18df6211bfd
Hook Linux's PCI probe and remove callbacks

Hijack the pci_bus_type probe and remove callbacks.  This option only
requires modification to the Xen specific part of Linux.

Signed-off-by: Joshua LeVasseur <joshua.levasseur@xxxxxxxxxxxxx>
---
 drivers/xen/core/Makefile |    1 
 drivers/xen/core/pci.c    |   61 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)

diff -r a2e385815f36 -r bb937c2f7382 drivers/xen/core/Makefile
--- a/drivers/xen/core/Makefile Fri Jul 04 17:53:20 2008 +0100
+++ b/drivers/xen/core/Makefile Fri Jul 04 17:55:07 2008 +0100
@@ -4,6 +4,7 @@
 
 obj-y := evtchn.o gnttab.o features.o reboot.o machine_reboot.o firmware.o
 
+obj-$(CONFIG_PCI)              += pci.o
 obj-$(CONFIG_PROC_FS)          += xen_proc.o
 obj-$(CONFIG_SYS_HYPERVISOR)   += hypervisor_sysfs.o
 obj-$(CONFIG_HOTPLUG_CPU)      += cpu_hotplug.o
diff -r a2e385815f36 -r bb937c2f7382 drivers/xen/core/pci.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/xen/core/pci.c    Fri Jul 04 17:55:07 2008 +0100
@@ -0,0 +1,61 @@
+/*
+ * vim:shiftwidth=8:noexpandtab
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <xen/interface/physdev.h>
+
+static int (*pci_bus_probe)(struct device *dev);
+static int (*pci_bus_remove)(struct device *dev);
+
+static int pci_bus_probe_wrapper(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_add, &manage_pci);
+       if (r)
+               return r;
+
+       r = pci_bus_probe(dev);
+       if (r)
+               HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove, &manage_pci);
+
+       return r;
+}
+
+static int pci_bus_remove_wrapper(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 = pci_bus_remove(dev);
+       /* dev and pci_dev are no longer valid!! */
+
+       HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove, &manage_pci);
+       return r;
+}
+
+static int __init hook_pci_bus(void)
+{
+       if (!is_running_on_xen() || !is_initial_xendomain())
+               return 0;
+
+       pci_bus_probe = pci_bus_type.probe;
+       pci_bus_type.probe = pci_bus_probe_wrapper;
+
+       pci_bus_remove = pci_bus_type.remove;
+       pci_bus_type.remove = pci_bus_remove_wrapper;
+
+       return 0;
+}
+
+core_initcall(hook_pci_bus);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] Hook Linux's PCI probe and remove callbacks, Xen patchbot-linux-2.6.18-xen <=