drivers/irqchip/irq-ls-scfg-msi.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-ls-scfg-msi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-ls-scfg-msi.c- Extension
.c- Size
- 10730 bytes
- Lines
- 421
- Domain
- Driver Families
- Bucket
- drivers/irqchip
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/msi.hlinux/interrupt.hlinux/iommu.hlinux/irq.hlinux/irqchip/chained_irq.hlinux/irqchip/irq-msi-lib.hlinux/irqdomain.hlinux/of_irq.hlinux/of_pci.hlinux/platform_device.hlinux/property.hlinux/spinlock.h
Detected Declarations
struct ls_scfg_msi_cfgstruct ls_scfg_msirstruct ls_scfg_msifunction early_parse_ls_scfg_msifunction ls_scfg_msi_compose_msgfunction ls_scfg_msi_set_affinityfunction ls_scfg_msi_domain_irq_allocfunction ls_scfg_msi_domain_irq_freefunction ls_scfg_msi_irq_handlerfunction for_each_set_bit_fromfunction ls_scfg_msi_domains_initfunction ls_scfg_msi_setup_hwirqfunction ls_scfg_msi_teardown_hwirqfunction ls_scfg_msi_probefunction ls_scfg_msi_remove
Annotated Snippet
struct ls_scfg_msi_cfg {
u32 ibs_shift; /* Shift of interrupt bit select */
u32 msir_irqs; /* The irq number per MSIR */
u32 msir_base; /* The base address of MSIR */
};
struct ls_scfg_msir {
struct ls_scfg_msi *msi_data;
unsigned int index;
unsigned int gic_irq;
unsigned int bit_start;
unsigned int bit_end;
unsigned int srs; /* Shared interrupt register select */
void __iomem *reg;
};
struct ls_scfg_msi {
spinlock_t lock;
struct platform_device *pdev;
struct irq_domain *parent;
void __iomem *regs;
phys_addr_t msiir_addr;
struct ls_scfg_msi_cfg *cfg;
u32 msir_num;
struct ls_scfg_msir *msir;
u32 irqs_num;
unsigned long *used;
};
#define MPIC_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
MSI_FLAG_USE_DEF_CHIP_OPS)
#define MPIC_MSI_FLAGS_SUPPORTED (MSI_FLAG_PCI_MSIX | \
MSI_GENERIC_FLAGS_MASK)
static const struct msi_parent_ops ls_scfg_msi_parent_ops = {
.required_flags = MPIC_MSI_FLAGS_REQUIRED,
.supported_flags = MPIC_MSI_FLAGS_SUPPORTED,
.bus_select_token = DOMAIN_BUS_NEXUS,
.bus_select_mask = MATCH_PCI_MSI,
.prefix = "MSI-",
.init_dev_msi_info = msi_lib_init_dev_msi_info,
};
static int msi_affinity_flag = 1;
static int __init early_parse_ls_scfg_msi(char *p)
{
if (p && strncmp(p, "no-affinity", 11) == 0)
msi_affinity_flag = 0;
else
msi_affinity_flag = 1;
return 0;
}
early_param("lsmsi", early_parse_ls_scfg_msi);
static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
{
struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(data);
msg->data = data->hwirq;
if (msi_affinity_flag) {
const struct cpumask *mask;
mask = irq_data_get_effective_affinity_mask(data);
msg->data |= cpumask_first(mask);
}
msi_msg_set_addr(irq_data_get_msi_desc(data), msg,
msi_data->msiir_addr);
}
static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,
const struct cpumask *mask, bool force)
{
struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(irq_data);
u32 cpu;
if (!msi_affinity_flag)
return -EINVAL;
if (!force)
cpu = cpumask_any_and(mask, cpu_online_mask);
else
cpu = cpumask_first(mask);
if (cpu >= msi_data->msir_num)
return -EINVAL;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/msi.h`, `linux/interrupt.h`, `linux/iommu.h`, `linux/irq.h`, `linux/irqchip/chained_irq.h`, `linux/irqchip/irq-msi-lib.h`.
- Detected declarations: `struct ls_scfg_msi_cfg`, `struct ls_scfg_msir`, `struct ls_scfg_msi`, `function early_parse_ls_scfg_msi`, `function ls_scfg_msi_compose_msg`, `function ls_scfg_msi_set_affinity`, `function ls_scfg_msi_domain_irq_alloc`, `function ls_scfg_msi_domain_irq_free`, `function ls_scfg_msi_irq_handler`, `function for_each_set_bit_from`.
- Atlas domain: Driver Families / drivers/irqchip.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.