Commit 88d7dda6 authored by Stephen Rothwell's avatar Stephen Rothwell

Merge commit 'pci/linux-next'

Conflicts:
	arch/powerpc/kernel/pci_64.c
parents df0e19f1 4b77b0a2
...@@ -84,6 +84,16 @@ Description: ...@@ -84,6 +84,16 @@ Description:
from this part of the device tree. from this part of the device tree.
Depends on CONFIG_HOTPLUG. Depends on CONFIG_HOTPLUG.
What: /sys/bus/pci/devices/.../reset
Date: July 2009
Contact: Michael S. Tsirkin <mst@redhat.com>
Description:
Some devices allow an individual function to be reset
without affecting other functions in the same device.
For devices that have this support, a file named reset
will be present in sysfs. Writing 1 to this file
will perform reset.
What: /sys/bus/pci/devices/.../vpd What: /sys/bus/pci/devices/.../vpd
Date: February 2008 Date: February 2008
Contact: Ben Hutchings <bhutchings@solarflare.com> Contact: Ben Hutchings <bhutchings@solarflare.com>
......
This diff is collapsed.
VGA Arbiter
===========
Graphic devices are accessed through ranges in I/O or memory space. While most
modern devices allow relocation of such ranges, some "Legacy" VGA devices
implemented on PCI will typically have the same "hard-decoded" addresses as
they did on ISA. For more details see "PCI Bus Binding to IEEE Std 1275-1994
Standard for Boot (Initialization Configuration) Firmware Revision 2.1"
Section 7, Legacy Devices.
The Resource Access Control (RAC) module inside the X server [0] existed for
the legacy VGA arbitration task (besides other bus management tasks) when more
than one legacy device co-exists on the same machine. But the problem happens
when these devices are trying to be accessed by different userspace clients
(e.g. two server in parallel). Their address assignments conflict. Moreover,
ideally, being an userspace application, it is not the role of the the X
server to control bus resources. Therefore an arbitration scheme outside of
the X server is needed to control the sharing of these resources. This
document introduces the operation of the VGA arbiter implemented for Linux
kernel.
----------------------------------------------------------------------------
I. Details and Theory of Operation
I.1 vgaarb
I.2 libpciaccess
I.3 xf86VGAArbiter (X server implementation)
II. Credits
III.References
I. Details and Theory of Operation
==================================
I.1 vgaarb
----------
The vgaarb is a module of the Linux Kernel. When it is initially loaded, it
scans all PCI devices and adds the VGA ones inside the arbitration. The
arbiter then enables/disables the decoding on different devices of the VGA
legacy instructions. Device which do not want/need to use the arbiter may
explicitly tell it by calling vga_set_legacy_decoding().
The kernel exports a char device interface (/dev/vga_arbiter) to the clients,
which has the following semantics:
open : open user instance of the arbiter. By default, it's attached to
the default VGA device of the system.
close : close user instance. Release locks made by the user
read : return a string indicating the status of the target like:
"<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)"
An IO state string is of the form {io,mem,io+mem,none}, mc and
ic are respectively mem and io lock counts (for debugging/
diagnostic only). "decodes" indicate what the card currently
decodes, "owns" indicates what is currently enabled on it, and
"locks" indicates what is locked by this card. If the card is
unplugged, we get "invalid" then for card_ID and an -ENODEV
error is returned for any command until a new card is targeted.
write : write a command to the arbiter. List of commands:
target <card_ID> : switch target to card <card_ID> (see below)
lock <io_state> : acquires locks on target ("none" is an invalid io_state)
trylock <io_state> : non-blocking acquire locks on target (returns EBUSY if
unsuccessful)
unlock <io_state> : release locks on target
unlock all : release all locks on target held by this user (not
implemented yet)
decodes <io_state> : set the legacy decoding attributes for the card
poll : event if something changes on any card (not just the
target)
card_ID is of the form "PCI:domain:bus:dev.fn". It can be set to "default"
to go back to the system default card (TODO: not implemented yet). Currently,
only PCI is supported as a prefix, but the userland API may support other bus
types in the future, even if the current kernel implementation doesn't.
Note about locks:
The driver keeps track of which user has which locks on which card. It
supports stacking, like the kernel one. This complexifies the implementation
a bit, but makes the arbiter more tolerant to user space problems and able
to properly cleanup in all cases when a process dies.
Currently, a max of 16 cards can have locks simultaneously issued from
user space for a given user (file descriptor instance) of the arbiter.
In the case of devices hot-{un,}plugged, there is a hook - pci_notify() - to
notify them being added/removed in the system and automatically added/removed
in the arbiter.
There's also a in-kernel API of the arbiter in the case of DRM, vgacon and
others which may use the arbiter.
I.2 libpciaccess
----------------
To use the vga arbiter char device it was implemented an API inside the
libpciaccess library. One fieldd was added to struct pci_device (each device
on the system):
/* the type of resource decoded by the device */
int vgaarb_rsrc;
Besides it, in pci_system were added:
int vgaarb_fd;
int vga_count;
struct pci_device *vga_target;
struct pci_device *vga_default_dev;
The vga_count is usually need to keep informed how many cards are being
arbitrated, so for instance if there's only one then it can totally escape the
scheme.
These functions below acquire VGA resources for the given card and mark those
resources as locked. If the resources requested are "normal" (and not legacy)
resources, the arbiter will first check whether the card is doing legacy
decoding for that type of resource. If yes, the lock is "converted" into a
legacy resource lock. The arbiter will first look for all VGA cards that
might conflict and disable their IOs and/or Memory access, including VGA
forwarding on P2P bridges if necessary, so that the requested resources can
be used. Then, the card is marked as locking these resources and the IO and/or
Memory access is enabled on the card (including VGA forwarding on parent
P2P bridges if any). In the case of vga_arb_lock(), the function will block
if some conflicting card is already locking one of the required resources (or
any resource on a different bus segment, since P2P bridges don't differentiate
VGA memory and IO afaik). If the card already owns the resources, the function
succeeds. vga_arb_trylock() will return (-EBUSY) instead of blocking. Nested
calls are supported (a per-resource counter is maintained).
Set the target device of this client.
int pci_device_vgaarb_set_target (struct pci_device *dev);
For instance, in x86 if two devices on the same bus want to lock different
resources, both will succeed (lock). If devices are in different buses and
trying to lock different resources, only the first who tried succeeds.
int pci_device_vgaarb_lock (void);
int pci_device_vgaarb_trylock (void);
Unlock resources of device.
int pci_device_vgaarb_unlock (void);
Indicates to the arbiter if the card decodes legacy VGA IOs, legacy VGA
Memory, both, or none. All cards default to both, the card driver (fbdev for
example) should tell the arbiter if it has disabled legacy decoding, so the
card can be left out of the arbitration process (and can be safe to take
interrupts at any time.
int pci_device_vgaarb_decodes (int new_vgaarb_rsrc);
Connects to the arbiter device, allocates the struct
int pci_device_vgaarb_init (void);
Close the connection
void pci_device_vgaarb_fini (void);
I.3 xf86VGAArbiter (X server implementation)
--------------------------------------------
(TODO)
X server basically wraps all the functions that touch VGA registers somehow.
II. Credits
===========
Benjamin Herrenschmidt (IBM?) started this work when he discussed such design
with the Xorg community in 2005 [1, 2]. In the end of 2007, Paulo Zanoni and
Tiago Vignatti (both of C3SL/Federal University of Paraná) proceeded his work
enhancing the kernel code to adapt as a kernel module and also did the
implementation of the user space side [3]. Now (2009) Tiago Vignatti and Dave
Airlie finally put this work in shape and queued to Jesse Barnes' PCI tree.
III. References
==============
[0] http://cgit.freedesktop.org/xorg/xserver/commit/?id=4b42448a2388d40f257774fbffdccaea87bd0347
[1] http://lists.freedesktop.org/archives/xorg/2005-March/006663.html
[2] http://lists.freedesktop.org/archives/xorg/2005-March/006745.html
[3] http://lists.freedesktop.org/archives/xorg/2007-October/029507.html
...@@ -52,7 +52,6 @@ struct pci_controller { ...@@ -52,7 +52,6 @@ struct pci_controller {
bus numbers. */ bus numbers. */
#define pcibios_assign_all_busses() 1 #define pcibios_assign_all_busses() 1
#define pcibios_scan_all_fns(a, b) 0
#define PCIBIOS_MIN_IO alpha_mv.min_io_address #define PCIBIOS_MIN_IO alpha_mv.min_io_address
#define PCIBIOS_MIN_MEM alpha_mv.min_mem_address #define PCIBIOS_MIN_MEM alpha_mv.min_mem_address
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include <mach/hardware.h> /* for PCIBIOS_MIN_* */ #include <mach/hardware.h> /* for PCIBIOS_MIN_* */
#define pcibios_scan_all_fns(a, b) 0
#ifdef CONFIG_PCI_HOST_ITE8152 #ifdef CONFIG_PCI_HOST_ITE8152
/* ITE bridge requires setting latency timer to avoid early bus access /* ITE bridge requires setting latency timer to avoid early bus access
termination by PIC bus mater devices termination by PIC bus mater devices
......
...@@ -86,7 +86,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) ...@@ -86,7 +86,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
struct pci_bus *bus; struct pci_bus *bus;
struct pci_dev *dev; struct pci_dev *dev;
int idx; int idx;
struct resource *r, *pr; struct resource *r;
/* Depth-First Search on bus tree */ /* Depth-First Search on bus tree */
for (ln=bus_list->next; ln != bus_list; ln=ln->next) { for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
...@@ -96,8 +96,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) ...@@ -96,8 +96,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
r = &dev->resource[idx]; r = &dev->resource[idx];
if (!r->start) if (!r->start)
continue; continue;
pr = pci_find_parent_resource(dev, r); if (pci_claim_resource(dev, idx) < 0)
if (!pr || request_resource(pr, r) < 0)
printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev)); printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev));
} }
} }
...@@ -110,7 +109,7 @@ static void __init pcibios_allocate_resources(int pass) ...@@ -110,7 +109,7 @@ static void __init pcibios_allocate_resources(int pass)
struct pci_dev *dev = NULL; struct pci_dev *dev = NULL;
int idx, disabled; int idx, disabled;
u16 command; u16 command;
struct resource *r, *pr; struct resource *r;
for_each_pci_dev(dev) { for_each_pci_dev(dev) {
pci_read_config_word(dev, PCI_COMMAND, &command); pci_read_config_word(dev, PCI_COMMAND, &command);
...@@ -127,8 +126,7 @@ static void __init pcibios_allocate_resources(int pass) ...@@ -127,8 +126,7 @@ static void __init pcibios_allocate_resources(int pass)
if (pass == disabled) { if (pass == disabled) {
DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n", DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n",
r->start, r->end, r->flags, disabled, pass); r->start, r->end, r->flags, disabled, pass);
pr = pci_find_parent_resource(dev, r); if (pci_claim_resource(dev, idx) < 0) {
if (!pr || request_resource(pr, r) < 0) {
printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev)); printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev));
/* We'll assign a new address later */ /* We'll assign a new address later */
r->end -= r->start; r->end -= r->start;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
*/ */
#define pcibios_assign_all_busses() 0 #define pcibios_assign_all_busses() 0
#define pcibios_scan_all_fns(a, b) 0
static inline void pcibios_set_master(struct pci_dev *dev) static inline void pcibios_set_master(struct pci_dev *dev)
{ {
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* loader. * loader.
*/ */
#define pcibios_assign_all_busses() 0 #define pcibios_assign_all_busses() 0
#define pcibios_scan_all_fns(a, b) 0
#define PCIBIOS_MIN_IO 0x1000 #define PCIBIOS_MIN_IO 0x1000
#define PCIBIOS_MIN_MEM 0x10000000 #define PCIBIOS_MIN_MEM 0x10000000
...@@ -135,7 +134,18 @@ extern void pcibios_resource_to_bus(struct pci_dev *dev, ...@@ -135,7 +134,18 @@ extern void pcibios_resource_to_bus(struct pci_dev *dev,
extern void pcibios_bus_to_resource(struct pci_dev *dev, extern void pcibios_bus_to_resource(struct pci_dev *dev,
struct resource *res, struct pci_bus_region *region); struct resource *res, struct pci_bus_region *region);
#define pcibios_scan_all_fns(a, b) 0 static inline struct resource *
pcibios_select_root(struct pci_dev *pdev, struct resource *res)
{
struct resource *root = NULL;
if (res->flags & IORESOURCE_IO)
root = &ioport_resource;
if (res->flags & IORESOURCE_MEM)
root = &iomem_resource;
return root;
}
#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ #define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
......
...@@ -65,8 +65,6 @@ extern int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin); ...@@ -65,8 +65,6 @@ extern int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
extern unsigned int pcibios_assign_all_busses(void); extern unsigned int pcibios_assign_all_busses(void);
#define pcibios_scan_all_fns(a, b) 0
extern unsigned long PCIBIOS_MIN_IO; extern unsigned long PCIBIOS_MIN_IO;
extern unsigned long PCIBIOS_MIN_MEM; extern unsigned long PCIBIOS_MIN_MEM;
......
...@@ -101,7 +101,18 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev, ...@@ -101,7 +101,18 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev,
struct resource *res, struct resource *res,
struct pci_bus_region *region); struct pci_bus_region *region);
#define pcibios_scan_all_fns(a, b) 0 static inline struct resource *
pcibios_select_root(struct pci_dev *pdev, struct resource *res)
{
struct resource *root = NULL;
if (res->flags & IORESOURCE_IO)
root = &ioport_resource;
if (res->flags & IORESOURCE_MEM)
root = &iomem_resource;
return root;
}
static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
{ {
......
...@@ -233,7 +233,6 @@ static inline void pcibios_register_hba(struct pci_hba_data *x) ...@@ -233,7 +233,6 @@ static inline void pcibios_register_hba(struct pci_hba_data *x)
* rp7420/8420 boxes and then revisit this issue. * rp7420/8420 boxes and then revisit this issue.
*/ */
#define pcibios_assign_all_busses() (1) #define pcibios_assign_all_busses() (1)
#define pcibios_scan_all_fns(a, b) (0)
#define PCIBIOS_MIN_IO 0x10 #define PCIBIOS_MIN_IO 0x10
#define PCIBIOS_MIN_MEM 0x1000 /* NBPG - but pci/setup-res.c dies */ #define PCIBIOS_MIN_MEM 0x1000 /* NBPG - but pci/setup-res.c dies */
......
...@@ -45,7 +45,6 @@ struct pci_dev; ...@@ -45,7 +45,6 @@ struct pci_dev;
*/ */
#define pcibios_assign_all_busses() \ #define pcibios_assign_all_busses() \
(ppc_pci_has_flag(PPC_PCI_REASSIGN_ALL_BUS)) (ppc_pci_has_flag(PPC_PCI_REASSIGN_ALL_BUS))
#define pcibios_scan_all_fns(a, b) 0
static inline void pcibios_set_master(struct pci_dev *dev) static inline void pcibios_set_master(struct pci_dev *dev)
{ {
......
...@@ -139,6 +139,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, ...@@ -139,6 +139,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
dev->dev.bus = &pci_bus_type; dev->dev.bus = &pci_bus_type;
dev->devfn = devfn; dev->devfn = devfn;
dev->multifunction = 0; /* maybe a lie? */ dev->multifunction = 0; /* maybe a lie? */
dev->needs_freset = 0; /* pcie fundamental reset required */
dev->vendor = get_int_prop(node, "vendor-id", 0xffff); dev->vendor = get_int_prop(node, "vendor-id", 0xffff);
dev->device = get_int_prop(node, "device-id", 0xffff); dev->device = get_int_prop(node, "device-id", 0xffff);
......
...@@ -744,7 +744,15 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state stat ...@@ -744,7 +744,15 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state stat
static void __rtas_set_slot_reset(struct pci_dn *pdn) static void __rtas_set_slot_reset(struct pci_dn *pdn)
{ {
rtas_pci_slot_reset (pdn, 1); struct pci_dev *dev = pdn->pcidev;
/* Determine type of EEH reset required by device,
* default hot reset or fundamental reset
*/
if (dev->needs_freset)
rtas_pci_slot_reset(pdn, 3);
else
rtas_pci_slot_reset(pdn, 1);
/* The PCI bus requires that the reset be held high for at least /* The PCI bus requires that the reset be held high for at least
* a 100 milliseconds. We wait a bit longer 'just in case'. */ * a 100 milliseconds. We wait a bit longer 'just in case'. */
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
or architectures with incomplete PCI setup by the loader */ or architectures with incomplete PCI setup by the loader */
#define pcibios_assign_all_busses() 1 #define pcibios_assign_all_busses() 1
#define pcibios_scan_all_fns(a, b) 0
/* /*
* A board can define one or more PCI channels that represent built-in (or * A board can define one or more PCI channels that represent built-in (or
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
* or architectures with incomplete PCI setup by the loader. * or architectures with incomplete PCI setup by the loader.
*/ */
#define pcibios_assign_all_busses() 0 #define pcibios_assign_all_busses() 0
#define pcibios_scan_all_fns(a, b) 0
#define PCIBIOS_MIN_IO 0UL #define PCIBIOS_MIN_IO 0UL
#define PCIBIOS_MIN_MEM 0UL #define PCIBIOS_MIN_MEM 0UL
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
* or architectures with incomplete PCI setup by the loader. * or architectures with incomplete PCI setup by the loader.
*/ */
#define pcibios_assign_all_busses() 0 #define pcibios_assign_all_busses() 0
#define pcibios_scan_all_fns(a, b) 0
#define PCIBIOS_MIN_IO 0UL #define PCIBIOS_MIN_IO 0UL
#define PCIBIOS_MIN_MEM 0UL #define PCIBIOS_MIN_MEM 0UL
......
...@@ -2,6 +2,5 @@ ...@@ -2,6 +2,5 @@
#define __UM_PCI_H #define __UM_PCI_H
#define PCI_DMA_BUS_IS_PHYS (1) #define PCI_DMA_BUS_IS_PHYS (1)
#define pcibios_scan_all_fns(a, b) 0
#endif #endif
...@@ -48,7 +48,6 @@ extern unsigned int pcibios_assign_all_busses(void); ...@@ -48,7 +48,6 @@ extern unsigned int pcibios_assign_all_busses(void);
#else #else
#define pcibios_assign_all_busses() 0 #define pcibios_assign_all_busses() 0
#endif #endif
#define pcibios_scan_all_fns(a, b) 0
extern unsigned long pci_mem_start; extern unsigned long pci_mem_start;
#define PCIBIOS_MIN_IO 0x1000 #define PCIBIOS_MIN_IO 0x1000
......
...@@ -225,10 +225,8 @@ static __init int iommu_setup(char *p) ...@@ -225,10 +225,8 @@ static __init int iommu_setup(char *p)
if (!strncmp(p, "soft", 4)) if (!strncmp(p, "soft", 4))
swiotlb = 1; swiotlb = 1;
#endif #endif
if (!strncmp(p, "pt", 2)) { if (!strncmp(p, "pt", 2))
iommu_pass_through = 1; iommu_pass_through = 1;
return 1;
}
gart_parse_options(p); gart_parse_options(p);
......
...@@ -508,7 +508,7 @@ static void __init quirk_amd_nb_node(struct pci_dev *dev) ...@@ -508,7 +508,7 @@ static void __init quirk_amd_nb_node(struct pci_dev *dev)
pci_read_config_dword(nb_ht, 0x60, &val); pci_read_config_dword(nb_ht, 0x60, &val);
set_dev_node(&dev->dev, val & 7); set_dev_node(&dev->dev, val & 7);
pci_dev_put(dev); pci_dev_put(nb_ht);
} }
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB, DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB,
......
...@@ -15,63 +15,6 @@ ...@@ -15,63 +15,6 @@
* also get peer root bus resource for io,mmio * also get peer root bus resource for io,mmio
*/ */
#ifdef CONFIG_NUMA
#define BUS_NR 256
#ifdef CONFIG_X86_64
static int mp_bus_to_node[BUS_NR];
void set_mp_bus_to_node(int busnum, int node)
{
if (busnum >= 0 && busnum < BUS_NR)
mp_bus_to_node[busnum] = node;
}
int get_mp_bus_to_node(int busnum)
{
int node = -1;
if (busnum < 0 || busnum > (BUS_NR - 1))
return node;
node = mp_bus_to_node[busnum];
/*
* let numa_node_id to decide it later in dma_alloc_pages
* if there is no ram on that node
*/
if (node != -1 && !node_online(node))
node = -1;
return node;
}
#else /* CONFIG_X86_32 */
static unsigned char mp_bus_to_node[BUS_NR];
void set_mp_bus_to_node(int busnum, int node)
{
if (busnum >= 0 && busnum < BUS_NR)
mp_bus_to_node[busnum] = (unsigned char) node;
}
int get_mp_bus_to_node(int busnum)
{
int node;
if (busnum < 0 || busnum > (BUS_NR - 1))
return 0;
node = mp_bus_to_node[busnum];
return node;
}
#endif /* CONFIG_X86_32 */
#endif /* CONFIG_NUMA */
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
/* /*
...@@ -301,11 +244,6 @@ static int __init early_fill_mp_bus_info(void) ...@@ -301,11 +244,6 @@ static int __init early_fill_mp_bus_info(void)
u64 val; u64 val;
u32 address; u32 address;
#ifdef CONFIG_NUMA
for (i = 0; i < BUS_NR; i++)
mp_bus_to_node[i] = -1;
#endif
if (!early_pci_allowed()) if (!early_pci_allowed())
return -1; return -1;
...@@ -346,7 +284,7 @@ static int __init early_fill_mp_bus_info(void) ...@@ -346,7 +284,7 @@ static int __init early_fill_mp_bus_info(void)
node = (reg >> 4) & 0x07; node = (reg >> 4) & 0x07;
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
for (j = min_bus; j <= max_bus; j++) for (j = min_bus; j <= max_bus; j++)
mp_bus_to_node[j] = (unsigned char) node; set_mp_bus_to_node(j, node);
#endif #endif
link = (reg >> 8) & 0x03; link = (reg >> 8) & 0x03;
......
...@@ -600,3 +600,72 @@ struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno) ...@@ -600,3 +600,72 @@ struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
{ {
return pci_scan_bus_on_node(busno, &pci_root_ops, -1); return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
} }
/*
* NUMA info for PCI busses
*
* Early arch code is responsible for filling in reasonable values here.
* A node id of "-1" means "use current node". In other words, if a bus
* has a -1 node id, it's not tightly coupled to any particular chunk
* of memory (as is the case on some Nehalem systems).
*/
#ifdef CONFIG_NUMA
#define BUS_NR 256
#ifdef CONFIG_X86_64
static int mp_bus_to_node[BUS_NR] = {
[0 ... BUS_NR - 1] = -1
};
void set_mp_bus_to_node(int busnum, int node)
{
if (busnum >= 0 && busnum < BUS_NR)
mp_bus_to_node[busnum] = node;
}
int get_mp_bus_to_node(int busnum)
{
int node = -1;
if (busnum < 0 || busnum > (BUS_NR - 1))
return node;
node = mp_bus_to_node[busnum];
/*
* let numa_node_id to decide it later in dma_alloc_pages
* if there is no ram on that node
*/
if (node != -1 && !node_online(node))
node = -1;
return node;
}
#else /* CONFIG_X86_32 */
static unsigned char mp_bus_to_node[BUS_NR] = {
[0 ... BUS_NR - 1] = -1
};
void set_mp_bus_to_node(int busnum, int node)
{
if (busnum >= 0 && busnum < BUS_NR)
mp_bus_to_node[busnum] = (unsigned char) node;
}
int get_mp_bus_to_node(int busnum)
{
int node;
if (busnum < 0 || busnum > (BUS_NR - 1))
return 0;
node = mp_bus_to_node[busnum];
return node;
}
#endif /* CONFIG_X86_32 */
#endif /* CONFIG_NUMA */
...@@ -61,20 +61,6 @@ static struct acpi_driver acpi_pci_root_driver = { ...@@ -61,20 +61,6 @@ static struct acpi_driver acpi_pci_root_driver = {
}, },
}; };
struct acpi_pci_root {
struct list_head node;
struct acpi_device *device;
struct pci_bus *bus;
u16 segment;
u8 bus_nr;
u32 osc_support_set; /* _OSC state of support bits */
u32 osc_control_set; /* _OSC state of control bits */
u32 osc_control_qry; /* the latest _OSC query result */
u32 osc_queried:1; /* has _OSC control been queried? */
};
static LIST_HEAD(acpi_pci_roots); static LIST_HEAD(acpi_pci_roots);
static struct acpi_pci_driver *sub_driver; static struct acpi_pci_driver *sub_driver;
...@@ -317,7 +303,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags) ...@@ -317,7 +303,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
return status; return status;
} }
static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
{ {
struct acpi_pci_root *root; struct acpi_pci_root *root;
...@@ -327,6 +313,7 @@ static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) ...@@ -327,6 +313,7 @@ static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
} }
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(acpi_pci_find_root);
struct acpi_handle_node { struct acpi_handle_node {
struct list_head node; struct list_head node;
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h> #include <acpi/acpi_drivers.h>
#include "sleep.h"
#define _COMPONENT ACPI_POWER_COMPONENT #define _COMPONENT ACPI_POWER_COMPONENT
ACPI_MODULE_NAME("power"); ACPI_MODULE_NAME("power");
#define ACPI_POWER_CLASS "power_resource" #define ACPI_POWER_CLASS "power_resource"
...@@ -361,17 +363,15 @@ int acpi_device_sleep_wake(struct acpi_device *dev, ...@@ -361,17 +363,15 @@ int acpi_device_sleep_wake(struct acpi_device *dev,
*/ */
int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
{ {
int i, err; int i, err = 0;
if (!dev || !dev->wakeup.flags.valid) if (!dev || !dev->wakeup.flags.valid)
return -EINVAL; return -EINVAL;
/* mutex_lock(&acpi_device_lock);
* Do not execute the code below twice in a row without calling
* acpi_disable_wakeup_device_power() in between for the same device if (dev->wakeup.prepare_count++)
*/ goto out;
if (dev->wakeup.flags.prepared)
return 0;
/* Open power resource */ /* Open power resource */
for (i = 0; i < dev->wakeup.resources.count; i++) { for (i = 0; i < dev->wakeup.resources.count; i++) {
...@@ -379,7 +379,8 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) ...@@ -379,7 +379,8 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
if (ret) { if (ret) {
printk(KERN_ERR PREFIX "Transition power state\n"); printk(KERN_ERR PREFIX "Transition power state\n");
dev->wakeup.flags.valid = 0; dev->wakeup.flags.valid = 0;
return -ENODEV; err = -ENODEV;
goto err_out;
} }
} }
...@@ -388,9 +389,13 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) ...@@ -388,9 +389,13 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
* in arbitrary power state afterwards. * in arbitrary power state afterwards.
*/ */
err = acpi_device_sleep_wake(dev, 1, sleep_state, 3); err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
if (!err)
dev->wakeup.flags.prepared = 1;
err_out:
if (err)
dev->wakeup.prepare_count = 0;
out:
mutex_unlock(&acpi_device_lock);
return err; return err;
} }
...@@ -402,35 +407,42 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) ...@@ -402,35 +407,42 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
*/ */
int acpi_disable_wakeup_device_power(struct acpi_device *dev) int acpi_disable_wakeup_device_power(struct acpi_device *dev)
{ {
int i, ret; int i, err = 0;
if (!dev || !dev->wakeup.flags.valid) if (!dev || !dev->wakeup.flags.valid)
return -EINVAL; return -EINVAL;
mutex_lock(&acpi_device_lock);
if (--dev->wakeup.prepare_count > 0)
goto out;
/* /*
* Do not execute the code below twice in a row without calling * Executing the code below even if prepare_count is already zero when
* acpi_enable_wakeup_device_power() in between for the same device * the function is called may be useful, for example for initialisation.
*/ */
if (!dev->wakeup.flags.prepared) if (dev->wakeup.prepare_count < 0)
return 0; dev->wakeup.prepare_count = 0;
dev->wakeup.flags.prepared = 0; err = acpi_device_sleep_wake(dev, 0, 0, 0);
if (err)
ret = acpi_device_sleep_wake(dev, 0, 0, 0); goto out;
if (ret)
return ret;
/* Close power resource */ /* Close power resource */
for (i = 0; i < dev->wakeup.resources.count; i++) { for (i = 0; i < dev->wakeup.resources.count; i++) {
ret = acpi_power_off_device(dev->wakeup.resources.handles[i], dev); int ret = acpi_power_off_device(
dev->wakeup.resources.handles[i], dev);
if (ret) { if (ret) {
printk(KERN_ERR PREFIX "Transition power state\n"); printk(KERN_ERR PREFIX "Transition power state\n");
dev->wakeup.flags.valid = 0; dev->wakeup.flags.valid = 0;
return -ENODEV; err = -ENODEV;
goto out;
} }
} }
return ret; out:
mutex_unlock(&acpi_device_lock);
return err;
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
......
...@@ -781,6 +781,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device) ...@@ -781,6 +781,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
kfree(buffer.pointer); kfree(buffer.pointer);
device->wakeup.flags.valid = 1; device->wakeup.flags.valid = 1;
device->wakeup.prepare_count = 0;
/* Call _PSW/_DSW object to disable its ability to wake the sleeping /* Call _PSW/_DSW object to disable its ability to wake the sleeping
* system for the ACPI device with the _PRW object. * system for the ACPI device with the _PRW object.
* The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW. * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
......
...@@ -689,19 +689,25 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable) ...@@ -689,19 +689,25 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
{ {
acpi_handle handle; acpi_handle handle;
struct acpi_device *adev; struct acpi_device *adev;
int error;
if (!device_may_wakeup(dev)) if (!device_can_wakeup(dev))
return -EINVAL; return -EINVAL;
handle = DEVICE_ACPI_HANDLE(dev); handle = DEVICE_ACPI_HANDLE(dev);
if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
printk(KERN_DEBUG "ACPI handle has no context!\n"); dev_dbg(dev, "ACPI handle has no context in %s!\n", __func__);
return -ENODEV; return -ENODEV;
} }
return enable ? error = enable ?
acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) : acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) :
acpi_disable_wakeup_device_power(adev); acpi_disable_wakeup_device_power(adev);
if (!error)
dev_info(dev, "wake-up capability %s by ACPI\n",
enable ? "enabled" : "disabled");
return error;
} }
#endif #endif
......
...@@ -68,7 +68,7 @@ void acpi_enable_wakeup_device(u8 sleep_state) ...@@ -68,7 +68,7 @@ void acpi_enable_wakeup_device(u8 sleep_state)
/* If users want to disable run-wake GPE, /* If users want to disable run-wake GPE,
* we only disable it for wake and leave it for runtime * we only disable it for wake and leave it for runtime
*/ */
if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared) if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count)
|| sleep_state > (u32) dev->wakeup.sleep_state) { || sleep_state > (u32) dev->wakeup.sleep_state) {
if (dev->wakeup.flags.run_wake) { if (dev->wakeup.flags.run_wake) {
/* set_gpe_type will disable GPE, leave it like that */ /* set_gpe_type will disable GPE, leave it like that */
...@@ -100,7 +100,7 @@ void acpi_disable_wakeup_device(u8 sleep_state) ...@@ -100,7 +100,7 @@ void acpi_disable_wakeup_device(u8 sleep_state)
if (!dev->wakeup.flags.valid) if (!dev->wakeup.flags.valid)
continue; continue;
if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared) if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count)
|| sleep_state > (u32) dev->wakeup.sleep_state) { || sleep_state > (u32) dev->wakeup.sleep_state) {
if (dev->wakeup.flags.run_wake) { if (dev->wakeup.flags.run_wake) {
acpi_set_gpe_type(dev->wakeup.gpe_device, acpi_set_gpe_type(dev->wakeup.gpe_device,
......
obj-y += drm/ obj-y += drm/ vga/
config VGA_ARB
bool "VGA Arbitration" if EMBEDDED
default y
depends on PCI
help
Some "legacy" VGA devices implemented on PCI typically have the same
hard-decoded addresses as they did on ISA. When multiple PCI devices
are accessed at same time they need some kind of coordination. Please
see Documentation/vgaarbiter.txt for more details. Select this to
enable VGA arbiter.
obj-$(CONFIG_VGA_ARB) += vgaarb.o
This diff is collapsed.
...@@ -8,6 +8,9 @@ obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \ ...@@ -8,6 +8,9 @@ obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \
obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_PROC_FS) += proc.o
obj-$(CONFIG_SYSFS) += slot.o obj-$(CONFIG_SYSFS) += slot.o
obj-$(CONFIG_PCI_LEGACY) += legacy.o
CFLAGS_legacy.o += -Wno-deprecated-declarations
# Build PCI Express stuff if needed # Build PCI Express stuff if needed
obj-$(CONFIG_PCIEPORTBUS) += pcie/ obj-$(CONFIG_PCIEPORTBUS) += pcie/
......
...@@ -500,18 +500,18 @@ check_hotplug(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -500,18 +500,18 @@ check_hotplug(acpi_handle handle, u32 lvl, void *context, void **rv)
/** /**
* acpi_pci_detect_ejectable - check if the PCI bus has ejectable slots * acpi_pci_detect_ejectable - check if the PCI bus has ejectable slots
* @pbus - PCI bus to scan * @handle - handle of the PCI bus to scan
* *
* Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise. * Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise.
*/ */
int acpi_pci_detect_ejectable(struct pci_bus *pbus) int acpi_pci_detect_ejectable(acpi_handle handle)
{ {
acpi_handle handle;
int found = 0; int found = 0;
if (!(handle = acpi_pci_get_bridge_handle(pbus))) if (!handle)
return 0; return found;
acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
check_hotplug, (void *)&found, NULL); check_hotplug, (void *)&found, NULL);
return found; return found;
} }
......
...@@ -261,14 +261,11 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -261,14 +261,11 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
/* see if it's worth looking at this bridge */ /* see if it's worth looking at this bridge */
static int detect_ejectable_slots(struct pci_bus *pbus) static int detect_ejectable_slots(acpi_handle handle)
{ {
int found = acpi_pci_detect_ejectable(pbus); int found = acpi_pci_detect_ejectable(handle);
if (!found) { if (!found) {
acpi_handle bridge_handle = acpi_pci_get_bridge_handle(pbus); acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
if (!bridge_handle)
return 0;
acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1,
is_pci_dock_device, (void *)&found, NULL); is_pci_dock_device, (void *)&found, NULL);
} }
return found; return found;
...@@ -399,9 +396,10 @@ static inline void config_p2p_bridge_flags(struct acpiphp_bridge *bridge) ...@@ -399,9 +396,10 @@ static inline void config_p2p_bridge_flags(struct acpiphp_bridge *bridge)
/* allocate and initialize host bridge data structure */ /* allocate and initialize host bridge data structure */
static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus) static void add_host_bridge(acpi_handle *handle)
{ {
struct acpiphp_bridge *bridge; struct acpiphp_bridge *bridge;
struct acpi_pci_root *root = acpi_pci_find_root(handle);
bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
if (bridge == NULL) if (bridge == NULL)
...@@ -410,7 +408,7 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus) ...@@ -410,7 +408,7 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus)
bridge->type = BRIDGE_TYPE_HOST; bridge->type = BRIDGE_TYPE_HOST;
bridge->handle = handle; bridge->handle = handle;
bridge->pci_bus = pci_bus; bridge->pci_bus = root->bus;
spin_lock_init(&bridge->res_lock); spin_lock_init(&bridge->res_lock);
...@@ -419,7 +417,7 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus) ...@@ -419,7 +417,7 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus)
/* allocate and initialize PCI-to-PCI bridge data structure */ /* allocate and initialize PCI-to-PCI bridge data structure */
static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev) static void add_p2p_bridge(acpi_handle *handle)
{ {
struct acpiphp_bridge *bridge; struct acpiphp_bridge *bridge;
...@@ -433,8 +431,8 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev) ...@@ -433,8 +431,8 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev)
bridge->handle = handle; bridge->handle = handle;
config_p2p_bridge_flags(bridge); config_p2p_bridge_flags(bridge);
bridge->pci_dev = pci_dev_get(pci_dev); bridge->pci_dev = acpi_get_pci_dev(handle);
bridge->pci_bus = pci_dev->subordinate; bridge->pci_bus = bridge->pci_dev->subordinate;
if (!bridge->pci_bus) { if (!bridge->pci_bus) {
err("This is not a PCI-to-PCI bridge!\n"); err("This is not a PCI-to-PCI bridge!\n");
goto err; goto err;
...@@ -451,7 +449,7 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev) ...@@ -451,7 +449,7 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev)
init_bridge_misc(bridge); init_bridge_misc(bridge);
return; return;
err: err:
pci_dev_put(pci_dev); pci_dev_put(bridge->pci_dev);
kfree(bridge); kfree(bridge);
return; return;
} }
...@@ -462,39 +460,21 @@ static acpi_status ...@@ -462,39 +460,21 @@ static acpi_status
find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
{ {
acpi_status status; acpi_status status;
acpi_handle dummy_handle;
unsigned long long tmp;
int device, function;
struct pci_dev *dev; struct pci_dev *dev;
struct pci_bus *pci_bus = context;
status = acpi_get_handle(handle, "_ADR", &dummy_handle);
if (ACPI_FAILURE(status))
return AE_OK; /* continue */
status = acpi_evaluate_integer(handle, "_ADR", NULL, &tmp);
if (ACPI_FAILURE(status)) {
dbg("%s: _ADR evaluation failure\n", __func__);
return AE_OK;
}
device = (tmp >> 16) & 0xffff;
function = tmp & 0xffff;
dev = pci_get_slot(pci_bus, PCI_DEVFN(device, function));
dev = acpi_get_pci_dev(handle);
if (!dev || !dev->subordinate) if (!dev || !dev->subordinate)
goto out; goto out;
/* check if this bridge has ejectable slots */ /* check if this bridge has ejectable slots */
if ((detect_ejectable_slots(dev->subordinate) > 0)) { if ((detect_ejectable_slots(handle) > 0)) {
dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev));
add_p2p_bridge(handle, dev); add_p2p_bridge(handle);
} }
/* search P2P bridges under this p2p bridge */ /* search P2P bridges under this p2p bridge */
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
find_p2p_bridge, dev->subordinate, NULL); find_p2p_bridge, NULL, NULL);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
warn("find_p2p_bridge failed (error code = 0x%x)\n", status); warn("find_p2p_bridge failed (error code = 0x%x)\n", status);
...@@ -509,9 +489,7 @@ static int add_bridge(acpi_handle handle) ...@@ -509,9 +489,7 @@ static int add_bridge(acpi_handle handle)
{ {
acpi_status status; acpi_status status;
unsigned long long tmp; unsigned long long tmp;
int seg, bus;
acpi_handle dummy_handle; acpi_handle dummy_handle;
struct pci_bus *pci_bus;
/* if the bridge doesn't have _STA, we assume it is always there */ /* if the bridge doesn't have _STA, we assume it is always there */
status = acpi_get_handle(handle, "_STA", &dummy_handle); status = acpi_get_handle(handle, "_STA", &dummy_handle);
...@@ -526,36 +504,15 @@ static int add_bridge(acpi_handle handle) ...@@ -526,36 +504,15 @@ static int add_bridge(acpi_handle handle)
return 0; return 0;
} }
/* get PCI segment number */
status = acpi_evaluate_integer(handle, "_SEG", NULL, &tmp);
seg = ACPI_SUCCESS(status) ? tmp : 0;
/* get PCI bus number */
status = acpi_evaluate_integer(handle, "_BBN", NULL, &tmp);
if (ACPI_SUCCESS(status)) {
bus = tmp;
} else {
warn("can't get bus number, assuming 0\n");
bus = 0;
}
pci_bus = pci_find_bus(seg, bus);
if (!pci_bus) {
err("Can't find bus %04x:%02x\n", seg, bus);
return 0;
}
/* check if this bridge has ejectable slots */ /* check if this bridge has ejectable slots */
if (detect_ejectable_slots(pci_bus) > 0) { if (detect_ejectable_slots(handle) > 0) {
dbg("found PCI host-bus bridge with hot-pluggable slots\n"); dbg("found PCI host-bus bridge with hot-pluggable slots\n");
add_host_bridge(handle, pci_bus); add_host_bridge(handle);
} }
/* search P2P bridges under this host bridge */ /* search P2P bridges under this host bridge */
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
find_p2p_bridge, pci_bus, NULL); find_p2p_bridge, NULL, NULL);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
warn("find_p2p_bridge failed (error code = 0x%x)\n", status); warn("find_p2p_bridge failed (error code = 0x%x)\n", status);
...@@ -1387,24 +1344,23 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus) ...@@ -1387,24 +1344,23 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
/* Program resources in newly inserted bridge */ /* Program resources in newly inserted bridge */
static int acpiphp_configure_bridge (acpi_handle handle) static int acpiphp_configure_bridge (acpi_handle handle)
{ {
struct pci_dev *dev;
struct pci_bus *bus; struct pci_bus *bus;
dev = acpi_get_pci_dev(handle); if (acpi_is_root_bridge(handle)) {
if (!dev) { struct acpi_pci_root *root = acpi_pci_find_root(handle);
err("cannot get PCI domain and bus number for bridge\n"); bus = root->bus;
return -EINVAL; } else {
struct pci_dev *pdev = acpi_get_pci_dev(handle);
bus = pdev->subordinate;
pci_dev_put(pdev);
} }
bus = dev->bus;
pci_bus_size_bridges(bus); pci_bus_size_bridges(bus);
pci_bus_assign_resources(bus); pci_bus_assign_resources(bus);
acpiphp_sanitize_bus(bus); acpiphp_sanitize_bus(bus);
acpiphp_set_hpp_values(handle, bus); acpiphp_set_hpp_values(handle, bus);
pci_enable_bridges(bus); pci_enable_bridges(bus);
acpiphp_configure_ioapics(handle); acpiphp_configure_ioapics(handle);
pci_dev_put(dev);
return 0; return 0;
} }
......
...@@ -86,7 +86,8 @@ static char *pci_bus_speed_strings[] = { ...@@ -86,7 +86,8 @@ static char *pci_bus_speed_strings[] = {
"66 MHz PCIX 533", /* 0x11 */ "66 MHz PCIX 533", /* 0x11 */
"100 MHz PCIX 533", /* 0x12 */ "100 MHz PCIX 533", /* 0x12 */
"133 MHz PCIX 533", /* 0x13 */ "133 MHz PCIX 533", /* 0x13 */
"25 GBps PCI-E", /* 0x14 */ "2.5 GT/s PCI-E", /* 0x14 */
"5.0 GT/s PCI-E", /* 0x15 */
}; };
#ifdef CONFIG_HOTPLUG_PCI_CPCI #ifdef CONFIG_HOTPLUG_PCI_CPCI
......
...@@ -47,7 +47,7 @@ int pciehp_acpi_slot_detection_check(struct pci_dev *dev) ...@@ -47,7 +47,7 @@ int pciehp_acpi_slot_detection_check(struct pci_dev *dev)
{ {
if (slot_detection_mode != PCIEHP_DETECT_ACPI) if (slot_detection_mode != PCIEHP_DETECT_ACPI)
return 0; return 0;
if (acpi_pci_detect_ejectable(dev->subordinate)) if (acpi_pci_detect_ejectable(DEVICE_ACPI_HANDLE(&dev->dev)))
return 0; return 0;
return -ENODEV; return -ENODEV;
} }
...@@ -76,9 +76,9 @@ static int __init dummy_probe(struct pcie_device *dev) ...@@ -76,9 +76,9 @@ static int __init dummy_probe(struct pcie_device *dev)
{ {
int pos; int pos;
u32 slot_cap; u32 slot_cap;
acpi_handle handle;
struct slot *slot, *tmp; struct slot *slot, *tmp;
struct pci_dev *pdev = dev->port; struct pci_dev *pdev = dev->port;
struct pci_bus *pbus = pdev->subordinate;
/* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */ /* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */
if (pciehp_get_hp_hw_control_from_firmware(pdev)) if (pciehp_get_hp_hw_control_from_firmware(pdev))
return -ENODEV; return -ENODEV;
...@@ -94,7 +94,8 @@ static int __init dummy_probe(struct pcie_device *dev) ...@@ -94,7 +94,8 @@ static int __init dummy_probe(struct pcie_device *dev)
dup_slot_id++; dup_slot_id++;
} }
list_add_tail(&slot->slot_list, &dummy_slots); list_add_tail(&slot->slot_list, &dummy_slots);
if (!acpi_slot_detected && acpi_pci_detect_ejectable(pbus)) handle = DEVICE_ACPI_HANDLE(&pdev->dev);
if (!acpi_slot_detected && acpi_pci_detect_ejectable(handle))
acpi_slot_detected = 1; acpi_slot_detected = 1;
return -ENODEV; /* dummy driver always returns error */ return -ENODEV; /* dummy driver always returns error */
} }
......
...@@ -246,11 +246,6 @@ static int board_added(struct slot *p_slot) ...@@ -246,11 +246,6 @@ static int board_added(struct slot *p_slot)
goto err_exit; goto err_exit;
} }
/*
* Some PCI Express root ports require fixup after hot-plug operation.
*/
if (pcie_mch_quirk)
pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
if (PWR_LED(ctrl)) if (PWR_LED(ctrl))
p_slot->hpc_ops->green_led_on(p_slot); p_slot->hpc_ops->green_led_on(p_slot);
......
...@@ -693,7 +693,10 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value) ...@@ -693,7 +693,10 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
switch (lnk_cap & 0x000F) { switch (lnk_cap & 0x000F) {
case 1: case 1:
lnk_speed = PCIE_2PT5GB; lnk_speed = PCIE_2_5GB;
break;
case 2:
lnk_speed = PCIE_5_0GB;
break; break;
default: default:
lnk_speed = PCIE_LNK_SPEED_UNKNOWN; lnk_speed = PCIE_LNK_SPEED_UNKNOWN;
...@@ -772,7 +775,10 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value) ...@@ -772,7 +775,10 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
switch (lnk_status & PCI_EXP_LNKSTA_CLS) { switch (lnk_status & PCI_EXP_LNKSTA_CLS) {
case 1: case 1:
lnk_speed = PCIE_2PT5GB; lnk_speed = PCIE_2_5GB;
break;
case 2:
lnk_speed = PCIE_5_0GB;
break; break;
default: default:
lnk_speed = PCIE_LNK_SPEED_UNKNOWN; lnk_speed = PCIE_LNK_SPEED_UNKNOWN;
......
...@@ -285,11 +285,6 @@ int pciehp_unconfigure_device(struct slot *p_slot) ...@@ -285,11 +285,6 @@ int pciehp_unconfigure_device(struct slot *p_slot)
} }
pci_dev_put(temp); pci_dev_put(temp);
} }
/*
* Some PCI Express root ports require fixup after hot-plug operation.
*/
if (pcie_mch_quirk)
pci_fixup_device(pci_fixup_final, p_slot->ctrl->pci_dev);
return rc; return rc;
} }
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include "pci.h"
/**
* pci_find_device - begin or continue searching for a PCI device by vendor/device id
* @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
* @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
* @from: Previous PCI device found in search, or %NULL for new search.
*
* Iterates through the list of known PCI devices. If a PCI device is found
* with a matching @vendor and @device, a pointer to its device structure is
* returned. Otherwise, %NULL is returned.
* A new search is initiated by passing %NULL as the @from argument.
* Otherwise if @from is not %NULL, searches continue from next device
* on the global list.
*
* NOTE: Do not use this function any more; use pci_get_device() instead, as
* the PCI device returned by this function can disappear at any moment in
* time.
*/
struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device,
struct pci_dev *from)
{
struct pci_dev *pdev;
pci_dev_get(from);
pdev = pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from);
pci_dev_put(pdev);
return pdev;
}
EXPORT_SYMBOL(pci_find_device);
This diff is collapsed.
...@@ -109,15 +109,32 @@ static bool acpi_pci_can_wakeup(struct pci_dev *dev) ...@@ -109,15 +109,32 @@ static bool acpi_pci_can_wakeup(struct pci_dev *dev)
return handle ? acpi_bus_can_wakeup(handle) : false; return handle ? acpi_bus_can_wakeup(handle) : false;
} }
static void acpi_pci_propagate_wakeup_enable(struct pci_bus *bus, bool enable)
{
while (bus->parent) {
struct pci_dev *bridge = bus->self;
int ret;
ret = acpi_pm_device_sleep_wake(&bridge->dev, enable);
if (!ret || bridge->is_pcie)
return;
bus = bus->parent;
}
/* We have reached the root bus. */
if (bus->bridge)
acpi_pm_device_sleep_wake(bus->bridge, enable);
}
static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable) static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable)
{ {
int error = acpi_pm_device_sleep_wake(&dev->dev, enable); if (acpi_pci_can_wakeup(dev))
return acpi_pm_device_sleep_wake(&dev->dev, enable);
if (!error) if (!dev->is_pcie)
dev_printk(KERN_INFO, &dev->dev, acpi_pci_propagate_wakeup_enable(dev->bus, enable);
"wake-up capability %s by ACPI\n",
enable ? "enabled" : "disabled"); return 0;
return error;
} }
static struct pci_platform_pm_ops acpi_pci_platform_pm = { static struct pci_platform_pm_ops acpi_pci_platform_pm = {
......
...@@ -19,37 +19,98 @@ ...@@ -19,37 +19,98 @@
#include <linux/cpu.h> #include <linux/cpu.h>
#include "pci.h" #include "pci.h"
/*
* Dynamic device IDs are disabled for !CONFIG_HOTPLUG
*/
struct pci_dynid { struct pci_dynid {
struct list_head node; struct list_head node;
struct pci_device_id id; struct pci_device_id id;
}; };
#ifdef CONFIG_HOTPLUG /**
* pci_add_dynid - add a new PCI device ID to this driver and re-probe devices
* @drv: target pci driver
* @vendor: PCI vendor ID
* @device: PCI device ID
* @subvendor: PCI subvendor ID
* @subdevice: PCI subdevice ID
* @class: PCI class
* @class_mask: PCI class mask
* @driver_data: private driver data
*
* Adds a new dynamic pci device ID to this driver and causes the
* driver to probe for all devices again. @drv must have been
* registered prior to calling this function.
*
* CONTEXT:
* Does GFP_KERNEL allocation.
*
* RETURNS:
* 0 on success, -errno on failure.
*/
int pci_add_dynid(struct pci_driver *drv,
unsigned int vendor, unsigned int device,
unsigned int subvendor, unsigned int subdevice,
unsigned int class, unsigned int class_mask,
unsigned long driver_data)
{
struct pci_dynid *dynid;
int retval;
dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
if (!dynid)
return -ENOMEM;
dynid->id.vendor = vendor;
dynid->id.device = device;
dynid->id.subvendor = subvendor;
dynid->id.subdevice = subdevice;
dynid->id.class = class;
dynid->id.class_mask = class_mask;
dynid->id.driver_data = driver_data;
spin_lock(&drv->dynids.lock);
list_add_tail(&dynid->node, &drv->dynids.list);
spin_unlock(&drv->dynids.lock);
get_driver(&drv->driver);
retval = driver_attach(&drv->driver);
put_driver(&drv->driver);
return retval;
}
static void pci_free_dynids(struct pci_driver *drv)
{
struct pci_dynid *dynid, *n;
spin_lock(&drv->dynids.lock);
list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
list_del(&dynid->node);
kfree(dynid);
}
spin_unlock(&drv->dynids.lock);
}
/*
* Dynamic device ID manipulation via sysfs is disabled for !CONFIG_HOTPLUG
*/
#ifdef CONFIG_HOTPLUG
/** /**
* store_new_id - add a new PCI device ID to this driver and re-probe devices * store_new_id - sysfs frontend to pci_add_dynid()
* @driver: target device driver * @driver: target device driver
* @buf: buffer for scanning device ID data * @buf: buffer for scanning device ID data
* @count: input size * @count: input size
* *
* Adds a new dynamic pci device ID to this driver, * Allow PCI IDs to be added to an existing driver via sysfs.
* and causes the driver to probe for all devices again.
*/ */
static ssize_t static ssize_t
store_new_id(struct device_driver *driver, const char *buf, size_t count) store_new_id(struct device_driver *driver, const char *buf, size_t count)
{ {
struct pci_dynid *dynid;
struct pci_driver *pdrv = to_pci_driver(driver); struct pci_driver *pdrv = to_pci_driver(driver);
const struct pci_device_id *ids = pdrv->id_table; const struct pci_device_id *ids = pdrv->id_table;
__u32 vendor, device, subvendor=PCI_ANY_ID, __u32 vendor, device, subvendor=PCI_ANY_ID,
subdevice=PCI_ANY_ID, class=0, class_mask=0; subdevice=PCI_ANY_ID, class=0, class_mask=0;
unsigned long driver_data=0; unsigned long driver_data=0;
int fields=0; int fields=0;
int retval=0; int retval;
fields = sscanf(buf, "%x %x %x %x %x %x %lx", fields = sscanf(buf, "%x %x %x %x %x %x %lx",
&vendor, &device, &subvendor, &subdevice, &vendor, &device, &subvendor, &subdevice,
...@@ -72,27 +133,8 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) ...@@ -72,27 +133,8 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
return retval; return retval;
} }
dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); retval = pci_add_dynid(pdrv, vendor, device, subvendor, subdevice,
if (!dynid) class, class_mask, driver_data);
return -ENOMEM;
dynid->id.vendor = vendor;
dynid->id.device = device;
dynid->id.subvendor = subvendor;
dynid->id.subdevice = subdevice;
dynid->id.class = class;
dynid->id.class_mask = class_mask;
dynid->id.driver_data = driver_data;
spin_lock(&pdrv->dynids.lock);
list_add_tail(&dynid->node, &pdrv->dynids.list);
spin_unlock(&pdrv->dynids.lock);
if (get_driver(&pdrv->driver)) {
retval = driver_attach(&pdrv->driver);
put_driver(&pdrv->driver);
}
if (retval) if (retval)
return retval; return retval;
return count; return count;
...@@ -145,19 +187,6 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count) ...@@ -145,19 +187,6 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count)
} }
static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);
static void
pci_free_dynids(struct pci_driver *drv)
{
struct pci_dynid *dynid, *n;
spin_lock(&drv->dynids.lock);
list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
list_del(&dynid->node);
kfree(dynid);
}
spin_unlock(&drv->dynids.lock);
}
static int static int
pci_create_newid_file(struct pci_driver *drv) pci_create_newid_file(struct pci_driver *drv)
{ {
...@@ -186,7 +215,6 @@ static void pci_remove_removeid_file(struct pci_driver *drv) ...@@ -186,7 +215,6 @@ static void pci_remove_removeid_file(struct pci_driver *drv)
driver_remove_file(&drv->driver, &driver_attr_remove_id); driver_remove_file(&drv->driver, &driver_attr_remove_id);
} }
#else /* !CONFIG_HOTPLUG */ #else /* !CONFIG_HOTPLUG */
static inline void pci_free_dynids(struct pci_driver *drv) {}
static inline int pci_create_newid_file(struct pci_driver *drv) static inline int pci_create_newid_file(struct pci_driver *drv)
{ {
return 0; return 0;
...@@ -417,8 +445,6 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state) ...@@ -417,8 +445,6 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
struct pci_dev * pci_dev = to_pci_dev(dev); struct pci_dev * pci_dev = to_pci_dev(dev);
struct pci_driver * drv = pci_dev->driver; struct pci_driver * drv = pci_dev->driver;
pci_dev->state_saved = false;
if (drv && drv->suspend) { if (drv && drv->suspend) {
pci_power_t prev = pci_dev->current_state; pci_power_t prev = pci_dev->current_state;
int error; int error;
...@@ -514,7 +540,6 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev) ...@@ -514,7 +540,6 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev)
static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev) static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
{ {
pci_restore_standard_config(pci_dev); pci_restore_standard_config(pci_dev);
pci_dev->state_saved = false;
pci_fixup_device(pci_fixup_resume_early, pci_dev); pci_fixup_device(pci_fixup_resume_early, pci_dev);
} }
...@@ -580,8 +605,6 @@ static int pci_pm_suspend(struct device *dev) ...@@ -580,8 +605,6 @@ static int pci_pm_suspend(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_SUSPEND); return pci_legacy_suspend(dev, PMSG_SUSPEND);
pci_dev->state_saved = false;
if (!pm) { if (!pm) {
pci_pm_default_suspend(pci_dev); pci_pm_default_suspend(pci_dev);
goto Fixup; goto Fixup;
...@@ -694,7 +717,7 @@ static int pci_pm_resume(struct device *dev) ...@@ -694,7 +717,7 @@ static int pci_pm_resume(struct device *dev)
pci_pm_reenable_device(pci_dev); pci_pm_reenable_device(pci_dev);
} }
return 0; return error;
} }
#else /* !CONFIG_SUSPEND */ #else /* !CONFIG_SUSPEND */
...@@ -716,8 +739,6 @@ static int pci_pm_freeze(struct device *dev) ...@@ -716,8 +739,6 @@ static int pci_pm_freeze(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_FREEZE); return pci_legacy_suspend(dev, PMSG_FREEZE);
pci_dev->state_saved = false;
if (!pm) { if (!pm) {
pci_pm_default_suspend(pci_dev); pci_pm_default_suspend(pci_dev);
return 0; return 0;
...@@ -793,6 +814,8 @@ static int pci_pm_thaw(struct device *dev) ...@@ -793,6 +814,8 @@ static int pci_pm_thaw(struct device *dev)
pci_pm_reenable_device(pci_dev); pci_pm_reenable_device(pci_dev);
} }
pci_dev->state_saved = false;
return error; return error;
} }
...@@ -804,8 +827,6 @@ static int pci_pm_poweroff(struct device *dev) ...@@ -804,8 +827,6 @@ static int pci_pm_poweroff(struct device *dev)
if (pci_has_legacy_pm_support(pci_dev)) if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_HIBERNATE); return pci_legacy_suspend(dev, PMSG_HIBERNATE);
pci_dev->state_saved = false;
if (!pm) { if (!pm) {
pci_pm_default_suspend(pci_dev); pci_pm_default_suspend(pci_dev);
goto Fixup; goto Fixup;
...@@ -1106,6 +1127,7 @@ static int __init pci_driver_init(void) ...@@ -1106,6 +1127,7 @@ static int __init pci_driver_init(void)
postcore_initcall(pci_driver_init); postcore_initcall(pci_driver_init);
EXPORT_SYMBOL_GPL(pci_add_dynid);
EXPORT_SYMBOL(pci_match_id); EXPORT_SYMBOL(pci_match_id);
EXPORT_SYMBOL(__pci_register_driver); EXPORT_SYMBOL(__pci_register_driver);
EXPORT_SYMBOL(pci_unregister_driver); EXPORT_SYMBOL(pci_unregister_driver);
......
...@@ -19,8 +19,16 @@ ...@@ -19,8 +19,16 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
static char ids[1024] __initdata;
module_param_string(ids, ids, sizeof(ids), 0);
MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the stub driver, format is "
"\"vendor:device[:subvendor[:subdevice[:class[:class_mask]]]]\""
" and multiple comma separated entries can be specified");
static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)
{ {
dev_printk(KERN_INFO, &dev->dev, "claimed by stub\n");
return 0; return 0;
} }
...@@ -32,7 +40,42 @@ static struct pci_driver stub_driver = { ...@@ -32,7 +40,42 @@ static struct pci_driver stub_driver = {
static int __init pci_stub_init(void) static int __init pci_stub_init(void)
{ {
return pci_register_driver(&stub_driver); char *p, *id;
int rc;
rc = pci_register_driver(&stub_driver);
if (rc)
return rc;
/* add ids specified in the module parameter */
p = ids;
while ((id = strsep(&p, ","))) {
unsigned int vendor, device, subvendor = PCI_ANY_ID,
subdevice = PCI_ANY_ID, class=0, class_mask=0;
int fields;
fields = sscanf(id, "%x:%x:%x:%x:%x:%x",
&vendor, &device, &subvendor, &subdevice,
&class, &class_mask);
if (fields < 2) {
printk(KERN_WARNING
"pci-stub: invalid id string \"%s\"\n", id);
continue;
}
printk(KERN_INFO
"pci-stub: add %04X:%04X sub=%04X:%04X cls=%08X/%08X\n",
vendor, device, subvendor, subdevice, class, class_mask);
rc = pci_add_dynid(&stub_driver, vendor, device,
subvendor, subdevice, class, class_mask, 0);
if (rc)
printk(KERN_WARNING
"pci-stub: failed to add dynamic id (%d)\n", rc);
}
return 0;
} }
static void __exit pci_stub_exit(void) static void __exit pci_stub_exit(void)
......
...@@ -916,6 +916,24 @@ int __attribute__ ((weak)) pcibios_add_platform_entries(struct pci_dev *dev) ...@@ -916,6 +916,24 @@ int __attribute__ ((weak)) pcibios_add_platform_entries(struct pci_dev *dev)
return 0; return 0;
} }
static ssize_t reset_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
struct pci_dev *pdev = to_pci_dev(dev);
unsigned long val;
ssize_t result = strict_strtoul(buf, 0, &val);
if (result < 0)
return result;
if (val != 1)
return -EINVAL;
return pci_reset_function(pdev);
}
static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_store);
static int pci_create_capabilities_sysfs(struct pci_dev *dev) static int pci_create_capabilities_sysfs(struct pci_dev *dev)
{ {
int retval; int retval;
...@@ -943,7 +961,22 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev) ...@@ -943,7 +961,22 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev)
/* Active State Power Management */ /* Active State Power Management */
pcie_aspm_create_sysfs_dev_files(dev); pcie_aspm_create_sysfs_dev_files(dev);
if (!pci_probe_reset_function(dev)) {
retval = device_create_file(&dev->dev, &reset_attr);
if (retval)
goto error;
dev->reset_fn = 1;
}
return 0; return 0;
error:
pcie_aspm_remove_sysfs_dev_files(dev);
if (dev->vpd && dev->vpd->attr) {
sysfs_remove_bin_file(&dev->dev.kobj, dev->vpd->attr);
kfree(dev->vpd->attr);
}
return retval;
} }
int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
...@@ -1037,6 +1070,10 @@ static void pci_remove_capabilities_sysfs(struct pci_dev *dev) ...@@ -1037,6 +1070,10 @@ static void pci_remove_capabilities_sysfs(struct pci_dev *dev)
} }
pcie_aspm_remove_sysfs_dev_files(dev); pcie_aspm_remove_sysfs_dev_files(dev);
if (dev->reset_fn) {
device_remove_file(&dev->dev, &reset_attr);
dev->reset_fn = 0;
}
} }
/** /**
......
...@@ -41,6 +41,12 @@ int pci_domains_supported = 1; ...@@ -41,6 +41,12 @@ int pci_domains_supported = 1;
unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE; unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE;
unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE; unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE;
#define DEFAULT_HOTPLUG_IO_SIZE (256)
#define DEFAULT_HOTPLUG_MEM_SIZE (2*1024*1024)
/* pci=hpmemsize=nnM,hpiosize=nn can override this */
unsigned long pci_hotplug_io_size = DEFAULT_HOTPLUG_IO_SIZE;
unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE;
/** /**
* pci_bus_max_busnr - returns maximum PCI bus number of given bus' children * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children
* @bus: pointer to PCI bus structure to search * @bus: pointer to PCI bus structure to search
...@@ -848,6 +854,7 @@ pci_restore_state(struct pci_dev *dev) ...@@ -848,6 +854,7 @@ pci_restore_state(struct pci_dev *dev)
if (!dev->state_saved) if (!dev->state_saved)
return 0; return 0;
/* PCI Express register must be restored first */ /* PCI Express register must be restored first */
pci_restore_pcie_state(dev); pci_restore_pcie_state(dev);
...@@ -869,6 +876,8 @@ pci_restore_state(struct pci_dev *dev) ...@@ -869,6 +876,8 @@ pci_restore_state(struct pci_dev *dev)
pci_restore_msi_state(dev); pci_restore_msi_state(dev);
pci_restore_iov_state(dev); pci_restore_iov_state(dev);
dev->state_saved = false;
return 0; return 0;
} }
...@@ -1214,30 +1223,40 @@ void pci_pme_active(struct pci_dev *dev, bool enable) ...@@ -1214,30 +1223,40 @@ void pci_pme_active(struct pci_dev *dev, bool enable)
*/ */
int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable)
{ {
int error = 0; int ret = 0;
bool pme_done = false;
if (enable && !device_may_wakeup(&dev->dev)) if (enable && !device_may_wakeup(&dev->dev))
return -EINVAL; return -EINVAL;
/* Don't do the same thing twice in a row for one device. */
if (!!enable == !!dev->wakeup_prepared)
return 0;
/* /*
* According to "PCI System Architecture" 4th ed. by Tom Shanley & Don * According to "PCI System Architecture" 4th ed. by Tom Shanley & Don
* Anderson we should be doing PME# wake enable followed by ACPI wake * Anderson we should be doing PME# wake enable followed by ACPI wake
* enable. To disable wake-up we call the platform first, for symmetry. * enable. To disable wake-up we call the platform first, for symmetry.
*/ */
if (!enable && platform_pci_can_wakeup(dev)) if (enable) {
error = platform_pci_sleep_wake(dev, false); int error;
if (!enable || pci_pme_capable(dev, state)) {
pci_pme_active(dev, enable);
pme_done = true;
}
if (enable && platform_pci_can_wakeup(dev)) if (pci_pme_capable(dev, state))
pci_pme_active(dev, true);
else
ret = 1;
error = platform_pci_sleep_wake(dev, true); error = platform_pci_sleep_wake(dev, true);
if (ret)
ret = error;
if (!ret)
dev->wakeup_prepared = true;
} else {
platform_pci_sleep_wake(dev, false);
pci_pme_active(dev, false);
dev->wakeup_prepared = false;
}
return pme_done ? 0 : error; return ret;
} }
/** /**
...@@ -1356,6 +1375,7 @@ void pci_pm_init(struct pci_dev *dev) ...@@ -1356,6 +1375,7 @@ void pci_pm_init(struct pci_dev *dev)
int pm; int pm;
u16 pmc; u16 pmc;
dev->wakeup_prepared = false;
dev->pm_cap = 0; dev->pm_cap = 0;
/* find PCI PM capability in list */ /* find PCI PM capability in list */
...@@ -2261,6 +2281,22 @@ int __pci_reset_function(struct pci_dev *dev) ...@@ -2261,6 +2281,22 @@ int __pci_reset_function(struct pci_dev *dev)
} }
EXPORT_SYMBOL_GPL(__pci_reset_function); EXPORT_SYMBOL_GPL(__pci_reset_function);
/**
* pci_probe_reset_function - check whether the device can be safely reset
* @dev: PCI device to reset
*
* Some devices allow an individual function to be reset without affecting
* other functions in the same device. The PCI device must be responsive
* to PCI config space in order to use this function.
*
* Returns 0 if the device function can be reset or negative if the
* device doesn't support resetting a single function.
*/
int pci_probe_reset_function(struct pci_dev *dev)
{
return pci_dev_reset(dev, 1);
}
/** /**
* pci_reset_function - quiesce and reset a PCI device function * pci_reset_function - quiesce and reset a PCI device function
* @dev: PCI device to reset * @dev: PCI device to reset
...@@ -2504,6 +2540,50 @@ int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type) ...@@ -2504,6 +2540,50 @@ int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
return 0; return 0;
} }
/**
* pci_set_vga_state - set VGA decode state on device and parents if requested
* @dev the PCI device
* @decode - true = enable decoding, false = disable decoding
* @command_bits PCI_COMMAND_IO and/or PCI_COMMAND_MEMORY
* @change_bridge - traverse ancestors and change bridges
*/
int pci_set_vga_state(struct pci_dev *dev, bool decode,
unsigned int command_bits, bool change_bridge)
{
struct pci_bus *bus;
struct pci_dev *bridge;
u16 cmd;
WARN_ON(command_bits & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY));
pci_read_config_word(dev, PCI_COMMAND, &cmd);
if (decode == true)
cmd |= command_bits;
else
cmd &= ~command_bits;
pci_write_config_word(dev, PCI_COMMAND, cmd);
if (change_bridge == false)
return 0;
bus = dev->bus;
while (bus) {
bridge = bus->self;
if (bridge) {
pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
&cmd);
if (decode == true)
cmd |= PCI_BRIDGE_CTL_VGA;
else
cmd &= ~PCI_BRIDGE_CTL_VGA;
pci_write_config_word(bridge, PCI_BRIDGE_CONTROL,
cmd);
}
bus = bus->parent;
}
return 0;
}
#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE #define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
spinlock_t resource_alignment_lock = SPIN_LOCK_UNLOCKED; spinlock_t resource_alignment_lock = SPIN_LOCK_UNLOCKED;
...@@ -2672,6 +2752,10 @@ static int __init pci_setup(char *str) ...@@ -2672,6 +2752,10 @@ static int __init pci_setup(char *str)
strlen(str + 19)); strlen(str + 19));
} else if (!strncmp(str, "ecrc=", 5)) { } else if (!strncmp(str, "ecrc=", 5)) {
pcie_ecrc_get_policy(str + 5); pcie_ecrc_get_policy(str + 5);
} else if (!strncmp(str, "hpiosize=", 9)) {
pci_hotplug_io_size = memparse(str + 9, &str);
} else if (!strncmp(str, "hpmemsize=", 10)) {
pci_hotplug_mem_size = memparse(str + 10, &str);
} else { } else {
printk(KERN_ERR "PCI: Unknown option `%s'\n", printk(KERN_ERR "PCI: Unknown option `%s'\n",
str); str);
......
...@@ -16,6 +16,7 @@ extern void pci_cleanup_rom(struct pci_dev *dev); ...@@ -16,6 +16,7 @@ extern void pci_cleanup_rom(struct pci_dev *dev);
extern int pci_mmap_fits(struct pci_dev *pdev, int resno, extern int pci_mmap_fits(struct pci_dev *pdev, int resno,
struct vm_area_struct *vma); struct vm_area_struct *vma);
#endif #endif
int pci_probe_reset_function(struct pci_dev *dev);
/** /**
* struct pci_platform_pm_ops - Firmware PM callbacks * struct pci_platform_pm_ops - Firmware PM callbacks
...@@ -133,7 +134,6 @@ static inline int pci_no_d1d2(struct pci_dev *dev) ...@@ -133,7 +134,6 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
return (dev->no_d1d2 || parent_dstates); return (dev->no_d1d2 || parent_dstates);
} }
extern int pcie_mch_quirk;
extern struct device_attribute pci_dev_attrs[]; extern struct device_attribute pci_dev_attrs[];
extern struct device_attribute dev_attr_cpuaffinity; extern struct device_attribute dev_attr_cpuaffinity;
extern struct device_attribute dev_attr_cpulistaffinity; extern struct device_attribute dev_attr_cpulistaffinity;
......
...@@ -22,11 +22,10 @@ ...@@ -22,11 +22,10 @@
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
#include "aerdrv.h" #include "aerdrv.h"
struct aer_error_inj struct aer_error_inj {
{
u8 bus; u8 bus;
u8 dev; u8 dev;
u8 fn; u8 fn;
...@@ -38,8 +37,7 @@ struct aer_error_inj ...@@ -38,8 +37,7 @@ struct aer_error_inj
u32 header_log3; u32 header_log3;
}; };
struct aer_error struct aer_error {
{
struct list_head list; struct list_head list;
unsigned int bus; unsigned int bus;
unsigned int devfn; unsigned int devfn;
...@@ -55,8 +53,7 @@ struct aer_error ...@@ -55,8 +53,7 @@ struct aer_error
u32 source_id; u32 source_id;
}; };
struct pci_bus_ops struct pci_bus_ops {
{
struct list_head list; struct list_head list;
struct pci_bus *bus; struct pci_bus *bus;
struct pci_ops *ops; struct pci_ops *ops;
...@@ -150,7 +147,7 @@ static u32 *find_pci_config_dword(struct aer_error *err, int where, ...@@ -150,7 +147,7 @@ static u32 *find_pci_config_dword(struct aer_error *err, int where,
target = &err->header_log1; target = &err->header_log1;
break; break;
case PCI_ERR_HEADER_LOG+8: case PCI_ERR_HEADER_LOG+8:
target = &err->header_log2; target = &err->header_log2;
break; break;
case PCI_ERR_HEADER_LOG+12: case PCI_ERR_HEADER_LOG+12:
target = &err->header_log3; target = &err->header_log3;
...@@ -258,8 +255,7 @@ static int pci_bus_set_aer_ops(struct pci_bus *bus) ...@@ -258,8 +255,7 @@ static int pci_bus_set_aer_ops(struct pci_bus *bus)
bus_ops = NULL; bus_ops = NULL;
out: out:
spin_unlock_irqrestore(&inject_lock, flags); spin_unlock_irqrestore(&inject_lock, flags);
if (bus_ops) kfree(bus_ops);
kfree(bus_ops);
return 0; return 0;
} }
...@@ -401,10 +397,8 @@ static int aer_inject(struct aer_error_inj *einj) ...@@ -401,10 +397,8 @@ static int aer_inject(struct aer_error_inj *einj)
else else
ret = -EINVAL; ret = -EINVAL;
out_put: out_put:
if (err_alloc) kfree(err_alloc);
kfree(err_alloc); kfree(rperr_alloc);
if (rperr_alloc)
kfree(rperr_alloc);
pci_dev_put(dev); pci_dev_put(dev);
return ret; return ret;
} }
...@@ -458,8 +452,7 @@ static void __exit aer_inject_exit(void) ...@@ -458,8 +452,7 @@ static void __exit aer_inject_exit(void)
} }
spin_lock_irqsave(&inject_lock, flags); spin_lock_irqsave(&inject_lock, flags);
list_for_each_entry_safe(err, err_next, list_for_each_entry_safe(err, err_next, &pci_bus_ops_list, list) {
&pci_bus_ops_list, list) {
list_del(&err->list); list_del(&err->list);
kfree(err); kfree(err);
} }
......
...@@ -38,7 +38,7 @@ MODULE_AUTHOR(DRIVER_AUTHOR); ...@@ -38,7 +38,7 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int __devinit aer_probe (struct pcie_device *dev); static int __devinit aer_probe(struct pcie_device *dev);
static void aer_remove(struct pcie_device *dev); static void aer_remove(struct pcie_device *dev);
static pci_ers_result_t aer_error_detected(struct pci_dev *dev, static pci_ers_result_t aer_error_detected(struct pci_dev *dev,
enum pci_channel_state error); enum pci_channel_state error);
...@@ -47,7 +47,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev); ...@@ -47,7 +47,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev);
static struct pci_error_handlers aer_error_handlers = { static struct pci_error_handlers aer_error_handlers = {
.error_detected = aer_error_detected, .error_detected = aer_error_detected,
.resume = aer_error_resume, .resume = aer_error_resume,
}; };
static struct pcie_port_service_driver aerdriver = { static struct pcie_port_service_driver aerdriver = {
...@@ -134,12 +134,12 @@ EXPORT_SYMBOL_GPL(aer_irq); ...@@ -134,12 +134,12 @@ EXPORT_SYMBOL_GPL(aer_irq);
* *
* Invoked when Root Port's AER service is loaded. * Invoked when Root Port's AER service is loaded.
**/ **/
static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev) static struct aer_rpc *aer_alloc_rpc(struct pcie_device *dev)
{ {
struct aer_rpc *rpc; struct aer_rpc *rpc;
if (!(rpc = kzalloc(sizeof(struct aer_rpc), rpc = kzalloc(sizeof(struct aer_rpc), GFP_KERNEL);
GFP_KERNEL))) if (!rpc)
return NULL; return NULL;
/* /*
...@@ -189,26 +189,28 @@ static void aer_remove(struct pcie_device *dev) ...@@ -189,26 +189,28 @@ static void aer_remove(struct pcie_device *dev)
* *
* Invoked when PCI Express bus loads AER service driver. * Invoked when PCI Express bus loads AER service driver.
**/ **/
static int __devinit aer_probe (struct pcie_device *dev) static int __devinit aer_probe(struct pcie_device *dev)
{ {
int status; int status;
struct aer_rpc *rpc; struct aer_rpc *rpc;
struct device *device = &dev->device; struct device *device = &dev->device;
/* Init */ /* Init */
if ((status = aer_init(dev))) status = aer_init(dev);
if (status)
return status; return status;
/* Alloc rpc data structure */ /* Alloc rpc data structure */
if (!(rpc = aer_alloc_rpc(dev))) { rpc = aer_alloc_rpc(dev);
if (!rpc) {
dev_printk(KERN_DEBUG, device, "alloc rpc failed\n"); dev_printk(KERN_DEBUG, device, "alloc rpc failed\n");
aer_remove(dev); aer_remove(dev);
return -ENOMEM; return -ENOMEM;
} }
/* Request IRQ ISR */ /* Request IRQ ISR */
if ((status = request_irq(dev->irq, aer_irq, IRQF_SHARED, "aerdrv", status = request_irq(dev->irq, aer_irq, IRQF_SHARED, "aerdrv", dev);
dev))) { if (status) {
dev_printk(KERN_DEBUG, device, "request IRQ failed\n"); dev_printk(KERN_DEBUG, device, "request IRQ failed\n");
aer_remove(dev); aer_remove(dev);
return status; return status;
......
...@@ -16,12 +16,9 @@ ...@@ -16,12 +16,9 @@
#define AER_NONFATAL 0 #define AER_NONFATAL 0
#define AER_FATAL 1 #define AER_FATAL 1
#define AER_CORRECTABLE 2 #define AER_CORRECTABLE 2
#define AER_UNCORRECTABLE 4
#define AER_ERROR_MASK 0x001fffff
#define AER_ERROR(d) (d & AER_ERROR_MASK)
/* Root Error Status Register Bits */ /* Root Error Status Register Bits */
#define ROOT_ERR_STATUS_MASKS 0x0f #define ROOT_ERR_STATUS_MASKS 0x0f
#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \ #define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \
PCI_EXP_RTCTL_SENFEE| \ PCI_EXP_RTCTL_SENFEE| \
...@@ -32,8 +29,6 @@ ...@@ -32,8 +29,6 @@
#define ERR_COR_ID(d) (d & 0xffff) #define ERR_COR_ID(d) (d & 0xffff)
#define ERR_UNCOR_ID(d) (d >> 16) #define ERR_UNCOR_ID(d) (d >> 16)
#define AER_SUCCESS 0
#define AER_UNSUCCESS 1
#define AER_ERROR_SOURCES_MAX 100 #define AER_ERROR_SOURCES_MAX 100
#define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \ #define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \
...@@ -43,13 +38,6 @@ ...@@ -43,13 +38,6 @@
PCI_ERR_UNC_UNX_COMP| \ PCI_ERR_UNC_UNX_COMP| \
PCI_ERR_UNC_MALF_TLP) PCI_ERR_UNC_MALF_TLP)
/* AER Error Info Flags */
#define AER_TLP_HEADER_VALID_FLAG 0x00000001
#define AER_MULTI_ERROR_VALID_FLAG 0x00000002
#define ERR_CORRECTABLE_ERROR_MASK 0x000031c1
#define ERR_UNCORRECTABLE_ERROR_MASK 0x001ff010
struct header_log_regs { struct header_log_regs {
unsigned int dw0; unsigned int dw0;
unsigned int dw1; unsigned int dw1;
...@@ -61,11 +49,20 @@ struct header_log_regs { ...@@ -61,11 +49,20 @@ struct header_log_regs {
struct aer_err_info { struct aer_err_info {
struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES]; struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
int error_dev_num; int error_dev_num;
u16 id;
int severity; /* 0:NONFATAL | 1:FATAL | 2:COR */ unsigned int id:16;
int flags;
unsigned int severity:2; /* 0:NONFATAL | 1:FATAL | 2:COR */
unsigned int __pad1:5;
unsigned int multi_error_valid:1;
unsigned int first_error:5;
unsigned int __pad2:2;
unsigned int tlp_header_valid:1;
unsigned int status; /* COR/UNCOR Error Status */ unsigned int status; /* COR/UNCOR Error Status */
struct header_log_regs tlp; /* TLP Header */ unsigned int mask; /* COR/UNCOR Error Mask */
struct header_log_regs tlp; /* TLP Header */
}; };
struct aer_err_source { struct aer_err_source {
...@@ -125,6 +122,7 @@ extern void aer_delete_rootport(struct aer_rpc *rpc); ...@@ -125,6 +122,7 @@ extern void aer_delete_rootport(struct aer_rpc *rpc);
extern int aer_init(struct pcie_device *dev); extern int aer_init(struct pcie_device *dev);
extern void aer_isr(struct work_struct *work); extern void aer_isr(struct work_struct *work);
extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
extern void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info);
extern irqreturn_t aer_irq(int irq, void *context); extern irqreturn_t aer_irq(int irq, void *context);
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
...@@ -136,4 +134,4 @@ static inline int aer_osc_setup(struct pcie_device *pciedev) ...@@ -136,4 +134,4 @@ static inline int aer_osc_setup(struct pcie_device *pciedev)
} }
#endif #endif
#endif //_AERDRV_H_ #endif /* _AERDRV_H_ */
...@@ -49,10 +49,11 @@ int pci_enable_pcie_error_reporting(struct pci_dev *dev) ...@@ -49,10 +49,11 @@ int pci_enable_pcie_error_reporting(struct pci_dev *dev)
PCI_EXP_DEVCTL_NFERE | PCI_EXP_DEVCTL_NFERE |
PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_FERE |
PCI_EXP_DEVCTL_URRE; PCI_EXP_DEVCTL_URRE;
pci_write_config_word(dev, pos+PCI_EXP_DEVCTL, pci_write_config_word(dev, pos+PCI_EXP_DEVCTL, reg16);
reg16);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
int pci_disable_pcie_error_reporting(struct pci_dev *dev) int pci_disable_pcie_error_reporting(struct pci_dev *dev)
{ {
...@@ -68,10 +69,11 @@ int pci_disable_pcie_error_reporting(struct pci_dev *dev) ...@@ -68,10 +69,11 @@ int pci_disable_pcie_error_reporting(struct pci_dev *dev)
PCI_EXP_DEVCTL_NFERE | PCI_EXP_DEVCTL_NFERE |
PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_FERE |
PCI_EXP_DEVCTL_URRE); PCI_EXP_DEVCTL_URRE);
pci_write_config_word(dev, pos+PCI_EXP_DEVCTL, pci_write_config_word(dev, pos+PCI_EXP_DEVCTL, reg16);
reg16);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev) int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
{ {
...@@ -92,6 +94,7 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev) ...@@ -92,6 +94,7 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
#if 0 #if 0
int pci_cleanup_aer_correct_error_status(struct pci_dev *dev) int pci_cleanup_aer_correct_error_status(struct pci_dev *dev)
...@@ -110,7 +113,6 @@ int pci_cleanup_aer_correct_error_status(struct pci_dev *dev) ...@@ -110,7 +113,6 @@ int pci_cleanup_aer_correct_error_status(struct pci_dev *dev)
} }
#endif /* 0 */ #endif /* 0 */
static int set_device_error_reporting(struct pci_dev *dev, void *data) static int set_device_error_reporting(struct pci_dev *dev, void *data)
{ {
bool enable = *((bool *)data); bool enable = *((bool *)data);
...@@ -164,8 +166,9 @@ static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev) ...@@ -164,8 +166,9 @@ static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev)
e_info->dev[e_info->error_dev_num] = dev; e_info->dev[e_info->error_dev_num] = dev;
e_info->error_dev_num++; e_info->error_dev_num++;
return 1; return 1;
} else }
return 0;
return 0;
} }
...@@ -193,7 +196,7 @@ static int find_device_iter(struct pci_dev *dev, void *data) ...@@ -193,7 +196,7 @@ static int find_device_iter(struct pci_dev *dev, void *data)
* If there is no multiple error, we stop * If there is no multiple error, we stop
* or continue based on the id comparing. * or continue based on the id comparing.
*/ */
if (!(e_info->flags & AER_MULTI_ERROR_VALID_FLAG)) if (!e_info->multi_error_valid)
return result; return result;
/* /*
...@@ -233,24 +236,16 @@ static int find_device_iter(struct pci_dev *dev, void *data) ...@@ -233,24 +236,16 @@ static int find_device_iter(struct pci_dev *dev, void *data)
status = 0; status = 0;
mask = 0; mask = 0;
if (e_info->severity == AER_CORRECTABLE) { if (e_info->severity == AER_CORRECTABLE) {
pci_read_config_dword(dev, pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &status);
pos + PCI_ERR_COR_STATUS, pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, &mask);
&status); if (status & ~mask) {
pci_read_config_dword(dev,
pos + PCI_ERR_COR_MASK,
&mask);
if (status & ERR_CORRECTABLE_ERROR_MASK & ~mask) {
add_error_device(e_info, dev); add_error_device(e_info, dev);
goto added; goto added;
} }
} else { } else {
pci_read_config_dword(dev, pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
pos + PCI_ERR_UNCOR_STATUS, pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
&status); if (status & ~mask) {
pci_read_config_dword(dev,
pos + PCI_ERR_UNCOR_MASK,
&mask);
if (status & ERR_UNCORRECTABLE_ERROR_MASK & ~mask) {
add_error_device(e_info, dev); add_error_device(e_info, dev);
goto added; goto added;
} }
...@@ -259,7 +254,7 @@ static int find_device_iter(struct pci_dev *dev, void *data) ...@@ -259,7 +254,7 @@ static int find_device_iter(struct pci_dev *dev, void *data)
return 0; return 0;
added: added:
if (e_info->flags & AER_MULTI_ERROR_VALID_FLAG) if (e_info->multi_error_valid)
return 0; return 0;
else else
return 1; return 1;
...@@ -411,8 +406,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, ...@@ -411,8 +406,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev,
pci_cleanup_aer_uncorrect_error_status(dev); pci_cleanup_aer_uncorrect_error_status(dev);
dev->error_state = pci_channel_io_normal; dev->error_state = pci_channel_io_normal;
} }
} } else {
else {
/* /*
* If the error is reported by an end point, we think this * If the error is reported by an end point, we think this
* error is related to the upstream link of the end point. * error is related to the upstream link of the end point.
...@@ -473,7 +467,7 @@ static pci_ers_result_t reset_link(struct pcie_device *aerdev, ...@@ -473,7 +467,7 @@ static pci_ers_result_t reset_link(struct pcie_device *aerdev,
if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)
udev = dev; udev = dev;
else else
udev= dev->bus->self; udev = dev->bus->self;
data.is_downstream = 0; data.is_downstream = 0;
data.aer_driver = NULL; data.aer_driver = NULL;
...@@ -576,7 +570,7 @@ static pci_ers_result_t do_recovery(struct pcie_device *aerdev, ...@@ -576,7 +570,7 @@ static pci_ers_result_t do_recovery(struct pcie_device *aerdev,
* *
* Invoked when an error being detected by Root Port. * Invoked when an error being detected by Root Port.
*/ */
static void handle_error_source(struct pcie_device * aerdev, static void handle_error_source(struct pcie_device *aerdev,
struct pci_dev *dev, struct pci_dev *dev,
struct aer_err_info *info) struct aer_err_info *info)
{ {
...@@ -682,7 +676,7 @@ static void disable_root_aer(struct aer_rpc *rpc) ...@@ -682,7 +676,7 @@ static void disable_root_aer(struct aer_rpc *rpc)
* *
* Invoked by DPC handler to consume an error. * Invoked by DPC handler to consume an error.
*/ */
static struct aer_err_source* get_e_source(struct aer_rpc *rpc) static struct aer_err_source *get_e_source(struct aer_rpc *rpc)
{ {
struct aer_err_source *e_source; struct aer_err_source *e_source;
unsigned long flags; unsigned long flags;
...@@ -702,32 +696,50 @@ static struct aer_err_source* get_e_source(struct aer_rpc *rpc) ...@@ -702,32 +696,50 @@ static struct aer_err_source* get_e_source(struct aer_rpc *rpc)
return e_source; return e_source;
} }
/**
* get_device_error_info - read error status from dev and store it to info
* @dev: pointer to the device expected to have a error record
* @info: pointer to structure to store the error record
*
* Return 1 on success, 0 on error.
*/
static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
{ {
int pos; int pos, temp;
info->status = 0;
info->tlp_header_valid = 0;
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
/* The device might not support AER */ /* The device might not support AER */
if (!pos) if (!pos)
return AER_SUCCESS; return 1;
if (info->severity == AER_CORRECTABLE) { if (info->severity == AER_CORRECTABLE) {
pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS,
&info->status); &info->status);
if (!(info->status & ERR_CORRECTABLE_ERROR_MASK)) pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK,
return AER_UNSUCCESS; &info->mask);
if (!(info->status & ~info->mask))
return 0;
} else if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE || } else if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE ||
info->severity == AER_NONFATAL) { info->severity == AER_NONFATAL) {
/* Link is still healthy for IO reads */ /* Link is still healthy for IO reads */
pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
&info->status); &info->status);
if (!(info->status & ERR_UNCORRECTABLE_ERROR_MASK)) pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK,
return AER_UNSUCCESS; &info->mask);
if (!(info->status & ~info->mask))
return 0;
/* Get First Error Pointer */
pci_read_config_dword(dev, pos + PCI_ERR_CAP, &temp);
info->first_error = PCI_ERR_CAP_FEP(temp);
if (info->status & AER_LOG_TLP_MASKS) { if (info->status & AER_LOG_TLP_MASKS) {
info->flags |= AER_TLP_HEADER_VALID_FLAG; info->tlp_header_valid = 1;
pci_read_config_dword(dev, pci_read_config_dword(dev,
pos + PCI_ERR_HEADER_LOG, &info->tlp.dw0); pos + PCI_ERR_HEADER_LOG, &info->tlp.dw0);
pci_read_config_dword(dev, pci_read_config_dword(dev,
...@@ -739,7 +751,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) ...@@ -739,7 +751,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
} }
} }
return AER_SUCCESS; return 1;
} }
static inline void aer_process_err_devices(struct pcie_device *p_device, static inline void aer_process_err_devices(struct pcie_device *p_device,
...@@ -753,14 +765,14 @@ static inline void aer_process_err_devices(struct pcie_device *p_device, ...@@ -753,14 +765,14 @@ static inline void aer_process_err_devices(struct pcie_device *p_device,
e_info->id); e_info->id);
} }
/* Report all before handle them, not to lost records by reset etc. */
for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
if (get_device_error_info(e_info->dev[i], e_info) == if (get_device_error_info(e_info->dev[i], e_info))
AER_SUCCESS) {
aer_print_error(e_info->dev[i], e_info); aer_print_error(e_info->dev[i], e_info);
handle_error_source(p_device, }
e_info->dev[i], for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
e_info); if (get_device_error_info(e_info->dev[i], e_info))
} handle_error_source(p_device, e_info->dev[i], e_info);
} }
} }
...@@ -806,7 +818,9 @@ static void aer_isr_one_error(struct pcie_device *p_device, ...@@ -806,7 +818,9 @@ static void aer_isr_one_error(struct pcie_device *p_device,
if (e_src->status & if (e_src->status &
(PCI_ERR_ROOT_MULTI_COR_RCV | (PCI_ERR_ROOT_MULTI_COR_RCV |
PCI_ERR_ROOT_MULTI_UNCOR_RCV)) PCI_ERR_ROOT_MULTI_UNCOR_RCV))
e_info->flags |= AER_MULTI_ERROR_VALID_FLAG; e_info->multi_error_valid = 1;
aer_print_port_info(p_device->port, e_info);
find_source_device(p_device->port, e_info); find_source_device(p_device->port, e_info);
aer_process_err_devices(p_device, e_info); aer_process_err_devices(p_device, e_info);
...@@ -863,10 +877,5 @@ int aer_init(struct pcie_device *dev) ...@@ -863,10 +877,5 @@ int aer_init(struct pcie_device *dev)
if (aer_osc_setup(dev) && !forceload) if (aer_osc_setup(dev) && !forceload)
return -ENXIO; return -ENXIO;
return AER_SUCCESS; return 0;
} }
EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
...@@ -27,69 +27,70 @@ ...@@ -27,69 +27,70 @@
#define AER_AGENT_COMPLETER 2 #define AER_AGENT_COMPLETER 2
#define AER_AGENT_TRANSMITTER 3 #define AER_AGENT_TRANSMITTER 3
#define AER_AGENT_REQUESTER_MASK (PCI_ERR_UNC_COMP_TIME| \ #define AER_AGENT_REQUESTER_MASK(t) ((t == AER_CORRECTABLE) ? \
PCI_ERR_UNC_UNSUP) 0 : (PCI_ERR_UNC_COMP_TIME|PCI_ERR_UNC_UNSUP))
#define AER_AGENT_COMPLETER_MASK(t) ((t == AER_CORRECTABLE) ? \
#define AER_AGENT_COMPLETER_MASK PCI_ERR_UNC_COMP_ABORT 0 : PCI_ERR_UNC_COMP_ABORT)
#define AER_AGENT_TRANSMITTER_MASK(t) ((t == AER_CORRECTABLE) ? \
#define AER_AGENT_TRANSMITTER_MASK(t, e) (e & (PCI_ERR_COR_REP_ROLL| \ (PCI_ERR_COR_REP_ROLL|PCI_ERR_COR_REP_TIMER) : 0)
((t == AER_CORRECTABLE) ? PCI_ERR_COR_REP_TIMER: 0)))
#define AER_GET_AGENT(t, e) \ #define AER_GET_AGENT(t, e) \
((e & AER_AGENT_COMPLETER_MASK) ? AER_AGENT_COMPLETER : \ ((e & AER_AGENT_COMPLETER_MASK(t)) ? AER_AGENT_COMPLETER : \
(e & AER_AGENT_REQUESTER_MASK) ? AER_AGENT_REQUESTER : \ (e & AER_AGENT_REQUESTER_MASK(t)) ? AER_AGENT_REQUESTER : \
(AER_AGENT_TRANSMITTER_MASK(t, e)) ? AER_AGENT_TRANSMITTER : \ (e & AER_AGENT_TRANSMITTER_MASK(t)) ? AER_AGENT_TRANSMITTER : \
AER_AGENT_RECEIVER) AER_AGENT_RECEIVER)
#define AER_PHYSICAL_LAYER_ERROR_MASK PCI_ERR_COR_RCVR
#define AER_DATA_LINK_LAYER_ERROR_MASK(t, e) \
(PCI_ERR_UNC_DLP| \
PCI_ERR_COR_BAD_TLP| \
PCI_ERR_COR_BAD_DLLP| \
PCI_ERR_COR_REP_ROLL| \
((t == AER_CORRECTABLE) ? \
PCI_ERR_COR_REP_TIMER: 0))
#define AER_PHYSICAL_LAYER_ERROR 0 #define AER_PHYSICAL_LAYER_ERROR 0
#define AER_DATA_LINK_LAYER_ERROR 1 #define AER_DATA_LINK_LAYER_ERROR 1
#define AER_TRANSACTION_LAYER_ERROR 2 #define AER_TRANSACTION_LAYER_ERROR 2
#define AER_GET_LAYER_ERROR(t, e) \ #define AER_PHYSICAL_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ? \
((e & AER_PHYSICAL_LAYER_ERROR_MASK) ? \ PCI_ERR_COR_RCVR : 0)
AER_PHYSICAL_LAYER_ERROR : \ #define AER_DATA_LINK_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ? \
(e & AER_DATA_LINK_LAYER_ERROR_MASK(t, e)) ? \ (PCI_ERR_COR_BAD_TLP| \
AER_DATA_LINK_LAYER_ERROR : \ PCI_ERR_COR_BAD_DLLP| \
AER_TRANSACTION_LAYER_ERROR) PCI_ERR_COR_REP_ROLL| \
PCI_ERR_COR_REP_TIMER) : PCI_ERR_UNC_DLP)
#define AER_GET_LAYER_ERROR(t, e) \
((e & AER_PHYSICAL_LAYER_ERROR_MASK(t)) ? AER_PHYSICAL_LAYER_ERROR : \
(e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
AER_TRANSACTION_LAYER_ERROR)
#define AER_PR(info, pdev, fmt, args...) \
printk("%s%s %s: " fmt, (info->severity == AER_CORRECTABLE) ? \
KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev), \
dev_name(&pdev->dev), ## args)
/* /*
* AER error strings * AER error strings
*/ */
static char* aer_error_severity_string[] = { static char *aer_error_severity_string[] = {
"Uncorrected (Non-Fatal)", "Uncorrected (Non-Fatal)",
"Uncorrected (Fatal)", "Uncorrected (Fatal)",
"Corrected" "Corrected"
}; };
static char* aer_error_layer[] = { static char *aer_error_layer[] = {
"Physical Layer", "Physical Layer",
"Data Link Layer", "Data Link Layer",
"Transaction Layer" "Transaction Layer"
}; };
static char* aer_correctable_error_string[] = { static char *aer_correctable_error_string[] = {
"Receiver Error ", /* Bit Position 0 */ "Receiver Error ", /* Bit Position 0 */
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
"Bad TLP ", /* Bit Position 6 */ "Bad TLP ", /* Bit Position 6 */
"Bad DLLP ", /* Bit Position 7 */ "Bad DLLP ", /* Bit Position 7 */
"RELAY_NUM Rollover ", /* Bit Position 8 */ "RELAY_NUM Rollover ", /* Bit Position 8 */
NULL, NULL,
NULL, NULL,
NULL, NULL,
"Replay Timer Timeout ", /* Bit Position 12 */ "Replay Timer Timeout ", /* Bit Position 12 */
"Advisory Non-Fatal ", /* Bit Position 13 */ "Advisory Non-Fatal ", /* Bit Position 13 */
NULL, NULL,
NULL, NULL,
NULL, NULL,
...@@ -110,7 +111,7 @@ static char* aer_correctable_error_string[] = { ...@@ -110,7 +111,7 @@ static char* aer_correctable_error_string[] = {
NULL, NULL,
}; };
static char* aer_uncorrectable_error_string[] = { static char *aer_uncorrectable_error_string[] = {
NULL, NULL,
NULL, NULL,
NULL, NULL,
...@@ -123,10 +124,10 @@ static char* aer_uncorrectable_error_string[] = { ...@@ -123,10 +124,10 @@ static char* aer_uncorrectable_error_string[] = {
NULL, NULL,
NULL, NULL,
NULL, NULL,
"Poisoned TLP ", /* Bit Position 12 */ "Poisoned TLP ", /* Bit Position 12 */
"Flow Control Protocol ", /* Bit Position 13 */ "Flow Control Protocol ", /* Bit Position 13 */
"Completion Timeout ", /* Bit Position 14 */ "Completion Timeout ", /* Bit Position 14 */
"Completer Abort ", /* Bit Position 15 */ "Completer Abort ", /* Bit Position 15 */
"Unexpected Completion ", /* Bit Position 16 */ "Unexpected Completion ", /* Bit Position 16 */
"Receiver Overflow ", /* Bit Position 17 */ "Receiver Overflow ", /* Bit Position 17 */
"Malformed TLP ", /* Bit Position 18 */ "Malformed TLP ", /* Bit Position 18 */
...@@ -145,98 +146,69 @@ static char* aer_uncorrectable_error_string[] = { ...@@ -145,98 +146,69 @@ static char* aer_uncorrectable_error_string[] = {
NULL, NULL,
}; };
static char* aer_agent_string[] = { static char *aer_agent_string[] = {
"Receiver ID", "Receiver ID",
"Requester ID", "Requester ID",
"Completer ID", "Completer ID",
"Transmitter ID" "Transmitter ID"
}; };
static char * aer_get_error_source_name(int severity, static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
unsigned int status,
char errmsg_buff[])
{ {
int i; int i, status;
char * errmsg = NULL; char *errmsg = NULL;
status = (info->status & ~info->mask);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (!(status & (1 << i))) if (!(status & (1 << i)))
continue; continue;
if (severity == AER_CORRECTABLE) if (info->severity == AER_CORRECTABLE)
errmsg = aer_correctable_error_string[i]; errmsg = aer_correctable_error_string[i];
else else
errmsg = aer_uncorrectable_error_string[i]; errmsg = aer_uncorrectable_error_string[i];
if (!errmsg) { if (errmsg)
sprintf(errmsg_buff, "Unknown Error Bit %2d ", i); AER_PR(info, dev, " [%2d] %s%s\n", i, errmsg,
errmsg = errmsg_buff; info->first_error == i ? " (First)" : "");
} else
AER_PR(info, dev, " [%2d] Unknown Error Bit%s\n", i,
break; info->first_error == i ? " (First)" : "");
} }
return errmsg;
} }
static DEFINE_SPINLOCK(logbuf_lock);
static char errmsg_buff[100];
void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
{ {
char * errmsg; int id = ((dev->bus->number << 8) | dev->devfn);
int err_layer, agent;
char * loglevel; if (info->status == 0) {
AER_PR(info, dev,
if (info->severity == AER_CORRECTABLE) "PCIE Bus Error: severity=%s, type=Unaccessible, "
loglevel = KERN_WARNING; "id=%04x(Unregistered Agent ID)\n",
else aer_error_severity_string[info->severity], id);
loglevel = KERN_ERR;
printk("%s+------ PCI-Express Device Error ------+\n", loglevel);
printk("%sError Severity\t\t: %s\n", loglevel,
aer_error_severity_string[info->severity]);
if ( info->status == 0) {
printk("%sPCIE Bus Error type\t: (Unaccessible)\n", loglevel);
printk("%sUnaccessible Received\t: %s\n", loglevel,
info->flags & AER_MULTI_ERROR_VALID_FLAG ?
"Multiple" : "First");
printk("%sUnregistered Agent ID\t: %04x\n", loglevel,
(dev->bus->number << 8) | dev->devfn);
} else { } else {
err_layer = AER_GET_LAYER_ERROR(info->severity, info->status); int layer, agent;
printk("%sPCIE Bus Error type\t: %s\n", loglevel,
aer_error_layer[err_layer]);
spin_lock(&logbuf_lock);
errmsg = aer_get_error_source_name(info->severity,
info->status,
errmsg_buff);
printk("%s%s\t: %s\n", loglevel, errmsg,
info->flags & AER_MULTI_ERROR_VALID_FLAG ?
"Multiple" : "First");
spin_unlock(&logbuf_lock);
layer = AER_GET_LAYER_ERROR(info->severity, info->status);
agent = AER_GET_AGENT(info->severity, info->status); agent = AER_GET_AGENT(info->severity, info->status);
printk("%s%s\t\t: %04x\n", loglevel,
aer_agent_string[agent], AER_PR(info, dev,
(dev->bus->number << 8) | dev->devfn); "PCIE Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
aer_error_severity_string[info->severity],
printk("%sVendorID=%04xh, DeviceID=%04xh," aer_error_layer[layer], id, aer_agent_string[agent]);
" Bus=%02xh, Device=%02xh, Function=%02xh\n",
loglevel, AER_PR(info, dev,
dev->vendor, " device [%04x:%04x] error status/mask=%08x/%08x\n",
dev->device, dev->vendor, dev->device, info->status, info->mask);
dev->bus->number,
PCI_SLOT(dev->devfn), __aer_print_error(info, dev);
PCI_FUNC(dev->devfn));
if (info->tlp_header_valid) {
if (info->flags & AER_TLP_HEADER_VALID_FLAG) {
unsigned char *tlp = (unsigned char *) &info->tlp; unsigned char *tlp = (unsigned char *) &info->tlp;
printk("%sTLP Header:\n", loglevel); AER_PR(info, dev, " TLP Header:"
printk("%s%02x%02x%02x%02x %02x%02x%02x%02x" " %02x%02x%02x%02x %02x%02x%02x%02x"
" %02x%02x%02x%02x %02x%02x%02x%02x\n", " %02x%02x%02x%02x %02x%02x%02x%02x\n",
loglevel,
*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
*(tlp + 11), *(tlp + 10), *(tlp + 9), *(tlp + 11), *(tlp + 10), *(tlp + 9),
...@@ -244,5 +216,15 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) ...@@ -244,5 +216,15 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
*(tlp + 13), *(tlp + 12)); *(tlp + 13), *(tlp + 12));
} }
} }
if (info->id && info->error_dev_num > 1 && info->id == id)
AER_PR(info, dev,
" Error of this Agent(%04x) is reported first\n", id);
} }
void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
{
dev_info(&dev->dev, "AER: %s%s error received: id=%04x\n",
info->multi_error_valid ? "Multiple " : "",
aer_error_severity_string[info->severity], info->id);
}
This diff is collapsed.
...@@ -187,14 +187,9 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask) ...@@ -187,14 +187,9 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
*/ */
static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask) static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
{ {
struct pcie_port_data *port_data = pci_get_drvdata(dev);
int irq, interrupt_mode = PCIE_PORT_NO_IRQ; int irq, interrupt_mode = PCIE_PORT_NO_IRQ;
int i; int i;
/* Check MSI quirk */
if (port_data->port_type == PCIE_RC_PORT && pcie_mch_quirk)
goto Fallback;
/* Try to use MSI-X if supported */ /* Try to use MSI-X if supported */
if (!pcie_port_enable_msix(dev, vectors, mask)) if (!pcie_port_enable_msix(dev, vectors, mask))
return PCIE_PORT_MSIX_MODE; return PCIE_PORT_MSIX_MODE;
...@@ -203,7 +198,6 @@ static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask) ...@@ -203,7 +198,6 @@ static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
if (!pci_enable_msi(dev)) if (!pci_enable_msi(dev))
interrupt_mode = PCIE_PORT_MSI_MODE; interrupt_mode = PCIE_PORT_MSI_MODE;
Fallback:
if (interrupt_mode == PCIE_PORT_NO_IRQ && dev->pin) if (interrupt_mode == PCIE_PORT_NO_IRQ && dev->pin)
interrupt_mode = PCIE_PORT_INTx_MODE; interrupt_mode = PCIE_PORT_INTx_MODE;
......
...@@ -205,6 +205,7 @@ static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev) ...@@ -205,6 +205,7 @@ static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
/* If fatal, restore cfg space for possible link reset at upstream */ /* If fatal, restore cfg space for possible link reset at upstream */
if (dev->error_state == pci_channel_io_frozen) { if (dev->error_state == pci_channel_io_frozen) {
dev->state_saved = true;
pci_restore_state(dev); pci_restore_state(dev);
pcie_portdrv_restore_config(dev); pcie_portdrv_restore_config(dev);
pci_enable_pcie_error_reporting(dev); pci_enable_pcie_error_reporting(dev);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -119,6 +119,7 @@ int pci_claim_resource(struct pci_dev *dev, int resource) ...@@ -119,6 +119,7 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
return err; return err;
} }
EXPORT_SYMBOL(pci_claim_resource);
#ifdef CONFIG_PCI_QUIRKS #ifdef CONFIG_PCI_QUIRKS
void pci_disable_bridge_window(struct pci_dev *dev) void pci_disable_bridge_window(struct pci_dev *dev)
......
This diff is collapsed.
...@@ -7,6 +7,8 @@ menu "Graphics support" ...@@ -7,6 +7,8 @@ menu "Graphics support"
source "drivers/char/agp/Kconfig" source "drivers/char/agp/Kconfig"
source "drivers/gpu/vga/Kconfig"
source "drivers/gpu/drm/Kconfig" source "drivers/gpu/drm/Kconfig"
config VGASTATE config VGASTATE
......
This diff is collapsed.
...@@ -30,7 +30,18 @@ pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, ...@@ -30,7 +30,18 @@ pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
res->end = region->end; res->end = region->end;
} }
#define pcibios_scan_all_fns(a, b) 0 static inline struct resource *
pcibios_select_root(struct pci_dev *pdev, struct resource *res)
{
struct resource *root = NULL;
if (res->flags & IORESOURCE_IO)
root = &ioport_resource;
if (res->flags & IORESOURCE_MEM)
root = &iomem_resource;
return root;
}
#ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ #ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment