Commit 62f87c0e authored by Yijing Wang's avatar Yijing Wang Committed by Bjorn Helgaas

PCI: Introduce pci_pcie_type(dev) to replace pci_dev->pcie_type

Introduce an inline function pci_pcie_type(dev) to extract PCIe
device type from pci_dev->pcie_flags_reg field, and prepare for
removing pci_dev->pcie_type.
Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 786e2288
...@@ -855,7 +855,7 @@ static void __devinit pnv_ioda_setup_PEs(struct pci_bus *bus) ...@@ -855,7 +855,7 @@ static void __devinit pnv_ioda_setup_PEs(struct pci_bus *bus)
if (pe == NULL) if (pe == NULL)
continue; continue;
/* Leaving the PCIe domain ... single PE# */ /* Leaving the PCIe domain ... single PE# */
if (dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) if (pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE)
pnv_ioda_setup_bus_PE(dev, pe); pnv_ioda_setup_bus_PE(dev, pe);
else if (dev->subordinate) else if (dev->subordinate)
pnv_ioda_setup_PEs(dev->subordinate); pnv_ioda_setup_PEs(dev->subordinate);
......
...@@ -2350,7 +2350,7 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup) ...@@ -2350,7 +2350,7 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
return 0; return 0;
if (pdev->class >> 8 == PCI_CLASS_BRIDGE_PCI) if (pdev->class >> 8 == PCI_CLASS_BRIDGE_PCI)
return 0; return 0;
} else if (pdev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) } else if (pci_pcie_type(pdev) == PCI_EXP_TYPE_PCI_BRIDGE)
return 0; return 0;
/* /*
...@@ -3545,10 +3545,10 @@ int dmar_find_matched_atsr_unit(struct pci_dev *dev) ...@@ -3545,10 +3545,10 @@ int dmar_find_matched_atsr_unit(struct pci_dev *dev)
struct pci_dev *bridge = bus->self; struct pci_dev *bridge = bus->self;
if (!bridge || !pci_is_pcie(bridge) || if (!bridge || !pci_is_pcie(bridge) ||
bridge->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) pci_pcie_type(bridge) == PCI_EXP_TYPE_PCI_BRIDGE)
return 0; return 0;
if (bridge->pcie_type == PCI_EXP_TYPE_ROOT_PORT) { if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT) {
for (i = 0; i < atsru->devices_cnt; i++) for (i = 0; i < atsru->devices_cnt; i++)
if (atsru->devices[i] == bridge) if (atsru->devices[i] == bridge)
return 1; return 1;
......
...@@ -7527,7 +7527,7 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, ...@@ -7527,7 +7527,7 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
goto skip_bad_vf_detection; goto skip_bad_vf_detection;
bdev = pdev->bus->self; bdev = pdev->bus->self;
while (bdev && (bdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT)) while (bdev && (pci_pcie_type(bdev) != PCI_EXP_TYPE_ROOT_PORT))
bdev = bdev->bus->self; bdev = bdev->bus->self;
if (!bdev) if (!bdev)
......
...@@ -1382,7 +1382,7 @@ static void netxen_mask_aer_correctable(struct netxen_adapter *adapter) ...@@ -1382,7 +1382,7 @@ static void netxen_mask_aer_correctable(struct netxen_adapter *adapter)
adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP) adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP)
return; return;
if (root->pcie_type != PCI_EXP_TYPE_ROOT_PORT) if (pci_pcie_type(root) != PCI_EXP_TYPE_ROOT_PORT)
return; return;
aer_pos = pci_find_ext_capability(root, PCI_EXT_CAP_ID_ERR); aer_pos = pci_find_ext_capability(root, PCI_EXT_CAP_ID_ERR);
......
...@@ -433,8 +433,8 @@ static int sriov_init(struct pci_dev *dev, int pos) ...@@ -433,8 +433,8 @@ static int sriov_init(struct pci_dev *dev, int pos)
struct resource *res; struct resource *res;
struct pci_dev *pdev; struct pci_dev *pdev;
if (dev->pcie_type != PCI_EXP_TYPE_RC_END && if (pci_pcie_type(dev) != PCI_EXP_TYPE_RC_END &&
dev->pcie_type != PCI_EXP_TYPE_ENDPOINT) pci_pcie_type(dev) != PCI_EXP_TYPE_ENDPOINT)
return -ENODEV; return -ENODEV;
pci_read_config_word(dev, pos + PCI_SRIOV_CTRL, &ctrl); pci_read_config_word(dev, pos + PCI_SRIOV_CTRL, &ctrl);
...@@ -503,7 +503,7 @@ static int sriov_init(struct pci_dev *dev, int pos) ...@@ -503,7 +503,7 @@ static int sriov_init(struct pci_dev *dev, int pos)
iov->self = dev; iov->self = dev;
pci_read_config_dword(dev, pos + PCI_SRIOV_CAP, &iov->cap); pci_read_config_dword(dev, pos + PCI_SRIOV_CAP, &iov->cap);
pci_read_config_byte(dev, pos + PCI_SRIOV_FUNC_LINK, &iov->link); pci_read_config_byte(dev, pos + PCI_SRIOV_FUNC_LINK, &iov->link);
if (dev->pcie_type == PCI_EXP_TYPE_RC_END) if (pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END)
iov->link = PCI_DEVFN(PCI_SLOT(dev->devfn), iov->link); iov->link = PCI_DEVFN(PCI_SLOT(dev->devfn), iov->link);
if (pdev) if (pdev)
......
...@@ -885,7 +885,7 @@ static struct pci_cap_saved_state *pci_find_saved_cap( ...@@ -885,7 +885,7 @@ static struct pci_cap_saved_state *pci_find_saved_cap(
static int pci_save_pcie_state(struct pci_dev *dev) static int pci_save_pcie_state(struct pci_dev *dev)
{ {
int pos, i = 0; int type, pos, i = 0;
struct pci_cap_saved_state *save_state; struct pci_cap_saved_state *save_state;
u16 *cap; u16 *cap;
u16 flags; u16 flags;
...@@ -903,13 +903,14 @@ static int pci_save_pcie_state(struct pci_dev *dev) ...@@ -903,13 +903,14 @@ static int pci_save_pcie_state(struct pci_dev *dev)
pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags);
if (pcie_cap_has_devctl(dev->pcie_type, flags)) type = pci_pcie_type(dev);
if (pcie_cap_has_devctl(type, flags))
pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &cap[i++]); pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &cap[i++]);
if (pcie_cap_has_lnkctl(dev->pcie_type, flags)) if (pcie_cap_has_lnkctl(type, flags))
pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]); pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]);
if (pcie_cap_has_sltctl(dev->pcie_type, flags)) if (pcie_cap_has_sltctl(type, flags))
pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]); pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]);
if (pcie_cap_has_rtctl(dev->pcie_type, flags)) if (pcie_cap_has_rtctl(type, flags))
pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]); pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]);
pos = pci_pcie_cap2(dev); pos = pci_pcie_cap2(dev);
...@@ -924,7 +925,7 @@ static int pci_save_pcie_state(struct pci_dev *dev) ...@@ -924,7 +925,7 @@ static int pci_save_pcie_state(struct pci_dev *dev)
static void pci_restore_pcie_state(struct pci_dev *dev) static void pci_restore_pcie_state(struct pci_dev *dev)
{ {
int i = 0, pos; int i = 0, pos, type;
struct pci_cap_saved_state *save_state; struct pci_cap_saved_state *save_state;
u16 *cap; u16 *cap;
u16 flags; u16 flags;
...@@ -937,13 +938,14 @@ static void pci_restore_pcie_state(struct pci_dev *dev) ...@@ -937,13 +938,14 @@ static void pci_restore_pcie_state(struct pci_dev *dev)
pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags);
if (pcie_cap_has_devctl(dev->pcie_type, flags)) type = pci_pcie_type(dev);
if (pcie_cap_has_devctl(type, flags))
pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, cap[i++]); pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, cap[i++]);
if (pcie_cap_has_lnkctl(dev->pcie_type, flags)) if (pcie_cap_has_lnkctl(type, flags))
pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]); pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]);
if (pcie_cap_has_sltctl(dev->pcie_type, flags)) if (pcie_cap_has_sltctl(type, flags))
pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]);
if (pcie_cap_has_rtctl(dev->pcie_type, flags)) if (pcie_cap_has_rtctl(type, flags))
pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]);
pos = pci_pcie_cap2(dev); pos = pci_pcie_cap2(dev);
...@@ -2459,8 +2461,8 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags) ...@@ -2459,8 +2461,8 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | acs_flags &= (PCI_ACS_RR | PCI_ACS_CR |
PCI_ACS_EC | PCI_ACS_DT); PCI_ACS_EC | PCI_ACS_DT);
if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM || if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM ||
pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT || pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT ||
pdev->multifunction) { pdev->multifunction) {
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS); pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS);
if (!pos) if (!pos)
......
...@@ -288,7 +288,7 @@ static struct pci_dev *pcie_find_root_port(struct pci_dev *dev) ...@@ -288,7 +288,7 @@ static struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
while (1) { while (1) {
if (!pci_is_pcie(dev)) if (!pci_is_pcie(dev))
break; break;
if (dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
return dev; return dev;
if (!dev->bus->self) if (!dev->bus->self)
break; break;
......
...@@ -81,10 +81,11 @@ bool pci_aer_available(void) ...@@ -81,10 +81,11 @@ bool pci_aer_available(void)
static int set_device_error_reporting(struct pci_dev *dev, void *data) static int set_device_error_reporting(struct pci_dev *dev, void *data)
{ {
bool enable = *((bool *)data); bool enable = *((bool *)data);
int type = pci_pcie_type(dev);
if ((dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) || if ((type == PCI_EXP_TYPE_ROOT_PORT) ||
(dev->pcie_type == PCI_EXP_TYPE_UPSTREAM) || (type == PCI_EXP_TYPE_UPSTREAM) ||
(dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)) { (type == PCI_EXP_TYPE_DOWNSTREAM)) {
if (enable) if (enable)
pci_enable_pcie_error_reporting(dev); pci_enable_pcie_error_reporting(dev);
else else
......
...@@ -60,7 +60,7 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data) ...@@ -60,7 +60,7 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
p = (struct acpi_hest_aer_common *)(hest_hdr + 1); p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
if (p->flags & ACPI_HEST_GLOBAL) { if (p->flags & ACPI_HEST_GLOBAL) {
if ((pci_is_pcie(info->pci_dev) && if ((pci_is_pcie(info->pci_dev) &&
info->pci_dev->pcie_type == pcie_type) || bridge) pci_pcie_type(info->pci_dev) == pcie_type) || bridge)
ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
} else } else
if (hest_match_pci(p, info->pci_dev)) if (hest_match_pci(p, info->pci_dev))
......
...@@ -465,7 +465,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) ...@@ -465,7 +465,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev)
if (driver && driver->reset_link) { if (driver && driver->reset_link) {
status = driver->reset_link(udev); status = driver->reset_link(udev);
} else if (udev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) { } else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM) {
status = default_downstream_reset_link(udev); status = default_downstream_reset_link(udev);
} else { } else {
dev_printk(KERN_DEBUG, &dev->dev, dev_printk(KERN_DEBUG, &dev->dev,
......
...@@ -412,7 +412,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) ...@@ -412,7 +412,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
* do ASPM for now. * do ASPM for now.
*/ */
list_for_each_entry(child, &linkbus->devices, bus_list) { list_for_each_entry(child, &linkbus->devices, bus_list) {
if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { if (pci_pcie_type(child) == PCI_EXP_TYPE_PCI_BRIDGE) {
link->aspm_disable = ASPM_STATE_ALL; link->aspm_disable = ASPM_STATE_ALL;
break; break;
} }
...@@ -425,8 +425,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) ...@@ -425,8 +425,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
struct aspm_latency *acceptable = struct aspm_latency *acceptable =
&link->acceptable[PCI_FUNC(child->devfn)]; &link->acceptable[PCI_FUNC(child->devfn)];
if (child->pcie_type != PCI_EXP_TYPE_ENDPOINT && if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT &&
child->pcie_type != PCI_EXP_TYPE_LEG_END) pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END)
continue; continue;
pos = pci_pcie_cap(child); pos = pci_pcie_cap(child);
...@@ -552,7 +552,7 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev) ...@@ -552,7 +552,7 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev)
INIT_LIST_HEAD(&link->children); INIT_LIST_HEAD(&link->children);
INIT_LIST_HEAD(&link->link); INIT_LIST_HEAD(&link->link);
link->pdev = pdev; link->pdev = pdev;
if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) { if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM) {
struct pcie_link_state *parent; struct pcie_link_state *parent;
parent = pdev->bus->parent->self->link_state; parent = pdev->bus->parent->self->link_state;
if (!parent) { if (!parent) {
...@@ -585,12 +585,12 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev) ...@@ -585,12 +585,12 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
if (!pci_is_pcie(pdev) || pdev->link_state) if (!pci_is_pcie(pdev) || pdev->link_state)
return; return;
if (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM)
return; return;
/* VIA has a strange chipset, root port is under a bridge */ /* VIA has a strange chipset, root port is under a bridge */
if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT && if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT &&
pdev->bus->self) pdev->bus->self)
return; return;
...@@ -647,8 +647,8 @@ static void pcie_update_aspm_capable(struct pcie_link_state *root) ...@@ -647,8 +647,8 @@ static void pcie_update_aspm_capable(struct pcie_link_state *root)
if (link->root != root) if (link->root != root)
continue; continue;
list_for_each_entry(child, &linkbus->devices, bus_list) { list_for_each_entry(child, &linkbus->devices, bus_list) {
if ((child->pcie_type != PCI_EXP_TYPE_ENDPOINT) && if ((pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT) &&
(child->pcie_type != PCI_EXP_TYPE_LEG_END)) (pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END))
continue; continue;
pcie_aspm_check_latency(child); pcie_aspm_check_latency(child);
} }
...@@ -663,8 +663,8 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev) ...@@ -663,8 +663,8 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
if (!pci_is_pcie(pdev) || !parent || !parent->link_state) if (!pci_is_pcie(pdev) || !parent || !parent->link_state)
return; return;
if ((parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && if ((pci_pcie_type(parent) != PCI_EXP_TYPE_ROOT_PORT) &&
(parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) (pci_pcie_type(parent) != PCI_EXP_TYPE_DOWNSTREAM))
return; return;
down_read(&pci_bus_sem); down_read(&pci_bus_sem);
...@@ -704,8 +704,8 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev) ...@@ -704,8 +704,8 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev)
if (aspm_disabled || !pci_is_pcie(pdev) || !link) if (aspm_disabled || !pci_is_pcie(pdev) || !link)
return; return;
if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
(pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
return; return;
/* /*
* Devices changed PM state, we should recheck if latency * Devices changed PM state, we should recheck if latency
...@@ -729,8 +729,8 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev) ...@@ -729,8 +729,8 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
if (aspm_policy != POLICY_POWERSAVE) if (aspm_policy != POLICY_POWERSAVE)
return; return;
if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
(pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
return; return;
down_read(&pci_bus_sem); down_read(&pci_bus_sem);
...@@ -757,8 +757,8 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem, ...@@ -757,8 +757,8 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
if (!pci_is_pcie(pdev)) if (!pci_is_pcie(pdev))
return; return;
if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT || if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT ||
pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM)
parent = pdev; parent = pdev;
if (!parent || !parent->link_state) if (!parent || !parent->link_state)
return; return;
...@@ -933,8 +933,8 @@ void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev) ...@@ -933,8 +933,8 @@ void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev)
struct pcie_link_state *link_state = pdev->link_state; struct pcie_link_state *link_state = pdev->link_state;
if (!pci_is_pcie(pdev) || if (!pci_is_pcie(pdev) ||
(pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
return; return;
if (link_state->aspm_support) if (link_state->aspm_support)
...@@ -950,8 +950,8 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) ...@@ -950,8 +950,8 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
struct pcie_link_state *link_state = pdev->link_state; struct pcie_link_state *link_state = pdev->link_state;
if (!pci_is_pcie(pdev) || if (!pci_is_pcie(pdev) ||
(pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
return; return;
if (link_state->aspm_support) if (link_state->aspm_support)
......
...@@ -120,7 +120,7 @@ static bool pcie_pme_from_pci_bridge(struct pci_bus *bus, u8 devfn) ...@@ -120,7 +120,7 @@ static bool pcie_pme_from_pci_bridge(struct pci_bus *bus, u8 devfn)
if (!dev) if (!dev)
return false; return false;
if (pci_is_pcie(dev) && dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { if (pci_is_pcie(dev) && pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) {
down_read(&pci_bus_sem); down_read(&pci_bus_sem);
if (pcie_pme_walk_bus(bus)) if (pcie_pme_walk_bus(bus))
found = true; found = true;
...@@ -335,13 +335,13 @@ static void pcie_pme_mark_devices(struct pci_dev *port) ...@@ -335,13 +335,13 @@ static void pcie_pme_mark_devices(struct pci_dev *port)
struct pci_dev *dev; struct pci_dev *dev;
/* Check if this is a root port event collector. */ /* Check if this is a root port event collector. */
if (port->pcie_type != PCI_EXP_TYPE_RC_EC || !bus) if (pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC || !bus)
return; return;
down_read(&pci_bus_sem); down_read(&pci_bus_sem);
list_for_each_entry(dev, &bus->devices, bus_list) list_for_each_entry(dev, &bus->devices, bus_list)
if (pci_is_pcie(dev) if (pci_is_pcie(dev)
&& dev->pcie_type == PCI_EXP_TYPE_RC_END) && pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END)
pcie_pme_set_native(dev, NULL); pcie_pme_set_native(dev, NULL);
up_read(&pci_bus_sem); up_read(&pci_bus_sem);
} }
......
...@@ -38,7 +38,7 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv) ...@@ -38,7 +38,7 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
return 0; return 0;
if ((driver->port_type != PCIE_ANY_PORT) && if ((driver->port_type != PCIE_ANY_PORT) &&
(driver->port_type != pciedev->port->pcie_type)) (driver->port_type != pci_pcie_type(pciedev->port)))
return 0; return 0;
return 1; return 1;
......
...@@ -298,7 +298,7 @@ static int get_port_device_capability(struct pci_dev *dev) ...@@ -298,7 +298,7 @@ static int get_port_device_capability(struct pci_dev *dev)
services |= PCIE_PORT_SERVICE_VC; services |= PCIE_PORT_SERVICE_VC;
/* Root ports are capable of generating PME too */ /* Root ports are capable of generating PME too */
if ((cap_mask & PCIE_PORT_SERVICE_PME) if ((cap_mask & PCIE_PORT_SERVICE_PME)
&& dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) { && pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {
services |= PCIE_PORT_SERVICE_PME; services |= PCIE_PORT_SERVICE_PME;
/* /*
* Disable PME interrupt on this port in case it's been enabled * Disable PME interrupt on this port in case it's been enabled
...@@ -336,7 +336,7 @@ static int pcie_device_init(struct pci_dev *pdev, int service, int irq) ...@@ -336,7 +336,7 @@ static int pcie_device_init(struct pci_dev *pdev, int service, int irq)
device->release = release_pcie_device; /* callback to free pcie dev */ device->release = release_pcie_device; /* callback to free pcie dev */
dev_set_name(device, "%s:pcie%02x", dev_set_name(device, "%s:pcie%02x",
pci_name(pdev), pci_name(pdev),
get_descriptor_id(pdev->pcie_type, service)); get_descriptor_id(pci_pcie_type(pdev), service));
device->parent = &pdev->dev; device->parent = &pdev->dev;
device_enable_async_suspend(device); device_enable_async_suspend(device);
......
...@@ -95,7 +95,7 @@ static int pcie_port_resume_noirq(struct device *dev) ...@@ -95,7 +95,7 @@ static int pcie_port_resume_noirq(struct device *dev)
* which breaks ACPI-based runtime wakeup on PCI Express, so clear those * which breaks ACPI-based runtime wakeup on PCI Express, so clear those
* bits now just in case (shouldn't hurt). * bits now just in case (shouldn't hurt).
*/ */
if(pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT)
pcie_clear_root_pme_status(pdev); pcie_clear_root_pme_status(pdev);
return 0; return 0;
} }
...@@ -186,9 +186,9 @@ static int __devinit pcie_portdrv_probe(struct pci_dev *dev, ...@@ -186,9 +186,9 @@ static int __devinit pcie_portdrv_probe(struct pci_dev *dev,
int status; int status;
if (!pci_is_pcie(dev) || if (!pci_is_pcie(dev) ||
((dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&
(dev->pcie_type != PCI_EXP_TYPE_UPSTREAM) && (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) &&
(dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))) (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM)))
return -ENODEV; return -ENODEV;
if (!dev->irq && dev->pin) { if (!dev->irq && dev->pin) {
......
...@@ -1384,9 +1384,9 @@ static int only_one_child(struct pci_bus *bus) ...@@ -1384,9 +1384,9 @@ static int only_one_child(struct pci_bus *bus)
if (!parent || !pci_is_pcie(parent)) if (!parent || !pci_is_pcie(parent))
return 0; return 0;
if (parent->pcie_type == PCI_EXP_TYPE_ROOT_PORT) if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT)
return 1; return 1;
if (parent->pcie_type == PCI_EXP_TYPE_DOWNSTREAM && if (pci_pcie_type(parent) == PCI_EXP_TYPE_DOWNSTREAM &&
!pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS)) !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS))
return 1; return 1;
return 0; return 0;
...@@ -1463,7 +1463,7 @@ static int pcie_find_smpss(struct pci_dev *dev, void *data) ...@@ -1463,7 +1463,7 @@ static int pcie_find_smpss(struct pci_dev *dev, void *data)
*/ */
if (dev->is_hotplug_bridge && (!list_is_singular(&dev->bus->devices) || if (dev->is_hotplug_bridge && (!list_is_singular(&dev->bus->devices) ||
(dev->bus->self && (dev->bus->self &&
dev->bus->self->pcie_type != PCI_EXP_TYPE_ROOT_PORT))) pci_pcie_type(dev->bus->self) != PCI_EXP_TYPE_ROOT_PORT)))
*smpss = 0; *smpss = 0;
if (*smpss > dev->pcie_mpss) if (*smpss > dev->pcie_mpss)
...@@ -1479,7 +1479,8 @@ static void pcie_write_mps(struct pci_dev *dev, int mps) ...@@ -1479,7 +1479,8 @@ static void pcie_write_mps(struct pci_dev *dev, int mps)
if (pcie_bus_config == PCIE_BUS_PERFORMANCE) { if (pcie_bus_config == PCIE_BUS_PERFORMANCE) {
mps = 128 << dev->pcie_mpss; mps = 128 << dev->pcie_mpss;
if (dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && dev->bus->self) if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT &&
dev->bus->self)
/* For "Performance", the assumption is made that /* For "Performance", the assumption is made that
* downstream communication will never be larger than * downstream communication will never be larger than
* the MRRS. So, the MPS only needs to be configured * the MRRS. So, the MPS only needs to be configured
......
...@@ -41,7 +41,7 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev) ...@@ -41,7 +41,7 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
continue; continue;
} }
/* PCI device should connect to a PCIe bridge */ /* PCI device should connect to a PCIe bridge */
if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) { if (pci_pcie_type(pdev) != PCI_EXP_TYPE_PCI_BRIDGE) {
/* Busted hardware? */ /* Busted hardware? */
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment