2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* pci.h
|
|
|
|
*
|
|
|
|
* PCI defines and function prototypes
|
|
|
|
* Copyright 1994, Drew Eckhardt
|
|
|
|
* Copyright 1997--1999 Martin Mares <mj@ucw.cz>
|
|
|
|
*
|
|
|
|
* For more information, please consult the following manuals (look at
|
|
|
|
* http://www.pcisig.com/ for how to get them):
|
|
|
|
*
|
|
|
|
* PCI BIOS Specification
|
|
|
|
* PCI Local Bus Specification
|
|
|
|
* PCI to PCI Bridge Specification
|
|
|
|
* PCI System Design Guide
|
|
|
|
*/
|
|
|
|
#ifndef LINUX_PCI_H
|
|
|
|
#define LINUX_PCI_H
|
|
|
|
|
|
|
|
|
2006-04-29 04:46:02 +04:00
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/types.h>
|
2008-04-30 00:38:48 +04:00
|
|
|
#include <linux/init.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/list.h>
|
2006-08-15 09:43:17 +04:00
|
|
|
#include <linux/compiler.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/errno.h>
|
2008-06-11 01:28:50 +04:00
|
|
|
#include <linux/kobject.h>
|
2011-07-27 03:09:06 +04:00
|
|
|
#include <linux/atomic.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/device.h>
|
2008-10-22 06:39:55 +04:00
|
|
|
#include <linux/io.h>
|
2009-03-20 06:25:16 +03:00
|
|
|
#include <linux/irqreturn.h>
|
2012-10-13 13:46:48 +04:00
|
|
|
#include <uapi/linux/pci.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-12-20 00:12:07 +03:00
|
|
|
#include <linux/pci_ids.h>
|
|
|
|
|
2013-02-28 04:06:45 +04:00
|
|
|
/*
|
|
|
|
* The PCI interface treats multi-function devices as independent
|
|
|
|
* devices. The slot/function address of each device is encoded
|
|
|
|
* in a single byte as follows:
|
|
|
|
*
|
|
|
|
* 7:3 = slot
|
|
|
|
* 2:0 = function
|
2013-11-14 22:28:18 +04:00
|
|
|
*
|
|
|
|
* PCI_DEVFN(), PCI_SLOT(), and PCI_FUNC() are defined in uapi/linux/pci.h.
|
2013-02-28 04:06:45 +04:00
|
|
|
* In the interest of not exposing interfaces to user-space unnecessarily,
|
2013-11-14 22:28:18 +04:00
|
|
|
* the following kernel-only defines are being added here.
|
2013-02-28 04:06:45 +04:00
|
|
|
*/
|
|
|
|
#define PCI_DEVID(bus, devfn) ((((u16)bus) << 8) | devfn)
|
|
|
|
/* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
|
|
|
|
#define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
|
|
|
|
|
2008-06-11 01:28:50 +04:00
|
|
|
/* pci_slot represents a physical slot */
|
|
|
|
struct pci_slot {
|
|
|
|
struct pci_bus *bus; /* The bus this slot is on */
|
|
|
|
struct list_head list; /* node in list of slots on this bus */
|
|
|
|
struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */
|
|
|
|
unsigned char number; /* PCI_SLOT(pci_dev->devfn) */
|
|
|
|
struct kobject kobj;
|
|
|
|
};
|
|
|
|
|
2008-10-21 03:41:07 +04:00
|
|
|
static inline const char *pci_slot_name(const struct pci_slot *slot)
|
|
|
|
{
|
|
|
|
return kobject_name(&slot->kobj);
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* File state for mmap()s on /proc/bus/pci/X/Y */
|
|
|
|
enum pci_mmap_state {
|
|
|
|
pci_mmap_io,
|
|
|
|
pci_mmap_mem
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This defines the direction arg to the DMA mapping routines. */
|
|
|
|
#define PCI_DMA_BIDIRECTIONAL 0
|
|
|
|
#define PCI_DMA_TODEVICE 1
|
|
|
|
#define PCI_DMA_FROMDEVICE 2
|
|
|
|
#define PCI_DMA_NONE 3
|
|
|
|
|
2008-11-21 21:39:32 +03:00
|
|
|
/*
|
|
|
|
* For PCI devices, the region numbers are assigned this way:
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
/* #0-5: standard PCI resources */
|
|
|
|
PCI_STD_RESOURCES,
|
|
|
|
PCI_STD_RESOURCE_END = 5,
|
|
|
|
|
|
|
|
/* #6: expansion ROM resource */
|
|
|
|
PCI_ROM_RESOURCE,
|
|
|
|
|
2009-03-20 06:25:11 +03:00
|
|
|
/* device specific resources */
|
|
|
|
#ifdef CONFIG_PCI_IOV
|
|
|
|
PCI_IOV_RESOURCES,
|
|
|
|
PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1,
|
|
|
|
#endif
|
|
|
|
|
2008-11-21 21:39:32 +03:00
|
|
|
/* resources assigned to buses behind the bridge */
|
|
|
|
#define PCI_BRIDGE_RESOURCE_NUM 4
|
|
|
|
|
|
|
|
PCI_BRIDGE_RESOURCES,
|
|
|
|
PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES +
|
|
|
|
PCI_BRIDGE_RESOURCE_NUM - 1,
|
|
|
|
|
|
|
|
/* total resources associated with a PCI device */
|
|
|
|
PCI_NUM_RESOURCES,
|
|
|
|
|
|
|
|
/* preserve this for compatibility */
|
2012-01-05 03:49:45 +04:00
|
|
|
DEVICE_COUNT_RESOURCE = PCI_NUM_RESOURCES,
|
2008-11-21 21:39:32 +03:00
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
typedef int __bitwise pci_power_t;
|
|
|
|
|
2005-07-28 22:37:33 +04:00
|
|
|
#define PCI_D0 ((pci_power_t __force) 0)
|
|
|
|
#define PCI_D1 ((pci_power_t __force) 1)
|
|
|
|
#define PCI_D2 ((pci_power_t __force) 2)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define PCI_D3hot ((pci_power_t __force) 3)
|
|
|
|
#define PCI_D3cold ((pci_power_t __force) 4)
|
2005-08-18 02:32:19 +04:00
|
|
|
#define PCI_UNKNOWN ((pci_power_t __force) 5)
|
2005-04-17 02:25:24 +04:00
|
|
|
#define PCI_POWER_ERROR ((pci_power_t __force) -1)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2009-04-27 21:33:16 +04:00
|
|
|
/* Remember to update this when the list above changes! */
|
|
|
|
extern const char *pci_power_names[];
|
|
|
|
|
|
|
|
static inline const char *pci_power_name(pci_power_t state)
|
|
|
|
{
|
|
|
|
return pci_power_names[1 + (int) state];
|
|
|
|
}
|
|
|
|
|
PCI/PM: add PCIe runtime D3cold support
This patch adds runtime D3cold support and corresponding ACPI platform
support. This patch only enables runtime D3cold support; it does not
enable D3cold support during system suspend/hibernate.
D3cold is the deepest power saving state for a PCIe device, where its main
power is removed. While it is in D3cold, you can't access the device at
all, not even its configuration space (which is still accessible in D3hot).
Therefore the PCI PM registers can not be used to transition into/out of
the D3cold state; that must be done by platform logic such as ACPI _PR3.
To support wakeup from D3cold, a system may provide auxiliary power, which
allows a device to request wakeup using a Beacon or the sideband WAKE#
signal. WAKE# is usually connected to platform logic such as ACPI GPE.
This is quite different from other power saving states, where devices
request wakeup via a PME message on the PCIe link.
Some devices, such as those in plug-in slots, have no direct platform
logic. For example, there is usually no ACPI _PR3 for them. D3cold
support for these devices can be done via the PCIe Downstream Port leading
to the device. When the PCIe port is powered on/off, the device is powered
on/off too. Wakeup events from the device will be notified to the
corresponding PCIe port.
For more information about PCIe D3cold and corresponding ACPI support,
please refer to:
- PCI Express Base Specification Revision 2.0
- Advanced Configuration and Power Interface Specification Revision 5.0
[bhelgaas: changelog]
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Originally-by: Zheng Yan <zheng.z.yan@intel.com>
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2012-06-23 06:23:51 +04:00
|
|
|
#define PCI_PM_D2_DELAY 200
|
|
|
|
#define PCI_PM_D3_WAIT 10
|
|
|
|
#define PCI_PM_D3COLD_WAIT 100
|
|
|
|
#define PCI_PM_BUS_WAIT 50
|
2009-01-16 23:54:43 +03:00
|
|
|
|
2005-11-17 02:10:41 +03:00
|
|
|
/** The pci_channel state describes connectivity between the CPU and
|
|
|
|
* the pci device. If some PCI bus between here and the pci device
|
|
|
|
* has crashed or locked up, this info is reflected here.
|
|
|
|
*/
|
|
|
|
typedef unsigned int __bitwise pci_channel_state_t;
|
|
|
|
|
|
|
|
enum pci_channel_state {
|
|
|
|
/* I/O channel is in normal state */
|
|
|
|
pci_channel_io_normal = (__force pci_channel_state_t) 1,
|
|
|
|
|
|
|
|
/* I/O to channel is blocked */
|
|
|
|
pci_channel_io_frozen = (__force pci_channel_state_t) 2,
|
|
|
|
|
|
|
|
/* PCI card is dead */
|
|
|
|
pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
|
|
|
|
};
|
|
|
|
|
2007-04-07 01:39:36 +04:00
|
|
|
typedef unsigned int __bitwise pcie_reset_state_t;
|
|
|
|
|
|
|
|
enum pcie_reset_state {
|
|
|
|
/* Reset is NOT asserted (Use to deassert reset) */
|
|
|
|
pcie_deassert_reset = (__force pcie_reset_state_t) 1,
|
|
|
|
|
2013-11-14 22:28:18 +04:00
|
|
|
/* Use #PERST to reset PCIe device */
|
2007-04-07 01:39:36 +04:00
|
|
|
pcie_warm_reset = (__force pcie_reset_state_t) 2,
|
|
|
|
|
2013-11-14 22:28:18 +04:00
|
|
|
/* Use PCIe Hot Reset to reset device */
|
2007-04-07 01:39:36 +04:00
|
|
|
pcie_hot_reset = (__force pcie_reset_state_t) 3
|
|
|
|
};
|
|
|
|
|
2007-10-25 12:16:30 +04:00
|
|
|
typedef unsigned short __bitwise pci_dev_flags_t;
|
|
|
|
enum pci_dev_flags {
|
|
|
|
/* INTX_DISABLE in PCI_COMMAND register disables MSI
|
|
|
|
* generation too.
|
|
|
|
*/
|
|
|
|
PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1,
|
2008-07-24 20:18:38 +04:00
|
|
|
/* Device configuration is irrevocably lost if disabled into D3 */
|
|
|
|
PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2,
|
2011-07-22 09:46:07 +04:00
|
|
|
/* Provide indication device is assigned by a Virtual Machine Manager */
|
|
|
|
PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4,
|
2007-10-25 12:16:30 +04:00
|
|
|
};
|
|
|
|
|
2008-06-11 18:35:17 +04:00
|
|
|
enum pci_irq_reroute_variant {
|
|
|
|
INTEL_IRQ_REROUTE_VARIANT = 1,
|
|
|
|
MAX_IRQ_REROUTE_VARIANTS = 3
|
|
|
|
};
|
|
|
|
|
2006-02-14 19:52:22 +03:00
|
|
|
typedef unsigned short __bitwise pci_bus_flags_t;
|
|
|
|
enum pci_bus_flags {
|
2007-05-15 15:59:13 +04:00
|
|
|
PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
|
|
|
|
PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2,
|
2006-02-14 19:52:22 +03:00
|
|
|
};
|
|
|
|
|
2013-07-31 10:53:21 +04:00
|
|
|
/* These values come from the PCI Express Spec */
|
|
|
|
enum pcie_link_width {
|
|
|
|
PCIE_LNK_WIDTH_RESRV = 0x00,
|
|
|
|
PCIE_LNK_X1 = 0x01,
|
|
|
|
PCIE_LNK_X2 = 0x02,
|
|
|
|
PCIE_LNK_X4 = 0x04,
|
|
|
|
PCIE_LNK_X8 = 0x08,
|
|
|
|
PCIE_LNK_X12 = 0x0C,
|
|
|
|
PCIE_LNK_X16 = 0x10,
|
|
|
|
PCIE_LNK_X32 = 0x20,
|
|
|
|
PCIE_LNK_WIDTH_UNKNOWN = 0xFF,
|
|
|
|
};
|
|
|
|
|
2009-12-13 16:11:31 +03:00
|
|
|
/* Based on the PCI Hotplug Spec, but some values are made up by us */
|
|
|
|
enum pci_bus_speed {
|
|
|
|
PCI_SPEED_33MHz = 0x00,
|
|
|
|
PCI_SPEED_66MHz = 0x01,
|
|
|
|
PCI_SPEED_66MHz_PCIX = 0x02,
|
|
|
|
PCI_SPEED_100MHz_PCIX = 0x03,
|
|
|
|
PCI_SPEED_133MHz_PCIX = 0x04,
|
|
|
|
PCI_SPEED_66MHz_PCIX_ECC = 0x05,
|
|
|
|
PCI_SPEED_100MHz_PCIX_ECC = 0x06,
|
|
|
|
PCI_SPEED_133MHz_PCIX_ECC = 0x07,
|
|
|
|
PCI_SPEED_66MHz_PCIX_266 = 0x09,
|
|
|
|
PCI_SPEED_100MHz_PCIX_266 = 0x0a,
|
|
|
|
PCI_SPEED_133MHz_PCIX_266 = 0x0b,
|
2009-12-13 16:11:34 +03:00
|
|
|
AGP_UNKNOWN = 0x0c,
|
|
|
|
AGP_1X = 0x0d,
|
|
|
|
AGP_2X = 0x0e,
|
|
|
|
AGP_4X = 0x0f,
|
|
|
|
AGP_8X = 0x10,
|
2009-12-13 16:11:31 +03:00
|
|
|
PCI_SPEED_66MHz_PCIX_533 = 0x11,
|
|
|
|
PCI_SPEED_100MHz_PCIX_533 = 0x12,
|
|
|
|
PCI_SPEED_133MHz_PCIX_533 = 0x13,
|
|
|
|
PCIE_SPEED_2_5GT = 0x14,
|
|
|
|
PCIE_SPEED_5_0GT = 0x15,
|
2009-12-13 16:11:35 +03:00
|
|
|
PCIE_SPEED_8_0GT = 0x16,
|
2009-12-13 16:11:31 +03:00
|
|
|
PCI_SPEED_UNKNOWN = 0xff,
|
|
|
|
};
|
|
|
|
|
2011-05-10 20:02:11 +04:00
|
|
|
struct pci_cap_saved_data {
|
2006-02-08 12:11:38 +03:00
|
|
|
char cap_nr;
|
2011-05-10 20:02:11 +04:00
|
|
|
unsigned int size;
|
2006-02-08 12:11:38 +03:00
|
|
|
u32 data[0];
|
|
|
|
};
|
|
|
|
|
2011-05-10 20:02:11 +04:00
|
|
|
struct pci_cap_saved_state {
|
|
|
|
struct hlist_node next;
|
|
|
|
struct pci_cap_saved_data cap;
|
|
|
|
};
|
|
|
|
|
PCI: add PCI Express ASPM support
PCI Express ASPM defines a protocol for PCI Express components in the D0
state to reduce Link power by placing their Links into a low power state
and instructing the other end of the Link to do likewise. This
capability allows hardware-autonomous, dynamic Link power reduction
beyond what is achievable by software-only controlled power management.
However, The device should be configured by software appropriately.
Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for
ASPM, a sysfs file /sys/module/pcie_aspm/parameters/policy can control
it. The interface can be used as a boot option too. Currently we have
below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM
state and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.
In my test, power difference between powersave mode and performance mode
is about 1.3w in a system with 3 PCIE links.
Note: some devices might not work well with aspm, either because chipset
issue or device issue. The patch provide API (pci_disable_link_state),
driver can disable ASPM for specific device.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-02-25 04:46:41 +03:00
|
|
|
struct pcie_link_state;
|
2008-04-28 23:30:35 +04:00
|
|
|
struct pci_vpd;
|
2009-03-20 06:25:11 +03:00
|
|
|
struct pci_sriov;
|
2009-05-18 09:51:32 +04:00
|
|
|
struct pci_ats;
|
2008-04-28 23:30:35 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* The pci_dev structure is used to describe PCI devices.
|
|
|
|
*/
|
|
|
|
struct pci_dev {
|
|
|
|
struct list_head bus_list; /* node in per-bus list */
|
|
|
|
struct pci_bus *bus; /* bus this device is on */
|
|
|
|
struct pci_bus *subordinate; /* bus this device bridges to */
|
|
|
|
|
|
|
|
void *sysdata; /* hook for sys-specific extension */
|
|
|
|
struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
|
2008-06-11 01:28:50 +04:00
|
|
|
struct pci_slot *slot; /* Physical slot this device is in */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
unsigned int devfn; /* encoded device & function index */
|
|
|
|
unsigned short vendor;
|
|
|
|
unsigned short device;
|
|
|
|
unsigned short subsystem_vendor;
|
|
|
|
unsigned short subsystem_device;
|
|
|
|
unsigned int class; /* 3 bytes: (base,sub,prog-if) */
|
2007-06-09 02:46:30 +04:00
|
|
|
u8 revision; /* PCI revision, low byte of class word */
|
2005-04-17 02:20:36 +04:00
|
|
|
u8 hdr_type; /* PCI header type (`multi' flag masked out) */
|
2013-11-14 22:28:18 +04:00
|
|
|
u8 pcie_cap; /* PCIe capability offset */
|
2013-04-04 20:54:30 +04:00
|
|
|
u8 msi_cap; /* MSI capability offset */
|
|
|
|
u8 msix_cap; /* MSI-X capability offset */
|
2013-11-14 22:28:18 +04:00
|
|
|
u8 pcie_mpss:3; /* PCIe Max Payload Size Supported */
|
2005-04-17 02:20:36 +04:00
|
|
|
u8 rom_base_reg; /* which config register controls the ROM */
|
2013-11-14 22:28:18 +04:00
|
|
|
u8 pin; /* which interrupt pin this device uses */
|
|
|
|
u16 pcie_flags_reg; /* cached PCIe Capabilities Register */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct pci_driver *driver; /* which driver has allocated this device */
|
|
|
|
u64 dma_mask; /* Mask of the bits of bus address this
|
|
|
|
device implements. Normally this is
|
|
|
|
0xffffffff. You only need to change
|
|
|
|
this if your device has broken DMA
|
|
|
|
or supports 64-bit transfers. */
|
|
|
|
|
2008-02-05 09:27:55 +03:00
|
|
|
struct device_dma_parameters dma_parms;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
pci_power_t current_state; /* Current operating state. In ACPI-speak,
|
|
|
|
this is D0-D3, D0 being fully functional,
|
|
|
|
and D3 being off. */
|
2013-04-18 02:57:56 +04:00
|
|
|
u8 pm_cap; /* PM capability offset */
|
2008-07-07 05:36:24 +04:00
|
|
|
unsigned int pme_support:5; /* Bitmask of states from which PME#
|
|
|
|
can be generated */
|
2010-02-18 01:39:08 +03:00
|
|
|
unsigned int pme_interrupt:1;
|
PCI / PM: Extend PME polling to all PCI devices
The land of PCI power management is a land of sorrow and ugliness,
especially in the area of signaling events by devices. There are
devices that set their PME Status bits, but don't really bother
to send a PME message or assert PME#. There are hardware vendors
who don't connect PME# lines to the system core logic (they know
who they are). There are PCI Express Root Ports that don't bother
to trigger interrupts when they receive PME messages from the devices
below. There are ACPI BIOSes that forget to provide _PRW methods for
devices capable of signaling wakeup. Finally, there are BIOSes that
do provide _PRW methods for such devices, but then don't bother to
call Notify() for those devices from the corresponding _Lxx/_Exx
GPE-handling methods. In all of these cases the kernel doesn't have
a chance to receive a proper notification that it should wake up a
device, so devices stay in low-power states forever. Worse yet, in
some cases they continuously send PME Messages that are silently
ignored, because the kernel simply doesn't know that it should clear
the device's PME Status bit.
This problem was first observed for "parallel" (non-Express) PCI
devices on add-on cards and Matthew Garrett addressed it by adding
code that polls PME Status bits of such devices, if they are enabled
to signal PME, to the kernel. Recently, however, it has turned out
that PCI Express devices are also affected by this issue and that it
is not limited to add-on devices, so it seems necessary to extend
the PME polling to all PCI devices, including PCI Express and planar
ones. Still, it would be wasteful to poll the PME Status bits of
devices that are known to receive proper PME notifications, so make
the kernel (1) poll the PME Status bits of all PCI and PCIe devices
enabled to signal PME and (2) disable the PME Status polling for
devices for which correct PME notifications are received.
Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-10-04 01:16:33 +04:00
|
|
|
unsigned int pme_poll:1; /* Poll device's PME status bit */
|
2008-07-07 05:36:24 +04:00
|
|
|
unsigned int d1_support:1; /* Low power state D1 is supported */
|
|
|
|
unsigned int d2_support:1; /* Low power state D2 is supported */
|
PCI/PM: add PCIe runtime D3cold support
This patch adds runtime D3cold support and corresponding ACPI platform
support. This patch only enables runtime D3cold support; it does not
enable D3cold support during system suspend/hibernate.
D3cold is the deepest power saving state for a PCIe device, where its main
power is removed. While it is in D3cold, you can't access the device at
all, not even its configuration space (which is still accessible in D3hot).
Therefore the PCI PM registers can not be used to transition into/out of
the D3cold state; that must be done by platform logic such as ACPI _PR3.
To support wakeup from D3cold, a system may provide auxiliary power, which
allows a device to request wakeup using a Beacon or the sideband WAKE#
signal. WAKE# is usually connected to platform logic such as ACPI GPE.
This is quite different from other power saving states, where devices
request wakeup via a PME message on the PCIe link.
Some devices, such as those in plug-in slots, have no direct platform
logic. For example, there is usually no ACPI _PR3 for them. D3cold
support for these devices can be done via the PCIe Downstream Port leading
to the device. When the PCIe port is powered on/off, the device is powered
on/off too. Wakeup events from the device will be notified to the
corresponding PCIe port.
For more information about PCIe D3cold and corresponding ACPI support,
please refer to:
- PCI Express Base Specification Revision 2.0
- Advanced Configuration and Power Interface Specification Revision 5.0
[bhelgaas: changelog]
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Originally-by: Zheng Yan <zheng.z.yan@intel.com>
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2012-06-23 06:23:51 +04:00
|
|
|
unsigned int no_d1d2:1; /* D1 and D2 are forbidden */
|
|
|
|
unsigned int no_d3cold:1; /* D3cold is forbidden */
|
|
|
|
unsigned int d3cold_allowed:1; /* D3cold is allowed by user */
|
2010-07-16 21:19:22 +04:00
|
|
|
unsigned int mmio_always_on:1; /* disallow turning off io/mem
|
|
|
|
decoding during bar sizing */
|
2009-09-09 01:14:49 +04:00
|
|
|
unsigned int wakeup_prepared:1;
|
PCI/PM: add PCIe runtime D3cold support
This patch adds runtime D3cold support and corresponding ACPI platform
support. This patch only enables runtime D3cold support; it does not
enable D3cold support during system suspend/hibernate.
D3cold is the deepest power saving state for a PCIe device, where its main
power is removed. While it is in D3cold, you can't access the device at
all, not even its configuration space (which is still accessible in D3hot).
Therefore the PCI PM registers can not be used to transition into/out of
the D3cold state; that must be done by platform logic such as ACPI _PR3.
To support wakeup from D3cold, a system may provide auxiliary power, which
allows a device to request wakeup using a Beacon or the sideband WAKE#
signal. WAKE# is usually connected to platform logic such as ACPI GPE.
This is quite different from other power saving states, where devices
request wakeup via a PME message on the PCIe link.
Some devices, such as those in plug-in slots, have no direct platform
logic. For example, there is usually no ACPI _PR3 for them. D3cold
support for these devices can be done via the PCIe Downstream Port leading
to the device. When the PCIe port is powered on/off, the device is powered
on/off too. Wakeup events from the device will be notified to the
corresponding PCIe port.
For more information about PCIe D3cold and corresponding ACPI support,
please refer to:
- PCI Express Base Specification Revision 2.0
- Advanced Configuration and Power Interface Specification Revision 5.0
[bhelgaas: changelog]
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Originally-by: Zheng Yan <zheng.z.yan@intel.com>
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2012-06-23 06:23:51 +04:00
|
|
|
unsigned int runtime_d3cold:1; /* whether go through runtime
|
|
|
|
D3cold, not set for devices
|
|
|
|
powered on/off by the
|
|
|
|
corresponding bridge */
|
2009-12-31 14:15:54 +03:00
|
|
|
unsigned int d3_delay; /* D3->D0 transition time in ms */
|
PCI/PM: add PCIe runtime D3cold support
This patch adds runtime D3cold support and corresponding ACPI platform
support. This patch only enables runtime D3cold support; it does not
enable D3cold support during system suspend/hibernate.
D3cold is the deepest power saving state for a PCIe device, where its main
power is removed. While it is in D3cold, you can't access the device at
all, not even its configuration space (which is still accessible in D3hot).
Therefore the PCI PM registers can not be used to transition into/out of
the D3cold state; that must be done by platform logic such as ACPI _PR3.
To support wakeup from D3cold, a system may provide auxiliary power, which
allows a device to request wakeup using a Beacon or the sideband WAKE#
signal. WAKE# is usually connected to platform logic such as ACPI GPE.
This is quite different from other power saving states, where devices
request wakeup via a PME message on the PCIe link.
Some devices, such as those in plug-in slots, have no direct platform
logic. For example, there is usually no ACPI _PR3 for them. D3cold
support for these devices can be done via the PCIe Downstream Port leading
to the device. When the PCIe port is powered on/off, the device is powered
on/off too. Wakeup events from the device will be notified to the
corresponding PCIe port.
For more information about PCIe D3cold and corresponding ACPI support,
please refer to:
- PCI Express Base Specification Revision 2.0
- Advanced Configuration and Power Interface Specification Revision 5.0
[bhelgaas: changelog]
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Originally-by: Zheng Yan <zheng.z.yan@intel.com>
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2012-06-23 06:23:51 +04:00
|
|
|
unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
PCI: add PCI Express ASPM support
PCI Express ASPM defines a protocol for PCI Express components in the D0
state to reduce Link power by placing their Links into a low power state
and instructing the other end of the Link to do likewise. This
capability allows hardware-autonomous, dynamic Link power reduction
beyond what is achievable by software-only controlled power management.
However, The device should be configured by software appropriately.
Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for
ASPM, a sysfs file /sys/module/pcie_aspm/parameters/policy can control
it. The interface can be used as a boot option too. Currently we have
below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM
state and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.
In my test, power difference between powersave mode and performance mode
is about 1.3w in a system with 3 PCIE links.
Note: some devices might not work well with aspm, either because chipset
issue or device issue. The patch provide API (pci_disable_link_state),
driver can disable ASPM for specific device.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-02-25 04:46:41 +03:00
|
|
|
#ifdef CONFIG_PCIEASPM
|
2013-11-14 22:28:18 +04:00
|
|
|
struct pcie_link_state *link_state; /* ASPM link state */
|
PCI: add PCI Express ASPM support
PCI Express ASPM defines a protocol for PCI Express components in the D0
state to reduce Link power by placing their Links into a low power state
and instructing the other end of the Link to do likewise. This
capability allows hardware-autonomous, dynamic Link power reduction
beyond what is achievable by software-only controlled power management.
However, The device should be configured by software appropriately.
Enabling ASPM will save power, but will introduce device latency.
This patch adds ASPM support in Linux. It introduces a global policy for
ASPM, a sysfs file /sys/module/pcie_aspm/parameters/policy can control
it. The interface can be used as a boot option too. Currently we have
below setting:
-default, BIOS default setting
-powersave, highest power saving mode, enable all available ASPM
state and clock power management
-performance, highest performance, disable ASPM and clock power
management
By default, the 'default' policy is used currently.
In my test, power difference between powersave mode and performance mode
is about 1.3w in a system with 3 PCIE links.
Note: some devices might not work well with aspm, either because chipset
issue or device issue. The patch provide API (pci_disable_link_state),
driver can disable ASPM for specific device.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-02-25 04:46:41 +03:00
|
|
|
#endif
|
|
|
|
|
2005-11-17 02:10:41 +03:00
|
|
|
pci_channel_state_t error_state; /* current connectivity state */
|
2005-04-17 02:20:36 +04:00
|
|
|
struct device dev; /* Generic device interface */
|
|
|
|
|
|
|
|
int cfg_size; /* Size of configuration space */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Instead of touching interrupt line and base address registers
|
|
|
|
* directly, use the values stored here. They might be different!
|
|
|
|
*/
|
|
|
|
unsigned int irq;
|
|
|
|
struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
|
|
|
|
|
2013-01-22 01:20:51 +04:00
|
|
|
bool match_driver; /* Skip attaching driver */
|
2005-04-17 02:20:36 +04:00
|
|
|
/* These fields are used by common fixups */
|
2013-11-14 22:28:18 +04:00
|
|
|
unsigned int transparent:1; /* Subtractive decode PCI bridge */
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int multifunction:1;/* Part of multi-function device */
|
|
|
|
/* keep track of device state */
|
2008-02-15 01:56:56 +03:00
|
|
|
unsigned int is_added:1;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int is_busmaster:1; /* device is busmaster */
|
2005-08-17 02:15:58 +04:00
|
|
|
unsigned int no_msi:1; /* device may not use msi */
|
2011-11-04 12:45:59 +04:00
|
|
|
unsigned int block_cfg_access:1; /* config space access is blocked */
|
2006-05-09 04:06:09 +04:00
|
|
|
unsigned int broken_parity_status:1; /* Device generates false positive parity */
|
2008-06-11 18:35:17 +04:00
|
|
|
unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */
|
2013-11-14 22:28:18 +04:00
|
|
|
unsigned int msi_enabled:1;
|
2006-05-26 06:58:27 +04:00
|
|
|
unsigned int msix_enabled:1;
|
2008-10-14 10:02:53 +04:00
|
|
|
unsigned int ari_enabled:1; /* ARI forwarding */
|
devres: device resource management
Implement device resource management, in short, devres. A device
driver can allocate arbirary size of devres data which is associated
with a release function. On driver detach, release function is
invoked on the devres data, then, devres data is freed.
devreses are typed by associated release functions. Some devreses are
better represented by single instance of the type while others need
multiple instances sharing the same release function. Both usages are
supported.
devreses can be grouped using devres group such that a device driver
can easily release acquired resources halfway through initialization
or selectively release resources (e.g. resources for port 1 out of 4
ports).
This patch adds devres core including documentation and the following
managed interfaces.
* alloc/free : devm_kzalloc(), devm_kzfree()
* IO region : devm_request_region(), devm_release_region()
* IRQ : devm_request_irq(), devm_free_irq()
* DMA : dmam_alloc_coherent(), dmam_free_coherent(),
dmam_declare_coherent_memory(), dmam_pool_create(),
dmam_pool_destroy()
* PCI : pcim_enable_device(), pcim_pin_device(), pci_is_managed()
* iomap : devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(),
devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(),
pcim_iomap(), pcim_iounmap()
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-01-20 10:00:26 +03:00
|
|
|
unsigned int is_managed:1;
|
2009-07-31 02:33:21 +04:00
|
|
|
unsigned int needs_freset:1; /* Dev requires fundamental reset */
|
2009-01-16 23:54:43 +03:00
|
|
|
unsigned int state_saved:1;
|
2009-03-20 06:25:11 +03:00
|
|
|
unsigned int is_physfn:1;
|
2009-03-20 06:25:15 +03:00
|
|
|
unsigned int is_virtfn:1;
|
2009-07-28 00:37:48 +04:00
|
|
|
unsigned int reset_fn:1;
|
2009-09-10 01:09:24 +04:00
|
|
|
unsigned int is_hotplug_bridge:1;
|
2010-05-18 10:35:16 +04:00
|
|
|
unsigned int __aer_firmware_first_valid:1;
|
|
|
|
unsigned int __aer_firmware_first:1;
|
2012-06-17 00:40:22 +04:00
|
|
|
unsigned int broken_intx_masking:1;
|
2012-07-09 23:38:57 +04:00
|
|
|
unsigned int io_window_1k:1; /* Intel P2P bridge 1K I/O windows */
|
2007-10-25 12:16:30 +04:00
|
|
|
pci_dev_flags_t dev_flags;
|
PCI: switch pci_{enable,disable}_device() to be nestable
Changes the pci_{enable,disable}_device() functions to work in a
nested basis, so that eg, three calls to enable_device() require three
calls to disable_device().
The reason for this is to simplify PCI drivers for
multi-interface/capability devices. These are devices that cram more
than one interface in a single function. A relevant example of that is
the Wireless [USB] Host Controller Interface (similar to EHCI) [see
http://www.intel.com/technology/comms/wusb/whci.htm].
In these kind of devices, multiple interfaces are accessed through a
single bar and IRQ line. For that, the drivers map only the smallest
area of the bar to access their register banks and use shared IRQ
handlers.
However, because the order at which those drivers load cannot be known
ahead of time, the sequence in which the calls to pci_enable_device()
and pci_disable_device() cannot be predicted. Thus:
1. driverA starts pci_enable_device()
2. driverB starts pci_enable_device()
3. driverA shutdown pci_disable_device()
4. driverB shutdown pci_disable_device()
between steps 3 and 4, driver B would loose access to it's device,
even if it didn't intend to.
By using this modification, the device won't be disabled until all the
callers to enable() have called disable().
This is implemented by replacing 'struct pci_dev->is_enabled' from a
bitfield to an atomic use count. Each caller to enable increments it,
each caller to disable decrements it. When the count increments from 0
to 1, __pci_enable_device() is called to actually enable the
device. When it drops to zero, pci_disable_device() actually does the
disabling.
We keep the backend __pci_enable_device() for pci_default_resume() to
use and also change the sysfs method implementation, so that userspace
enabling/disabling the device doesn't disable it one time too much.
Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-11-22 23:40:31 +03:00
|
|
|
atomic_t enable_cnt; /* pci_enable_device has been called */
|
2005-08-17 02:15:58 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
u32 saved_config_space[16]; /* config space saved at suspend time */
|
2006-02-08 12:11:38 +03:00
|
|
|
struct hlist_head saved_cap_space;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */
|
|
|
|
int rom_attr_enabled; /* has display of the rom attribute been enabled? */
|
|
|
|
struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */
|
2008-03-19 03:00:22 +03:00
|
|
|
struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */
|
2007-01-28 22:42:52 +03:00
|
|
|
#ifdef CONFIG_PCI_MSI
|
2007-04-05 11:19:10 +04:00
|
|
|
struct list_head msi_list;
|
2011-10-06 22:08:18 +04:00
|
|
|
struct kset *msi_kset;
|
2007-01-28 22:42:52 +03:00
|
|
|
#endif
|
2008-03-05 19:52:39 +03:00
|
|
|
struct pci_vpd *vpd;
|
2011-10-30 19:35:08 +04:00
|
|
|
#ifdef CONFIG_PCI_ATS
|
2009-03-20 06:25:15 +03:00
|
|
|
union {
|
|
|
|
struct pci_sriov *sriov; /* SR-IOV capability related */
|
|
|
|
struct pci_dev *physfn; /* the PF this VF is associated with */
|
|
|
|
};
|
2009-05-18 09:51:32 +04:00
|
|
|
struct pci_ats *ats; /* Address Translation Service */
|
2009-03-20 06:25:11 +03:00
|
|
|
#endif
|
2012-12-10 22:24:42 +04:00
|
|
|
phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */
|
2012-12-06 01:33:27 +04:00
|
|
|
size_t romlen; /* Length of ROM if it's not from the BAR */
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
2010-04-09 04:07:55 +04:00
|
|
|
static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_PCI_IOV
|
|
|
|
if (dev->is_virtfn)
|
|
|
|
dev = dev->physfn;
|
|
|
|
#endif
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
2013-05-25 17:48:30 +04:00
|
|
|
struct pci_dev *pci_alloc_dev(struct pci_bus *bus);
|
|
|
|
struct pci_dev * __deprecated alloc_pci_dev(void);
|
2007-04-05 11:19:08 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
|
|
|
|
#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
|
|
|
|
|
2006-12-13 01:55:59 +03:00
|
|
|
static inline int pci_channel_offline(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
return (pdev->error_state != pci_channel_io_normal);
|
|
|
|
}
|
|
|
|
|
2012-05-18 05:51:12 +04:00
|
|
|
extern struct resource busn_resource;
|
|
|
|
|
2012-02-24 07:19:00 +04:00
|
|
|
struct pci_host_bridge_window {
|
|
|
|
struct list_head list;
|
|
|
|
struct resource *res; /* host bridge aperture (CPU address) */
|
|
|
|
resource_size_t offset; /* bus address + offset = CPU address */
|
|
|
|
};
|
2006-02-08 12:11:38 +03:00
|
|
|
|
2012-02-24 07:18:59 +04:00
|
|
|
struct pci_host_bridge {
|
2012-04-03 05:31:53 +04:00
|
|
|
struct device dev;
|
2012-02-24 07:18:59 +04:00
|
|
|
struct pci_bus *bus; /* root bus */
|
2012-02-24 07:19:00 +04:00
|
|
|
struct list_head windows; /* pci_host_bridge_windows */
|
2012-04-03 05:31:53 +04:00
|
|
|
void (*release_fn)(struct pci_host_bridge *);
|
|
|
|
void *release_data;
|
2012-02-24 07:18:59 +04:00
|
|
|
};
|
2006-02-08 12:11:38 +03:00
|
|
|
|
2012-04-03 05:31:53 +04:00
|
|
|
#define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
|
2012-04-03 05:31:53 +04:00
|
|
|
void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
|
|
|
|
void (*release_fn)(struct pci_host_bridge *),
|
|
|
|
void *release_data);
|
2012-04-03 05:31:53 +04:00
|
|
|
|
ACPI / PCI: Set root bridge ACPI handle in advance
The ACPI handles of PCI root bridges need to be known to
acpi_bind_one(), so that it can create the appropriate
"firmware_node" and "physical_node" files for them, but currently
the way it gets to know those handles is not exactly straightforward
(to put it lightly).
This is how it works, roughly:
1. acpi_bus_scan() finds the handle of a PCI root bridge,
creates a struct acpi_device object for it and passes that
object to acpi_pci_root_add().
2. acpi_pci_root_add() creates a struct acpi_pci_root object,
populates its "device" field with its argument's address
(device->handle is the ACPI handle found in step 1).
3. The struct acpi_pci_root object created in step 2 is passed
to pci_acpi_scan_root() and used to get resources that are
passed to pci_create_root_bus().
4. pci_create_root_bus() creates a struct pci_host_bridge object
and passes its "dev" member to device_register().
5. platform_notify(), which for systems with ACPI is set to
acpi_platform_notify(), is called.
So far, so good. Now it starts to be "interesting".
6. acpi_find_bridge_device() is used to find the ACPI handle of
the given device (which is the PCI root bridge) and executes
acpi_pci_find_root_bridge(), among other things, for the
given device object.
7. acpi_pci_find_root_bridge() uses the name (sic!) of the given
device object to extract the segment and bus numbers of the PCI
root bridge and passes them to acpi_get_pci_rootbridge_handle().
8. acpi_get_pci_rootbridge_handle() browses the list of ACPI PCI
root bridges and finds the one that matches the given segment
and bus numbers. Its handle is then used to initialize the
ACPI handle of the PCI root bridge's device object by
acpi_bind_one(). However, this is *exactly* the ACPI handle we
started with in step 1.
Needless to say, this is quite embarassing, but it may be avoided
thanks to commit f3fd0c8 (ACPI: Allow ACPI handles of devices to be
initialized in advance), which makes it possible to initialize the
ACPI handle of a device before passing it to device_register().
Accordingly, add a new __weak routine, pcibios_root_bridge_prepare(),
defaulting to an empty implementation that can be replaced by the
interested architecutres (x86 and ia64 at the moment) with functions
that will set the root bridge's ACPI handle before its dev member is
passed to device_register(). Make both x86 and ia64 provide such
implementations of pcibios_root_bridge_prepare() and remove
acpi_pci_find_root_bridge() and acpi_get_pci_rootbridge_handle() that
aren't necessary any more.
Included is a fix for breakage on systems with non-ACPI PCI host
bridges from Bjorn Helgaas.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2013-01-10 01:33:37 +04:00
|
|
|
int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
|
|
|
|
|
2010-02-23 20:24:36 +03:00
|
|
|
/*
|
|
|
|
* The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
|
|
|
|
* to P2P or CardBus bridge windows) go in a table. Additional ones (for
|
|
|
|
* buses below host bridges or subtractive decode bridges) go in the list.
|
|
|
|
* Use pci_bus_for_each_resource() to iterate through all the resources.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCI_SUBTRACTIVE_DECODE means the bridge forwards the window implicitly
|
|
|
|
* and there's no way to program the bridge with the details of the window.
|
|
|
|
* This does not apply to ACPI _CRS windows, even with the _DEC subtractive-
|
|
|
|
* decode bit set, because they are explicit and can be programmed with _SRS.
|
|
|
|
*/
|
|
|
|
#define PCI_SUBTRACTIVE_DECODE 0x1
|
|
|
|
|
|
|
|
struct pci_bus_resource {
|
|
|
|
struct list_head list;
|
|
|
|
struct resource *res;
|
|
|
|
unsigned int flags;
|
|
|
|
};
|
2005-07-28 22:37:33 +04:00
|
|
|
|
|
|
|
#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct pci_bus {
|
|
|
|
struct list_head node; /* node in list of buses */
|
|
|
|
struct pci_bus *parent; /* parent bus this bridge is on */
|
|
|
|
struct list_head children; /* list of child buses */
|
|
|
|
struct list_head devices; /* list of devices on this bus */
|
|
|
|
struct pci_dev *self; /* bridge device as seen by parent */
|
2008-06-11 01:28:50 +04:00
|
|
|
struct list_head slots; /* list of slots on this bus */
|
2010-02-23 20:24:36 +03:00
|
|
|
struct resource *resource[PCI_BRIDGE_RESOURCE_NUM];
|
|
|
|
struct list_head resources; /* address space routed to this bus */
|
2012-05-18 05:51:11 +04:00
|
|
|
struct resource busn_res; /* bus numbers routed to this bus */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct pci_ops *ops; /* configuration access functions */
|
2013-08-10 00:27:08 +04:00
|
|
|
struct msi_chip *msi; /* MSI controller */
|
2005-04-17 02:20:36 +04:00
|
|
|
void *sysdata; /* hook for sys-specific extension */
|
|
|
|
struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
|
|
|
|
|
|
|
|
unsigned char number; /* bus number */
|
|
|
|
unsigned char primary; /* number of primary bridge */
|
2009-12-13 16:11:32 +03:00
|
|
|
unsigned char max_bus_speed; /* enum pci_bus_speed */
|
|
|
|
unsigned char cur_bus_speed; /* enum pci_bus_speed */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
char name[48];
|
|
|
|
|
|
|
|
unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */
|
2013-11-14 22:28:18 +04:00
|
|
|
pci_bus_flags_t bus_flags; /* inherited by child buses */
|
2005-04-17 02:20:36 +04:00
|
|
|
struct device *bridge;
|
2007-05-23 06:47:54 +04:00
|
|
|
struct device dev;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct bin_attribute *legacy_io; /* legacy I/O for this bus */
|
|
|
|
struct bin_attribute *legacy_mem; /* legacy mem */
|
2008-03-13 07:48:03 +03:00
|
|
|
unsigned int is_added:1;
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define pci_bus_b(n) list_entry(n, struct pci_bus, node)
|
2007-05-23 06:47:54 +04:00
|
|
|
#define to_pci_bus(n) container_of(n, struct pci_bus, dev)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2009-03-20 23:55:55 +03:00
|
|
|
/*
|
2013-11-14 22:28:18 +04:00
|
|
|
* Returns true if the PCI bus is root (behind host-PCI bridge),
|
2009-03-20 23:55:55 +03:00
|
|
|
* false otherwise
|
2013-09-25 01:14:57 +04:00
|
|
|
*
|
|
|
|
* Some code assumes that "bus->self == NULL" means that bus is a root bus.
|
|
|
|
* This is incorrect because "virtual" buses added for SR-IOV (via
|
|
|
|
* virtfn_add_bus()) have "bus->self == NULL" but are not root buses.
|
2009-03-20 23:55:55 +03:00
|
|
|
*/
|
|
|
|
static inline bool pci_is_root_bus(struct pci_bus *pbus)
|
|
|
|
{
|
|
|
|
return !(pbus->parent);
|
|
|
|
}
|
|
|
|
|
2013-11-06 21:11:48 +04:00
|
|
|
static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
dev = pci_physfn(dev);
|
|
|
|
if (pci_is_root_bus(dev->bus))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return dev->bus->self;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:50:27 +03:00
|
|
|
#ifdef CONFIG_PCI_MSI
|
|
|
|
static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev)
|
|
|
|
{
|
|
|
|
return pci_dev->msi_enabled || pci_dev->msix_enabled;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false; }
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Error values that may be returned by PCI functions.
|
|
|
|
*/
|
|
|
|
#define PCIBIOS_SUCCESSFUL 0x00
|
|
|
|
#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81
|
|
|
|
#define PCIBIOS_BAD_VENDOR_ID 0x83
|
|
|
|
#define PCIBIOS_DEVICE_NOT_FOUND 0x86
|
|
|
|
#define PCIBIOS_BAD_REGISTER_NUMBER 0x87
|
|
|
|
#define PCIBIOS_SET_FAILED 0x88
|
|
|
|
#define PCIBIOS_BUFFER_TOO_SMALL 0x89
|
|
|
|
|
2012-06-11 09:27:33 +04:00
|
|
|
/*
|
2013-11-14 22:28:18 +04:00
|
|
|
* Translate above to generic errno for passing back through non-PCI code.
|
2012-06-11 09:27:33 +04:00
|
|
|
*/
|
|
|
|
static inline int pcibios_err_to_errno(int err)
|
|
|
|
{
|
|
|
|
if (err <= PCIBIOS_SUCCESSFUL)
|
|
|
|
return err; /* Assume already errno */
|
|
|
|
|
|
|
|
switch (err) {
|
|
|
|
case PCIBIOS_FUNC_NOT_SUPPORTED:
|
|
|
|
return -ENOENT;
|
|
|
|
case PCIBIOS_BAD_VENDOR_ID:
|
|
|
|
return -EINVAL;
|
|
|
|
case PCIBIOS_DEVICE_NOT_FOUND:
|
|
|
|
return -ENODEV;
|
|
|
|
case PCIBIOS_BAD_REGISTER_NUMBER:
|
|
|
|
return -EFAULT;
|
|
|
|
case PCIBIOS_SET_FAILED:
|
|
|
|
return -EIO;
|
|
|
|
case PCIBIOS_BUFFER_TOO_SMALL:
|
|
|
|
return -ENOSPC;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOTTY;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Low-level architecture-dependent routines */
|
|
|
|
|
|
|
|
struct pci_ops {
|
|
|
|
int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
|
|
|
|
int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
|
|
|
|
};
|
|
|
|
|
2008-02-10 17:45:28 +03:00
|
|
|
/*
|
|
|
|
* ACPI needs to be able to access PCI config space before we've done a
|
|
|
|
* PCI bus scan and created pci_bus structures.
|
|
|
|
*/
|
2013-04-12 22:02:59 +04:00
|
|
|
int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
|
|
|
|
int reg, int len, u32 *val);
|
|
|
|
int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
|
|
|
|
int reg, int len, u32 val);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct pci_bus_region {
|
2013-12-21 19:39:47 +04:00
|
|
|
dma_addr_t start;
|
|
|
|
dma_addr_t end;
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pci_dynids {
|
|
|
|
spinlock_t lock; /* protects list, index */
|
|
|
|
struct list_head list; /* for IDs added at runtime */
|
|
|
|
};
|
|
|
|
|
2013-11-14 22:28:18 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* PCI Error Recovery System (PCI-ERS). If a PCI device driver provides
|
|
|
|
* a set of callbacks in struct pci_error_handlers, that device driver
|
|
|
|
* will be notified of PCI bus errors, and will be driven to recovery
|
|
|
|
* when an error occurs.
|
2005-11-17 02:10:41 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef unsigned int __bitwise pci_ers_result_t;
|
|
|
|
|
|
|
|
enum pci_ers_result {
|
|
|
|
/* no result/none/not supported in device driver */
|
|
|
|
PCI_ERS_RESULT_NONE = (__force pci_ers_result_t) 1,
|
|
|
|
|
|
|
|
/* Device driver can recover without slot reset */
|
|
|
|
PCI_ERS_RESULT_CAN_RECOVER = (__force pci_ers_result_t) 2,
|
|
|
|
|
|
|
|
/* Device driver wants slot to be reset. */
|
|
|
|
PCI_ERS_RESULT_NEED_RESET = (__force pci_ers_result_t) 3,
|
|
|
|
|
|
|
|
/* Device has completely failed, is unrecoverable */
|
|
|
|
PCI_ERS_RESULT_DISCONNECT = (__force pci_ers_result_t) 4,
|
|
|
|
|
|
|
|
/* Device driver is fully recovered and operational */
|
|
|
|
PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5,
|
2012-11-17 15:47:18 +04:00
|
|
|
|
|
|
|
/* No AER capabilities registered for the driver */
|
|
|
|
PCI_ERS_RESULT_NO_AER_DRIVER = (__force pci_ers_result_t) 6,
|
2005-11-17 02:10:41 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* PCI bus error event callbacks */
|
2008-01-31 02:21:33 +03:00
|
|
|
struct pci_error_handlers {
|
2005-11-17 02:10:41 +03:00
|
|
|
/* PCI bus error detected on this device */
|
|
|
|
pci_ers_result_t (*error_detected)(struct pci_dev *dev,
|
2008-01-31 02:21:33 +03:00
|
|
|
enum pci_channel_state error);
|
2005-11-17 02:10:41 +03:00
|
|
|
|
|
|
|
/* MMIO has been re-enabled, but not DMA */
|
|
|
|
pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);
|
|
|
|
|
|
|
|
/* PCI Express link has been reset */
|
|
|
|
pci_ers_result_t (*link_reset)(struct pci_dev *dev);
|
|
|
|
|
|
|
|
/* PCI slot has been reset */
|
|
|
|
pci_ers_result_t (*slot_reset)(struct pci_dev *dev);
|
|
|
|
|
|
|
|
/* Device driver may resume normal operations */
|
|
|
|
void (*resume)(struct pci_dev *dev);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
struct module;
|
|
|
|
struct pci_driver {
|
|
|
|
struct list_head node;
|
2010-09-03 01:28:51 +04:00
|
|
|
const char *name;
|
2005-04-17 02:20:36 +04:00
|
|
|
const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */
|
|
|
|
int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
|
|
|
|
void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
|
|
|
|
int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */
|
2006-06-25 01:50:29 +04:00
|
|
|
int (*suspend_late) (struct pci_dev *dev, pm_message_t state);
|
|
|
|
int (*resume_early) (struct pci_dev *dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
int (*resume) (struct pci_dev *dev); /* Device woken up */
|
2005-04-08 09:53:31 +04:00
|
|
|
void (*shutdown) (struct pci_dev *dev);
|
2012-11-06 00:20:36 +04:00
|
|
|
int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* PF pdev */
|
2012-09-07 20:33:14 +04:00
|
|
|
const struct pci_error_handlers *err_handler;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct device_driver driver;
|
|
|
|
struct pci_dynids dynids;
|
|
|
|
};
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-02-22 13:02:21 +03:00
|
|
|
/**
|
2008-03-10 21:43:34 +03:00
|
|
|
* DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
|
2008-02-22 13:02:21 +03:00
|
|
|
* @_table: device table name
|
|
|
|
*
|
|
|
|
* This macro is used to create a struct pci_device_id array (a device table)
|
|
|
|
* in a generic manner.
|
|
|
|
*/
|
2008-03-10 21:43:34 +03:00
|
|
|
#define DEFINE_PCI_DEVICE_TABLE(_table) \
|
2012-11-22 00:35:00 +04:00
|
|
|
const struct pci_device_id _table[]
|
2008-02-22 13:02:21 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/**
|
|
|
|
* PCI_DEVICE - macro used to describe a specific pci device
|
|
|
|
* @vend: the 16 bit PCI Vendor ID
|
|
|
|
* @dev: the 16 bit PCI Device ID
|
|
|
|
*
|
|
|
|
* This macro is used to create a struct pci_device_id that matches a
|
|
|
|
* specific device. The subvendor and subdevice fields will be set to
|
|
|
|
* PCI_ANY_ID.
|
|
|
|
*/
|
|
|
|
#define PCI_DEVICE(vend,dev) \
|
|
|
|
.vendor = (vend), .device = (dev), \
|
|
|
|
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
|
|
|
|
|
2012-11-14 18:44:26 +04:00
|
|
|
/**
|
|
|
|
* PCI_DEVICE_SUB - macro used to describe a specific pci device with subsystem
|
|
|
|
* @vend: the 16 bit PCI Vendor ID
|
|
|
|
* @dev: the 16 bit PCI Device ID
|
|
|
|
* @subvend: the 16 bit PCI Subvendor ID
|
|
|
|
* @subdev: the 16 bit PCI Subdevice ID
|
|
|
|
*
|
|
|
|
* This macro is used to create a struct pci_device_id that matches a
|
|
|
|
* specific device with subsystem information.
|
|
|
|
*/
|
|
|
|
#define PCI_DEVICE_SUB(vend, dev, subvend, subdev) \
|
|
|
|
.vendor = (vend), .device = (dev), \
|
|
|
|
.subvendor = (subvend), .subdevice = (subdev)
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/**
|
|
|
|
* PCI_DEVICE_CLASS - macro used to describe a specific pci device class
|
|
|
|
* @dev_class: the class, subclass, prog-if triple for this device
|
|
|
|
* @dev_class_mask: the class mask for this device
|
|
|
|
*
|
|
|
|
* This macro is used to create a struct pci_device_id that matches a
|
2005-07-28 22:37:33 +04:00
|
|
|
* specific PCI class. The vendor, device, subvendor, and subdevice
|
2005-04-17 02:20:36 +04:00
|
|
|
* fields will be set to PCI_ANY_ID.
|
|
|
|
*/
|
|
|
|
#define PCI_DEVICE_CLASS(dev_class,dev_class_mask) \
|
|
|
|
.class = (dev_class), .class_mask = (dev_class_mask), \
|
|
|
|
.vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
|
|
|
|
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
|
|
|
|
|
2006-12-05 02:14:45 +03:00
|
|
|
/**
|
|
|
|
* PCI_VDEVICE - macro used to describe a specific pci device in short form
|
2008-10-13 15:36:05 +04:00
|
|
|
* @vendor: the vendor name
|
|
|
|
* @device: the 16 bit PCI Device ID
|
2006-12-05 02:14:45 +03:00
|
|
|
*
|
|
|
|
* This macro is used to create a struct pci_device_id that matches a
|
|
|
|
* specific PCI device. The subvendor, and subdevice fields will be set
|
|
|
|
* to PCI_ANY_ID. The macro allows the next field to follow as the device
|
|
|
|
* private data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PCI_VDEVICE(vendor, device) \
|
|
|
|
PCI_VENDOR_ID_##vendor, (device), \
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, 0, 0
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* these external functions are only available when PCI support is enabled */
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
2013-08-22 07:24:44 +04:00
|
|
|
void pcie_bus_configure_settings(struct pci_bus *bus);
|
PCI: Set PCI-E Max Payload Size on fabric
On a given PCI-E fabric, each device, bridge, and root port can have a
different PCI-E maximum payload size. There is a sizable performance
boost for having the largest possible maximum payload size on each PCI-E
device. However, if improperly configured, fatal bus errors can occur.
Thus, it is important to ensure that PCI-E payloads sends by a device
are never larger than the MPS setting of all devices on the way to the
destination.
This can be achieved two ways:
- A conservative approach is to use the smallest common denominator of
the entire tree below a root complex for every device on that fabric.
This means for example that having a 128 bytes MPS USB controller on one
leg of a switch will dramatically reduce performances of a video card or
10GE adapter on another leg of that same switch.
It also means that any hierarchy supporting hotplug slots (including
expresscard or thunderbolt I suppose, dbl check that) will have to be
entirely clamped to 128 bytes since we cannot predict what will be
plugged into those slots, and we cannot change the MPS on a "live"
system.
- A more optimal way is possible, if it falls within a couple of
constraints:
* The top-level host bridge will never generate packets larger than the
smallest TLP (or if it can be controlled independently from its MPS at
least)
* The device will never generate packets larger than MPS (which can be
configured via MRRS)
* No support of direct PCI-E <-> PCI-E transfers between devices without
some additional code to specifically deal with that case
Then we can use an approach that basically ignores downstream requests
and focuses exclusively on upstream requests. In that case, all we need
to care about is that a device MPS is no larger than its parent MPS,
which allows us to keep all switches/bridges to the max MPS supported by
their parent and eventually the PHB.
In this case, your USB controller would no longer "starve" your 10GE
Ethernet and your hotplug slots won't affect your global MPS.
Additionally, the hotplugged devices themselves can be configured to a
larger MPS up to the value configured in the hotplug bridge.
To choose between the two available options, two PCI kernel boot args
have been added to the PCI calls. "pcie_bus_safe" will provide the
former behavior, while "pcie_bus_perf" will perform the latter behavior.
By default, the latter behavior is used.
NOTE: due to the location of the enablement, each arch will need to add
calls to this function. This patch only enables x86.
This patch includes a number of changes recommended by Benjamin
Herrenschmidt.
Tested-by: Jordan_Hargrave@dell.com
Signed-off-by: Jon Mason <mason@myri.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-07-21 00:20:54 +04:00
|
|
|
|
|
|
|
enum pcie_bus_config_types {
|
2011-10-03 18:50:20 +04:00
|
|
|
PCIE_BUS_TUNE_OFF,
|
PCI: Set PCI-E Max Payload Size on fabric
On a given PCI-E fabric, each device, bridge, and root port can have a
different PCI-E maximum payload size. There is a sizable performance
boost for having the largest possible maximum payload size on each PCI-E
device. However, if improperly configured, fatal bus errors can occur.
Thus, it is important to ensure that PCI-E payloads sends by a device
are never larger than the MPS setting of all devices on the way to the
destination.
This can be achieved two ways:
- A conservative approach is to use the smallest common denominator of
the entire tree below a root complex for every device on that fabric.
This means for example that having a 128 bytes MPS USB controller on one
leg of a switch will dramatically reduce performances of a video card or
10GE adapter on another leg of that same switch.
It also means that any hierarchy supporting hotplug slots (including
expresscard or thunderbolt I suppose, dbl check that) will have to be
entirely clamped to 128 bytes since we cannot predict what will be
plugged into those slots, and we cannot change the MPS on a "live"
system.
- A more optimal way is possible, if it falls within a couple of
constraints:
* The top-level host bridge will never generate packets larger than the
smallest TLP (or if it can be controlled independently from its MPS at
least)
* The device will never generate packets larger than MPS (which can be
configured via MRRS)
* No support of direct PCI-E <-> PCI-E transfers between devices without
some additional code to specifically deal with that case
Then we can use an approach that basically ignores downstream requests
and focuses exclusively on upstream requests. In that case, all we need
to care about is that a device MPS is no larger than its parent MPS,
which allows us to keep all switches/bridges to the max MPS supported by
their parent and eventually the PHB.
In this case, your USB controller would no longer "starve" your 10GE
Ethernet and your hotplug slots won't affect your global MPS.
Additionally, the hotplugged devices themselves can be configured to a
larger MPS up to the value configured in the hotplug bridge.
To choose between the two available options, two PCI kernel boot args
have been added to the PCI calls. "pcie_bus_safe" will provide the
former behavior, while "pcie_bus_perf" will perform the latter behavior.
By default, the latter behavior is used.
NOTE: due to the location of the enablement, each arch will need to add
calls to this function. This patch only enables x86.
This patch includes a number of changes recommended by Benjamin
Herrenschmidt.
Tested-by: Jordan_Hargrave@dell.com
Signed-off-by: Jon Mason <mason@myri.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-07-21 00:20:54 +04:00
|
|
|
PCIE_BUS_SAFE,
|
2011-10-03 18:50:20 +04:00
|
|
|
PCIE_BUS_PERFORMANCE,
|
PCI: Set PCI-E Max Payload Size on fabric
On a given PCI-E fabric, each device, bridge, and root port can have a
different PCI-E maximum payload size. There is a sizable performance
boost for having the largest possible maximum payload size on each PCI-E
device. However, if improperly configured, fatal bus errors can occur.
Thus, it is important to ensure that PCI-E payloads sends by a device
are never larger than the MPS setting of all devices on the way to the
destination.
This can be achieved two ways:
- A conservative approach is to use the smallest common denominator of
the entire tree below a root complex for every device on that fabric.
This means for example that having a 128 bytes MPS USB controller on one
leg of a switch will dramatically reduce performances of a video card or
10GE adapter on another leg of that same switch.
It also means that any hierarchy supporting hotplug slots (including
expresscard or thunderbolt I suppose, dbl check that) will have to be
entirely clamped to 128 bytes since we cannot predict what will be
plugged into those slots, and we cannot change the MPS on a "live"
system.
- A more optimal way is possible, if it falls within a couple of
constraints:
* The top-level host bridge will never generate packets larger than the
smallest TLP (or if it can be controlled independently from its MPS at
least)
* The device will never generate packets larger than MPS (which can be
configured via MRRS)
* No support of direct PCI-E <-> PCI-E transfers between devices without
some additional code to specifically deal with that case
Then we can use an approach that basically ignores downstream requests
and focuses exclusively on upstream requests. In that case, all we need
to care about is that a device MPS is no larger than its parent MPS,
which allows us to keep all switches/bridges to the max MPS supported by
their parent and eventually the PHB.
In this case, your USB controller would no longer "starve" your 10GE
Ethernet and your hotplug slots won't affect your global MPS.
Additionally, the hotplugged devices themselves can be configured to a
larger MPS up to the value configured in the hotplug bridge.
To choose between the two available options, two PCI kernel boot args
have been added to the PCI calls. "pcie_bus_safe" will provide the
former behavior, while "pcie_bus_perf" will perform the latter behavior.
By default, the latter behavior is used.
NOTE: due to the location of the enablement, each arch will need to add
calls to this function. This patch only enables x86.
This patch includes a number of changes recommended by Benjamin
Herrenschmidt.
Tested-by: Jordan_Hargrave@dell.com
Signed-off-by: Jon Mason <mason@myri.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-07-21 00:20:54 +04:00
|
|
|
PCIE_BUS_PEER2PEER,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern enum pcie_bus_config_types pcie_bus_config;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern struct bus_type pci_bus_type;
|
|
|
|
|
2013-11-14 22:28:18 +04:00
|
|
|
/* Do NOT directly access these two variables, unless you are arch-specific PCI
|
|
|
|
* code, or PCI core code. */
|
2005-04-17 02:20:36 +04:00
|
|
|
extern struct list_head pci_root_buses; /* list of all known PCI buses */
|
2013-11-14 22:28:18 +04:00
|
|
|
/* Some device drivers need know if PCI is initiated */
|
2013-04-12 22:02:59 +04:00
|
|
|
int no_pci_devices(void);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-11-04 08:39:31 +04:00
|
|
|
void pcibios_resource_survey_bus(struct pci_bus *bus);
|
2013-04-12 09:44:20 +04:00
|
|
|
void pcibios_add_bus(struct pci_bus *bus);
|
|
|
|
void pcibios_remove_bus(struct pci_bus *bus);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pcibios_fixup_bus(struct pci_bus *);
|
2006-08-15 09:43:17 +04:00
|
|
|
int __must_check pcibios_enable_device(struct pci_dev *, int mask);
|
2013-11-14 22:28:18 +04:00
|
|
|
/* Architecture-specific versions may override this (weak) */
|
2008-01-31 02:21:33 +03:00
|
|
|
char *pcibios_setup(char *str);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Used only when drivers/pci/setup.c is used */
|
2010-01-01 19:40:50 +03:00
|
|
|
resource_size_t pcibios_align_resource(void *, const struct resource *,
|
2010-01-01 19:40:49 +03:00
|
|
|
resource_size_t,
|
2006-06-13 04:06:02 +04:00
|
|
|
resource_size_t);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pcibios_update_irq(struct pci_dev *, int irq);
|
|
|
|
|
2009-12-09 09:52:13 +03:00
|
|
|
/* Weak but can be overriden by arch */
|
|
|
|
void pci_fixup_cardbus(struct pci_bus *);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Generic PCI functions used internally */
|
|
|
|
|
PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev
These interfaces:
pcibios_resource_to_bus(struct pci_dev *dev, *bus_region, *resource)
pcibios_bus_to_resource(struct pci_dev *dev, *resource, *bus_region)
took a pci_dev, but they really depend only on the pci_bus. And we want to
use them in resource allocation paths where we have the bus but not a
device, so this patch converts them to take the pci_bus instead of the
pci_dev:
pcibios_resource_to_bus(struct pci_bus *bus, *bus_region, *resource)
pcibios_bus_to_resource(struct pci_bus *bus, *resource, *bus_region)
In fact, with standard PCI-PCI bridges, they only depend on the host
bridge, because that's the only place address translation occurs, but
we aren't going that far yet.
[bhelgaas: changelog]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2013-12-10 10:54:40 +04:00
|
|
|
void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
|
2012-02-24 07:19:00 +04:00
|
|
|
struct resource *res);
|
PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev
These interfaces:
pcibios_resource_to_bus(struct pci_dev *dev, *bus_region, *resource)
pcibios_bus_to_resource(struct pci_dev *dev, *resource, *bus_region)
took a pci_dev, but they really depend only on the pci_bus. And we want to
use them in resource allocation paths where we have the bus but not a
device, so this patch converts them to take the pci_bus instead of the
pci_dev:
pcibios_resource_to_bus(struct pci_bus *bus, *bus_region, *resource)
pcibios_bus_to_resource(struct pci_bus *bus, *resource, *bus_region)
In fact, with standard PCI-PCI bridges, they only depend on the host
bridge, because that's the only place address translation occurs, but
we aren't going that far yet.
[bhelgaas: changelog]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2013-12-10 10:54:40 +04:00
|
|
|
void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
|
2012-02-24 07:19:00 +04:00
|
|
|
struct pci_bus_region *region);
|
2009-07-11 01:39:53 +04:00
|
|
|
void pcibios_scan_specific_bus(int busn);
|
2013-04-12 22:02:59 +04:00
|
|
|
struct pci_bus *pci_find_bus(int domain, int busnr);
|
2009-02-04 02:45:26 +03:00
|
|
|
void pci_bus_add_devices(const struct pci_bus *bus);
|
2008-01-31 02:21:33 +03:00
|
|
|
struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
|
|
|
|
struct pci_ops *ops, void *sysdata);
|
2011-10-29 02:25:55 +04:00
|
|
|
struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
|
2011-10-29 02:25:45 +04:00
|
|
|
struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
|
|
|
|
struct pci_ops *ops, void *sysdata,
|
|
|
|
struct list_head *resources);
|
2012-05-18 21:35:50 +04:00
|
|
|
int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
|
|
|
|
int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
|
|
|
|
void pci_bus_release_busn_res(struct pci_bus *b);
|
2012-11-22 00:35:00 +04:00
|
|
|
struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
|
2011-10-29 02:25:50 +04:00
|
|
|
struct pci_ops *ops, void *sysdata,
|
|
|
|
struct list_head *resources);
|
2008-01-31 02:21:33 +03:00
|
|
|
struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
|
|
|
|
int busnr);
|
2009-12-13 16:11:32 +03:00
|
|
|
void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
|
2008-06-11 01:28:50 +04:00
|
|
|
struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
|
2008-10-21 03:40:52 +04:00
|
|
|
const char *name,
|
|
|
|
struct hotplug_slot *hotplug);
|
2008-06-11 01:28:50 +04:00
|
|
|
void pci_destroy_slot(struct pci_slot *slot);
|
2008-10-21 03:40:47 +04:00
|
|
|
void pci_renumber_slot(struct pci_slot *slot, int slot_nr);
|
2005-04-17 02:20:36 +04:00
|
|
|
int pci_scan_slot(struct pci_bus *bus, int devfn);
|
2008-01-31 02:21:33 +03:00
|
|
|
struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
|
2005-09-06 03:31:03 +04:00
|
|
|
void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int pci_scan_child_bus(struct pci_bus *bus);
|
2006-08-28 22:43:25 +04:00
|
|
|
int __must_check pci_bus_add_device(struct pci_dev *dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_read_bridge_bases(struct pci_bus *child);
|
2008-01-31 02:21:33 +03:00
|
|
|
struct resource *pci_find_parent_resource(const struct pci_dev *dev,
|
|
|
|
struct resource *res);
|
2012-04-12 19:33:07 +04:00
|
|
|
u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin);
|
2005-04-17 02:20:36 +04:00
|
|
|
int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
|
2008-12-17 07:36:55 +03:00
|
|
|
u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp);
|
2013-04-12 22:02:59 +04:00
|
|
|
struct pci_dev *pci_dev_get(struct pci_dev *dev);
|
|
|
|
void pci_dev_put(struct pci_dev *dev);
|
|
|
|
void pci_remove_bus(struct pci_bus *b);
|
|
|
|
void pci_stop_and_remove_bus_device(struct pci_dev *dev);
|
2012-10-31 00:31:38 +04:00
|
|
|
void pci_stop_root_bus(struct pci_bus *bus);
|
|
|
|
void pci_remove_root_bus(struct pci_bus *bus);
|
2005-09-10 00:03:23 +04:00
|
|
|
void pci_setup_cardbus(struct pci_bus *bus);
|
2013-04-12 22:02:59 +04:00
|
|
|
void pci_sort_breadthfirst(void);
|
2010-02-10 04:43:04 +03:00
|
|
|
#define dev_is_pci(d) ((d)->bus == &pci_bus_type)
|
|
|
|
#define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
|
|
|
|
#define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Generic PCI functions exported to card drivers */
|
|
|
|
|
2008-08-03 22:02:12 +04:00
|
|
|
enum pci_lost_interrupt_reason {
|
|
|
|
PCI_LOST_IRQ_NO_INFORMATION = 0,
|
|
|
|
PCI_LOST_IRQ_DISABLE_MSI,
|
|
|
|
PCI_LOST_IRQ_DISABLE_MSIX,
|
|
|
|
PCI_LOST_IRQ_DISABLE_ACPI,
|
|
|
|
};
|
|
|
|
enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev);
|
2008-01-31 02:21:33 +03:00
|
|
|
int pci_find_capability(struct pci_dev *dev, int cap);
|
|
|
|
int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap);
|
|
|
|
int pci_find_ext_capability(struct pci_dev *dev, int cap);
|
2012-07-14 00:24:59 +04:00
|
|
|
int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
|
2008-01-31 02:21:33 +03:00
|
|
|
int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
|
|
|
|
int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
|
2006-10-17 03:20:21 +04:00
|
|
|
struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-10-21 21:24:12 +04:00
|
|
|
struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
|
|
|
|
struct pci_dev *from);
|
2008-01-31 02:21:33 +03:00
|
|
|
struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int ss_vendor, unsigned int ss_device,
|
2008-08-26 19:20:34 +04:00
|
|
|
struct pci_dev *from);
|
2008-01-31 02:21:33 +03:00
|
|
|
struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
|
2009-10-12 23:14:00 +04:00
|
|
|
struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
|
|
|
|
unsigned int devfn);
|
|
|
|
static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
|
|
|
|
unsigned int devfn)
|
|
|
|
{
|
|
|
|
return pci_get_domain_bus_and_slot(0, bus, devfn);
|
|
|
|
}
|
2008-01-31 02:21:33 +03:00
|
|
|
struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
|
2005-04-17 02:20:36 +04:00
|
|
|
int pci_dev_present(const struct pci_device_id *ids);
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
|
|
|
|
int where, u8 *val);
|
|
|
|
int pci_bus_read_config_word(struct pci_bus *bus, unsigned int devfn,
|
|
|
|
int where, u16 *val);
|
|
|
|
int pci_bus_read_config_dword(struct pci_bus *bus, unsigned int devfn,
|
|
|
|
int where, u32 *val);
|
|
|
|
int pci_bus_write_config_byte(struct pci_bus *bus, unsigned int devfn,
|
|
|
|
int where, u8 val);
|
|
|
|
int pci_bus_write_config_word(struct pci_bus *bus, unsigned int devfn,
|
|
|
|
int where, u16 val);
|
|
|
|
int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn,
|
|
|
|
int where, u32 val);
|
2009-04-24 06:45:17 +04:00
|
|
|
struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-03-19 04:01:09 +04:00
|
|
|
static inline int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-01-31 02:21:33 +03:00
|
|
|
return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-03-19 04:01:09 +04:00
|
|
|
static inline int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-01-31 02:21:33 +03:00
|
|
|
return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-03-19 04:01:09 +04:00
|
|
|
static inline int pci_read_config_dword(const struct pci_dev *dev, int where,
|
2008-01-31 02:21:33 +03:00
|
|
|
u32 *val)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-01-31 02:21:33 +03:00
|
|
|
return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-03-19 04:01:09 +04:00
|
|
|
static inline int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-01-31 02:21:33 +03:00
|
|
|
return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-03-19 04:01:09 +04:00
|
|
|
static inline int pci_write_config_word(const struct pci_dev *dev, int where, u16 val)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-01-31 02:21:33 +03:00
|
|
|
return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-03-19 04:01:09 +04:00
|
|
|
static inline int pci_write_config_dword(const struct pci_dev *dev, int where,
|
2008-01-31 02:21:33 +03:00
|
|
|
u32 val)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-01-31 02:21:33 +03:00
|
|
|
return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
PCI: Add accessors for PCI Express Capability
The PCI Express Capability (PCIe spec r3.0, sec 7.8) comes in two
versions, v1 and v2. In v1 Capability structures (PCIe spec r1.0 and
r1.1), some fields are optional, so the structure size depends on the
device type.
This patch adds functions to access this capability so drivers don't
have to be aware of the differences between v1 and v2. Note that these
new functions apply only to the "PCI Express Capability," not to any of
the other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.)
Function pcie_capability_read_word/dword() reads the PCIe Capabilities
register and returns the value in the reference parameter "val". If
the PCIe Capabilities register is not implemented on the PCIe device,
"val" is set to 0.
Function pcie_capability_write_word/dword() writes the value to the
specified PCIe Capability register.
Function pcie_capability_clear_and_set_word/dword() sets and/or clears bits
of a PCIe Capability register.
[bhelgaas: changelog, drop "pci_" prefixes, don't export
pcie_capability_reg_implemented()]
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2012-07-24 13:20:05 +04:00
|
|
|
int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
|
|
|
|
int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);
|
|
|
|
int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val);
|
|
|
|
int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val);
|
|
|
|
int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,
|
|
|
|
u16 clear, u16 set);
|
|
|
|
int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
|
|
|
|
u32 clear, u32 set);
|
|
|
|
|
|
|
|
static inline int pcie_capability_set_word(struct pci_dev *dev, int pos,
|
|
|
|
u16 set)
|
|
|
|
{
|
|
|
|
return pcie_capability_clear_and_set_word(dev, pos, 0, set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos,
|
|
|
|
u32 set)
|
|
|
|
{
|
|
|
|
return pcie_capability_clear_and_set_dword(dev, pos, 0, set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos,
|
|
|
|
u16 clear)
|
|
|
|
{
|
|
|
|
return pcie_capability_clear_and_set_word(dev, pos, clear, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
|
|
|
|
u32 clear)
|
|
|
|
{
|
|
|
|
return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
|
|
|
|
}
|
|
|
|
|
2012-06-11 09:27:19 +04:00
|
|
|
/* user-space driven config access */
|
|
|
|
int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
|
|
|
|
int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val);
|
|
|
|
int pci_user_read_config_dword(struct pci_dev *dev, int where, u32 *val);
|
|
|
|
int pci_user_write_config_byte(struct pci_dev *dev, int where, u8 val);
|
|
|
|
int pci_user_write_config_word(struct pci_dev *dev, int where, u16 val);
|
|
|
|
int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val);
|
|
|
|
|
2006-08-15 09:43:17 +04:00
|
|
|
int __must_check pci_enable_device(struct pci_dev *dev);
|
2007-12-20 07:28:08 +03:00
|
|
|
int __must_check pci_enable_device_io(struct pci_dev *dev);
|
|
|
|
int __must_check pci_enable_device_mem(struct pci_dev *dev);
|
2007-07-27 09:43:35 +04:00
|
|
|
int __must_check pci_reenable_device(struct pci_dev *);
|
devres: device resource management
Implement device resource management, in short, devres. A device
driver can allocate arbirary size of devres data which is associated
with a release function. On driver detach, release function is
invoked on the devres data, then, devres data is freed.
devreses are typed by associated release functions. Some devreses are
better represented by single instance of the type while others need
multiple instances sharing the same release function. Both usages are
supported.
devreses can be grouped using devres group such that a device driver
can easily release acquired resources halfway through initialization
or selectively release resources (e.g. resources for port 1 out of 4
ports).
This patch adds devres core including documentation and the following
managed interfaces.
* alloc/free : devm_kzalloc(), devm_kzfree()
* IO region : devm_request_region(), devm_release_region()
* IRQ : devm_request_irq(), devm_free_irq()
* DMA : dmam_alloc_coherent(), dmam_free_coherent(),
dmam_declare_coherent_memory(), dmam_pool_create(),
dmam_pool_destroy()
* PCI : pcim_enable_device(), pcim_pin_device(), pci_is_managed()
* iomap : devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(),
devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(),
pcim_iomap(), pcim_iounmap()
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-01-20 10:00:26 +03:00
|
|
|
int __must_check pcim_enable_device(struct pci_dev *pdev);
|
|
|
|
void pcim_pin_device(struct pci_dev *pdev);
|
|
|
|
|
2009-04-03 11:41:46 +04:00
|
|
|
static inline int pci_is_enabled(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
return (atomic_read(&pdev->enable_cnt) > 0);
|
|
|
|
}
|
|
|
|
|
devres: device resource management
Implement device resource management, in short, devres. A device
driver can allocate arbirary size of devres data which is associated
with a release function. On driver detach, release function is
invoked on the devres data, then, devres data is freed.
devreses are typed by associated release functions. Some devreses are
better represented by single instance of the type while others need
multiple instances sharing the same release function. Both usages are
supported.
devreses can be grouped using devres group such that a device driver
can easily release acquired resources halfway through initialization
or selectively release resources (e.g. resources for port 1 out of 4
ports).
This patch adds devres core including documentation and the following
managed interfaces.
* alloc/free : devm_kzalloc(), devm_kzfree()
* IO region : devm_request_region(), devm_release_region()
* IRQ : devm_request_irq(), devm_free_irq()
* DMA : dmam_alloc_coherent(), dmam_free_coherent(),
dmam_declare_coherent_memory(), dmam_pool_create(),
dmam_pool_destroy()
* PCI : pcim_enable_device(), pcim_pin_device(), pci_is_managed()
* iomap : devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(),
devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(),
pcim_iomap(), pcim_iounmap()
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-01-20 10:00:26 +03:00
|
|
|
static inline int pci_is_managed(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
return pdev->is_managed;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_disable_device(struct pci_dev *dev);
|
2011-10-29 01:48:38 +04:00
|
|
|
|
|
|
|
extern unsigned int pcibios_max_latency;
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_set_master(struct pci_dev *dev);
|
2008-12-23 06:08:29 +03:00
|
|
|
void pci_clear_master(struct pci_dev *dev);
|
2011-10-29 01:48:38 +04:00
|
|
|
|
2007-04-07 01:39:36 +04:00
|
|
|
int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
|
2009-09-22 12:34:48 +04:00
|
|
|
int pci_set_cacheline_size(struct pci_dev *dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
#define HAVE_PCI_SET_MWI
|
2006-08-15 09:43:17 +04:00
|
|
|
int __must_check pci_set_mwi(struct pci_dev *dev);
|
2007-07-09 22:55:54 +04:00
|
|
|
int pci_try_set_mwi(struct pci_dev *dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_clear_mwi(struct pci_dev *dev);
|
2005-08-15 23:23:41 +04:00
|
|
|
void pci_intx(struct pci_dev *dev, int enable);
|
2011-11-04 12:46:00 +04:00
|
|
|
bool pci_intx_mask_supported(struct pci_dev *dev);
|
|
|
|
bool pci_check_and_mask_intx(struct pci_dev *dev);
|
|
|
|
bool pci_check_and_unmask_intx(struct pci_dev *dev);
|
2007-03-05 11:30:07 +03:00
|
|
|
void pci_msi_off(struct pci_dev *dev);
|
2008-02-05 09:27:55 +03:00
|
|
|
int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size);
|
2008-02-05 09:28:14 +03:00
|
|
|
int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask);
|
2013-08-06 14:18:36 +04:00
|
|
|
int pci_wait_for_pending_transaction(struct pci_dev *dev);
|
2007-05-15 15:59:13 +04:00
|
|
|
int pcix_get_max_mmrbc(struct pci_dev *dev);
|
|
|
|
int pcix_get_mmrbc(struct pci_dev *dev);
|
|
|
|
int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc);
|
2007-08-14 14:43:48 +04:00
|
|
|
int pcie_get_readrq(struct pci_dev *dev);
|
2007-05-15 15:59:13 +04:00
|
|
|
int pcie_set_readrq(struct pci_dev *dev, int rq);
|
PCI: Set PCI-E Max Payload Size on fabric
On a given PCI-E fabric, each device, bridge, and root port can have a
different PCI-E maximum payload size. There is a sizable performance
boost for having the largest possible maximum payload size on each PCI-E
device. However, if improperly configured, fatal bus errors can occur.
Thus, it is important to ensure that PCI-E payloads sends by a device
are never larger than the MPS setting of all devices on the way to the
destination.
This can be achieved two ways:
- A conservative approach is to use the smallest common denominator of
the entire tree below a root complex for every device on that fabric.
This means for example that having a 128 bytes MPS USB controller on one
leg of a switch will dramatically reduce performances of a video card or
10GE adapter on another leg of that same switch.
It also means that any hierarchy supporting hotplug slots (including
expresscard or thunderbolt I suppose, dbl check that) will have to be
entirely clamped to 128 bytes since we cannot predict what will be
plugged into those slots, and we cannot change the MPS on a "live"
system.
- A more optimal way is possible, if it falls within a couple of
constraints:
* The top-level host bridge will never generate packets larger than the
smallest TLP (or if it can be controlled independently from its MPS at
least)
* The device will never generate packets larger than MPS (which can be
configured via MRRS)
* No support of direct PCI-E <-> PCI-E transfers between devices without
some additional code to specifically deal with that case
Then we can use an approach that basically ignores downstream requests
and focuses exclusively on upstream requests. In that case, all we need
to care about is that a device MPS is no larger than its parent MPS,
which allows us to keep all switches/bridges to the max MPS supported by
their parent and eventually the PHB.
In this case, your USB controller would no longer "starve" your 10GE
Ethernet and your hotplug slots won't affect your global MPS.
Additionally, the hotplugged devices themselves can be configured to a
larger MPS up to the value configured in the hotplug bridge.
To choose between the two available options, two PCI kernel boot args
have been added to the PCI calls. "pcie_bus_safe" will provide the
former behavior, while "pcie_bus_perf" will perform the latter behavior.
By default, the latter behavior is used.
NOTE: due to the location of the enablement, each arch will need to add
calls to this function. This patch only enables x86.
This patch includes a number of changes recommended by Benjamin
Herrenschmidt.
Tested-by: Jordan_Hargrave@dell.com
Signed-off-by: Jon Mason <mason@myri.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-07-21 00:20:54 +04:00
|
|
|
int pcie_get_mps(struct pci_dev *dev);
|
|
|
|
int pcie_set_mps(struct pci_dev *dev, int mps);
|
2013-07-31 10:53:26 +04:00
|
|
|
int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
|
|
|
|
enum pcie_link_width *width);
|
2009-06-13 11:52:13 +04:00
|
|
|
int __pci_reset_function(struct pci_dev *dev);
|
2012-01-04 23:23:56 +04:00
|
|
|
int __pci_reset_function_locked(struct pci_dev *dev);
|
2008-10-21 13:38:25 +04:00
|
|
|
int pci_reset_function(struct pci_dev *dev);
|
2013-08-15 00:06:05 +04:00
|
|
|
int pci_probe_reset_slot(struct pci_slot *slot);
|
2013-08-09 00:09:55 +04:00
|
|
|
int pci_reset_slot(struct pci_slot *slot);
|
2013-08-15 00:06:05 +04:00
|
|
|
int pci_probe_reset_bus(struct pci_bus *bus);
|
2013-08-09 00:09:55 +04:00
|
|
|
int pci_reset_bus(struct pci_bus *bus);
|
2013-08-09 00:09:24 +04:00
|
|
|
void pci_reset_bridge_secondary_bus(struct pci_dev *dev);
|
2008-11-21 21:38:52 +03:00
|
|
|
void pci_update_resource(struct pci_dev *dev, int resno);
|
2006-08-15 09:43:17 +04:00
|
|
|
int __must_check pci_assign_resource(struct pci_dev *dev, int i);
|
2011-07-26 00:08:39 +04:00
|
|
|
int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align);
|
2006-12-18 04:31:06 +03:00
|
|
|
int pci_select_bars(struct pci_dev *dev, unsigned long flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* ROM control related routines */
|
2008-09-23 20:25:10 +04:00
|
|
|
int pci_enable_rom(struct pci_dev *pdev);
|
|
|
|
void pci_disable_rom(struct pci_dev *pdev);
|
2005-08-09 08:20:10 +04:00
|
|
|
void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
|
2009-01-29 22:12:47 +03:00
|
|
|
size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size);
|
2013-03-27 01:25:54 +04:00
|
|
|
void __iomem __must_check *pci_platform_rom(struct pci_dev *pdev, size_t *size);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Power management related routines */
|
|
|
|
int pci_save_state(struct pci_dev *dev);
|
2010-12-01 02:43:26 +03:00
|
|
|
void pci_restore_state(struct pci_dev *dev);
|
2011-05-10 20:02:27 +04:00
|
|
|
struct pci_saved_state *pci_store_saved_state(struct pci_dev *dev);
|
|
|
|
int pci_load_saved_state(struct pci_dev *dev, struct pci_saved_state *state);
|
|
|
|
int pci_load_and_free_saved_state(struct pci_dev *dev,
|
|
|
|
struct pci_saved_state **state);
|
2009-03-27 00:51:40 +03:00
|
|
|
int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state);
|
2005-09-10 02:43:46 +04:00
|
|
|
int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
|
|
|
|
pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
|
2008-07-19 16:39:24 +04:00
|
|
|
bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
|
2008-08-08 02:14:24 +04:00
|
|
|
void pci_pme_active(struct pci_dev *dev, bool enable);
|
2010-02-18 01:44:58 +03:00
|
|
|
int __pci_enable_wake(struct pci_dev *dev, pci_power_t state,
|
|
|
|
bool runtime, bool enable);
|
2008-08-18 23:38:00 +04:00
|
|
|
int pci_wake_from_d3(struct pci_dev *dev, bool enable);
|
2008-07-19 16:39:24 +04:00
|
|
|
pci_power_t pci_target_state(struct pci_dev *dev);
|
2008-07-07 05:35:26 +04:00
|
|
|
int pci_prepare_to_sleep(struct pci_dev *dev);
|
|
|
|
int pci_back_from_sleep(struct pci_dev *dev);
|
2010-02-18 01:44:09 +03:00
|
|
|
bool pci_dev_run_wake(struct pci_dev *dev);
|
2010-10-04 22:22:26 +04:00
|
|
|
bool pci_check_pme_status(struct pci_dev *dev);
|
|
|
|
void pci_pme_wakeup_bus(struct pci_bus *bus);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-02-18 01:44:58 +03:00
|
|
|
static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
return __pci_enable_wake(dev, state, false, enable);
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-10-20 00:07:57 +04:00
|
|
|
#define PCI_EXP_IDO_REQUEST (1<<0)
|
|
|
|
#define PCI_EXP_IDO_COMPLETION (1<<1)
|
|
|
|
void pci_enable_ido(struct pci_dev *dev, unsigned long type);
|
|
|
|
void pci_disable_ido(struct pci_dev *dev, unsigned long type);
|
|
|
|
|
2011-01-10 23:46:36 +03:00
|
|
|
enum pci_obff_signal_type {
|
2011-07-08 01:00:36 +04:00
|
|
|
PCI_EXP_OBFF_SIGNAL_L0 = 0,
|
|
|
|
PCI_EXP_OBFF_SIGNAL_ALWAYS = 1,
|
2011-01-10 23:46:36 +03:00
|
|
|
};
|
|
|
|
int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type);
|
|
|
|
void pci_disable_obff(struct pci_dev *dev);
|
|
|
|
|
2011-01-14 19:53:04 +03:00
|
|
|
int pci_enable_ltr(struct pci_dev *dev);
|
|
|
|
void pci_disable_ltr(struct pci_dev *dev);
|
|
|
|
int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns);
|
|
|
|
|
2010-01-26 20:10:03 +03:00
|
|
|
/* For use by arch with custom probe code */
|
|
|
|
void set_pcie_port_type(struct pci_dev *pdev);
|
|
|
|
void set_pcie_hotplug_bridge(struct pci_dev *pdev);
|
|
|
|
|
2007-07-17 08:27:10 +04:00
|
|
|
/* Functions for PCI Hotplug drivers to use */
|
2008-01-31 02:21:33 +03:00
|
|
|
int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
|
2012-01-21 14:08:22 +04:00
|
|
|
unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge);
|
2009-03-20 23:56:25 +03:00
|
|
|
unsigned int pci_rescan_bus(struct pci_bus *bus);
|
2007-07-17 08:27:10 +04:00
|
|
|
|
2008-12-18 20:17:16 +03:00
|
|
|
/* Vital product data routines */
|
|
|
|
ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
|
|
|
|
ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
|
2008-12-18 20:17:16 +03:00
|
|
|
int pci_vpd_truncate(struct pci_dev *dev, size_t size);
|
2008-12-18 20:17:16 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
|
2011-11-21 22:54:13 +04:00
|
|
|
resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);
|
2009-02-18 21:44:29 +03:00
|
|
|
void pci_bus_assign_resources(const struct pci_bus *bus);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_bus_size_bridges(struct pci_bus *bus);
|
|
|
|
int pci_claim_resource(struct pci_dev *, int);
|
|
|
|
void pci_assign_unassigned_resources(void);
|
2010-01-22 12:02:25 +03:00
|
|
|
void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge);
|
2012-10-31 00:31:10 +04:00
|
|
|
void pci_assign_unassigned_bus_resources(struct pci_bus *bus);
|
2013-07-23 01:37:18 +04:00
|
|
|
void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pdev_enable_device(struct pci_dev *);
|
2008-03-04 21:56:47 +03:00
|
|
|
int pci_enable_resources(struct pci_dev *, int mask);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
|
2011-06-10 18:30:21 +04:00
|
|
|
int (*)(const struct pci_dev *, u8, u8));
|
2005-04-17 02:20:36 +04:00
|
|
|
#define HAVE_PCI_REQ_REGIONS 2
|
2006-08-15 09:43:17 +04:00
|
|
|
int __must_check pci_request_regions(struct pci_dev *, const char *);
|
2008-10-23 06:55:31 +04:00
|
|
|
int __must_check pci_request_regions_exclusive(struct pci_dev *, const char *);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_release_regions(struct pci_dev *);
|
2006-08-15 09:43:17 +04:00
|
|
|
int __must_check pci_request_region(struct pci_dev *, int, const char *);
|
2008-10-23 06:55:31 +04:00
|
|
|
int __must_check pci_request_region_exclusive(struct pci_dev *, int, const char *);
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_release_region(struct pci_dev *, int);
|
2006-12-18 04:31:06 +03:00
|
|
|
int pci_request_selected_regions(struct pci_dev *, int, const char *);
|
2008-10-23 06:55:31 +04:00
|
|
|
int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
|
2006-12-18 04:31:06 +03:00
|
|
|
void pci_release_selected_regions(struct pci_dev *, int);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* drivers/pci/bus.c */
|
2013-05-25 17:48:29 +04:00
|
|
|
struct pci_bus *pci_bus_get(struct pci_bus *bus);
|
|
|
|
void pci_bus_put(struct pci_bus *bus);
|
2011-10-29 02:25:35 +04:00
|
|
|
void pci_add_resource(struct list_head *resources, struct resource *res);
|
2012-02-24 07:19:00 +04:00
|
|
|
void pci_add_resource_offset(struct list_head *resources, struct resource *res,
|
|
|
|
resource_size_t offset);
|
2011-10-29 02:25:35 +04:00
|
|
|
void pci_free_resource_list(struct list_head *resources);
|
2010-02-23 20:24:36 +03:00
|
|
|
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
|
|
|
|
struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
|
|
|
|
void pci_bus_remove_resources(struct pci_bus *bus);
|
|
|
|
|
2010-02-23 20:24:31 +03:00
|
|
|
#define pci_bus_for_each_resource(bus, res, i) \
|
2010-02-23 20:24:36 +03:00
|
|
|
for (i = 0; \
|
|
|
|
(res = pci_bus_resource_n(bus, i)) || i < PCI_BRIDGE_RESOURCE_NUM; \
|
|
|
|
i++)
|
2010-02-23 20:24:31 +03:00
|
|
|
|
2006-08-15 09:43:17 +04:00
|
|
|
int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
|
|
|
|
struct resource *res, resource_size_t size,
|
|
|
|
resource_size_t align, resource_size_t min,
|
|
|
|
unsigned int type_mask,
|
2010-01-01 19:40:50 +03:00
|
|
|
resource_size_t (*alignf)(void *,
|
|
|
|
const struct resource *,
|
2010-01-01 19:40:49 +03:00
|
|
|
resource_size_t,
|
|
|
|
resource_size_t),
|
2006-08-15 09:43:17 +04:00
|
|
|
void *alignf_data);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-10-28 01:12:54 +04:00
|
|
|
/* Proper probing supporting hot-pluggable devices */
|
2007-01-15 22:50:02 +03:00
|
|
|
int __must_check __pci_register_driver(struct pci_driver *, struct module *,
|
|
|
|
const char *mod_name);
|
2008-07-30 23:07:04 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* pci_register_driver must be a macro so that KBUILD_MODNAME can be expanded
|
|
|
|
*/
|
|
|
|
#define pci_register_driver(driver) \
|
|
|
|
__pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
|
2005-10-28 01:12:54 +04:00
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
void pci_unregister_driver(struct pci_driver *dev);
|
2011-11-18 22:12:49 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* module_pci_driver() - Helper macro for registering a PCI driver
|
|
|
|
* @__pci_driver: pci_driver struct
|
|
|
|
*
|
|
|
|
* Helper macro for PCI drivers which do not do anything special in module
|
|
|
|
* init/exit. This eliminates a lot of boilerplate. Each module may only
|
|
|
|
* use this macro once, and calling it replaces module_init() and module_exit()
|
|
|
|
*/
|
|
|
|
#define module_pci_driver(__pci_driver) \
|
|
|
|
module_driver(__pci_driver, pci_register_driver, \
|
|
|
|
pci_unregister_driver)
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
|
2009-09-03 10:26:36 +04:00
|
|
|
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);
|
2008-01-31 02:21:33 +03:00
|
|
|
const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
|
|
|
|
struct pci_dev *dev);
|
|
|
|
int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
|
|
|
|
int pass);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2009-06-16 09:34:38 +04:00
|
|
|
void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
|
2005-08-18 08:33:01 +04:00
|
|
|
void *userdata);
|
2008-04-29 03:27:23 +04:00
|
|
|
int pci_cfg_space_size_ext(struct pci_dev *dev);
|
2005-12-13 10:09:16 +03:00
|
|
|
int pci_cfg_space_size(struct pci_dev *dev);
|
2008-01-31 02:21:33 +03:00
|
|
|
unsigned char pci_bus_max_busnr(struct pci_bus *bus);
|
2011-09-11 21:08:38 +04:00
|
|
|
void pci_setup_bridge(struct pci_bus *bus);
|
2012-09-12 02:59:45 +04:00
|
|
|
resource_size_t pcibios_window_alignment(struct pci_bus *bus,
|
|
|
|
unsigned long type);
|
2005-08-18 08:33:01 +04:00
|
|
|
|
2010-06-01 09:32:24 +04:00
|
|
|
#define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0)
|
|
|
|
#define PCI_VGA_STATE_CHANGE_DECODES (1 << 1)
|
|
|
|
|
2009-08-11 09:52:06 +04:00
|
|
|
int pci_set_vga_state(struct pci_dev *pdev, bool decode,
|
2010-06-01 09:32:24 +04:00
|
|
|
unsigned int command_bits, u32 flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
/* kmem_cache style wrapper around pci_alloc_consistent() */
|
|
|
|
|
2010-03-11 02:23:30 +03:00
|
|
|
#include <linux/pci-dma.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/dmapool.h>
|
|
|
|
|
|
|
|
#define pci_pool dma_pool
|
|
|
|
#define pci_pool_create(name, pdev, size, align, allocation) \
|
|
|
|
dma_pool_create(name, &pdev->dev, size, align, allocation)
|
|
|
|
#define pci_pool_destroy(pool) dma_pool_destroy(pool)
|
|
|
|
#define pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, handle)
|
|
|
|
#define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr)
|
|
|
|
|
2005-06-02 23:55:50 +04:00
|
|
|
enum pci_dma_burst_strategy {
|
|
|
|
PCI_DMA_BURST_INFINITY, /* make bursts as large as possible,
|
|
|
|
strategy_parameter is N/A */
|
|
|
|
PCI_DMA_BURST_BOUNDARY, /* disconnect at every strategy_parameter
|
|
|
|
byte boundaries */
|
|
|
|
PCI_DMA_BURST_MULTIPLE, /* disconnect at some multiple of
|
|
|
|
strategy_parameter byte boundaries */
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
struct msix_entry {
|
2008-08-16 06:36:45 +04:00
|
|
|
u32 vector; /* kernel uses to write allocated vector */
|
2005-04-17 02:20:36 +04:00
|
|
|
u16 entry; /* driver uses to specify entry, OS writes */
|
|
|
|
};
|
|
|
|
|
2006-10-04 13:16:33 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifndef CONFIG_PCI_MSI
|
2009-03-17 15:54:10 +03:00
|
|
|
static inline int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
|
2008-01-31 02:21:33 +03:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-11-19 19:02:10 +04:00
|
|
|
static inline int
|
|
|
|
pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-04-24 01:58:09 +04:00
|
|
|
static inline void pci_msi_shutdown(struct pci_dev *dev)
|
|
|
|
{ }
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline void pci_disable_msi(struct pci_dev *dev)
|
|
|
|
{ }
|
|
|
|
|
2009-01-24 02:21:14 +03:00
|
|
|
static inline int pci_msix_table_size(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline int pci_enable_msix(struct pci_dev *dev,
|
|
|
|
struct msix_entry *entries, int nvec)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-04-24 01:58:09 +04:00
|
|
|
static inline void pci_msix_shutdown(struct pci_dev *dev)
|
|
|
|
{ }
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline void pci_disable_msix(struct pci_dev *dev)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
static inline void pci_restore_msi_state(struct pci_dev *dev)
|
|
|
|
{ }
|
2008-11-11 01:31:05 +03:00
|
|
|
static inline int pci_msi_enabled(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
#else
|
2013-04-12 22:02:59 +04:00
|
|
|
int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);
|
|
|
|
int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec);
|
|
|
|
void pci_msi_shutdown(struct pci_dev *dev);
|
|
|
|
void pci_disable_msi(struct pci_dev *dev);
|
|
|
|
int pci_msix_table_size(struct pci_dev *dev);
|
|
|
|
int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
|
|
|
|
void pci_msix_shutdown(struct pci_dev *dev);
|
|
|
|
void pci_disable_msix(struct pci_dev *dev);
|
|
|
|
void msi_remove_pci_irq_vectors(struct pci_dev *dev);
|
|
|
|
void pci_restore_msi_state(struct pci_dev *dev);
|
|
|
|
int pci_msi_enabled(void);
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
|
2011-01-15 02:07:22 +03:00
|
|
|
#ifdef CONFIG_PCIEPORTBUS
|
2011-01-07 02:55:09 +03:00
|
|
|
extern bool pcie_ports_disabled;
|
|
|
|
extern bool pcie_ports_auto;
|
2011-01-15 02:07:22 +03:00
|
|
|
#else
|
|
|
|
#define pcie_ports_disabled true
|
|
|
|
#define pcie_ports_auto false
|
|
|
|
#endif
|
2011-01-07 02:55:09 +03:00
|
|
|
|
2008-11-11 01:30:55 +03:00
|
|
|
#ifndef CONFIG_PCIEASPM
|
2011-03-05 15:21:51 +03:00
|
|
|
static inline int pcie_aspm_enabled(void) { return 0; }
|
|
|
|
static inline bool pcie_aspm_support_enabled(void) { return false; }
|
2008-11-11 01:30:55 +03:00
|
|
|
#else
|
2013-04-12 22:02:59 +04:00
|
|
|
int pcie_aspm_enabled(void);
|
|
|
|
bool pcie_aspm_support_enabled(void);
|
2008-11-11 01:30:55 +03:00
|
|
|
#endif
|
|
|
|
|
2011-01-07 02:55:09 +03:00
|
|
|
#ifdef CONFIG_PCIEAER
|
|
|
|
void pci_no_aer(void);
|
|
|
|
bool pci_aer_available(void);
|
|
|
|
#else
|
|
|
|
static inline void pci_no_aer(void) { }
|
|
|
|
static inline bool pci_aer_available(void) { return false; }
|
|
|
|
#endif
|
|
|
|
|
2009-04-23 02:52:09 +04:00
|
|
|
#ifndef CONFIG_PCIE_ECRC
|
|
|
|
static inline void pcie_set_ecrc_checking(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
static inline void pcie_ecrc_get_policy(char *str) {};
|
|
|
|
#else
|
2013-04-12 22:02:59 +04:00
|
|
|
void pcie_set_ecrc_checking(struct pci_dev *dev);
|
|
|
|
void pcie_ecrc_get_policy(char *str);
|
2009-04-23 02:52:09 +04:00
|
|
|
#endif
|
|
|
|
|
2009-03-17 15:54:10 +03:00
|
|
|
#define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1)
|
|
|
|
|
2006-10-04 13:16:55 +04:00
|
|
|
#ifdef CONFIG_HT_IRQ
|
|
|
|
/* The functions a driver should call */
|
|
|
|
int ht_create_irq(struct pci_dev *dev, int idx);
|
|
|
|
void ht_destroy_irq(unsigned int irq);
|
|
|
|
#endif /* CONFIG_HT_IRQ */
|
|
|
|
|
2013-04-12 22:02:59 +04:00
|
|
|
void pci_cfg_access_lock(struct pci_dev *dev);
|
|
|
|
bool pci_cfg_access_trylock(struct pci_dev *dev);
|
|
|
|
void pci_cfg_access_unlock(struct pci_dev *dev);
|
2005-09-27 12:21:55 +04:00
|
|
|
|
2005-07-28 22:37:33 +04:00
|
|
|
/*
|
|
|
|
* PCI domain support. Sometimes called PCI segment (eg by ACPI),
|
2013-11-14 22:28:18 +04:00
|
|
|
* a PCI domain is defined to be a set of PCI buses which share
|
2005-07-28 22:37:33 +04:00
|
|
|
* configuration space.
|
|
|
|
*/
|
2007-10-12 00:57:27 +04:00
|
|
|
#ifdef CONFIG_PCI_DOMAINS
|
|
|
|
extern int pci_domains_supported;
|
|
|
|
#else
|
|
|
|
enum { pci_domains_supported = 0 };
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline int pci_domain_nr(struct pci_bus *bus)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-28 22:37:33 +04:00
|
|
|
static inline int pci_proc_domain(struct pci_bus *bus)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-12 00:57:27 +04:00
|
|
|
#endif /* CONFIG_PCI_DOMAINS */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-02-03 01:38:13 +03:00
|
|
|
/* some architectures require additional setup to direct VGA traffic */
|
|
|
|
typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode,
|
2010-06-01 09:32:24 +04:00
|
|
|
unsigned int command_bits, u32 flags);
|
2013-04-12 22:02:59 +04:00
|
|
|
void pci_register_set_vga_state(arch_set_vga_state_t func);
|
2010-02-03 01:38:13 +03:00
|
|
|
|
2005-07-28 22:37:33 +04:00
|
|
|
#else /* CONFIG_PCI is not enabled */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the system does not have PCI, clearly these return errors. Define
|
|
|
|
* these as simple inline functions to avoid hair in drivers.
|
|
|
|
*/
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
#define _PCI_NOP(o, s, t) \
|
|
|
|
static inline int pci_##o##_config_##s(struct pci_dev *dev, \
|
|
|
|
int where, t val) \
|
2005-04-17 02:20:36 +04:00
|
|
|
{ return PCIBIOS_FUNC_NOT_SUPPORTED; }
|
2008-01-31 02:21:33 +03:00
|
|
|
|
|
|
|
#define _PCI_NOP_ALL(o, x) _PCI_NOP(o, byte, u8 x) \
|
|
|
|
_PCI_NOP(o, word, u16 x) \
|
|
|
|
_PCI_NOP(o, dword, u32 x)
|
2005-04-17 02:20:36 +04:00
|
|
|
_PCI_NOP_ALL(read, *)
|
|
|
|
_PCI_NOP_ALL(write,)
|
|
|
|
|
2006-10-21 21:24:12 +04:00
|
|
|
static inline struct pci_dev *pci_get_device(unsigned int vendor,
|
2008-01-31 02:21:33 +03:00
|
|
|
unsigned int device,
|
|
|
|
struct pci_dev *from)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-10-21 21:24:12 +04:00
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline struct pci_dev *pci_get_subsys(unsigned int vendor,
|
|
|
|
unsigned int device,
|
|
|
|
unsigned int ss_vendor,
|
|
|
|
unsigned int ss_device,
|
2008-08-26 19:20:34 +04:00
|
|
|
struct pci_dev *from)
|
2008-01-31 02:21:33 +03:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline struct pci_dev *pci_get_class(unsigned int class,
|
|
|
|
struct pci_dev *from)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define pci_dev_present(ids) (0)
|
2007-07-16 10:39:39 +04:00
|
|
|
#define no_pci_devices() (1)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define pci_dev_put(dev) do { } while (0)
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline void pci_set_master(struct pci_dev *dev)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
static inline int pci_enable_device(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pci_disable_device(struct pci_dev *dev)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
|
|
|
|
{
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2008-06-30 22:35:53 +04:00
|
|
|
static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
|
|
|
|
{
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2008-02-05 09:27:55 +03:00
|
|
|
static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
|
|
|
|
unsigned int size)
|
|
|
|
{
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2008-02-05 09:28:14 +03:00
|
|
|
static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
|
|
|
|
unsigned long mask)
|
|
|
|
{
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline int pci_assign_resource(struct pci_dev *dev, int i)
|
|
|
|
{
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int __pci_register_driver(struct pci_driver *drv,
|
|
|
|
struct module *owner)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pci_register_driver(struct pci_driver *drv)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pci_unregister_driver(struct pci_driver *drv)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
static inline int pci_find_capability(struct pci_dev *dev, int cap)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pci_find_next_capability(struct pci_dev *dev, u8 post,
|
|
|
|
int cap)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pci_find_ext_capability(struct pci_dev *dev, int cap)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Power management related routines */
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline int pci_save_state(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-01 02:43:26 +03:00
|
|
|
static inline void pci_restore_state(struct pci_dev *dev)
|
|
|
|
{ }
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-14 23:27:50 +03:00
|
|
|
static inline int pci_wake_from_d3(struct pci_dev *dev, bool enable)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline pci_power_t pci_choose_state(struct pci_dev *dev,
|
|
|
|
pm_message_t state)
|
|
|
|
{
|
|
|
|
return PCI_D0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
|
|
|
|
int enable)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-20 00:07:57 +04:00
|
|
|
static inline void pci_enable_ido(struct pci_dev *dev, unsigned long type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pci_disable_ido(struct pci_dev *dev, unsigned long type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-10 23:46:36 +03:00
|
|
|
static inline int pci_enable_obff(struct pci_dev *dev, unsigned long type)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pci_disable_obff(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline int pci_request_regions(struct pci_dev *dev, const char *res_name)
|
|
|
|
{
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pci_release_regions(struct pci_dev *dev)
|
|
|
|
{ }
|
2007-04-01 21:13:58 +04:00
|
|
|
|
2005-07-29 23:16:27 +04:00
|
|
|
#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0)
|
|
|
|
|
2011-11-04 12:45:59 +04:00
|
|
|
static inline void pci_block_cfg_access(struct pci_dev *dev)
|
2008-01-31 02:21:33 +03:00
|
|
|
{ }
|
|
|
|
|
2011-11-04 12:45:59 +04:00
|
|
|
static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
|
|
|
|
{ return 0; }
|
|
|
|
|
|
|
|
static inline void pci_unblock_cfg_access(struct pci_dev *dev)
|
2008-01-31 02:21:33 +03:00
|
|
|
{ }
|
2005-09-27 12:21:55 +04:00
|
|
|
|
2007-07-01 23:06:37 +04:00
|
|
|
static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
|
|
|
|
{ return NULL; }
|
|
|
|
|
|
|
|
static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
|
|
|
|
unsigned int devfn)
|
|
|
|
{ return NULL; }
|
|
|
|
|
|
|
|
static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
|
|
|
|
unsigned int devfn)
|
|
|
|
{ return NULL; }
|
|
|
|
|
2010-08-13 04:22:17 +04:00
|
|
|
static inline int pci_domain_nr(struct pci_bus *bus)
|
|
|
|
{ return 0; }
|
|
|
|
|
2012-06-11 09:26:55 +04:00
|
|
|
static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
|
|
|
|
{ return NULL; }
|
|
|
|
|
2010-02-10 04:43:04 +03:00
|
|
|
#define dev_is_pci(d) (false)
|
|
|
|
#define dev_is_pf(d) (false)
|
|
|
|
#define dev_num_vf(d) (0)
|
2005-07-28 22:37:33 +04:00
|
|
|
#endif /* CONFIG_PCI */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-07-28 22:37:33 +04:00
|
|
|
/* Include architecture-dependent settings and functions */
|
|
|
|
|
|
|
|
#include <asm/pci.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2009-04-24 07:48:32 +04:00
|
|
|
#ifndef PCIBIOS_MAX_MEM_32
|
|
|
|
#define PCIBIOS_MAX_MEM_32 (-1)
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* these helpers provide future and backwards compatibility
|
|
|
|
* for accessing popular PCI BAR info */
|
2008-01-31 02:21:33 +03:00
|
|
|
#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
|
|
|
|
#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end)
|
|
|
|
#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define pci_resource_len(dev,bar) \
|
2008-01-31 02:21:33 +03:00
|
|
|
((pci_resource_start((dev), (bar)) == 0 && \
|
|
|
|
pci_resource_end((dev), (bar)) == \
|
|
|
|
pci_resource_start((dev), (bar))) ? 0 : \
|
|
|
|
\
|
|
|
|
(pci_resource_end((dev), (bar)) - \
|
|
|
|
pci_resource_start((dev), (bar)) + 1))
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Similar to the helpers above, these manipulate per-pci_dev
|
|
|
|
* driver-specific data. They are really just a wrapper around
|
|
|
|
* the generic device structure functions of these calls.
|
|
|
|
*/
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline void *pci_get_drvdata(struct pci_dev *pdev)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return dev_get_drvdata(&pdev->dev);
|
|
|
|
}
|
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
static inline void pci_set_drvdata(struct pci_dev *pdev, void *data)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
dev_set_drvdata(&pdev->dev, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If you want to know what to call your pci_dev, ask this function.
|
|
|
|
* Again, it's a wrapper around the generic device.
|
|
|
|
*/
|
2009-06-24 16:22:30 +04:00
|
|
|
static inline const char *pci_name(const struct pci_dev *pdev)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-07-03 20:49:39 +04:00
|
|
|
return dev_name(&pdev->dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-05-13 11:44:10 +04:00
|
|
|
|
|
|
|
/* Some archs don't want to expose struct resource to userland as-is
|
|
|
|
* in sysfs and /proc
|
|
|
|
*/
|
|
|
|
#ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER
|
|
|
|
static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
|
2008-01-31 02:21:33 +03:00
|
|
|
const struct resource *rsrc, resource_size_t *start,
|
2006-06-13 04:06:02 +04:00
|
|
|
resource_size_t *end)
|
2005-05-13 11:44:10 +04:00
|
|
|
{
|
|
|
|
*start = rsrc->start;
|
|
|
|
*end = rsrc->end;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */
|
|
|
|
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* The world is not perfect and supplies us with broken PCI devices.
|
|
|
|
* For at least a part of these bugs we need a work-around, so both
|
|
|
|
* generic (drivers/pci/quirks.c) and per-architecture code can define
|
|
|
|
* fixup hooks to be called for particular buggy devices.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct pci_fixup {
|
2012-02-24 11:46:49 +04:00
|
|
|
u16 vendor; /* You can use PCI_ANY_ID here of course */
|
|
|
|
u16 device; /* You can use PCI_ANY_ID here of course */
|
|
|
|
u32 class; /* You can use PCI_ANY_ID here too */
|
|
|
|
unsigned int class_shift; /* should be 0, 8, 16 */
|
2005-04-17 02:20:36 +04:00
|
|
|
void (*hook)(struct pci_dev *dev);
|
|
|
|
};
|
|
|
|
|
|
|
|
enum pci_fixup_pass {
|
|
|
|
pci_fixup_early, /* Before probing BARs */
|
|
|
|
pci_fixup_header, /* After reading configuration header */
|
|
|
|
pci_fixup_final, /* Final phase of device fixups */
|
|
|
|
pci_fixup_enable, /* pci_enable_device() time */
|
2008-05-15 23:51:31 +04:00
|
|
|
pci_fixup_resume, /* pci_device_resume() */
|
|
|
|
pci_fixup_suspend, /* pci_device_suspend */
|
|
|
|
pci_fixup_resume_early, /* pci_device_resume_early() */
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Anonymous variables would be nice... */
|
2012-02-24 11:46:49 +04:00
|
|
|
#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \
|
|
|
|
class_shift, hook) \
|
2012-09-03 01:37:24 +04:00
|
|
|
static const struct pci_fixup __pci_fixup_##name __used \
|
2012-02-24 11:46:49 +04:00
|
|
|
__attribute__((__section__(#section), aligned((sizeof(void *))))) \
|
|
|
|
= { vendor, device, class, class_shift, hook };
|
|
|
|
|
|
|
|
#define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class, \
|
|
|
|
class_shift, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
|
|
|
|
vendor##device##hook, vendor, device, class, class_shift, hook)
|
|
|
|
#define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, class, \
|
|
|
|
class_shift, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
|
|
|
|
vendor##device##hook, vendor, device, class, class_shift, hook)
|
|
|
|
#define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, class, \
|
|
|
|
class_shift, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
|
|
|
|
vendor##device##hook, vendor, device, class, class_shift, hook)
|
|
|
|
#define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, class, \
|
|
|
|
class_shift, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
|
|
|
|
vendor##device##hook, vendor, device, class, class_shift, hook)
|
|
|
|
#define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class, \
|
|
|
|
class_shift, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
|
|
|
|
resume##vendor##device##hook, vendor, device, class, \
|
|
|
|
class_shift, hook)
|
|
|
|
#define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class, \
|
|
|
|
class_shift, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
|
|
|
|
resume_early##vendor##device##hook, vendor, device, \
|
|
|
|
class, class_shift, hook)
|
|
|
|
#define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class, \
|
|
|
|
class_shift, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
|
|
|
|
suspend##vendor##device##hook, vendor, device, class, \
|
|
|
|
class_shift, hook)
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
|
2012-02-24 11:46:49 +04:00
|
|
|
vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
|
2012-02-24 11:46:49 +04:00
|
|
|
vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
|
2012-02-24 11:46:49 +04:00
|
|
|
vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
|
2012-02-24 11:46:49 +04:00
|
|
|
vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
|
2006-12-05 02:14:45 +03:00
|
|
|
#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
|
2012-02-24 11:46:49 +04:00
|
|
|
resume##vendor##device##hook, vendor, device, \
|
|
|
|
PCI_ANY_ID, 0, hook)
|
2008-05-15 23:51:31 +04:00
|
|
|
#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
|
2012-02-24 11:46:49 +04:00
|
|
|
resume_early##vendor##device##hook, vendor, device, \
|
|
|
|
PCI_ANY_ID, 0, hook)
|
2008-05-15 23:51:31 +04:00
|
|
|
#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \
|
|
|
|
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
|
2012-02-24 11:46:49 +04:00
|
|
|
suspend##vendor##device##hook, vendor, device, \
|
|
|
|
PCI_ANY_ID, 0, hook)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-01-03 00:57:24 +03:00
|
|
|
#ifdef CONFIG_PCI_QUIRKS
|
2005-04-17 02:20:36 +04:00
|
|
|
void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
|
2012-06-11 09:26:55 +04:00
|
|
|
struct pci_dev *pci_get_dma_source(struct pci_dev *dev);
|
2012-06-11 09:27:07 +04:00
|
|
|
int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags);
|
2010-01-03 00:57:24 +03:00
|
|
|
#else
|
|
|
|
static inline void pci_fixup_device(enum pci_fixup_pass pass,
|
|
|
|
struct pci_dev *dev) {}
|
2012-06-11 09:26:55 +04:00
|
|
|
static inline struct pci_dev *pci_get_dma_source(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return pci_dev_get(dev);
|
|
|
|
}
|
2012-06-11 09:27:07 +04:00
|
|
|
static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev,
|
|
|
|
u16 acs_flags)
|
|
|
|
{
|
|
|
|
return -ENOTTY;
|
|
|
|
}
|
2010-01-03 00:57:24 +03:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-01-31 02:21:33 +03:00
|
|
|
void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
|
2007-02-11 18:41:31 +03:00
|
|
|
void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
|
2008-01-31 02:21:33 +03:00
|
|
|
void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
|
2012-01-05 03:50:02 +04:00
|
|
|
int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name);
|
|
|
|
int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
|
2008-03-12 09:26:34 +03:00
|
|
|
const char *name);
|
2012-01-05 03:50:02 +04:00
|
|
|
void pcim_iounmap_regions(struct pci_dev *pdev, int mask);
|
2007-02-11 18:41:31 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int pci_pci_problems;
|
2006-10-01 10:27:03 +04:00
|
|
|
#define PCIPCI_FAIL 1 /* No PCI PCI DMA */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define PCIPCI_TRITON 2
|
|
|
|
#define PCIPCI_NATOMA 4
|
|
|
|
#define PCIPCI_VIAETBF 8
|
|
|
|
#define PCIPCI_VSFX 16
|
2006-10-01 10:27:03 +04:00
|
|
|
#define PCIPCI_ALIMAGIK 32 /* Need low latency setting */
|
|
|
|
#define PCIAGP_FAIL 64 /* No PCI to AGP DMA */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-02-06 03:36:06 +03:00
|
|
|
extern unsigned long pci_cardbus_io_size;
|
|
|
|
extern unsigned long pci_cardbus_mem_size;
|
2012-11-22 00:35:00 +04:00
|
|
|
extern u8 pci_dfl_cache_line_size;
|
2009-10-26 23:20:44 +03:00
|
|
|
extern u8 pci_cache_line_size;
|
2007-02-06 03:36:06 +03:00
|
|
|
|
2009-09-10 01:09:24 +04:00
|
|
|
extern unsigned long pci_hotplug_io_size;
|
|
|
|
extern unsigned long pci_hotplug_mem_size;
|
|
|
|
|
2013-11-14 22:28:18 +04:00
|
|
|
/* Architecture-specific versions may override these (weak) */
|
2008-05-05 22:25:47 +04:00
|
|
|
int pcibios_add_platform_entries(struct pci_dev *dev);
|
|
|
|
void pcibios_disable_device(struct pci_dev *dev);
|
2011-10-29 01:47:35 +04:00
|
|
|
void pcibios_set_master(struct pci_dev *dev);
|
2008-05-05 22:25:47 +04:00
|
|
|
int pcibios_set_pcie_reset_state(struct pci_dev *dev,
|
|
|
|
enum pcie_reset_state state);
|
2012-12-06 01:33:27 +04:00
|
|
|
int pcibios_add_device(struct pci_dev *dev);
|
2013-06-04 21:18:14 +04:00
|
|
|
void pcibios_release_device(struct pci_dev *dev);
|
2007-05-08 06:03:07 +04:00
|
|
|
|
2013-08-20 18:41:02 +04:00
|
|
|
#ifdef CONFIG_HIBERNATE_CALLBACKS
|
|
|
|
extern struct dev_pm_ops pcibios_pm_ops;
|
|
|
|
#endif
|
|
|
|
|
2008-02-15 12:27:20 +03:00
|
|
|
#ifdef CONFIG_PCI_MMCONFIG
|
2013-04-12 22:02:59 +04:00
|
|
|
void __init pci_mmcfg_early_init(void);
|
|
|
|
void __init pci_mmcfg_late_init(void);
|
2008-02-15 12:27:20 +03:00
|
|
|
#else
|
2008-02-29 10:56:50 +03:00
|
|
|
static inline void pci_mmcfg_early_init(void) { }
|
2008-02-15 12:27:20 +03:00
|
|
|
static inline void pci_mmcfg_late_init(void) { }
|
|
|
|
#endif
|
|
|
|
|
2012-10-30 10:26:18 +04:00
|
|
|
int pci_ext_cfg_avail(void);
|
2008-11-11 01:30:50 +03:00
|
|
|
|
2008-12-02 01:30:30 +03:00
|
|
|
void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
|
2008-09-29 03:36:11 +04:00
|
|
|
|
2009-03-20 06:25:15 +03:00
|
|
|
#ifdef CONFIG_PCI_IOV
|
2013-04-12 22:02:59 +04:00
|
|
|
int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
|
|
|
|
void pci_disable_sriov(struct pci_dev *dev);
|
|
|
|
irqreturn_t pci_sriov_migration(struct pci_dev *dev);
|
|
|
|
int pci_num_vf(struct pci_dev *dev);
|
2013-04-25 08:42:29 +04:00
|
|
|
int pci_vfs_assigned(struct pci_dev *dev);
|
2013-04-12 22:02:59 +04:00
|
|
|
int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
|
|
|
|
int pci_sriov_get_totalvfs(struct pci_dev *dev);
|
2009-03-20 06:25:15 +03:00
|
|
|
#else
|
|
|
|
static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
static inline void pci_disable_sriov(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
}
|
2009-03-20 06:25:16 +03:00
|
|
|
static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
2010-02-10 04:43:04 +03:00
|
|
|
static inline int pci_num_vf(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-25 08:42:29 +04:00
|
|
|
static inline int pci_vfs_assigned(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2012-11-06 00:20:37 +04:00
|
|
|
static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int pci_sriov_get_totalvfs(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2009-03-20 06:25:15 +03:00
|
|
|
#endif
|
|
|
|
|
2009-06-16 06:01:25 +04:00
|
|
|
#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
|
2013-04-12 22:02:59 +04:00
|
|
|
void pci_hp_create_module_link(struct pci_slot *pci_slot);
|
|
|
|
void pci_hp_remove_module_link(struct pci_slot *pci_slot);
|
2009-06-16 06:01:25 +04:00
|
|
|
#endif
|
|
|
|
|
2009-11-11 08:29:54 +03:00
|
|
|
/**
|
|
|
|
* pci_pcie_cap - get the saved PCIe capability offset
|
|
|
|
* @dev: PCI device
|
|
|
|
*
|
|
|
|
* PCIe capability offset is calculated at PCI device initialization
|
|
|
|
* time and saved in the data structure. This function returns saved
|
|
|
|
* PCIe capability offset. Using this instead of pci_find_capability()
|
|
|
|
* reduces unnecessary search in the PCI configuration space. If you
|
|
|
|
* need to calculate PCIe capability offset from raw device for some
|
|
|
|
* reasons, please use pci_find_capability() instead.
|
|
|
|
*/
|
|
|
|
static inline int pci_pcie_cap(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->pcie_cap;
|
|
|
|
}
|
|
|
|
|
2009-11-11 08:35:22 +03:00
|
|
|
/**
|
|
|
|
* pci_is_pcie - check if the PCI device is PCI Express capable
|
|
|
|
* @dev: PCI device
|
|
|
|
*
|
2013-09-04 00:31:05 +04:00
|
|
|
* Returns: true if the PCI device is PCI Express capable, false otherwise.
|
2009-11-11 08:35:22 +03:00
|
|
|
*/
|
|
|
|
static inline bool pci_is_pcie(struct pci_dev *dev)
|
|
|
|
{
|
2013-09-04 00:31:05 +04:00
|
|
|
return pci_pcie_cap(dev);
|
2009-11-11 08:35:22 +03:00
|
|
|
}
|
|
|
|
|
2013-01-26 04:55:39 +04:00
|
|
|
/**
|
|
|
|
* pcie_caps_reg - get the PCIe Capabilities Register
|
|
|
|
* @dev: PCI device
|
|
|
|
*/
|
|
|
|
static inline u16 pcie_caps_reg(const struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->pcie_flags_reg;
|
|
|
|
}
|
|
|
|
|
2012-07-24 13:20:02 +04:00
|
|
|
/**
|
|
|
|
* pci_pcie_type - get the PCIe device/port type
|
|
|
|
* @dev: PCI device
|
|
|
|
*/
|
|
|
|
static inline int pci_pcie_type(const struct pci_dev *dev)
|
|
|
|
{
|
2013-01-26 04:55:45 +04:00
|
|
|
return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
|
2012-07-24 13:20:02 +04:00
|
|
|
}
|
|
|
|
|
2009-12-04 23:15:21 +03:00
|
|
|
void pci_request_acs(void);
|
2012-06-11 09:27:07 +04:00
|
|
|
bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags);
|
|
|
|
bool pci_acs_path_enabled(struct pci_dev *start,
|
|
|
|
struct pci_dev *end, u16 acs_flags);
|
2010-02-26 17:04:39 +03:00
|
|
|
|
2010-02-26 17:04:40 +03:00
|
|
|
#define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */
|
|
|
|
#define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT)
|
|
|
|
|
|
|
|
/* Large Resource Data Type Tag Item Names */
|
|
|
|
#define PCI_VPD_LTIN_ID_STRING 0x02 /* Identifier String */
|
|
|
|
#define PCI_VPD_LTIN_RO_DATA 0x10 /* Read-Only Data */
|
|
|
|
#define PCI_VPD_LTIN_RW_DATA 0x11 /* Read-Write Data */
|
|
|
|
|
|
|
|
#define PCI_VPD_LRDT_ID_STRING PCI_VPD_LRDT_ID(PCI_VPD_LTIN_ID_STRING)
|
|
|
|
#define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA)
|
|
|
|
#define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA)
|
|
|
|
|
|
|
|
/* Small Resource Data Type Tag Item Names */
|
|
|
|
#define PCI_VPD_STIN_END 0x78 /* End */
|
|
|
|
|
|
|
|
#define PCI_VPD_SRDT_END PCI_VPD_STIN_END
|
|
|
|
|
|
|
|
#define PCI_VPD_SRDT_TIN_MASK 0x78
|
|
|
|
#define PCI_VPD_SRDT_LEN_MASK 0x07
|
|
|
|
|
|
|
|
#define PCI_VPD_LRDT_TAG_SIZE 3
|
|
|
|
#define PCI_VPD_SRDT_TAG_SIZE 1
|
2010-02-26 17:04:39 +03:00
|
|
|
|
2010-02-26 17:04:42 +03:00
|
|
|
#define PCI_VPD_INFO_FLD_HDR_SIZE 3
|
|
|
|
|
2010-02-26 17:04:43 +03:00
|
|
|
#define PCI_VPD_RO_KEYWORD_PARTNO "PN"
|
|
|
|
#define PCI_VPD_RO_KEYWORD_MFR_ID "MN"
|
|
|
|
#define PCI_VPD_RO_KEYWORD_VENDOR0 "V0"
|
2011-03-09 19:58:21 +03:00
|
|
|
#define PCI_VPD_RO_KEYWORD_CHKSUM "RV"
|
2010-02-26 17:04:43 +03:00
|
|
|
|
2010-02-26 17:04:39 +03:00
|
|
|
/**
|
|
|
|
* pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
|
|
|
|
* @lrdt: Pointer to the beginning of the Large Resource Data Type tag
|
|
|
|
*
|
|
|
|
* Returns the extracted Large Resource Data Type length.
|
|
|
|
*/
|
|
|
|
static inline u16 pci_vpd_lrdt_size(const u8 *lrdt)
|
|
|
|
{
|
|
|
|
return (u16)lrdt[1] + ((u16)lrdt[2] << 8);
|
|
|
|
}
|
|
|
|
|
2010-02-26 17:04:40 +03:00
|
|
|
/**
|
|
|
|
* pci_vpd_srdt_size - Extracts the Small Resource Data Type length
|
|
|
|
* @lrdt: Pointer to the beginning of the Small Resource Data Type tag
|
|
|
|
*
|
|
|
|
* Returns the extracted Small Resource Data Type length.
|
|
|
|
*/
|
|
|
|
static inline u8 pci_vpd_srdt_size(const u8 *srdt)
|
|
|
|
{
|
|
|
|
return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
|
|
|
|
}
|
|
|
|
|
2010-02-26 17:04:42 +03:00
|
|
|
/**
|
|
|
|
* pci_vpd_info_field_size - Extracts the information field length
|
|
|
|
* @lrdt: Pointer to the beginning of an information field header
|
|
|
|
*
|
|
|
|
* Returns the extracted information field length.
|
|
|
|
*/
|
|
|
|
static inline u8 pci_vpd_info_field_size(const u8 *info_field)
|
|
|
|
{
|
|
|
|
return info_field[2];
|
|
|
|
}
|
|
|
|
|
2010-02-26 17:04:41 +03:00
|
|
|
/**
|
|
|
|
* pci_vpd_find_tag - Locates the Resource Data Type tag provided
|
|
|
|
* @buf: Pointer to buffered vpd data
|
|
|
|
* @off: The offset into the buffer at which to begin the search
|
|
|
|
* @len: The length of the vpd buffer
|
|
|
|
* @rdt: The Resource Data Type to search for
|
|
|
|
*
|
|
|
|
* Returns the index where the Resource Data Type was found or
|
|
|
|
* -ENOENT otherwise.
|
|
|
|
*/
|
|
|
|
int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt);
|
|
|
|
|
2010-02-26 17:04:43 +03:00
|
|
|
/**
|
|
|
|
* pci_vpd_find_info_keyword - Locates an information field keyword in the VPD
|
|
|
|
* @buf: Pointer to buffered vpd data
|
|
|
|
* @off: The offset into the buffer at which to begin the search
|
|
|
|
* @len: The length of the buffer area, relative to off, in which to search
|
|
|
|
* @kw: The keyword to search for
|
|
|
|
*
|
|
|
|
* Returns the index where the information field keyword was found or
|
|
|
|
* -ENOENT otherwise.
|
|
|
|
*/
|
|
|
|
int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
|
|
|
|
unsigned int len, const char *kw);
|
|
|
|
|
2011-04-11 05:37:07 +04:00
|
|
|
/* PCI <-> OF binding helpers */
|
|
|
|
#ifdef CONFIG_OF
|
|
|
|
struct device_node;
|
2013-04-12 22:02:59 +04:00
|
|
|
void pci_set_of_node(struct pci_dev *dev);
|
|
|
|
void pci_release_of_node(struct pci_dev *dev);
|
|
|
|
void pci_set_bus_of_node(struct pci_bus *bus);
|
|
|
|
void pci_release_bus_of_node(struct pci_bus *bus);
|
2011-04-11 05:37:07 +04:00
|
|
|
|
|
|
|
/* Arch may override this (weak) */
|
2013-04-17 20:31:34 +04:00
|
|
|
struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus);
|
2011-04-11 05:37:07 +04:00
|
|
|
|
2012-04-12 19:33:07 +04:00
|
|
|
static inline struct device_node *
|
|
|
|
pci_device_to_OF_node(const struct pci_dev *pdev)
|
2011-04-07 07:09:47 +04:00
|
|
|
{
|
|
|
|
return pdev ? pdev->dev.of_node : NULL;
|
|
|
|
}
|
|
|
|
|
2011-04-11 05:34:33 +04:00
|
|
|
static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
|
|
|
|
{
|
|
|
|
return bus ? bus->dev.of_node : NULL;
|
|
|
|
}
|
|
|
|
|
2011-04-11 05:37:07 +04:00
|
|
|
#else /* CONFIG_OF */
|
|
|
|
static inline void pci_set_of_node(struct pci_dev *dev) { }
|
|
|
|
static inline void pci_release_of_node(struct pci_dev *dev) { }
|
|
|
|
static inline void pci_set_bus_of_node(struct pci_bus *bus) { }
|
|
|
|
static inline void pci_release_bus_of_node(struct pci_bus *bus) { }
|
|
|
|
#endif /* CONFIG_OF */
|
|
|
|
|
powerpc/eeh: Introduce EEH device
Original EEH implementation depends on struct pci_dn heavily. However,
EEH shouldn't depend on that actually because EEH needn't share much
information with other PCI components. That's to say, EEH should have
worked independently.
The patch introduces struct eeh_dev so that EEH core components needn't
be working based on struct pci_dn in future. Also, struct pci_dn, struct
eeh_dev instances are created in dynamic fasion and the binding with EEH
device, OF node, PCI device is implemented as well.
The EEH devices are created after PHBs are detected and initialized, but
PCI emunation hasn't started yet. Apart from that, PHB might be created
dynamically through DLPAR component and the EEH devices should be creatd
as well. Another case might be OF node is created dynamically by DR
(Dynamic Reconfiguration), which has been defined by PAPR. For those OF
nodes created by DR, EEH devices should be also created accordingly. The
binding between EEH device and OF node is done while the EEH device is
initially created.
The binding between EEH device and PCI device should be done after PCI
emunation is done. Besides, PCI hotplug also needs the binding so that
the EEH devices could be traced from the newly coming PCI buses or PCI
devices.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-02-28 00:04:04 +04:00
|
|
|
#ifdef CONFIG_EEH
|
|
|
|
static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
return pdev->dev.archdata.edev;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-06-10 22:42:27 +04:00
|
|
|
/**
|
|
|
|
* pci_find_upstream_pcie_bridge - find upstream PCIe-to-PCI bridge of a device
|
|
|
|
* @pdev: the PCI device
|
|
|
|
*
|
|
|
|
* if the device is PCIE, return NULL
|
|
|
|
* if the device isn't connected to a PCIe bridge (that is its parent is a
|
|
|
|
* legacy PCI bridge and the bridge is directly connected to bus 0), return its
|
|
|
|
* parent
|
|
|
|
*/
|
|
|
|
struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif /* LINUX_PCI_H */
|