Skip to content

Commit 2dfded4

Browse files
lvjianmin-loongsonMarc Zyngier
authored andcommitted
LoongArch: Prepare to support multiple pch-pic and pch-msi irqdomain
For systems with two chipsets, there are two related pch-pic and pch-msi irqdomains, each of which has the same node id as its parent irqdomain. So we use a structure to mantain the relation of node and it's parent irqdomain as pch irqdomin, the 'pci_segment' field is only used to match the pci segment of a pci device when setting msi irqdomain for the device. struct acpi_vector_group { int node; int pci_segment; struct irq_domain *parent; }; The field 'pci_segment' and 'node' are initialized from MCFG, and the parent irqdomain driver will set field 'parent' by matching same 'node'. Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/1658314292-35346-7-git-send-email-lvjianmin@loongson.cn
1 parent cd05766 commit 2dfded4

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

arch/loongarch/include/asm/irq.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ void arch_trigger_cpumask_backtrace(const struct cpumask *mask, bool exclude_sel
4848
#define MAX_IO_PICS 2
4949
#define NR_IRQS (64 + (256 * MAX_IO_PICS))
5050

51+
struct acpi_vector_group {
52+
int node;
53+
int pci_segment;
54+
struct irq_domain *parent;
55+
};
56+
extern struct acpi_vector_group pch_group[MAX_IO_PICS];
57+
extern struct acpi_vector_group msi_group[MAX_IO_PICS];
58+
5159
#define CORES_PER_EIO_NODE 4
5260

5361
#define LOONGSON_CPU_UART0_VEC 10 /* CPU UART0 */

arch/loongarch/kernel/irq.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ struct irq_domain *pch_lpc_domain;
3131
struct irq_domain *pch_msi_domain[MAX_IO_PICS];
3232
struct irq_domain *pch_pic_domain[MAX_IO_PICS];
3333

34+
struct acpi_vector_group pch_group[MAX_IO_PICS];
35+
struct acpi_vector_group msi_group[MAX_IO_PICS];
3436
/*
3537
* 'what should we do if we get a hw irq event on an illegal vector'.
3638
* each architecture has to answer this themselves.
@@ -56,6 +58,41 @@ int arch_show_interrupts(struct seq_file *p, int prec)
5658
return 0;
5759
}
5860

61+
static int __init early_pci_mcfg_parse(struct acpi_table_header *header)
62+
{
63+
struct acpi_table_mcfg *mcfg;
64+
struct acpi_mcfg_allocation *mptr;
65+
int i, n;
66+
67+
if (header->length < sizeof(struct acpi_table_mcfg))
68+
return -EINVAL;
69+
70+
n = (header->length - sizeof(struct acpi_table_mcfg)) /
71+
sizeof(struct acpi_mcfg_allocation);
72+
mcfg = (struct acpi_table_mcfg *)header;
73+
mptr = (struct acpi_mcfg_allocation *) &mcfg[1];
74+
75+
for (i = 0; i < n; i++, mptr++) {
76+
msi_group[i].pci_segment = mptr->pci_segment;
77+
pch_group[i].node = msi_group[i].node = (mptr->address >> 44) & 0xf;
78+
}
79+
80+
return 0;
81+
}
82+
83+
static void __init init_vec_parent_group(void)
84+
{
85+
int i;
86+
87+
for (i = 0; i < MAX_IO_PICS; i++) {
88+
msi_group[i].pci_segment = -1;
89+
msi_group[i].node = -1;
90+
pch_group[i].node = -1;
91+
}
92+
93+
acpi_table_parse(ACPI_SIG_MCFG, early_pci_mcfg_parse);
94+
}
95+
5996
void __init init_IRQ(void)
6097
{
6198
int i;
@@ -69,6 +106,7 @@ void __init init_IRQ(void)
69106
clear_csr_ecfg(ECFG0_IM);
70107
clear_csr_estat(ESTATF_IP);
71108

109+
init_vec_parent_group();
72110
irqchip_init();
73111
#ifdef CONFIG_SMP
74112
ipi_irq = EXCCODE_IPI - EXCCODE_INT_START;

0 commit comments

Comments
 (0)