# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1237376730 0
# Node ID c1f0373ff44ea3f9ba3845e05faf3d27d7d52731
# Parent cc27ca4b86c13480eaa3d9f45cb013ffde4ef26b
backport: allocate cap save buffers for PCIe/PCI-X.
Changeset 819:e8a9f8910a3f doesn't backport all the necessary code.
This patch adds the missing part. It is also backported from upstream
Linux kernel and the git commit is:
commit 63f4898ace2788a89ed685672aab092e1c3e50e6
Author: Rafael J. Wysocki <rjw@xxxxxxx>
Date: Sun Dec 7 22:02:58 2008 +0100
PCI: handle PCI state saving with interrupts disabled
Since interrupts will soon be disabled at PCI resume time, we need
to
pre-allocate memory to save/restore PCI config space (or use
GFP_ATOMIC=, but this is safer).
Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: "Rafael J. Wysocki" <rjw@xxxxxxx>
Signed-off-by: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>
Signed-off-by: Dexuan Cui <dexuan.cui@xxxxxxxxx>=
---
drivers/pci/pci.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
drivers/pci/pci.h | 2 ++
drivers/pci/probe.c | 3 +++
3 files changed, 50 insertions(+)
diff -r cc27ca4b86c1 -r c1f0373ff44e drivers/pci/pci.c
--- a/drivers/pci/pci.c Wed Mar 18 11:43:57 2009 +0000
+++ b/drivers/pci/pci.c Wed Mar 18 11:45:30 2009 +0000
@@ -706,6 +706,51 @@ int pci_enable_wake(struct pci_dev *dev,
}
/**
+ * pci_add_save_buffer - allocate buffer for saving given capability registers
+ * @dev: the PCI device
+ * @cap: the capability to allocate the buffer for
+ * @size: requested size of the buffer
+ */
+static int pci_add_cap_save_buffer(
+ struct pci_dev *dev, char cap, unsigned int size)
+{
+ int pos;
+ struct pci_cap_saved_state *save_state;
+
+ pos = pci_find_capability(dev, cap);
+ if (pos <= 0)
+ return 0;
+
+ save_state = kzalloc(sizeof(*save_state) + size, GFP_KERNEL);
+ if (!save_state)
+ return -ENOMEM;
+
+ save_state->cap_nr = cap;
+ pci_add_saved_cap(dev, save_state);
+
+ return 0;
+}
+
+/**
+ * pci_allocate_cap_save_buffers - allocate buffers for saving capabilities
+ * @dev: the PCI device
+ */
+void pci_allocate_cap_save_buffers(struct pci_dev *dev)
+{
+ int error;
+
+ error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP, 4 * sizeof(u16));
+ if (error)
+ dev_err(&dev->dev,
+ "unable to preallocate PCI Express save buffer\n");
+
+ error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_PCIX, sizeof(u16));
+ if (error)
+ dev_err(&dev->dev,
+ "unable to preallocate PCI-X save buffer\n");
+}
+
+/**
* pci_enable_ari - enable ARI forwarding if hardware support it
* @dev: the PCI device
*/
diff -r cc27ca4b86c1 -r c1f0373ff44e drivers/pci/pci.h
--- a/drivers/pci/pci.h Wed Mar 18 11:43:57 2009 +0000
+++ b/drivers/pci/pci.h Wed Mar 18 11:45:30 2009 +0000
@@ -14,6 +14,8 @@ extern int pci_bus_alloc_resource(struct
/* Firmware callbacks */
extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t
state);
extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t
state);
+
+extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
extern int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val);
diff -r cc27ca4b86c1 -r c1f0373ff44e drivers/pci/probe.c
--- a/drivers/pci/probe.c Wed Mar 18 11:43:57 2009 +0000
+++ b/drivers/pci/probe.c Wed Mar 18 11:45:30 2009 +0000
@@ -892,6 +892,9 @@ void __devinit pci_device_add(struct pci
/* Fix up broken headers */
pci_fixup_device(pci_fixup_header, dev);
+ /* Buffers for saving PCIe and PCI-X capabilities */
+ pci_allocate_cap_save_buffers(dev);
+
/* Alternative Routing-ID Forwarding */
pci_enable_ari(dev);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|