Lines Matching +full:retain +full:- +full:state +full:- +full:suspended

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright 1993 -- 1997 Drew Eckhardt, Frederic Potter,
6 * David Mosberger-Tang
8 * Copyright 1997 -- 2000 Martin Mares <mj@ucw.cz>
66 unsigned int delay = dev->d3hot_delay; in pci_dev_d3_sleep()
91 * pci=hpmmiosize=nnM overrides non-prefetchable MMIO size,
102 /* PCIe MPS/MRRS strategy; can be overridden by kernel command-line param */
119 * measured in 32-bit words, not bytes.
164 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children
175 max = bus->busn_res.end; in pci_bus_max_busnr()
176 list_for_each_entry(tmp, &bus->children, node) { in pci_bus_max_busnr()
186 * pci_status_get_and_clear_errors - return and clear error bits in PCI_STATUS
198 return -EIO; in pci_status_get_and_clear_errors()
211 struct resource *res = &pdev->resource[bar]; in pci_ioremap_bar()
216 if (res->flags & IORESOURCE_UNSET || !(res->flags & IORESOURCE_MEM)) { in pci_ioremap_bar()
220 return ioremap(res->start, resource_size(res)); in pci_ioremap_bar()
240 * pci_dev_str_match_path - test if a path string matches a device
251 * A path for a device can be obtained using 'lspci -t'. Using a path
268 wpath = kmemdup_nul(path, *endptr - path, GFP_KERNEL); in pci_dev_str_match_path()
270 return -ENOMEM; in pci_dev_str_match_path()
278 ret = -EINVAL; in pci_dev_str_match_path()
282 if (dev->devfn != PCI_DEVFN(slot, func)) { in pci_dev_str_match_path()
308 ret = -EINVAL; in pci_dev_str_match_path()
313 ret = (seg == pci_domain_nr(dev->bus) && in pci_dev_str_match_path()
314 bus == dev->bus->number && in pci_dev_str_match_path()
315 dev->devfn == PCI_DEVFN(slot, func)); in pci_dev_str_match_path()
323 * pci_dev_str_match - test if a string matches a device
340 * through the use of 'lspci -t'.
345 * in-kernel code that uses PCI_ANY_ID which is ~0; this is for
367 return -EINVAL; in pci_dev_str_match()
375 if ((!vendor || vendor == dev->vendor) && in pci_dev_str_match()
376 (!device || device == dev->device) && in pci_dev_str_match()
378 subsystem_vendor == dev->subsystem_vendor) && in pci_dev_str_match()
380 subsystem_device == dev->subsystem_device)) in pci_dev_str_match()
410 while ((*ttl)--) { in __pci_find_next_cap_ttl()
436 return __pci_find_next_cap(dev->bus, dev->devfn, in pci_find_next_capability()
462 * pci_find_capability - query for devices' capabilities
477 * %PCI_CAP_ID_PCIX PCI-X
484 pos = __pci_bus_find_cap_start(dev->bus, dev->devfn, dev->hdr_type); in pci_find_capability()
486 pos = __pci_find_next_cap(dev->bus, dev->devfn, pos, cap); in pci_find_capability()
493 * pci_bus_find_capability - query for devices' capabilities
521 * pci_find_next_ext_capability - Find an extended capability
529 * vendor-specific capability, and this provides a way to find them all.
538 ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8; in pci_find_next_ext_capability()
540 if (dev->cfg_size <= PCI_CFG_SPACE_SIZE) in pci_find_next_ext_capability()
556 while (ttl-- > 0) { in pci_find_next_ext_capability()
573 * pci_find_ext_capability - Find an extended capability
593 * pci_get_dsn - Read and return the 8-byte Device Serial Number
636 pos = __pci_find_next_cap_ttl(dev->bus, dev->devfn, pos, in __pci_find_next_ht_cap()
646 pos = __pci_find_next_cap_ttl(dev->bus, dev->devfn, in __pci_find_next_ht_cap()
654 * pci_find_next_ht_capability - query a device's Hypertransport capabilities
673 * pci_find_ht_capability - query a device's Hypertransport capabilities
687 pos = __pci_bus_find_cap_start(dev->bus, dev->devfn, dev->hdr_type); in pci_find_ht_capability()
696 * pci_find_parent_resource - return resource region of parent bus of given
707 const struct pci_bus *bus = dev->bus; in pci_find_parent_resource()
720 if (r->flags & IORESOURCE_PREFETCH && in pci_find_parent_resource()
721 !(res->flags & IORESOURCE_PREFETCH)) in pci_find_parent_resource()
726 * be both a positively-decoded aperture and a in pci_find_parent_resource()
727 * subtractively-decoded region that contain the BAR. in pci_find_parent_resource()
728 * We want the positively-decoded one, so this depends in pci_find_parent_resource()
740 * pci_find_resource - Return matching PCI device resource
753 struct resource *r = &dev->resource[i]; in pci_find_resource()
755 if (r->start && resource_contains(r, res)) in pci_find_resource()
764 * pci_wait_for_pending - wait for @mask bit(s) to clear in status word @pos
779 msleep((1 << (i - 1)) * 100); in pci_wait_for_pending()
792 * pci_request_acs - ask for ACS to be enabled if supported
802 * pci_disable_acs_redir - disable ACS redirect capabilities
843 pos = dev->acs_cap; in pci_disable_acs_redir()
860 * pci_std_enable_acs - enable ACS on devices using standard ACS capabilities
869 pos = dev->acs_cap; in pci_std_enable_acs()
889 if (dev->external_facing || dev->untrusted) in pci_std_enable_acs()
896 * pci_enable_acs - enable ACS if hardware support it
921 * pci_restore_bars - restore a device's BAR values (e.g. after wake-up)
939 if (!ops->is_manageable || !ops->set_state || !ops->get_state || in pci_set_platform_pm()
940 !ops->choose_state || !ops->set_wakeup || !ops->need_resume) in pci_set_platform_pm()
941 return -EINVAL; in pci_set_platform_pm()
948 return pci_platform_pm ? pci_platform_pm->is_manageable(dev) : false; in platform_pci_power_manageable()
954 return pci_platform_pm ? pci_platform_pm->set_state(dev, t) : -ENOSYS; in platform_pci_set_power_state()
959 return pci_platform_pm ? pci_platform_pm->get_state(dev) : PCI_UNKNOWN; in platform_pci_get_power_state()
964 if (pci_platform_pm && pci_platform_pm->refresh_state) in platform_pci_refresh_power_state()
965 pci_platform_pm->refresh_state(dev); in platform_pci_refresh_power_state()
971 pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR; in platform_pci_choose_state()
977 pci_platform_pm->set_wakeup(dev, enable) : -ENODEV; in platform_pci_set_wakeup()
982 return pci_platform_pm ? pci_platform_pm->need_resume(dev) : false; in platform_pci_need_resume()
987 if (pci_platform_pm && pci_platform_pm->bridge_d3) in platform_pci_bridge_d3()
988 return pci_platform_pm->bridge_d3(dev); in platform_pci_bridge_d3()
993 * pci_raw_set_power_state - Use PCI PM registers to set the power state of
996 * @state: PCI power state (D0, D1, D2, D3hot) to put the device into.
999 * -EINVAL if the requested state is invalid.
1000 * -EIO if device does not support PCI PM or its PM capabilities register has a
1001 * wrong version, or device doesn't support the requested state.
1002 * 0 if device already is in the requested state.
1003 * 0 if device's power state has been successfully changed.
1005 static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) in pci_raw_set_power_state() argument
1011 if (dev->current_state == state) in pci_raw_set_power_state()
1014 if (!dev->pm_cap) in pci_raw_set_power_state()
1015 return -EIO; in pci_raw_set_power_state()
1017 if (state < PCI_D0 || state > PCI_D3hot) in pci_raw_set_power_state()
1018 return -EINVAL; in pci_raw_set_power_state()
1021 * Validate transition: We can enter D0 from any state, but if in pci_raw_set_power_state()
1022 * we're already in a low-power state, we can only go deeper. E.g., in pci_raw_set_power_state()
1026 if (state != PCI_D0 && dev->current_state <= PCI_D3cold in pci_raw_set_power_state()
1027 && dev->current_state > state) { in pci_raw_set_power_state()
1029 pci_power_name(dev->current_state), in pci_raw_set_power_state()
1030 pci_power_name(state)); in pci_raw_set_power_state()
1031 return -EINVAL; in pci_raw_set_power_state()
1034 /* Check if this device supports the desired state */ in pci_raw_set_power_state()
1035 if ((state == PCI_D1 && !dev->d1_support) in pci_raw_set_power_state()
1036 || (state == PCI_D2 && !dev->d2_support)) in pci_raw_set_power_state()
1037 return -EIO; in pci_raw_set_power_state()
1039 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); in pci_raw_set_power_state()
1041 pci_err(dev, "can't change power state from %s to %s (config space inaccessible)\n", in pci_raw_set_power_state()
1042 pci_power_name(dev->current_state), in pci_raw_set_power_state()
1043 pci_power_name(state)); in pci_raw_set_power_state()
1044 return -EIO; in pci_raw_set_power_state()
1052 switch (dev->current_state) { in pci_raw_set_power_state()
1057 pmcsr |= state; in pci_raw_set_power_state()
1061 case PCI_UNKNOWN: /* Boot-up */ in pci_raw_set_power_state()
1071 /* Enter specified state */ in pci_raw_set_power_state()
1072 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); in pci_raw_set_power_state()
1078 if (state == PCI_D3hot || dev->current_state == PCI_D3hot) in pci_raw_set_power_state()
1080 else if (state == PCI_D2 || dev->current_state == PCI_D2) in pci_raw_set_power_state()
1083 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); in pci_raw_set_power_state()
1084 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); in pci_raw_set_power_state()
1085 if (dev->current_state != state) in pci_raw_set_power_state()
1086 pci_info_ratelimited(dev, "refused to change power state from %s to %s\n", in pci_raw_set_power_state()
1087 pci_power_name(dev->current_state), in pci_raw_set_power_state()
1088 pci_power_name(state)); in pci_raw_set_power_state()
1099 * devices in a D3hot state at boot. Consequently, we need to in pci_raw_set_power_state()
1106 if (dev->bus->self) in pci_raw_set_power_state()
1107 pcie_aspm_pm_state_change(dev->bus->self); in pci_raw_set_power_state()
1113 * pci_update_current_state - Read power state of given device and cache it
1115 * @state: State to cache in case the device doesn't have the PM capability
1117 * The power state is read from the PMCSR register, which however is
1120 * reports an incorrect state or the device isn't power manageable by the
1124 void pci_update_current_state(struct pci_dev *dev, pci_power_t state) in pci_update_current_state() argument
1128 dev->current_state = PCI_D3cold; in pci_update_current_state()
1129 } else if (dev->pm_cap) { in pci_update_current_state()
1132 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); in pci_update_current_state()
1133 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); in pci_update_current_state()
1135 dev->current_state = state; in pci_update_current_state()
1140 * pci_refresh_power_state - Refresh the given device's power state data
1143 * Ask the platform to refresh the devices power state information and invoke
1144 * pci_update_current_state() to update its current PCI power state.
1151 pci_update_current_state(dev, dev->current_state); in pci_refresh_power_state()
1155 * pci_platform_power_transition - Use platform to change device power state
1157 * @state: State to put the device into.
1159 int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state) in pci_platform_power_transition() argument
1164 error = platform_pci_set_power_state(dev, state); in pci_platform_power_transition()
1166 pci_update_current_state(dev, state); in pci_platform_power_transition()
1168 error = -ENODEV; in pci_platform_power_transition()
1170 if (error && !dev->pm_cap) /* Fall back to PCI_D0 */ in pci_platform_power_transition()
1171 dev->current_state = PCI_D0; in pci_platform_power_transition()
1178 * pci_wakeup - Wake up a PCI device
1185 pm_request_resume(&pci_dev->dev); in pci_wakeup()
1190 * pci_wakeup_bus - Walk given bus and wake up devices on it
1212 * Wait for the device to return a non-CRS completion. Read the in pci_dev_wait()
1220 delay - 1, reset_type); in pci_dev_wait()
1221 return -ENOTTY; in pci_dev_wait()
1226 delay - 1, reset_type); in pci_dev_wait()
1234 pci_info(dev, "ready %dms after %s\n", delay - 1, in pci_dev_wait()
1241 * pci_power_up - Put the given device into D0
1253 if (dev->runtime_d3cold) { in pci_power_up()
1256 * may be powered on into D0uninitialized state, resume them to in pci_power_up()
1259 pci_wakeup_bus(dev->subordinate); in pci_power_up()
1266 * __pci_dev_set_current_state - Set current state of a PCI device
1268 * @data: pointer to state to be set
1272 pci_power_t state = *(pci_power_t *)data; in __pci_dev_set_current_state() local
1274 dev->current_state = state; in __pci_dev_set_current_state()
1279 * pci_bus_set_current_state - Walk given bus and set current state of devices
1281 * @state: state to be set
1283 void pci_bus_set_current_state(struct pci_bus *bus, pci_power_t state) in pci_bus_set_current_state() argument
1286 pci_walk_bus(bus, __pci_dev_set_current_state, &state); in pci_bus_set_current_state()
1290 * pci_set_power_state - Set the power state of a PCI device
1292 * @state: PCI power state (D0, D1, D2, D3hot) to put the device into.
1294 * Transition a device to a new power state, using the platform firmware and/or
1298 * -EINVAL if the requested state is invalid.
1299 * -EIO if device does not support PCI PM or its PM capabilities register has a
1300 * wrong version, or device doesn't support the requested state.
1302 * 0 if device already is in the requested state.
1304 * 0 if device's power state has been successfully changed.
1306 int pci_set_power_state(struct pci_dev *dev, pci_power_t state) in pci_set_power_state() argument
1310 /* Bound the state we're entering */ in pci_set_power_state()
1311 if (state > PCI_D3cold) in pci_set_power_state()
1312 state = PCI_D3cold; in pci_set_power_state()
1313 else if (state < PCI_D0) in pci_set_power_state()
1314 state = PCI_D0; in pci_set_power_state()
1315 else if ((state == PCI_D1 || state == PCI_D2) && pci_no_d1d2(dev)) in pci_set_power_state()
1326 if (dev->current_state == state) in pci_set_power_state()
1329 if (state == PCI_D0) in pci_set_power_state()
1336 if (state >= PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3)) in pci_set_power_state()
1343 error = pci_raw_set_power_state(dev, state > PCI_D3hot ? in pci_set_power_state()
1344 PCI_D3hot : state); in pci_set_power_state()
1346 if (pci_platform_power_transition(dev, state)) in pci_set_power_state()
1350 if (state == PCI_D3cold) in pci_set_power_state()
1351 pci_bus_set_current_state(dev->subordinate, PCI_D3cold); in pci_set_power_state()
1358 * pci_choose_state - Choose the power state of a PCI device
1359 * @dev: PCI device to be suspended
1360 * @state: target sleep state for the whole system. This is the value
1363 * Returns PCI power state suitable for given device and given system
1366 pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) in pci_choose_state() argument
1370 if (!dev->pm_cap) in pci_choose_state()
1377 switch (state.event) { in pci_choose_state()
1382 /* REVISIT both freeze and pre-thaw "should" use D0 */ in pci_choose_state()
1388 state.event); in pci_choose_state()
1402 hlist_for_each_entry(tmp, &pci_dev->saved_cap_space, next) { in _pci_find_saved_cap()
1403 if (tmp->cap.cap_extended == extended && tmp->cap.cap_nr == cap) in _pci_find_saved_cap()
1431 return -ENOMEM; in pci_save_pcie_state()
1434 cap = (u16 *)&save_state->cap.data[0]; in pci_save_pcie_state()
1456 cap = (u16 *)&save_state->cap.data[0]; in pci_restore_pcie_state()
1478 return -ENOMEM; in pci_save_pcix_state()
1482 (u16 *)save_state->cap.data); in pci_save_pcix_state()
1497 cap = (u16 *)&save_state->cap.data[0]; in pci_restore_pcix_state()
1521 cap = (u16 *)&save_state->cap.data[0]; in pci_save_ltr_state()
1537 cap = (u16 *)&save_state->cap.data[0]; in pci_restore_ltr_state()
1543 * pci_save_state - save the PCI configuration space of a device before
1552 pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]); in pci_save_state()
1554 i * 4, dev->saved_config_space[i]); in pci_save_state()
1556 dev->state_saved = true; in pci_save_state()
1586 if (retry-- <= 0) in pci_restore_config_dword()
1603 for (index = end; index >= start; index--) in pci_restore_config_space_range()
1605 pdev->saved_config_space[index], in pci_restore_config_space_range()
1611 if (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL) { in pci_restore_config_space()
1616 } else if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { in pci_restore_config_space()
1650 res = pdev->resource + bar_idx; in pci_restore_rebar_state()
1651 size = ilog2(resource_size(res)) - 20; in pci_restore_rebar_state()
1659 * pci_restore_state - Restore the saved state of a PCI device
1664 if (!dev->state_saved) in pci_restore_state()
1689 /* Restore ACS and IOV configuration state */ in pci_restore_state()
1693 dev->state_saved = false; in pci_restore_state()
1703 * pci_store_saved_state - Allocate and return an opaque struct containing
1704 * the device saved state.
1707 * Return NULL if no state or error.
1711 struct pci_saved_state *state; in pci_store_saved_state() local
1716 if (!dev->state_saved) in pci_store_saved_state()
1719 size = sizeof(*state) + sizeof(struct pci_cap_saved_data); in pci_store_saved_state()
1721 hlist_for_each_entry(tmp, &dev->saved_cap_space, next) in pci_store_saved_state()
1722 size += sizeof(struct pci_cap_saved_data) + tmp->cap.size; in pci_store_saved_state()
1724 state = kzalloc(size, GFP_KERNEL); in pci_store_saved_state()
1725 if (!state) in pci_store_saved_state()
1728 memcpy(state->config_space, dev->saved_config_space, in pci_store_saved_state()
1729 sizeof(state->config_space)); in pci_store_saved_state()
1731 cap = state->cap; in pci_store_saved_state()
1732 hlist_for_each_entry(tmp, &dev->saved_cap_space, next) { in pci_store_saved_state()
1733 size_t len = sizeof(struct pci_cap_saved_data) + tmp->cap.size; in pci_store_saved_state()
1734 memcpy(cap, &tmp->cap, len); in pci_store_saved_state()
1739 return state; in pci_store_saved_state()
1744 * pci_load_saved_state - Reload the provided save state into struct pci_dev.
1746 * @state: Saved state returned from pci_store_saved_state()
1749 struct pci_saved_state *state) in pci_load_saved_state() argument
1753 dev->state_saved = false; in pci_load_saved_state()
1755 if (!state) in pci_load_saved_state()
1758 memcpy(dev->saved_config_space, state->config_space, in pci_load_saved_state()
1759 sizeof(state->config_space)); in pci_load_saved_state()
1761 cap = state->cap; in pci_load_saved_state()
1762 while (cap->size) { in pci_load_saved_state()
1765 tmp = _pci_find_saved_cap(dev, cap->cap_nr, cap->cap_extended); in pci_load_saved_state()
1766 if (!tmp || tmp->cap.size != cap->size) in pci_load_saved_state()
1767 return -EINVAL; in pci_load_saved_state()
1769 memcpy(tmp->cap.data, cap->data, tmp->cap.size); in pci_load_saved_state()
1771 sizeof(struct pci_cap_saved_data) + cap->size); in pci_load_saved_state()
1774 dev->state_saved = true; in pci_load_saved_state()
1780 * pci_load_and_free_saved_state - Reload the save state pointed to by state,
1783 * @state: Pointer to saved state returned from pci_store_saved_state()
1786 struct pci_saved_state **state) in pci_load_and_free_saved_state() argument
1788 int ret = pci_load_saved_state(dev, *state); in pci_load_and_free_saved_state()
1789 kfree(*state); in pci_load_and_free_saved_state()
1790 *state = NULL; in pci_load_and_free_saved_state()
1808 if (err < 0 && err != -EIO) in do_pci_enable_device()
1820 if (dev->msi_enabled || dev->msix_enabled) in do_pci_enable_device()
1835 * pci_reenable_device - Resume abandoned device
1844 return do_pci_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1); in pci_reenable_device()
1859 if (!dev->is_busmaster) in pci_enable_bridge()
1878 * Power state could be unknown at this point, either due to a fresh in pci_enable_device_flags()
1879 * boot or a device removal call. So get the current power state in pci_enable_device_flags()
1883 if (dev->pm_cap) { in pci_enable_device_flags()
1885 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); in pci_enable_device_flags()
1886 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); in pci_enable_device_flags()
1889 if (atomic_inc_return(&dev->enable_cnt) > 1) in pci_enable_device_flags()
1898 if (dev->resource[i].flags & flags) in pci_enable_device_flags()
1901 if (dev->resource[i].flags & flags) in pci_enable_device_flags()
1906 atomic_dec(&dev->enable_cnt); in pci_enable_device_flags()
1911 * pci_enable_device_io - Initialize a device for use with IO space
1914 * Initialize device before it's used by a driver. Ask low-level code
1915 * to enable I/O resources. Wake up the device if it was suspended.
1925 * pci_enable_device_mem - Initialize a device for use with Memory space
1928 * Initialize device before it's used by a driver. Ask low-level code
1929 * to enable Memory resources. Wake up the device if it was suspended.
1939 * pci_enable_device - Initialize device before it's used by a driver.
1942 * Initialize device before it's used by a driver. Ask low-level code
1943 * to enable I/O and memory. Wake up the device if it was suspended.
1956 * Managed PCI resources. This manages device on/off, INTx/MSI/MSI-X
1957 * on/off and BAR regions. pci_dev itself records MSI/MSI-X status, so
1976 if (dev->msi_enabled) in pcim_release()
1978 if (dev->msix_enabled) in pcim_release()
1982 if (this->region_mask & (1 << i)) in pcim_release()
1985 if (this->mwi) in pcim_release()
1988 if (this->restore_intx) in pcim_release()
1989 pci_intx(dev, this->orig_intx); in pcim_release()
1991 if (this->enabled && !this->pinned) in pcim_release()
1999 dr = devres_find(&pdev->dev, pcim_release, NULL, NULL); in get_pci_dr()
2006 return devres_get(&pdev->dev, new_dr, NULL, NULL); in get_pci_dr()
2012 return devres_find(&pdev->dev, pcim_release, NULL, NULL); in find_pci_dr()
2017 * pcim_enable_device - Managed pci_enable_device()
2029 return -ENOMEM; in pcim_enable_device()
2030 if (dr->enabled) in pcim_enable_device()
2035 pdev->is_managed = 1; in pcim_enable_device()
2036 dr->enabled = 1; in pcim_enable_device()
2043 * pcim_pin_device - Pin managed PCI device
2055 WARN_ON(!dr || !dr->enabled); in pcim_pin_device()
2057 dr->pinned = 1; in pcim_pin_device()
2062 * pcibios_add_device - provide arch specific hooks when adding device dev
2075 * pcibios_release_device - provide arch specific hooks when releasing
2086 * pcibios_disable_device - disable arch specific PCI resources for device dev
2096 * pcibios_penalize_isa_irq - penalize an ISA IRQ
2100 * Permits the platform to provide architecture-specific functionality when
2120 * pci_disable_enabled_device - Disable device without updating enable_cnt
2133 * pci_disable_device - Disable PCI device after use
2137 * anymore. This only involves disabling PCI bus-mastering, if active.
2148 dr->enabled = 0; in pci_disable_device()
2150 dev_WARN_ONCE(&dev->dev, atomic_read(&dev->enable_cnt) <= 0, in pci_disable_device()
2151 "disabling already-disabled device"); in pci_disable_device()
2153 if (atomic_dec_return(&dev->enable_cnt) != 0) in pci_disable_device()
2158 dev->is_busmaster = 0; in pci_disable_device()
2163 * pcibios_set_pcie_reset_state - set reset state for device dev
2165 * @state: Reset state to enter into
2167 * Set the PCIe reset state for the device. This is the default
2171 enum pcie_reset_state state) in pcibios_set_pcie_reset_state() argument
2173 return -EINVAL; in pcibios_set_pcie_reset_state()
2177 * pci_set_pcie_reset_state - set reset state for device dev
2179 * @state: Reset state to enter into
2181 * Sets the PCI reset state for the device.
2183 int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state) in pci_set_pcie_reset_state() argument
2185 return pcibios_set_pcie_reset_state(dev, state); in pci_set_pcie_reset_state()
2198 * pcie_clear_root_pme_status - Clear root port PME interrupt status.
2207 * pci_check_pme_status - Check if given device has generated PME.
2220 if (!dev->pm_cap) in pci_check_pme_status()
2223 pmcsr_pos = dev->pm_cap + PCI_PM_CTRL; in pci_check_pme_status()
2242 * pci_pme_wakeup - Wake up a PCI device if its PME Status bit is set.
2251 if (pme_poll_reset && dev->pme_poll) in pci_pme_wakeup()
2252 dev->pme_poll = false; in pci_pme_wakeup()
2256 pm_request_resume(&dev->dev); in pci_pme_wakeup()
2262 * pci_pme_wakeup_bus - Walk given bus and wake up devices on it, if necessary.
2273 * pci_pme_capable - check the capability of PCI device to generate PME#
2275 * @state: PCI state from which device will issue PME#.
2277 bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) in pci_pme_capable() argument
2279 if (!dev->pm_cap) in pci_pme_capable()
2282 return !!(dev->pme_support & (1 << state)); in pci_pme_capable()
2292 if (pme_dev->dev->pme_poll) { in pci_pme_list_scan()
2295 bridge = pme_dev->dev->bus->self; in pci_pme_list_scan()
2297 * If bridge is in low power state, the in pci_pme_list_scan()
2301 if (bridge && bridge->current_state != PCI_D0) in pci_pme_list_scan()
2307 if (pme_dev->dev->current_state == PCI_D3cold) in pci_pme_list_scan()
2310 pci_pme_wakeup(pme_dev->dev, NULL); in pci_pme_list_scan()
2312 list_del(&pme_dev->list); in pci_pme_list_scan()
2326 if (!dev->pme_support) in __pci_pme_active()
2329 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); in __pci_pme_active()
2335 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); in __pci_pme_active()
2339 * pci_pme_restore - Restore PME configuration after config space restore.
2346 if (!dev->pme_support) in pci_pme_restore()
2349 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); in pci_pme_restore()
2350 if (dev->wakeup_prepared) { in pci_pme_restore()
2357 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); in pci_pme_restore()
2361 * pci_pme_active - enable or disable PCI device's PME# function
2377 * periodically walk the list of suspended devices and check in pci_pme_active()
2383 * Although PCIe uses in-band PME message instead of PME# line in pci_pme_active()
2392 if (dev->pme_poll) { in pci_pme_active()
2401 pme_dev->dev = dev; in pci_pme_active()
2403 list_add(&pme_dev->list, &pci_pme_list); in pci_pme_active()
2412 if (pme_dev->dev == dev) { in pci_pme_active()
2413 list_del(&pme_dev->list); in pci_pme_active()
2427 * __pci_enable_wake - enable PCI device as wakeup event source
2429 * @state: PCI state from which device will issue wakeup events
2433 * When such events involves platform-specific hooks, those hooks are
2441 * -EINVAL is returned if device is not supposed to wake up the system
2443 * the native mechanism fail to enable the generation of wake-up events
2445 static int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) in __pci_enable_wake() argument
2450 * Bridges that are not power-manageable directly only signal in __pci_enable_wake()
2453 * power-manageable may signal wakeup for themselves (for example, in __pci_enable_wake()
2460 if (!!enable == !!dev->wakeup_prepared) in __pci_enable_wake()
2466 * enable. To disable wake-up we call the platform first, for symmetry. in __pci_enable_wake()
2472 if (pci_pme_capable(dev, state)) in __pci_enable_wake()
2480 dev->wakeup_prepared = true; in __pci_enable_wake()
2484 dev->wakeup_prepared = false; in __pci_enable_wake()
2491 * pci_enable_wake - change wakeup settings for a PCI device
2493 * @state: PCI state from which device will issue wakeup events
2499 int pci_enable_wake(struct pci_dev *pci_dev, pci_power_t state, bool enable) in pci_enable_wake() argument
2501 if (enable && !device_may_wakeup(&pci_dev->dev)) in pci_enable_wake()
2502 return -EINVAL; in pci_enable_wake()
2504 return __pci_enable_wake(pci_dev, state, enable); in pci_enable_wake()
2509 * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold
2511 * @enable: True to enable wake-up event generation; false to disable
2514 * and this function allows them to set that up cleanly - pci_enable_wake()
2515 * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI
2520 * D3_hot and D3_cold and the platform is unable to enable wake-up power for it.
2531 * pci_target_state - find an appropriate low power state for a given PCI dev
2535 * Use underlying platform code to find a supported low power state for @dev.
2536 * If the platform can't manage @dev, return the deepest state from which it
2545 * Call the platform to find the target state for the device. in pci_target_state()
2547 pci_power_t state = platform_pci_choose_state(dev); in pci_target_state() local
2549 switch (state) { in pci_target_state()
2559 target_state = state; in pci_target_state()
2565 if (!dev->pm_cap) in pci_target_state()
2569 * If the device is in D3cold even though it's not power-manageable by in pci_target_state()
2570 * the platform, it may have been powered down by non-standard means. in pci_target_state()
2573 if (dev->current_state == PCI_D3cold) in pci_target_state()
2578 * Find the deepest state from which the device can generate in pci_target_state()
2581 if (dev->pme_support) { in pci_target_state()
2583 && !(dev->pme_support & (1 << target_state))) in pci_target_state()
2584 target_state--; in pci_target_state()
2592 * pci_prepare_to_sleep - prepare PCI device for system-wide transition
2593 * into a sleep state
2596 * Choose the power state appropriate for the device depending on whether
2598 * (PCI_D3hot is the default) and put the device into that state.
2602 bool wakeup = device_may_wakeup(&dev->dev); in pci_prepare_to_sleep()
2607 return -EIO; in pci_prepare_to_sleep()
2621 * pci_back_from_sleep - turn PCI device on during system-wide transition
2622 * into working state
2625 * Disable device's system wake-up capability and put it into D0.
2635 * pci_finish_runtime_suspend - Carry out PCI-specific part of runtime suspend.
2636 * @dev: PCI device being suspended.
2638 * Prepare @dev to generate wake-up events at run time and put it into a low
2639 * power state.
2646 target_state = pci_target_state(dev, device_can_wakeup(&dev->dev)); in pci_finish_runtime_suspend()
2648 return -EIO; in pci_finish_runtime_suspend()
2650 dev->runtime_d3cold = target_state == PCI_D3cold; in pci_finish_runtime_suspend()
2658 dev->runtime_d3cold = false; in pci_finish_runtime_suspend()
2665 * pci_dev_run_wake - Check if device can generate run-time wake-up events.
2668 * Return true if the device itself is capable of generating wake-up events
2670 * PME and one of its upstream bridges can generate wake-up events.
2674 struct pci_bus *bus = dev->bus; in pci_dev_run_wake()
2676 if (!dev->pme_support) in pci_dev_run_wake()
2679 /* PME-capable in principle, but not from the target power state */ in pci_dev_run_wake()
2683 if (device_can_wakeup(&dev->dev)) in pci_dev_run_wake()
2686 while (bus->parent) { in pci_dev_run_wake()
2687 struct pci_dev *bridge = bus->self; in pci_dev_run_wake()
2689 if (device_can_wakeup(&bridge->dev)) in pci_dev_run_wake()
2692 bus = bus->parent; in pci_dev_run_wake()
2696 if (bus->bridge) in pci_dev_run_wake()
2697 return device_can_wakeup(bus->bridge); in pci_dev_run_wake()
2704 * pci_dev_need_resume - Check if it is necessary to resume the device.
2707 * Return 'true' if the device is not runtime-suspended or it has to be
2709 * suspend, or the current power state of it is not suitable for the upcoming
2710 * (system-wide) transition.
2714 struct device *dev = &pci_dev->dev; in pci_dev_need_resume()
2727 return target_state != pci_dev->current_state && in pci_dev_need_resume()
2729 pci_dev->current_state != PCI_D3hot; in pci_dev_need_resume()
2733 * pci_dev_adjust_pme - Adjust PME setting for a suspended device.
2736 * If the device is suspended and it is not configured for system wakeup,
2739 * Note that if the device's power state is D3cold and the platform check in
2745 struct device *dev = &pci_dev->dev; in pci_dev_adjust_pme()
2747 spin_lock_irq(&dev->power.lock); in pci_dev_adjust_pme()
2750 pci_dev->current_state < PCI_D3cold) in pci_dev_adjust_pme()
2753 spin_unlock_irq(&dev->power.lock); in pci_dev_adjust_pme()
2757 * pci_dev_complete_resume - Finalize resume from system sleep for a device.
2760 * If the device is runtime suspended and wakeup-capable, enable PME for it as
2766 struct device *dev = &pci_dev->dev; in pci_dev_complete_resume()
2771 spin_lock_irq(&dev->power.lock); in pci_dev_complete_resume()
2773 if (pm_runtime_suspended(dev) && pci_dev->current_state < PCI_D3cold) in pci_dev_complete_resume()
2776 spin_unlock_irq(&dev->power.lock); in pci_dev_complete_resume()
2781 struct device *dev = &pdev->dev; in pci_config_pm_runtime_get()
2782 struct device *parent = dev->parent; in pci_config_pm_runtime_get()
2788 * pdev->current_state is set to PCI_D3cold during suspending, in pci_config_pm_runtime_get()
2794 * registers are still accessible for devices suspended but in pci_config_pm_runtime_get()
2797 if (pdev->current_state == PCI_D3cold) in pci_config_pm_runtime_get()
2803 struct device *dev = &pdev->dev; in pci_config_pm_runtime_put()
2804 struct device *parent = dev->parent; in pci_config_pm_runtime_put()
2820 .ident = "X299 DESIGNARE EX-CF",
2823 DMI_MATCH(DMI_BOARD_NAME, "X299 DESIGNARE EX-CF"),
2831 * pci_bridge_d3_possible - Is it possible to put the bridge into D3
2851 * may not be put into D3 by the OS (Thunderbolt on non-Macs). in pci_bridge_d3_possible()
2853 if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge)) in pci_bridge_d3_possible()
2860 if (bridge->is_thunderbolt) in pci_bridge_d3_possible()
2872 if (bridge->is_hotplug_bridge) in pci_bridge_d3_possible()
2895 dev->no_d3cold || !dev->d3cold_allowed || in pci_dev_check_d3cold()
2898 (device_may_wakeup(&dev->dev) && in pci_dev_check_d3cold()
2910 * pci_bridge_d3_update - Update bridge D3 capabilities
2919 bool remove = !device_is_registered(&dev->dev); in pci_bridge_d3_update()
2931 if (remove && bridge->bridge_d3) in pci_bridge_d3_update()
2951 if (d3cold_ok && !bridge->bridge_d3) in pci_bridge_d3_update()
2952 pci_walk_bus(bridge->subordinate, pci_dev_check_d3cold, in pci_bridge_d3_update()
2955 if (bridge->bridge_d3 != d3cold_ok) { in pci_bridge_d3_update()
2956 bridge->bridge_d3 = d3cold_ok; in pci_bridge_d3_update()
2963 * pci_d3cold_enable - Enable D3cold for device
2972 if (dev->no_d3cold) { in pci_d3cold_enable()
2973 dev->no_d3cold = false; in pci_d3cold_enable()
2980 * pci_d3cold_disable - Disable D3cold for device
2989 if (!dev->no_d3cold) { in pci_d3cold_disable()
2990 dev->no_d3cold = true; in pci_d3cold_disable()
2997 * pci_pm_init - Initialize PM functions of given PCI device
3006 pm_runtime_forbid(&dev->dev); in pci_pm_init()
3007 pm_runtime_set_active(&dev->dev); in pci_pm_init()
3008 pm_runtime_enable(&dev->dev); in pci_pm_init()
3009 device_enable_async_suspend(&dev->dev); in pci_pm_init()
3010 dev->wakeup_prepared = false; in pci_pm_init()
3012 dev->pm_cap = 0; in pci_pm_init()
3013 dev->pme_support = 0; in pci_pm_init()
3028 dev->pm_cap = pm; in pci_pm_init()
3029 dev->d3hot_delay = PCI_PM_D3HOT_WAIT; in pci_pm_init()
3030 dev->d3cold_delay = PCI_PM_D3COLD_WAIT; in pci_pm_init()
3031 dev->bridge_d3 = pci_bridge_d3_possible(dev); in pci_pm_init()
3032 dev->d3cold_allowed = true; in pci_pm_init()
3034 dev->d1_support = false; in pci_pm_init()
3035 dev->d2_support = false; in pci_pm_init()
3038 dev->d1_support = true; in pci_pm_init()
3040 dev->d2_support = true; in pci_pm_init()
3042 if (dev->d1_support || dev->d2_support) in pci_pm_init()
3044 dev->d1_support ? " D1" : "", in pci_pm_init()
3045 dev->d2_support ? " D2" : ""); in pci_pm_init()
3056 dev->pme_support = pmc >> PCI_PM_CAP_PME_SHIFT; in pci_pm_init()
3057 dev->pme_poll = true; in pci_pm_init()
3059 * Make device's PM flags reflect the wake-up capability, but in pci_pm_init()
3062 device_set_wakeup_capable(&dev->dev, true); in pci_pm_init()
3069 dev->imm_ready = 1; in pci_pm_init()
3099 return &dev->resource[bei]; in pci_ea_get_resource()
3103 return &dev->resource[PCI_IOV_RESOURCES + in pci_ea_get_resource()
3104 bei - PCI_EA_BEI_VF_BAR0]; in pci_ea_get_resource()
3107 return &dev->resource[PCI_ROM_RESOURCE]; in pci_ea_get_resource()
3165 /* Read Base MSBs (if 64-bit entry) */ in pci_ea_read()
3174 /* entry starts above 32-bit boundary, can't use */ in pci_ea_read()
3184 /* Read MaxOffset MSBs (if 64-bit entry) */ in pci_ea_read()
3206 if (ent_size != ent_offset - offset) { in pci_ea_read()
3208 ent_size, ent_offset - offset); in pci_ea_read()
3212 res->name = pci_name(dev); in pci_ea_read()
3213 res->start = start; in pci_ea_read()
3214 res->end = end; in pci_ea_read()
3215 res->flags = flags; in pci_ea_read()
3225 bei - PCI_EA_BEI_VF_BAR0, res, prop); in pci_ea_read()
3248 pci_bus_read_config_byte(dev->bus, dev->devfn, ea + PCI_EA_NUM_ENT, in pci_ea_init()
3255 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) in pci_ea_init()
3266 hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); in pci_add_saved_cap()
3270 * _pci_add_cap_save_buffer - allocate buffer for saving given
3293 return -ENOMEM; in _pci_add_cap_save_buffer()
3295 save_state->cap.cap_nr = cap; in _pci_add_cap_save_buffer()
3296 save_state->cap.cap_extended = extended; in _pci_add_cap_save_buffer()
3297 save_state->cap.size = size; in _pci_add_cap_save_buffer()
3314 * pci_allocate_cap_save_buffers - allocate buffers for saving capabilities
3328 pci_err(dev, "unable to preallocate PCI-X save buffer\n"); in pci_allocate_cap_save_buffers()
3343 hlist_for_each_entry_safe(tmp, n, &dev->saved_cap_space, next) in pci_free_cap_save_buffers()
3348 * pci_configure_ari - enable or disable ARI forwarding
3359 if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) in pci_configure_ari()
3362 bridge = dev->bus->self; in pci_configure_ari()
3373 bridge->ari_enabled = 1; in pci_configure_ari()
3377 bridge->ari_enabled = 0; in pci_configure_ari()
3386 pos = pdev->acs_cap; in pci_acs_flags_enabled()
3393 * capability field can therefore be assumed as hard-wired enabled. in pci_acs_flags_enabled()
3403 * pci_acs_enabled - test ACS against required flags for a given device
3413 * opportunity for peer-to-peer access. We therefore return 'true'
3427 * Conventional PCI and PCI-X devices never support ACS, either in pci_acs_enabled()
3436 * PCI/X-to-PCIe bridges are not specifically mentioned by the spec, in pci_acs_enabled()
3438 * handle them as we would a non-PCIe device. in pci_acs_enabled()
3452 * implement ACS in order to indicate their peer-to-peer capabilities, in pci_acs_enabled()
3453 * regardless of whether they are single- or multi-function devices. in pci_acs_enabled()
3460 * implemented by the remaining PCIe types to indicate peer-to-peer in pci_acs_enabled()
3469 if (!pdev->multifunction) in pci_acs_enabled()
3483 * pci_acs_path_enable - test ACS flags from start to end in a hierarchy
3502 if (pci_is_root_bus(pdev->bus)) in pci_acs_path_enabled()
3505 parent = pdev->bus->self; in pci_acs_path_enabled()
3512 * pci_acs_init - Initialize ACS if hardware supports it
3517 dev->acs_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); in pci_acs_init()
3529 * pci_rebar_find_pos - find position of resize ctrl reg for BAR
3534 * Returns -ENOTSUPP if resizable BARs are not supported at all.
3535 * Returns -ENOENT if no ctrl register for the BAR could be found.
3544 return -ENOTSUPP; in pci_rebar_find_pos()
3559 return -ENOENT; in pci_rebar_find_pos()
3563 * pci_rebar_get_possible_sizes - get possible sizes for BAR
3584 * pci_rebar_get_current_size - get the current size of a BAR
3605 * pci_rebar_set_size - set a new size for a BAR
3630 * pci_enable_atomic_ops_to_root - enable AtomicOp requests to root port
3639 * the requested completion capabilities (32-bit, 64-bit and/or 128-bit
3644 struct pci_bus *bus = dev->bus; in pci_enable_atomic_ops_to_root()
3649 return -EINVAL; in pci_enable_atomic_ops_to_root()
3655 * completers, and no peer-to-peer. in pci_enable_atomic_ops_to_root()
3664 return -EINVAL; in pci_enable_atomic_ops_to_root()
3667 while (bus->parent) { in pci_enable_atomic_ops_to_root()
3668 bridge = bus->self; in pci_enable_atomic_ops_to_root()
3677 return -EINVAL; in pci_enable_atomic_ops_to_root()
3683 return -EINVAL; in pci_enable_atomic_ops_to_root()
3692 return -EINVAL; in pci_enable_atomic_ops_to_root()
3695 bus = bus->parent; in pci_enable_atomic_ops_to_root()
3705 * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge
3710 * required by section 9.1 of the PCI-to-PCI bridge specification for devices
3711 * behind bridges on add-in cards. For devices with ARI enabled, the slot
3719 if (pci_ari_enabled(dev->bus)) in pci_swizzle_interrupt_pin()
3722 slot = PCI_SLOT(dev->devfn); in pci_swizzle_interrupt_pin()
3724 return (((pin - 1) + slot) % 4) + 1; in pci_swizzle_interrupt_pin()
3731 pin = dev->pin; in pci_get_interrupt_pin()
3733 return -1; in pci_get_interrupt_pin()
3735 while (!pci_is_root_bus(dev->bus)) { in pci_get_interrupt_pin()
3737 dev = dev->bus->self; in pci_get_interrupt_pin()
3744 * pci_common_swizzle - swizzle INTx all the way to root bridge
3748 * Perform INTx swizzling for a device. This traverses through all PCI-to-PCI
3755 while (!pci_is_root_bus(dev->bus)) { in pci_common_swizzle()
3757 dev = dev->bus->self; in pci_common_swizzle()
3760 return PCI_SLOT(dev->devfn); in pci_common_swizzle()
3765 * pci_release_region - Release a PCI bar
3789 dr->region_mask &= ~(1 << bar); in pci_release_region()
3794 * __pci_request_region - Reserved PCI I/O and memory resource
3833 dr->region_mask |= 1 << bar; in __pci_request_region()
3839 &pdev->resource[bar]); in __pci_request_region()
3840 return -EBUSY; in __pci_request_region()
3844 * pci_request_region - Reserve PCI I/O and memory resource
3864 * pci_release_selected_regions - Release selected PCI I/O and memory resources
3893 while (--i >= 0) in __pci_request_selected_regions()
3897 return -EBUSY; in __pci_request_selected_regions()
3902 * pci_request_selected_regions - Reserve selected PCI I/O and memory resources
3923 * pci_release_regions - Release reserved PCI I/O and memory resources
3934 pci_release_selected_regions(pdev, (1 << PCI_STD_NUM_BARS) - 1); in pci_release_regions()
3939 * pci_request_regions - Reserve PCI I/O and memory resources
3954 ((1 << PCI_STD_NUM_BARS) - 1), res_name); in pci_request_regions()
3959 * pci_request_regions_exclusive - Reserve PCI I/O and memory resources
3976 ((1 << PCI_STD_NUM_BARS) - 1), res_name); in pci_request_regions_exclusive()
3992 return -EINVAL; in pci_register_io_range()
3996 return -ENOMEM; in pci_register_io_range()
3998 range->fwnode = fwnode; in pci_register_io_range()
3999 range->size = size; in pci_register_io_range()
4000 range->hw_start = addr; in pci_register_io_range()
4001 range->flags = LOGIC_PIO_CPU_MMIO; in pci_register_io_range()
4031 return (unsigned long)-1; in pci_address_to_pio()
4038 * pci_remap_iospace - Remap the memory mapped I/O space
4050 unsigned long vaddr = (unsigned long)PCI_IOBASE + res->start; in pci_remap_iospace()
4052 if (!(res->flags & IORESOURCE_IO)) in pci_remap_iospace()
4053 return -EINVAL; in pci_remap_iospace()
4055 if (res->end > IO_SPACE_LIMIT) in pci_remap_iospace()
4056 return -EINVAL; in pci_remap_iospace()
4066 return -ENODEV; in pci_remap_iospace()
4072 * pci_unmap_iospace - Unmap the memory mapped I/O space
4082 unsigned long vaddr = (unsigned long)PCI_IOBASE + res->start; in pci_unmap_iospace()
4097 * devm_pci_remap_iospace - Managed pci_remap_iospace()
4113 return -ENOMEM; in devm_pci_remap_iospace()
4128 * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace()
4158 * devm_pci_remap_cfg_resource - check, request region and ioremap cfg resource
4172 * base = devm_pci_remap_cfg_resource(&pdev->dev, res);
4187 return IOMEM_ERR_PTR(-EINVAL); in devm_pci_remap_cfg_resource()
4191 name = res->name ?: dev_name(dev); in devm_pci_remap_cfg_resource()
4193 if (!devm_request_mem_region(dev, res->start, size, name)) { in devm_pci_remap_cfg_resource()
4195 return IOMEM_ERR_PTR(-EBUSY); in devm_pci_remap_cfg_resource()
4198 dest_ptr = devm_pci_remap_cfgspace(dev, res->start, size); in devm_pci_remap_cfg_resource()
4201 devm_release_mem_region(dev, res->start, size); in devm_pci_remap_cfg_resource()
4202 dest_ptr = IOMEM_ERR_PTR(-ENOMEM); in devm_pci_remap_cfg_resource()
4223 dev->is_busmaster = enable; in __pci_set_master()
4227 * pcibios_setup - process "pci=" kernel boot arguments
4239 * pcibios_set_master - enable PCI bus-mastering for device dev
4242 * Enables PCI bus-mastering for the device. This is the default
4266 * pci_set_master - enables bus-mastering for device dev
4269 * Enables bus-mastering on the device and calls pcibios_set_master()
4280 * pci_clear_master - disables bus-mastering for device dev
4290 * pci_set_cacheline_size - ensure the CACHE_LINE_SIZE register is programmed
4295 * Copyright 1998-2001 by Jes Sorensen, <jes@trained-monkey.org>.
4297 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
4304 return -EINVAL; in pci_set_cacheline_size()
4323 return -EINVAL; in pci_set_cacheline_size()
4328 * pci_set_mwi - enables memory-write-invalidate PCI transaction
4331 * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND.
4333 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
4349 pci_dbg(dev, "enabling Mem-Wr-Inval\n"); in pci_set_mwi()
4359 * pcim_set_mwi - a device-managed pci_set_mwi()
4364 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
4372 return -ENOMEM; in pcim_set_mwi()
4374 dr->mwi = 1; in pcim_set_mwi()
4380 * pci_try_set_mwi - enables memory-write-invalidate PCI transaction
4383 * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND.
4386 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
4399 * pci_clear_mwi - disables Memory-Write-Invalidate for device dev
4402 * Disables PCI Memory-Write-Invalidate transaction on the device
4419 * pci_intx - enables/disables PCI INTx for device dev
4442 if (dr && !dr->restore_intx) { in pci_intx()
4443 dr->restore_intx = 1; in pci_intx()
4444 dr->orig_intx = !enable; in pci_intx()
4452 struct pci_bus *bus = dev->bus; in pci_check_and_set_intx_mask()
4468 bus->ops->read(bus, dev->devfn, PCI_COMMAND, 4, &cmd_status_dword); in pci_check_and_set_intx_mask()
4487 bus->ops->write(bus, dev->devfn, PCI_COMMAND, 2, newcmd); in pci_check_and_set_intx_mask()
4496 * pci_check_and_mask_intx - mask INTx on pending interrupt
4509 * pci_check_and_unmask_intx - unmask INTx if no interrupt is pending
4523 * pci_wait_for_pending_transaction - wait for pending transaction
4539 * pcie_has_flr - check if a device supports function level resets
4549 if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET) in pcie_has_flr()
4558 * pcie_flr - initiate a PCIe function level reset
4572 if (dev->imm_ready) in pcie_flr()
4593 return -ENOTTY; in pci_af_flr()
4595 if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET) in pci_af_flr()
4596 return -ENOTTY; in pci_af_flr()
4600 return -ENOTTY; in pci_af_flr()
4606 * Wait for Transaction Pending bit to clear. A word-aligned test in pci_af_flr()
4616 if (dev->imm_ready) in pci_af_flr()
4631 * pci_pm_reset - Put device into PCI_D3 and back into PCI_D0.
4637 * PCI_D0. If that's the case and the device is not in a low-power state
4641 * cooldown period, which for the D0->D3hot and D3hot->D0 transitions is 10 ms
4649 if (!dev->pm_cap || dev->dev_flags & PCI_DEV_FLAGS_NO_PM_RESET) in pci_pm_reset()
4650 return -ENOTTY; in pci_pm_reset()
4652 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &csr); in pci_pm_reset()
4654 return -ENOTTY; in pci_pm_reset()
4659 if (dev->current_state != PCI_D0) in pci_pm_reset()
4660 return -EINVAL; in pci_pm_reset()
4664 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, csr); in pci_pm_reset()
4669 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, csr); in pci_pm_reset()
4672 return pci_dev_wait(dev, "PM D3hot->D0", PCIE_RESET_READY_POLL_MS); in pci_pm_reset()
4676 * pcie_wait_for_link_delay - Wait until link is active or inactive
4694 if (!pdev->link_active_reporting) { in pcie_wait_for_link_delay()
4718 timeout -= 10; in pcie_wait_for_link_delay()
4727 * pcie_wait_for_link - Wait until link is active or inactive
4751 list_for_each_entry(pdev, &bus->devices, bus_list) { in pci_bus_max_d3cold_delay()
4752 if (pdev->d3cold_delay < min_delay) in pci_bus_max_d3cold_delay()
4753 min_delay = pdev->d3cold_delay; in pci_bus_max_d3cold_delay()
4754 if (pdev->d3cold_delay > max_delay) in pci_bus_max_d3cold_delay()
4755 max_delay = pdev->d3cold_delay; in pci_bus_max_d3cold_delay()
4762 * pci_bridge_wait_for_secondary_bus - Wait for secondary bus to be accessible
4780 if (!pci_is_bridge(dev) || !dev->bridge_d3) in pci_bridge_wait_for_secondary_bus()
4787 * For any hot-added devices the access delay is handled in pciehp in pci_bridge_wait_for_secondary_bus()
4791 if (!dev->subordinate || list_empty(&dev->subordinate->devices)) { in pci_bridge_wait_for_secondary_bus()
4797 delay = pci_bus_max_d3cold_delay(dev->subordinate); in pci_bridge_wait_for_secondary_bus()
4803 child = list_first_entry(&dev->subordinate->devices, struct pci_dev, in pci_bridge_wait_for_secondary_bus()
4808 * Conventional PCI and PCI-X we need to wait Tpvrh + Trhfa before in pci_bridge_wait_for_secondary_bus()
4879 * be re-initialized. PCIe has some ways to shorten this, in pci_reset_secondary_bus()
4891 * pci_bridge_secondary_bus_reset - Reset the secondary bus on a PCI bridge.
4895 * Devices on the secondary bus are left in power-on state.
4909 if (pci_is_root_bus(dev->bus) || dev->subordinate || in pci_parent_bus_reset()
4910 !dev->bus->self || dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET) in pci_parent_bus_reset()
4911 return -ENOTTY; in pci_parent_bus_reset()
4913 list_for_each_entry(pdev, &dev->bus->devices, bus_list) in pci_parent_bus_reset()
4915 return -ENOTTY; in pci_parent_bus_reset()
4920 return pci_bridge_secondary_bus_reset(dev->bus->self); in pci_parent_bus_reset()
4925 int rc = -ENOTTY; in pci_reset_hotplug_slot()
4927 if (!hotplug || !try_module_get(hotplug->owner)) in pci_reset_hotplug_slot()
4930 if (hotplug->ops->reset_slot) in pci_reset_hotplug_slot()
4931 rc = hotplug->ops->reset_slot(hotplug, probe); in pci_reset_hotplug_slot()
4933 module_put(hotplug->owner); in pci_reset_hotplug_slot()
4940 if (dev->multifunction || dev->subordinate || !dev->slot || in pci_dev_reset_slot_function()
4941 dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET) in pci_dev_reset_slot_function()
4942 return -ENOTTY; in pci_dev_reset_slot_function()
4944 return pci_reset_hotplug_slot(dev->slot->hotplug, probe); in pci_dev_reset_slot_function()
4951 device_lock(&dev->dev); in pci_dev_lock()
4958 if (device_trylock(&dev->dev)) in pci_dev_trylock()
4968 device_unlock(&dev->dev); in pci_dev_unlock()
4975 dev->driver ? dev->driver->err_handler : NULL; in pci_dev_save_and_disable()
4978 * dev->driver->err_handler->reset_prepare() is protected against in pci_dev_save_and_disable()
4979 * races with ->remove() by the device lock, which must be held by in pci_dev_save_and_disable()
4982 if (err_handler && err_handler->reset_prepare) in pci_dev_save_and_disable()
4983 err_handler->reset_prepare(dev); in pci_dev_save_and_disable()
4986 * Wake-up device prior to save. PM registers default to D0 after in pci_dev_save_and_disable()
4988 * to a non-D0 state anyway. in pci_dev_save_and_disable()
4995 * INTx-disable which is set. This not only disables MMIO and I/O port in pci_dev_save_and_disable()
4997 * DMA from the device including MSI/MSI-X interrupts. For PCI 2.3 in pci_dev_save_and_disable()
4998 * compliant devices, INTx-disable prevents legacy interrupts. in pci_dev_save_and_disable()
5006 dev->driver ? dev->driver->err_handler : NULL; in pci_dev_restore()
5011 * dev->driver->err_handler->reset_done() is protected against in pci_dev_restore()
5012 * races with ->remove() by the device lock, which must be held by in pci_dev_restore()
5015 if (err_handler && err_handler->reset_done) in pci_dev_restore()
5016 err_handler->reset_done(dev); in pci_dev_restore()
5020 * __pci_reset_function_locked - reset a PCI device function while holding
5046 * A reset method returns -ENOTTY if it doesn't support this device in __pci_reset_function_locked()
5054 if (rc != -ENOTTY) in __pci_reset_function_locked()
5058 if (rc != -ENOTTY) in __pci_reset_function_locked()
5062 if (rc != -ENOTTY) in __pci_reset_function_locked()
5065 if (rc != -ENOTTY) in __pci_reset_function_locked()
5068 if (rc != -ENOTTY) in __pci_reset_function_locked()
5075 * pci_probe_reset_function - check whether the device can be safely reset
5092 if (rc != -ENOTTY) in pci_probe_reset_function()
5097 if (rc != -ENOTTY) in pci_probe_reset_function()
5100 if (rc != -ENOTTY) in pci_probe_reset_function()
5103 if (rc != -ENOTTY) in pci_probe_reset_function()
5110 * pci_reset_function - quiesce and reset a PCI device function
5118 * clears all the state associated with the device. This function differs
5119 * from __pci_reset_function_locked() in that it saves and restores device state
5129 if (!dev->reset_fn) in pci_reset_function()
5130 return -ENOTTY; in pci_reset_function()
5145 * pci_reset_function_locked - quiesce and reset a PCI device function
5153 * clears all the state associated with the device. This function differs
5154 * from __pci_reset_function_locked() in that it saves and restores device state
5165 if (!dev->reset_fn) in pci_reset_function_locked()
5166 return -ENOTTY; in pci_reset_function_locked()
5179 * pci_try_reset_function - quiesce and reset a PCI device function
5182 * Same as above, except return -EAGAIN if unable to lock device.
5188 if (!dev->reset_fn) in pci_try_reset_function()
5189 return -ENOTTY; in pci_try_reset_function()
5192 return -EAGAIN; in pci_try_reset_function()
5209 if (bus->self && (bus->self->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)) in pci_bus_resetable()
5212 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_resetable()
5213 if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET || in pci_bus_resetable()
5214 (dev->subordinate && !pci_bus_resetable(dev->subordinate))) in pci_bus_resetable()
5226 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_lock()
5228 if (dev->subordinate) in pci_bus_lock()
5229 pci_bus_lock(dev->subordinate); in pci_bus_lock()
5238 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_unlock()
5239 if (dev->subordinate) in pci_bus_unlock()
5240 pci_bus_unlock(dev->subordinate); in pci_bus_unlock()
5250 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_trylock()
5253 if (dev->subordinate) { in pci_bus_trylock()
5254 if (!pci_bus_trylock(dev->subordinate)) { in pci_bus_trylock()
5263 list_for_each_entry_continue_reverse(dev, &bus->devices, bus_list) { in pci_bus_trylock()
5264 if (dev->subordinate) in pci_bus_trylock()
5265 pci_bus_unlock(dev->subordinate); in pci_bus_trylock()
5276 if (slot->bus->self && in pci_slot_resetable()
5277 (slot->bus->self->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)) in pci_slot_resetable()
5280 list_for_each_entry(dev, &slot->bus->devices, bus_list) { in pci_slot_resetable()
5281 if (!dev->slot || dev->slot != slot) in pci_slot_resetable()
5283 if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET || in pci_slot_resetable()
5284 (dev->subordinate && !pci_bus_resetable(dev->subordinate))) in pci_slot_resetable()
5296 list_for_each_entry(dev, &slot->bus->devices, bus_list) { in pci_slot_lock()
5297 if (!dev->slot || dev->slot != slot) in pci_slot_lock()
5300 if (dev->subordinate) in pci_slot_lock()
5301 pci_bus_lock(dev->subordinate); in pci_slot_lock()
5310 list_for_each_entry(dev, &slot->bus->devices, bus_list) { in pci_slot_unlock()
5311 if (!dev->slot || dev->slot != slot) in pci_slot_unlock()
5313 if (dev->subordinate) in pci_slot_unlock()
5314 pci_bus_unlock(dev->subordinate); in pci_slot_unlock()
5324 list_for_each_entry(dev, &slot->bus->devices, bus_list) { in pci_slot_trylock()
5325 if (!dev->slot || dev->slot != slot) in pci_slot_trylock()
5329 if (dev->subordinate) { in pci_slot_trylock()
5330 if (!pci_bus_trylock(dev->subordinate)) { in pci_slot_trylock()
5340 &slot->bus->devices, bus_list) { in pci_slot_trylock()
5341 if (!dev->slot || dev->slot != slot) in pci_slot_trylock()
5343 if (dev->subordinate) in pci_slot_trylock()
5344 pci_bus_unlock(dev->subordinate); in pci_slot_trylock()
5358 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_save_and_disable_locked()
5360 if (dev->subordinate) in pci_bus_save_and_disable_locked()
5361 pci_bus_save_and_disable_locked(dev->subordinate); in pci_bus_save_and_disable_locked()
5374 list_for_each_entry(dev, &bus->devices, bus_list) { in pci_bus_restore_locked()
5376 if (dev->subordinate) in pci_bus_restore_locked()
5377 pci_bus_restore_locked(dev->subordinate); in pci_bus_restore_locked()
5389 list_for_each_entry(dev, &slot->bus->devices, bus_list) { in pci_slot_save_and_disable_locked()
5390 if (!dev->slot || dev->slot != slot) in pci_slot_save_and_disable_locked()
5393 if (dev->subordinate) in pci_slot_save_and_disable_locked()
5394 pci_bus_save_and_disable_locked(dev->subordinate); in pci_slot_save_and_disable_locked()
5407 list_for_each_entry(dev, &slot->bus->devices, bus_list) { in pci_slot_restore_locked()
5408 if (!dev->slot || dev->slot != slot) in pci_slot_restore_locked()
5411 if (dev->subordinate) in pci_slot_restore_locked()
5412 pci_bus_restore_locked(dev->subordinate); in pci_slot_restore_locked()
5421 return -ENOTTY; in pci_slot_reset()
5428 rc = pci_reset_hotplug_slot(slot->hotplug, probe); in pci_slot_reset()
5437 * pci_probe_reset_slot - probe whether a PCI slot can be reset
5449 * __pci_reset_slot - Try to reset a PCI slot
5461 * Same as above except return -EAGAIN if the slot cannot be locked
5474 rc = pci_reset_hotplug_slot(slot->hotplug, 0); in __pci_reset_slot()
5478 rc = -EAGAIN; in __pci_reset_slot()
5487 if (!bus->self || !pci_bus_resetable(bus)) in pci_bus_reset()
5488 return -ENOTTY; in pci_bus_reset()
5497 ret = pci_bridge_secondary_bus_reset(bus->self); in pci_bus_reset()
5505 * pci_bus_error_reset - reset the bridge's subordinate bus
5514 struct pci_bus *bus = bridge->subordinate; in pci_bus_error_reset()
5518 return -ENOTTY; in pci_bus_error_reset()
5521 if (list_empty(&bus->slots)) in pci_bus_error_reset()
5524 list_for_each_entry(slot, &bus->slots, list) in pci_bus_error_reset()
5528 list_for_each_entry(slot, &bus->slots, list) in pci_bus_error_reset()
5536 return pci_bus_reset(bridge->subordinate, 0); in pci_bus_error_reset()
5540 * pci_probe_reset_bus - probe whether a PCI bus can be reset
5552 * __pci_reset_bus - Try to reset a PCI bus
5555 * Same as above except return -EAGAIN if the bus cannot be locked
5568 rc = pci_bridge_secondary_bus_reset(bus->self); in __pci_reset_bus()
5572 rc = -EAGAIN; in __pci_reset_bus()
5578 * pci_reset_bus - Try to reset a PCI bus
5581 * Same as above except return -EAGAIN if the bus cannot be locked
5585 return (!pci_probe_reset_slot(pdev->slot)) ? in pci_reset_bus()
5586 __pci_reset_slot(pdev->slot) : __pci_reset_bus(pdev->bus); in pci_reset_bus()
5591 * pcix_get_max_mmrbc - get PCI-X maximum designed memory read byte count
5604 return -EINVAL; in pcix_get_max_mmrbc()
5607 return -EINVAL; in pcix_get_max_mmrbc()
5614 * pcix_get_mmrbc - get PCI-X maximum memory read byte count
5627 return -EINVAL; in pcix_get_mmrbc()
5630 return -EINVAL; in pcix_get_mmrbc()
5637 * pcix_set_mmrbc - set PCI-X maximum memory read byte count
5652 return -EINVAL; in pcix_set_mmrbc()
5654 v = ffs(mmrbc) - 10; in pcix_set_mmrbc()
5658 return -EINVAL; in pcix_set_mmrbc()
5661 return -EINVAL; in pcix_set_mmrbc()
5664 return -E2BIG; in pcix_set_mmrbc()
5667 return -EINVAL; in pcix_set_mmrbc()
5671 if (v > o && (dev->bus->bus_flags & PCI_BUS_FLAGS_NO_MMRBC)) in pcix_set_mmrbc()
5672 return -EIO; in pcix_set_mmrbc()
5677 return -EIO; in pcix_set_mmrbc()
5684 * pcie_get_readrq - get PCI Express read request size
5700 * pcie_set_readrq - set PCI Express maximum memory read request
5713 return -EINVAL; in pcie_set_readrq()
5727 v = (ffs(rq) - 8) << 12; in pcie_set_readrq()
5737 * pcie_get_mps - get PCI Express maximum payload size
5753 * pcie_set_mps - set PCI Express maximum payload size
5766 return -EINVAL; in pcie_set_mps()
5768 v = ffs(mps) - 8; in pcie_set_mps()
5769 if (v > dev->pcie_mpss) in pcie_set_mps()
5770 return -EINVAL; in pcie_set_mps()
5781 * pcie_bandwidth_available - determine minimum link settings of a PCIe
5839 * pcie_get_speed_cap - query for the PCI device's link speed capability
5860 /* PCIe r3.0-compliant */ in pcie_get_speed_cap()
5875 * pcie_get_width_cap - query for the PCI device's link width capability
5894 * pcie_bandwidth_capable - calculate a PCI device's link bandwidth capability
5916 * __pcie_print_link_status - Report the PCI device's link speed and width
5949 * pcie_print_link_status - Report the PCI device's link speed and width
5961 * pci_select_bars - Make BAR mask from the type of resource
5995 * pci_set_vga_state - set VGA decode state on device and parents if requested
6029 bus = dev->bus; in pci_set_vga_state()
6031 bridge = bus->self; in pci_set_vga_state()
6042 bus = bus->parent; in pci_set_vga_state()
6055 adev = ACPI_COMPANION(&pdev->dev); in pci_pr3_present()
6059 return adev->power.flags.power_resources && in pci_pr3_present()
6060 acpi_has_method(adev->handle, "_PR3"); in pci_pr3_present()
6066 * pci_add_dma_alias - Add a DMA devfn alias for a device
6071 * This helper encodes an 8-bit devfn as a bit number in dma_alias_mask
6072 * which is used to program permissible bus-devfn source addresses for DMA
6075 * from their logical bus-devfn. Examples include device quirks where the
6076 * device simply uses the wrong devfn, as well as non-transparent bridges
6089 nr_devfns = min(nr_devfns, (unsigned) MAX_NR_DEVFNS - devfn_from); in pci_add_dma_alias()
6090 devfn_to = devfn_from + nr_devfns - 1; in pci_add_dma_alias()
6092 if (!dev->dma_alias_mask) in pci_add_dma_alias()
6093 dev->dma_alias_mask = bitmap_zalloc(MAX_NR_DEVFNS, GFP_KERNEL); in pci_add_dma_alias()
6094 if (!dev->dma_alias_mask) { in pci_add_dma_alias()
6099 bitmap_set(dev->dma_alias_mask, devfn_from, nr_devfns); in pci_add_dma_alias()
6112 return (dev1->dma_alias_mask && in pci_devs_are_dma_aliases()
6113 test_bit(dev2->devfn, dev1->dma_alias_mask)) || in pci_devs_are_dma_aliases()
6114 (dev2->dma_alias_mask && in pci_devs_are_dma_aliases()
6115 test_bit(dev1->devfn, dev2->dma_alias_mask)) || in pci_devs_are_dma_aliases()
6126 return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0); in pci_device_is_present()
6132 struct pci_dev *bridge = dev->bus->self; in pci_ignore_hotplug()
6134 dev->ignore_hotplug = 1; in pci_ignore_hotplug()
6137 bridge->ignore_hotplug = 1; in pci_ignore_hotplug()
6142 * pci_real_dma_dev - Get PCI DMA device for PCI device
6145 * Permits the platform to provide architecture-specific functionality to
6162 * Arches that don't want to expose struct resource to userland as-is in
6169 *start = rsrc->start; in pci_resource_to_user()
6170 *end = rsrc->end; in pci_resource_to_user()
6177 * pci_specified_resource_alignment - get resource alignment specified by user.
6208 align_order = -1; in pci_specified_resource_alignment()
6214 if (align_order == -1) in pci_specified_resource_alignment()
6239 struct resource *r = &dev->resource[bar]; in pci_request_resource_alignment()
6242 if (!(r->flags & IORESOURCE_MEM)) in pci_request_resource_alignment()
6245 if (r->flags & IORESOURCE_PCI_FIXED) { in pci_request_resource_alignment()
6271 * 2) Retain the resource size, but use IORESOURCE_STARTALIGN and in pci_request_resource_alignment()
6272 * set r->start to the desired alignment. By itself this in pci_request_resource_alignment()
6287 r->start = 0; in pci_request_resource_alignment()
6288 r->end = align - 1; in pci_request_resource_alignment()
6290 r->flags &= ~IORESOURCE_SIZEALIGN; in pci_request_resource_alignment()
6291 r->flags |= IORESOURCE_STARTALIGN; in pci_request_resource_alignment()
6292 r->start = align; in pci_request_resource_alignment()
6293 r->end = r->start + size - 1; in pci_request_resource_alignment()
6295 r->flags |= IORESOURCE_UNSET; in pci_request_resource_alignment()
6302 * Later on, the kernel will assign page-aligned memory resource back
6314 * VF BARs are read-only zero according to SR-IOV spec r1.1, sec in pci_reassigndev_resource_alignment()
6316 * described by the VF BARx register in the PF's SR-IOV capability. in pci_reassigndev_resource_alignment()
6319 if (dev->is_virtfn) in pci_reassigndev_resource_alignment()
6327 if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL && in pci_reassigndev_resource_alignment()
6328 (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) { in pci_reassigndev_resource_alignment()
6345 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { in pci_reassigndev_resource_alignment()
6347 r = &dev->resource[i]; in pci_reassigndev_resource_alignment()
6348 if (!(r->flags & IORESOURCE_MEM)) in pci_reassigndev_resource_alignment()
6350 r->flags |= IORESOURCE_UNSET; in pci_reassigndev_resource_alignment()
6351 r->end = resource_size(r) - 1; in pci_reassigndev_resource_alignment()
6352 r->start = 0; in pci_reassigndev_resource_alignment()
6372 if (count >= 2 && buf[count - 2] != '\n' && count < PAGE_SIZE - 1) { in resource_alignment_show()
6373 buf[count - 1] = '\n'; in resource_alignment_show()
6386 return -ENOMEM; in resource_alignment_store()
6412 static atomic_t __domain_nr = ATOMIC_INIT(-1);
6421 static int use_dt_domains = -1; in of_pci_bus_find_domain_nr()
6422 int domain = -1; in of_pci_bus_find_domain_nr()
6425 domain = of_get_pci_domain_nr(parent->of_node); in of_pci_bus_find_domain_nr()
6450 * invalidating the domain value (domain = -1) and printing a in of_pci_bus_find_domain_nr()
6460 pr_err("Node %pOF has ", parent->of_node); in of_pci_bus_find_domain_nr()
6461 pr_err("Inconsistent \"linux,pci-domain\" property in DT\n"); in of_pci_bus_find_domain_nr()
6462 domain = -1; in of_pci_bus_find_domain_nr()
6476 * pci_ext_cfg_avail - can we access extended PCI config space?