drivers/irqchip/irq-msi-lib.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-msi-lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-msi-lib.c- Extension
.c- Size
- 5564 bytes
- Lines
- 170
- Domain
- Driver Families
- Bucket
- drivers/irqchip
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/irqchip/irq-msi-lib.h
Detected Declarations
function msi_lib_init_dev_msi_infofunction msi_lib_irq_domain_selectexport msi_lib_init_dev_msi_infoexport msi_lib_irq_domain_select
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (C) 2022 Linutronix GmbH
// Copyright (C) 2022 Intel
#include <linux/export.h>
#include <linux/irqchip/irq-msi-lib.h>
/**
* msi_lib_init_dev_msi_info - Domain info setup for MSI domains
* @dev: The device for which the domain is created for
* @domain: The domain providing this callback
* @real_parent: The real parent domain of the domain to be initialized
* which might be a domain built on top of @domain or
* @domain itself
* @info: The domain info for the domain to be initialize
*
* This function is to be used for all types of MSI domains above the root
* parent domain and any intermediates. The topmost parent domain specific
* functionality is determined via @real_parent.
*
* All intermediate domains between the root and the device domain must
* have either msi_parent_ops.init_dev_msi_info = msi_parent_init_dev_msi_info
* or invoke it down the line.
*/
bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
struct irq_domain *real_parent,
struct msi_domain_info *info)
{
const struct msi_parent_ops *pops = real_parent->msi_parent_ops;
struct irq_chip *chip = info->chip;
u32 required_flags;
/* Parent ops available? */
if (WARN_ON_ONCE(!pops))
return false;
/*
* MSI parent domain specific settings. For now there is only the
* root parent domain, e.g. NEXUS, acting as a MSI parent, but it is
* possible to stack MSI parents. See x86 vector -> irq remapping
*/
if (domain->bus_token == pops->bus_select_token) {
if (WARN_ON_ONCE(domain != real_parent))
return false;
} else {
WARN_ON_ONCE(1);
return false;
}
if (WARN_ON_ONCE(!chip->irq_write_msi_msg))
return false;
required_flags = pops->required_flags;
/* Is the target domain bus token supported? */
switch(info->bus_token) {
case DOMAIN_BUS_PCI_DEVICE_MSI:
case DOMAIN_BUS_PCI_DEVICE_MSIX:
if (WARN_ON_ONCE(!IS_ENABLED(CONFIG_PCI_MSI)))
return false;
break;
case DOMAIN_BUS_DEVICE_MSI:
/*
* Per device MSI should never have any MSI feature bits
* set. It's sole purpose is to create a dumb interrupt
* chip which has a device specific irq_write_msi_msg()
* callback.
*/
if (WARN_ON_ONCE(info->flags))
return false;
/* Core managed MSI descriptors */
info->flags = MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS;
fallthrough;
case DOMAIN_BUS_WIRED_TO_MSI:
/* Remove PCI specific flags */
required_flags &= ~MSI_FLAG_PCI_MSI_MASK_PARENT;
break;
default:
/*
* This should never be reached. See
* msi_lib_irq_domain_select()
*/
WARN_ON_ONCE(1);
return false;
}
/*
Annotation
- Immediate include surface: `linux/export.h`, `linux/irqchip/irq-msi-lib.h`.
- Detected declarations: `function msi_lib_init_dev_msi_info`, `function msi_lib_irq_domain_select`, `export msi_lib_init_dev_msi_info`, `export msi_lib_irq_domain_select`.
- Atlas domain: Driver Families / drivers/irqchip.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.