Subject: xen/dom0: Reassign memory resources to device for pci passthrough
-From: http://xenbits.xensource.com/linux-2.6.18-xen.hg (tip 745:2268be46c75e)
+From: http://xenbits.xensource.com/linux-2.6.18-xen.hg (tip 852:571229e265e2)
Patch-mainline: obsolete
Acked-by: jbeulich@novell.com
-Index: head-2008-12-01/drivers/pci/Makefile
-===================================================================
---- head-2008-12-01.orig/drivers/pci/Makefile 2008-12-01 10:53:15.000000000 +0100
-+++ head-2008-12-01/drivers/pci/Makefile 2008-10-21 13:09:46.000000000 +0200
+--- sle11-2009-04-09.orig/drivers/pci/Kconfig 2009-04-09 14:29:05.000000000 +0200
++++ sle11-2009-04-09/drivers/pci/Kconfig 2008-11-10 11:49:15.000000000 +0100
+@@ -21,6 +21,9 @@ config PCI_MSI
+
+ If you don't know what to do here, say N.
+
++config PCI_REASSIGN
++ bool
++
+ config PCI_LEGACY
+ bool "Enable deprecated pci_find_* API"
+ depends on PCI
+--- sle11-2009-04-09.orig/drivers/pci/Makefile 2009-04-09 14:29:05.000000000 +0200
++++ sle11-2009-04-09/drivers/pci/Makefile 2008-10-21 13:09:46.000000000 +0200
@@ -4,6 +4,7 @@
obj-y += access.o bus.o probe.o remove.o pci.o quirks.o slot.o \
obj-$(CONFIG_PROC_FS) += proc.o
# Build PCI Express stuff if needed
-Index: head-2008-12-01/drivers/pci/pci.h
-===================================================================
---- head-2008-12-01.orig/drivers/pci/pci.h 2008-12-01 10:53:15.000000000 +0100
-+++ head-2008-12-01/drivers/pci/pci.h 2008-10-21 13:09:01.000000000 +0200
-@@ -144,3 +144,9 @@ struct pci_slot_attribute {
+--- sle11-2009-04-09.orig/drivers/pci/pci.h 2009-04-09 14:29:05.000000000 +0200
++++ sle11-2009-04-09/drivers/pci/pci.h 2008-10-21 13:09:01.000000000 +0200
+@@ -145,3 +145,9 @@ struct pci_slot_attribute {
};
#define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr)
+#else
+#define is_reassigndev(dev) 0
+#endif
-Index: head-2008-12-01/drivers/pci/quirks.c
-===================================================================
---- head-2008-12-01.orig/drivers/pci/quirks.c 2008-12-01 10:53:15.000000000 +0100
-+++ head-2008-12-01/drivers/pci/quirks.c 2008-10-29 10:52:40.000000000 +0100
-@@ -24,6 +24,54 @@
- #include <linux/kallsyms.h>
+--- sle11-2009-04-09.orig/drivers/pci/quirks.c 2009-04-09 14:29:05.000000000 +0200
++++ sle11-2009-04-09/drivers/pci/quirks.c 2009-04-09 14:34:32.000000000 +0200
+@@ -25,6 +25,57 @@
+ #include <linux/pci-aspm.h>
#include "pci.h"
+#ifdef CONFIG_PCI_REASSIGN
+/*
-+ * This quirk function disables the device and releases resources
-+ * which is specified by kernel's boot parameter 'reassigndev'.
++ * This quirk function disables memory decoding and releases memory
++ * resources which is specified by kernel's boot parameter 'reassigndev'.
+ * Later on, kernel will assign page-aligned memory resource back
-+ * to that device.
++ * to the device.
+ */
+static void __devinit quirk_release_resources(struct pci_dev *dev)
+{
+ int i;
+ struct resource *r;
++ u16 command;
+
+ if (is_reassigndev(dev)) {
+ if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL &&
+ return;
+ }
+ printk(KERN_INFO
-+ "PCI: Disable device and release resources [%s].\n",
++ "PCI: Disable memory decoding and release memory resources [%s].\n",
+ pci_name(dev));
-+ pci_disable_device(dev);
++ pci_read_config_word(dev, PCI_COMMAND, &command);
++ command &= ~PCI_COMMAND_MEMORY;
++ pci_write_config_word(dev, PCI_COMMAND, command);
+
+ for (i=0; i < PCI_NUM_RESOURCES; i++) {
+ r = &dev->resource[i];
/* The Mellanox Tavor device gives false positive parity errors
* Mark this device with a broken_parity_status, to allow
* PCI scanning code to "skip" this now blacklisted device.
-Index: head-2008-12-01/drivers/pci/reassigndev.c
-===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ head-2008-12-01/drivers/pci/reassigndev.c 2008-10-21 13:13:38.000000000 +0200
++++ sle11-2009-04-09/drivers/pci/reassigndev.c 2008-10-21 13:13:38.000000000 +0200
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2008, NEC Corporation.
+
+ return 0;
+}
-Index: head-2008-12-01/drivers/pci/setup-bus.c
-===================================================================
---- head-2008-12-01.orig/drivers/pci/setup-bus.c 2008-12-01 10:53:15.000000000 +0100
-+++ head-2008-12-01/drivers/pci/setup-bus.c 2008-10-21 13:09:01.000000000 +0200
+--- sle11-2009-04-09.orig/drivers/pci/setup-bus.c 2009-04-09 14:29:05.000000000 +0200
++++ sle11-2009-04-09/drivers/pci/setup-bus.c 2008-10-21 13:09:01.000000000 +0200
@@ -26,6 +26,7 @@
#include <linux/cache.h>
#include <linux/slab.h>
/* For bridges size != alignment */
align = resource_alignment(r);
order = __ffs(align) - 20;
-Index: head-2008-12-01/drivers/pci/setup-res.c
-===================================================================
---- head-2008-12-01.orig/drivers/pci/setup-res.c 2008-12-01 10:53:15.000000000 +0100
-+++ head-2008-12-01/drivers/pci/setup-res.c 2008-12-01 11:10:02.000000000 +0100
+--- sle11-2009-04-09.orig/drivers/pci/setup-res.c 2009-04-09 14:29:05.000000000 +0200
++++ sle11-2009-04-09/drivers/pci/setup-res.c 2008-12-01 11:10:02.000000000 +0100
@@ -126,6 +126,21 @@ int pci_claim_resource(struct pci_dev *d
return err;
}