drivers/pci/setup-res.c
Source file repositories/reference/linux-study-clean/drivers/pci/setup-res.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/setup-res.c- Extension
.c- Size
- 14123 bytes
- Lines
- 523
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/export.hlinux/pci.hlinux/errno.hlinux/ioport.hlinux/cache.hlinux/slab.hpci.h
Detected Declarations
function Ruslingfunction pci_update_resourcefunction pci_claim_resourcefunction pci_disable_bridge_windowfunction pcibios_retrieve_fw_addrfunction pci_revert_fw_addressfunction pci_align_resourcefunction pcibios_align_resourcefunction __pci_assign_resourcefunction _pci_assign_resourcefunction pci_assign_resourcefunction pci_reassign_resourcefunction pci_release_resourcefunction pci_enable_resourcesfunction pci_dev_for_each_resourceexport pci_claim_resourceexport pci_assign_resourceexport pci_release_resource
Annotated Snippet
if (check != new) {
pci_err(dev, "%s: error updating (high %#010x != %#010x)\n",
res_name, new, check);
}
}
if (disable)
pci_write_config_word(dev, PCI_COMMAND, cmd);
}
void pci_update_resource(struct pci_dev *dev, int resno)
{
if (resno <= PCI_ROM_RESOURCE)
pci_std_update_resource(dev, resno);
else if (pci_resource_is_iov(resno))
pci_iov_update_resource(dev, resno);
}
int pci_claim_resource(struct pci_dev *dev, int resource)
{
struct resource *res = &dev->resource[resource];
const char *res_name = pci_resource_name(dev, resource);
struct resource *root, *conflict;
if (res->flags & IORESOURCE_UNSET) {
pci_info(dev, "%s %pR: can't claim; no address assigned\n",
res_name, res);
return -EINVAL;
}
/*
* If we have a shadow copy in RAM, the PCI device doesn't respond
* to the shadow range, so we don't need to claim it, and upstream
* bridges don't need to route the range to the device.
*/
if (res->flags & IORESOURCE_ROM_SHADOW)
return 0;
root = pci_find_parent_resource(dev, res);
if (!root) {
pci_info(dev, "%s %pR: can't claim; no compatible bridge window\n",
res_name, res);
res->flags |= IORESOURCE_UNSET;
return -EINVAL;
}
conflict = request_resource_conflict(root, res);
if (conflict) {
pci_info(dev, "%s %pR: can't claim; address conflict with %s %pR\n",
res_name, res, conflict->name, conflict);
res->flags |= IORESOURCE_UNSET;
return -EBUSY;
}
return 0;
}
EXPORT_SYMBOL(pci_claim_resource);
void pci_disable_bridge_window(struct pci_dev *dev)
{
/* MMIO Base/Limit */
pci_write_config_dword(dev, PCI_MEMORY_BASE, 0x0000fff0);
/* Prefetchable MMIO Base/Limit */
pci_write_config_dword(dev, PCI_PREF_LIMIT_UPPER32, 0);
pci_write_config_dword(dev, PCI_PREF_MEMORY_BASE, 0x0000fff0);
pci_write_config_dword(dev, PCI_PREF_BASE_UPPER32, 0xffffffff);
}
/*
* Generic function that returns a value indicating that the device's
* original BIOS BAR address was not saved and so is not available for
* reinstatement.
*
* Can be over-ridden by architecture specific code that implements
* reinstatement functionality rather than leaving it disabled when
* normal allocation attempts fail.
*/
resource_size_t __weak pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)
{
return 0;
}
static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev,
int resno, resource_size_t size)
{
struct resource *root, *conflict;
resource_size_t fw_addr, start, end;
const char *res_name = pci_resource_name(dev, resno);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/pci.h`, `linux/errno.h`, `linux/ioport.h`, `linux/cache.h`, `linux/slab.h`, `pci.h`.
- Detected declarations: `function Rusling`, `function pci_update_resource`, `function pci_claim_resource`, `function pci_disable_bridge_window`, `function pcibios_retrieve_fw_addr`, `function pci_revert_fw_address`, `function pci_align_resource`, `function pcibios_align_resource`, `function __pci_assign_resource`, `function _pci_assign_resource`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.