drivers/pci/pcie/err.c
Source file repositories/reference/linux-study-clean/drivers/pci/pcie/err.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/pcie/err.c- Extension
.c- Size
- 8410 bytes
- Lines
- 300
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/pm_runtime.hlinux/module.hlinux/kernel.hlinux/errno.hlinux/aer.hportdrv.h../pci.h
Detected Declarations
function Copyrightfunction report_error_detectedfunction pci_pm_runtime_get_syncfunction pci_pm_runtime_putfunction report_frozen_detectedfunction report_normal_detectedfunction report_perm_failure_detectedfunction report_mmio_enabledfunction report_slot_resetfunction report_resumefunction pci_walk_bridgefunction pcie_do_recovery
Annotated Snippet
struct pci_driver *pdrv;
pci_ers_result_t vote;
const struct pci_error_handlers *err_handler;
device_lock(&dev->dev);
pdrv = dev->driver;
if (pci_dev_is_disconnected(dev)) {
vote = PCI_ERS_RESULT_DISCONNECT;
} else if (!pci_dev_set_io_state(dev, state)) {
pci_info(dev, "can't recover (state transition %u -> %u invalid)\n",
dev->error_state, state);
vote = PCI_ERS_RESULT_NONE;
} else if (!pdrv || !pdrv->err_handler ||
!pdrv->err_handler->error_detected) {
/*
* If any device in the subtree does not have an error_detected
* callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent
* error callbacks of "any" device in the subtree, and will
* exit in the disconnected error state.
*/
if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
vote = PCI_ERS_RESULT_NO_AER_DRIVER;
pci_info(dev, "can't recover (no error_detected callback)\n");
} else {
vote = PCI_ERS_RESULT_NONE;
}
} else {
err_handler = pdrv->err_handler;
vote = err_handler->error_detected(dev, state);
}
pci_uevent_ers(dev, vote);
*result = merge_result(*result, vote);
device_unlock(&dev->dev);
return 0;
}
static int pci_pm_runtime_get_sync(struct pci_dev *pdev, void *data)
{
pm_runtime_get_sync(&pdev->dev);
return 0;
}
static int pci_pm_runtime_put(struct pci_dev *pdev, void *data)
{
pm_runtime_put(&pdev->dev);
return 0;
}
static int report_frozen_detected(struct pci_dev *dev, void *data)
{
return report_error_detected(dev, pci_channel_io_frozen, data);
}
static int report_normal_detected(struct pci_dev *dev, void *data)
{
return report_error_detected(dev, pci_channel_io_normal, data);
}
static int report_perm_failure_detected(struct pci_dev *dev, void *data)
{
struct pci_driver *pdrv;
const struct pci_error_handlers *err_handler;
device_lock(&dev->dev);
pdrv = dev->driver;
if (!pdrv || !pdrv->err_handler || !pdrv->err_handler->error_detected)
goto out;
err_handler = pdrv->err_handler;
err_handler->error_detected(dev, pci_channel_io_perm_failure);
out:
pci_uevent_ers(dev, PCI_ERS_RESULT_DISCONNECT);
device_unlock(&dev->dev);
return 0;
}
static int report_mmio_enabled(struct pci_dev *dev, void *data)
{
struct pci_driver *pdrv;
pci_ers_result_t vote, *result = data;
const struct pci_error_handlers *err_handler;
device_lock(&dev->dev);
pdrv = dev->driver;
if (!pdrv || !pdrv->err_handler || !pdrv->err_handler->mmio_enabled)
goto out;
err_handler = pdrv->err_handler;
vote = err_handler->mmio_enabled(dev);
*result = merge_result(*result, vote);
Annotation
- Immediate include surface: `linux/pci.h`, `linux/pm_runtime.h`, `linux/module.h`, `linux/kernel.h`, `linux/errno.h`, `linux/aer.h`, `portdrv.h`, `../pci.h`.
- Detected declarations: `function Copyright`, `function report_error_detected`, `function pci_pm_runtime_get_sync`, `function pci_pm_runtime_put`, `function report_frozen_detected`, `function report_normal_detected`, `function report_perm_failure_detected`, `function report_mmio_enabled`, `function report_slot_reset`, `function report_resume`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: pattern 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.