ia64/linux-2.6.18-xen.hg

changeset 831:c1f0373ff44e

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@sisk.pl>
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@linux-foundation.org>
Signed-off-by: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>=
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 18 11:45:30 2009 +0000 (2009-03-18)
parents cc27ca4b86c1
children c0f2f398aa3c
files drivers/pci/pci.c drivers/pci/pci.h drivers/pci/probe.c
line diff
     1.1 --- a/drivers/pci/pci.c	Wed Mar 18 11:43:57 2009 +0000
     1.2 +++ b/drivers/pci/pci.c	Wed Mar 18 11:45:30 2009 +0000
     1.3 @@ -706,6 +706,51 @@ int pci_enable_wake(struct pci_dev *dev,
     1.4  }
     1.5  
     1.6  /**
     1.7 + * pci_add_save_buffer - allocate buffer for saving given capability registers
     1.8 + * @dev: the PCI device
     1.9 + * @cap: the capability to allocate the buffer for
    1.10 + * @size: requested size of the buffer
    1.11 + */
    1.12 +static int pci_add_cap_save_buffer(
    1.13 +	struct pci_dev *dev, char cap, unsigned int size)
    1.14 +{
    1.15 +	int pos;
    1.16 +	struct pci_cap_saved_state *save_state;
    1.17 +
    1.18 +	pos = pci_find_capability(dev, cap);
    1.19 +	if (pos <= 0)
    1.20 +		return 0;
    1.21 +
    1.22 +	save_state = kzalloc(sizeof(*save_state) + size, GFP_KERNEL);
    1.23 +	if (!save_state)
    1.24 +		return -ENOMEM;
    1.25 +
    1.26 +	save_state->cap_nr = cap;
    1.27 +	pci_add_saved_cap(dev, save_state);
    1.28 +
    1.29 +	return 0;
    1.30 +}
    1.31 +
    1.32 +/**
    1.33 + * pci_allocate_cap_save_buffers - allocate buffers for saving capabilities
    1.34 + * @dev: the PCI device
    1.35 + */
    1.36 +void pci_allocate_cap_save_buffers(struct pci_dev *dev)
    1.37 +{
    1.38 +	int error;
    1.39 +
    1.40 +	error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP, 4 * sizeof(u16));
    1.41 +	if (error)
    1.42 +		dev_err(&dev->dev,
    1.43 +			"unable to preallocate PCI Express save buffer\n");
    1.44 +
    1.45 +	error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_PCIX, sizeof(u16));
    1.46 +	if (error)
    1.47 +		dev_err(&dev->dev,
    1.48 +			"unable to preallocate PCI-X save buffer\n");
    1.49 +}
    1.50 +
    1.51 +/**
    1.52   * pci_enable_ari - enable ARI forwarding if hardware support it
    1.53   * @dev: the PCI device
    1.54   */
     2.1 --- a/drivers/pci/pci.h	Wed Mar 18 11:43:57 2009 +0000
     2.2 +++ b/drivers/pci/pci.h	Wed Mar 18 11:45:30 2009 +0000
     2.3 @@ -15,6 +15,8 @@ extern int pci_bus_alloc_resource(struct
     2.4  extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
     2.5  extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state);
     2.6  
     2.7 +extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
     2.8 +
     2.9  extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
    2.10  extern int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val);
    2.11  extern int pci_user_read_config_dword(struct pci_dev *dev, int where, u32 *val);
     3.1 --- a/drivers/pci/probe.c	Wed Mar 18 11:43:57 2009 +0000
     3.2 +++ b/drivers/pci/probe.c	Wed Mar 18 11:45:30 2009 +0000
     3.3 @@ -892,6 +892,9 @@ void __devinit pci_device_add(struct pci
     3.4  	/* Fix up broken headers */
     3.5  	pci_fixup_device(pci_fixup_header, dev);
     3.6  
     3.7 +	/* Buffers for saving PCIe and PCI-X capabilities */
     3.8 +	pci_allocate_cap_save_buffers(dev);
     3.9 + 
    3.10  	/* Alternative Routing-ID Forwarding */
    3.11  	pci_enable_ari(dev);
    3.12