linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jianmin Lv <lvjianmin@loongson.cn>
To: Thomas Gleixner <tglx@linutronix.de>, Marc Zyngier <maz@kernel.org>
Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
	Hanjun Guo <guohanjun@huawei.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Huacai Chen <chenhuacai@loongson.cn>
Subject: [PATCH V16 11/14] LoongArch: prepare to support multiple pch-pic and pch-msi irqdomain
Date: Mon, 18 Jul 2022 22:13:38 +0800	[thread overview]
Message-ID: <1658153621-40445-12-git-send-email-lvjianmin@loongson.cn> (raw)
In-Reply-To: <1658153621-40445-1-git-send-email-lvjianmin@loongson.cn>

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>
---
 arch/loongarch/include/asm/irq.h |  8 ++++++++
 arch/loongarch/kernel/irq.c      | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/arch/loongarch/include/asm/irq.h b/arch/loongarch/include/asm/irq.h
index de8af43..c847300 100644
--- a/arch/loongarch/include/asm/irq.h
+++ b/arch/loongarch/include/asm/irq.h
@@ -48,6 +48,14 @@ static inline bool on_irq_stack(int cpu, unsigned long sp)
 #define MAX_IO_PICS 2
 #define NR_IRQS	(64 + (256 * MAX_IO_PICS))
 
+struct acpi_vector_group {
+	int node;
+	int pci_segment;
+	struct irq_domain *parent;
+};
+extern struct acpi_vector_group pch_group[MAX_IO_PICS];
+extern struct acpi_vector_group msi_group[MAX_IO_PICS];
+
 #define CORES_PER_EIO_NODE	4
 
 #define LOONGSON_CPU_UART0_VEC		10 /* CPU UART0 */
diff --git a/arch/loongarch/kernel/irq.c b/arch/loongarch/kernel/irq.c
index b04201c..06f2a15 100644
--- a/arch/loongarch/kernel/irq.c
+++ b/arch/loongarch/kernel/irq.c
@@ -26,6 +26,8 @@
 EXPORT_PER_CPU_SYMBOL(irq_stat);
 
 struct irq_domain *cpu_domain;
+struct acpi_vector_group pch_group[MAX_IO_PICS];
+struct acpi_vector_group msi_group[MAX_IO_PICS];
 
 /*
  * 'what should we do if we get a hw irq event on an illegal vector'.
@@ -52,6 +54,41 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	return 0;
 }
 
+static int __init early_pci_mcfg_parse(struct acpi_table_header *header)
+{
+	struct acpi_table_mcfg *mcfg;
+	struct acpi_mcfg_allocation *mptr;
+	int i, n;
+
+	if (header->length < sizeof(struct acpi_table_mcfg))
+		return -EINVAL;
+
+	n = (header->length - sizeof(struct acpi_table_mcfg)) /
+					sizeof(struct acpi_mcfg_allocation);
+	mcfg = (struct acpi_table_mcfg *)header;
+	mptr = (struct acpi_mcfg_allocation *) &mcfg[1];
+
+	for (i = 0; i < n; i++, mptr++) {
+		msi_group[i].pci_segment = mptr->pci_segment;
+		pch_group[i].node = msi_group[i].node = (mptr->address >> 44) & 0xf;
+	}
+
+	return 0;
+}
+
+static void __init init_vec_parent_group(void)
+{
+	int i;
+
+	for (i = 0; i < MAX_IO_PICS; i++) {
+		msi_group[i].pci_segment = -1;
+		msi_group[i].node = -1;
+		pch_group[i].node = -1;
+	}
+
+	acpi_table_parse(ACPI_SIG_MCFG, early_pci_mcfg_parse);
+}
+
 void __init init_IRQ(void)
 {
 	int i;
@@ -65,6 +102,7 @@ void __init init_IRQ(void)
 	clear_csr_ecfg(ECFG0_IM);
 	clear_csr_estat(ESTATF_IP);
 
+	init_vec_parent_group();
 	irqchip_init();
 #ifdef CONFIG_SMP
 	ipi_irq = EXCCODE_IPI - EXCCODE_INT_START;
-- 
1.8.3.1


  parent reply	other threads:[~2022-07-18 14:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 14:13 [PATCH V16 00/14] irqchip: Add LoongArch-related irqchip drivers Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 01/14] LoongArch: Provisionally add ACPICA data structures Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 02/14] APCI: irq: Add support for multiple GSI domains Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 03/14] ACPI: irq: Allow acpi_gsi_to_irq() to have an arch-specific fallback Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 04/14] genirq/generic_chip: export irq_unmap_generic_chip Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 05/14] LoongArch: Use ACPI_GENERIC_GSI for gsi handling Jianmin Lv
2022-07-18 15:19   ` Huacai Chen
2022-07-18 14:13 ` [PATCH V16 06/14] irqchip: Add Loongson PCH LPC controller support Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 07/14] irqchip: remove COMPILE_TEST for pch-pic and pch-msi Jianmin Lv
2022-07-19  1:06   ` Huacai Chen
2022-07-19 13:42     ` Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 08/14] irqchip/loongson-pch-pic: Add ACPI init support Jianmin Lv
2022-07-18 15:27   ` Huacai Chen
2022-07-19 13:42     ` Jianmin Lv
2022-07-19  3:15   ` Huacai Chen
2022-07-19 13:37     ` Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 09/14] irqchip/loongson-pch-msi: " Jianmin Lv
2022-07-19  2:40   ` Huacai Chen
2022-07-19 13:40     ` Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 10/14] irqchip/loongson-liointc: " Jianmin Lv
2022-07-18 14:13 ` Jianmin Lv [this message]
2022-07-19  2:38   ` [PATCH V16 11/14] LoongArch: prepare to support multiple pch-pic and pch-msi irqdomain Huacai Chen
2022-07-19 13:41     ` Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 12/14] irqchip: Add Loongson Extended I/O interrupt controller support Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 13/14] irqchip: Add LoongArch CPU " Jianmin Lv
2022-07-18 15:21   ` Huacai Chen
2022-07-19 13:43     ` Jianmin Lv
2022-07-18 14:13 ` [PATCH V16 14/14] irqchip / ACPI: Introduce ACPI_IRQ_MODEL_LPIC for LoongArch Jianmin Lv
2022-07-19  2:25   ` Huacai Chen
2022-07-19 13:41     ` Jianmin Lv
2022-07-19 22:40   ` kernel test robot
2022-07-19  1:12 ` [PATCH V16 00/14] irqchip: Add LoongArch-related irqchip drivers Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1658153621-40445-12-git-send-email-lvjianmin@loongson.cn \
    --to=lvjianmin@loongson.cn \
    --cc=chenhuacai@loongson.cn \
    --cc=guohanjun@huawei.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).