lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 31 May 2022 19:01:09 +0800 (GMT+08:00)
From:   吕建民 <lvjianmin@...ngson.cn>
To:     "Marc Zyngier" <maz@...nel.org>
Cc:     "Thomas Gleixner" <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org, "Xuefeng Li" <lixuefeng@...ngson.cn>,
        "Huacai Chen" <chenhuacai@...il.com>,
        "Jiaxun Yang" <jiaxun.yang@...goat.com>,
        "Huacai Chen" <chenhuacai@...ngson.cn>
Subject: Re: Re: [PATCH RFC V2 02/10] irqchip: Add LoongArch CPU interrupt
 controller support




&gt; -----Original Messages-----
&gt; From: "Marc Zyngier" <maz@...nel.org>
&gt; Sent Time: 2022-05-31 00:20:31 (Tuesday)
&gt; To: "Jianmin Lv" <lvjianmin@...ngson.cn>
&gt; Cc: "Thomas Gleixner" <tglx@...utronix.de>, linux-kernel@...r.kernel.org, "Xuefeng Li" <lixuefeng@...ngson.cn>, "Huacai Chen" <chenhuacai@...il.com>, "Jiaxun Yang" <jiaxun.yang@...goat.com>, "Huacai Chen" <chenhuacai@...ngson.cn>
&gt; Subject: Re: [PATCH RFC V2 02/10] irqchip: Add LoongArch CPU interrupt controller support
&gt; 
&gt; On Fri, 27 May 2022 12:02:12 +0100,
&gt; Jianmin Lv <lvjianmin@...ngson.cn> wrote:
&gt; &gt; 
&gt; &gt; We are preparing to add new Loongson (based on LoongArch, not compatible
&gt; &gt; with old MIPS-based Loongson) support. This patch add the LoongArch CPU
&gt; &gt; interrupt controller support.
&gt; 
&gt; Please drop this paragraph, as it doesn't help at all.
&gt; 
Ok,thanks, I'll drop it.

&gt; &gt; 
&gt; &gt; LoongArch CPUINTC stands for CSR.ECFG/CSR.ESTAT and related interrupt
&gt; &gt; controller that described in Section 7.4 of "LoongArch Reference Manual,
&gt; &gt; Vol 1". For more information please refer Documentation/loongarch/irq-
&gt; &gt; chip-model.rst.
&gt; 
&gt; Where is this the patch adding this document?
&gt; 
See https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

&gt; &gt; 
&gt; &gt; LoongArch CPUINTC has 13 interrupt sources: SWI0~1, HWI0~7, IPI, TI
&gt; &gt; (Timer) and PCOV (PMC). IRQ mappings of HWI0~7 are configurable (can be
&gt; &gt; created from DT/ACPI), but IPI, TI (Timer) and PCOV (PMC) are hardcoded
&gt; &gt; bits, so we define get_xxx_irq() for them.
&gt; 
&gt; Where are these functions? How are they used?
&gt; 
Sorry, these functions are implemented in previours version, and they are deleted in current version because I changed to use legacy irqdomain in this version so that we don't have to use these functions to create irq mapping for IPI, PMC and TIMER. Of cause, if you sugguest us to use linear irqdomain, I'll restore them to be what like as last version.

&gt; &gt; 
&gt; &gt; Signed-off-by: Huacai Chen <chenhuacai@...ngson.cn>
&gt; &gt; Signed-off-by: Jianmin Lv <lvjianmin@...ngson.cn>
&gt; &gt; ---
&gt; &gt;  drivers/irqchip/Kconfig                    |  10 ++
&gt; &gt;  drivers/irqchip/Makefile                   |   1 +
&gt; &gt;  drivers/irqchip/irq-loongarch-cpu.c        | 115 +++++++++++++++++
&gt; &gt;  drivers/irqchip/irq-loongarch-pic-common.c | 201 +++++++++++++++++++++++++++++
&gt; 
&gt; One patch per driver, please.
&gt; 
Ok, I'll split them to be seperate patch.

&gt; &gt;  drivers/irqchip/irq-loongarch-pic-common.h |  44 +++++++
&gt; &gt;  5 files changed, 371 insertions(+)
&gt; &gt;  create mode 100644 drivers/irqchip/irq-loongarch-cpu.c
&gt; &gt;  create mode 100644 drivers/irqchip/irq-loongarch-pic-common.c
&gt; &gt;  create mode 100644 drivers/irqchip/irq-loongarch-pic-common.h
&gt; &gt; 
&gt; &gt; diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
&gt; &gt; index 39d6be2..a596ee7 100644
&gt; &gt; --- a/drivers/irqchip/Kconfig
&gt; &gt; +++ b/drivers/irqchip/Kconfig
&gt; &gt; @@ -545,6 +545,16 @@ config EXYNOS_IRQ_COMBINER
&gt; &gt;  	  Say yes here to add support for the IRQ combiner devices embedded
&gt; &gt;  	  in Samsung Exynos chips.
&gt; &gt;  
&gt; &gt; +config IRQ_LOONGARCH_CPU
&gt; &gt; +	bool
&gt; &gt; +	select GENERIC_IRQ_CHIP
&gt; &gt; +	select IRQ_DOMAIN
&gt; &gt; +	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
&gt; &gt; +	help
&gt; &gt; +	  Support for the LoongArch CPU Interrupt Controller. For details of
&gt; &gt; +	  irq chip hierarchy on LoongArch platforms please read the document
&gt; &gt; +	  Documentation/loongarch/irq-chip-model.rst.
&gt; &gt; +
&gt; &gt;  config LOONGSON_LIOINTC
&gt; &gt;  	bool "Loongson Local I/O Interrupt Controller"
&gt; &gt;  	depends on MACH_LOONGSON64
&gt; &gt; diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
&gt; &gt; index 160a1d8..736f030 100644
&gt; &gt; --- a/drivers/irqchip/Makefile
&gt; &gt; +++ b/drivers/irqchip/Makefile
&gt; &gt; @@ -105,6 +105,7 @@ obj-$(CONFIG_LS1X_IRQ)			+= irq-ls1x.o
&gt; &gt;  obj-$(CONFIG_TI_SCI_INTR_IRQCHIP)	+= irq-ti-sci-intr.o
&gt; &gt;  obj-$(CONFIG_TI_SCI_INTA_IRQCHIP)	+= irq-ti-sci-inta.o
&gt; &gt;  obj-$(CONFIG_TI_PRUSS_INTC)		+= irq-pruss-intc.o
&gt; &gt; +obj-$(CONFIG_IRQ_LOONGARCH_CPU)		+= irq-loongarch-cpu.o irq-loongarch-pic-common.o
&gt; &gt;  obj-$(CONFIG_LOONGSON_LIOINTC)		+= irq-loongson-liointc.o
&gt; &gt;  obj-$(CONFIG_LOONGSON_HTPIC)		+= irq-loongson-htpic.o
&gt; &gt;  obj-$(CONFIG_LOONGSON_HTVEC)		+= irq-loongson-htvec.o
&gt; &gt; diff --git a/drivers/irqchip/irq-loongarch-cpu.c b/drivers/irqchip/irq-loongarch-cpu.c
&gt; &gt; new file mode 100644
&gt; &gt; index 0000000..26f948f
&gt; &gt; --- /dev/null
&gt; &gt; +++ b/drivers/irqchip/irq-loongarch-cpu.c
&gt; &gt; @@ -0,0 +1,115 @@
&gt; &gt; +// SPDX-License-Identifier: GPL-2.0
&gt; &gt; +/*
&gt; &gt; + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
&gt; &gt; + */
&gt; &gt; +
&gt; &gt; +#include <linux init.h="">
&gt; &gt; +#include <linux kernel.h="">
&gt; &gt; +#include <linux interrupt.h="">
&gt; &gt; +#include <linux irq.h="">
&gt; &gt; +#include <linux irqchip.h="">
&gt; &gt; +#include <linux irqdomain.h="">
&gt; &gt; +
&gt; &gt; +#include <asm loongarch.h="">
&gt; &gt; +#include <asm setup.h="">
&gt; &gt; +#include "irq-loongarch-pic-common.h"
&gt; &gt; +
&gt; &gt; +static struct irq_domain *irq_domain;
&gt; &gt; +
&gt; &gt; +static void mask_loongarch_irq(struct irq_data *d)
&gt; &gt; +{
&gt; &gt; +	clear_csr_ecfg(ECFGF(d-&gt;hwirq));
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +static void unmask_loongarch_irq(struct irq_data *d)
&gt; &gt; +{
&gt; &gt; +	set_csr_ecfg(ECFGF(d-&gt;hwirq));
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +static struct irq_chip cpu_irq_controller = {
&gt; &gt; +	.name		= "LoongArch",
&gt; &gt; +	.irq_mask	= mask_loongarch_irq,
&gt; &gt; +	.irq_unmask	= unmask_loongarch_irq,
&gt; &gt; +};
&gt; &gt; +
&gt; &gt; +static void handle_cpu_irq(struct pt_regs *regs)
&gt; &gt; +{
&gt; &gt; +	int hwirq;
&gt; &gt; +	unsigned int estat = read_csr_estat() &amp; CSR_ESTAT_IS;
&gt; &gt; +
&gt; &gt; +	while ((hwirq = ffs(estat))) {
&gt; &gt; +		estat &amp;= ~BIT(hwirq - 1);
&gt; &gt; +		generic_handle_domain_irq(irq_domain, hwirq - 1);
&gt; &gt; +	}
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +static int loongarch_cpu_intc_map(struct irq_domain *d, unsigned int irq,
&gt; &gt; +			     irq_hw_number_t hwirq)
&gt; &gt; +{
&gt; &gt; +	irq_set_noprobe(irq);
&gt; &gt; +	irq_set_chip_and_handler(irq, &amp;cpu_irq_controller, handle_percpu_irq);
&gt; &gt; +
&gt; &gt; +	return 0;
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +static const struct irq_domain_ops loongarch_cpu_intc_irq_domain_ops = {
&gt; &gt; +	.map = loongarch_cpu_intc_map,
&gt; &gt; +	.xlate = irq_domain_xlate_onecell,
&gt; &gt; +};
&gt; &gt; +
&gt; &gt; +struct irq_domain * __init loongarch_cpu_irq_init(void)
&gt; &gt; +{
&gt; &gt; +	/* Mask interrupts. */
&gt; &gt; +	clear_csr_ecfg(ECFG0_IM);
&gt; &gt; +	clear_csr_estat(ESTATF_IP);
&gt; &gt; +
&gt; &gt; +	irq_domain = irq_domain_add_legacy(NULL, EXCCODE_INT_NUM, 0, 0,
&gt; &gt; +						&amp;loongarch_cpu_intc_irq_domain_ops, NULL);
&gt; 
&gt; I already commented on this in the past, and my position is still the
&gt; same: this isn't a legacy architecture, you are not converting
&gt; anything from a board file, so there is no reason why you get to use a
&gt; legacy domain.
&gt; 
&gt; Since you are using ACPI, irq_domain_add_*() really is the wrong API,
&gt; as they take an of_node. Use irq_domain_create_linear(), and pass an
&gt; actual fwnode there (there are plenty of examples in the tree).
&gt; 
Sorry, as I mentioned above, the only reason that I use legacy irqdomain here is to avoid to export get_xxx_irq functions for others(like arch files). As you recommend here, I'll recover them in next version.

&gt; &gt; +	if (!irq_domain)
&gt; &gt; +		panic("Failed to add irqdomain for LoongArch CPU");
&gt; &gt; +
&gt; &gt; +	set_handle_irq(&amp;handle_cpu_irq);
&gt; &gt; +
&gt; &gt; +	return irq_domain;
&gt; 
&gt; What uses this irq_domain in the arch code?
&gt; 
Thanks, sure, there is no need to return irq_domain, and I'll change it in next version.

&gt; &gt; +}
&gt; &gt; +#ifdef CONFIG_ACPI
&gt; 
&gt; Why the #ifdef? Isn't this system supposed to be ACPI only? There is
&gt; no DT support anyway, so you should make the driver depend on ACPI and
&gt; that's about it.
&gt; 
Yes, we'll support DT in future(in fatct, DT for the driver has been supported in our internel repo for SOC products) for the driver as other irqchip drivers. Should we delete it now and take it into count later when adding DT supporting?

&gt; &gt; +static int __init
&gt; &gt; +liointc_parse_madt(union acpi_subtable_headers *header,
&gt; &gt; +		       const unsigned long end)
&gt; &gt; +{
&gt; &gt; +	struct acpi_madt_lio_pic *liointc_entry = (struct acpi_madt_lio_pic *)header;
&gt; &gt; +
&gt; &gt; +	return liointc_acpi_init(irq_domain, liointc_entry);
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +static int __init
&gt; &gt; +eiointc_parse_madt(union acpi_subtable_headers *header,
&gt; &gt; +		       const unsigned long end)
&gt; &gt; +{
&gt; &gt; +	struct acpi_madt_eio_pic *eiointc_entry = (struct acpi_madt_eio_pic *)header;
&gt; &gt; +
&gt; &gt; +	return eiointc_acpi_init(irq_domain, eiointc_entry);
&gt; &gt; +}
&gt; &gt; +static int __init acpi_cascade_irqdomain_init(void)
&gt; &gt; +{
&gt; &gt; +	acpi_table_parse_madt(ACPI_MADT_TYPE_LIO_PIC,
&gt; &gt; +			      liointc_parse_madt, 0);
&gt; &gt; +	acpi_table_parse_madt(ACPI_MADT_TYPE_EIO_PIC,
&gt; &gt; +			      eiointc_parse_madt, 0);
&gt; &gt; +	return 0;
&gt; &gt; +}
&gt; &gt; +static int __init coreintc_acpi_init_v1(union acpi_subtable_headers *header,
&gt; &gt; +				   const unsigned long end)
&gt; &gt; +{
&gt; &gt; +	if (irq_domain)
&gt; &gt; +		return 0;
&gt; &gt; +
&gt; &gt; +	init_vector_parent_group();
&gt; &gt; +	loongarch_cpu_irq_init();
&gt; &gt; +	acpi_cascade_irqdomain_init();
&gt; &gt; +	return 0;
&gt; &gt; +}
&gt; &gt; +IRQCHIP_ACPI_DECLARE(coreintc_v1, ACPI_MADT_TYPE_CORE_PIC,
&gt; &gt; +		NULL, ACPI_MADT_CORE_PIC_VERSION_V1,
&gt; &gt; +		coreintc_acpi_init_v1);
&gt; &gt; +#endif
&gt; &gt; diff --git a/drivers/irqchip/irq-loongarch-pic-common.c b/drivers/irqchip/irq-loongarch-pic-common.c
&gt; &gt; new file mode 100644
&gt; &gt; index 0000000..94437e4
&gt; &gt; --- /dev/null
&gt; &gt; +++ b/drivers/irqchip/irq-loongarch-pic-common.c
&gt; &gt; @@ -0,0 +1,201 @@
&gt; &gt; +// SPDX-License-Identifier: GPL-2.0-only
&gt; &gt; +/*
&gt; &gt; + * Copyright (C) 2022 Loongson Limited, All Rights Reserved.
&gt; &gt; + */
&gt; &gt; +
&gt; &gt; +#include <linux irq.h="">
&gt; &gt; +#include <linux acpi.h="">
&gt; &gt; +#include <linux pci.h="">
&gt; &gt; +#include "irq-loongarch-pic-common.h"
&gt; &gt; +
&gt; &gt; +static struct acpi_vector_group vector_group[MAX_IO_PICS];
&gt; &gt; +struct acpi_madt_bio_pic *acpi_pchpic[MAX_IO_PICS];
&gt; &gt; +
&gt; &gt; +struct irq_domain *liointc_domain;
&gt; &gt; +struct irq_domain *pch_lpc_domain;
&gt; &gt; +struct irq_domain *pch_msi_domain[MAX_IO_PICS];
&gt; &gt; +struct irq_domain *pch_pic_domain[MAX_IO_PICS];
&gt; 
&gt; Why isn't this static? If someone needs to know, why isn't there an
&gt; accessor?
&gt; 
These irq_domains will be initialized in other irqchip drivers(e.g. liointc_domain is set in liointc driver).

&gt; 
&gt; &gt; +
&gt; &gt; +static int find_pch_pic(u32 gsi)
&gt; &gt; +{
&gt; &gt; +	int i, start, end;
&gt; &gt; +
&gt; &gt; +	/* Find the PCH_PIC that manages this GSI. */
&gt; &gt; +	for (i = 0; i &lt; MAX_IO_PICS; i++) {
&gt; &gt; +		struct acpi_madt_bio_pic *irq_cfg = acpi_pchpic[i];
&gt; &gt; +
&gt; &gt; +		if (!irq_cfg)
&gt; &gt; +			return -1;
&gt; &gt; +
&gt; &gt; +		start = irq_cfg-&gt;gsi_base;
&gt; &gt; +		end   = irq_cfg-&gt;gsi_base + irq_cfg-&gt;size;
&gt; &gt; +		if (gsi &gt;= start &amp;&amp; gsi &lt; end)
&gt; &gt; +			return i;
&gt; &gt; +	}
&gt; &gt; +
&gt; &gt; +	pr_err("ERROR: Unable to locate PCH_PIC for GSI %d\n", gsi);
&gt; &gt; +	return -1;
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +int pcibios_device_add(struct pci_dev *dev)
&gt; &gt; +{
&gt; &gt; +	int id = pci_domain_nr(dev-&gt;bus);
&gt; &gt; +
&gt; &gt; +	dev_set_msi_domain(&amp;dev-&gt;dev, pch_msi_domain[id]);
&gt; &gt; +
&gt; &gt; +	return 0;
&gt; &gt; +}
&gt; 
&gt; This doesn't belong here at all. Please move it to the PCI code.
&gt; 
Ok, I'll put them into PCI code of arch directory.

&gt; &gt; +
&gt; &gt; +int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
&gt; &gt; +{
&gt; &gt; +	if (irqp != NULL)
&gt; &gt; +		*irqp = acpi_register_gsi(NULL, gsi, -1, -1);
&gt; &gt; +	return (*irqp &gt;= 0) ? 0 : -EINVAL;
&gt; &gt; +}
&gt; &gt; +EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
&gt; &gt; +
&gt; &gt; +int acpi_isa_irq_to_gsi(unsigned int isa_irq, u32 *gsi)
&gt; &gt; +{
&gt; &gt; +	if (gsi)
&gt; &gt; +		*gsi = isa_irq;
&gt; &gt; +	return 0;
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +/*
&gt; &gt; + * success: return IRQ number (&gt;=0)
&gt; &gt; + * failure: return &lt; 0
&gt; &gt; + */
&gt; &gt; +int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
&gt; &gt; +{
&gt; &gt; +	int id;
&gt; &gt; +	struct irq_fwspec fwspec;
&gt; &gt; +
&gt; &gt; +	switch (gsi) {
&gt; &gt; +	case GSI_MIN_CPU_IRQ ... GSI_MAX_CPU_IRQ:
&gt; &gt; +		fwspec.fwnode = liointc_domain-&gt;fwnode;
&gt; &gt; +		fwspec.param[0] = gsi - GSI_MIN_CPU_IRQ;
&gt; &gt; +		fwspec.param_count = 1;
&gt; &gt; +
&gt; &gt; +		return irq_create_fwspec_mapping(&amp;fwspec);
&gt; &gt; +
&gt; &gt; +	case GSI_MIN_LPC_IRQ ... GSI_MAX_LPC_IRQ:
&gt; &gt; +		if (!pch_lpc_domain)
&gt; &gt; +			return -EINVAL;
&gt; &gt; +
&gt; &gt; +		fwspec.fwnode = pch_lpc_domain-&gt;fwnode;
&gt; &gt; +		fwspec.param[0] = gsi - GSI_MIN_LPC_IRQ;
&gt; &gt; +		fwspec.param[1] = acpi_dev_get_irq_type(trigger, polarity);
&gt; &gt; +		fwspec.param_count = 2;
&gt; &gt; +
&gt; &gt; +		return irq_create_fwspec_mapping(&amp;fwspec);
&gt; &gt; +
&gt; &gt; +	case GSI_MIN_PCH_IRQ ... GSI_MAX_PCH_IRQ:
&gt; &gt; +		id = find_pch_pic(gsi);
&gt; &gt; +		if (id &lt; 0)
&gt; &gt; +			return -EINVAL;
&gt; &gt; +
&gt; &gt; +		fwspec.fwnode = pch_pic_domain[id]-&gt;fwnode;
&gt; &gt; +		fwspec.param[0] = gsi - acpi_pchpic[id]-&gt;gsi_base;
&gt; &gt; +		fwspec.param[1] = IRQ_TYPE_LEVEL_HIGH;
&gt; &gt; +		fwspec.param_count = 2;
&gt; &gt; +
&gt; &gt; +		return irq_create_fwspec_mapping(&amp;fwspec);
&gt; &gt; +	}
&gt; 
&gt; So all the complexity here seems to stem from the fact that you deal
&gt; with three ranges of interrupts, managed by three different pieces of
&gt; code?
&gt; 
Yes.

&gt; Other architectures have similar requirements, and don't require to
&gt; re-implement a private version of the ACPI API. Instead, they expose a
&gt; single irqdomain, and deal with the various ranges internally.
&gt; 
&gt; Clearly, not being able to reuse drivers/acpi/irq.c *is* an issue.
&gt; 
Thanks, I agree, that sounds a good and reasonable suggestion, and I'll reserach it further and reuse code from drivers/acpi/irq.c as can as possible.

&gt; &gt; +
&gt; &gt; +	return -EINVAL;
&gt; &gt; +}
&gt; &gt; +EXPORT_SYMBOL_GPL(acpi_register_gsi);
&gt; &gt; +
&gt; &gt; +void acpi_unregister_gsi(u32 gsi)
&gt; &gt; +{
&gt; &gt; +	int id, irq, hw_irq;
&gt; &gt; +	struct irq_domain *d;
&gt; &gt; +
&gt; &gt; +	switch (gsi) {
&gt; &gt; +	case GSI_MIN_CPU_IRQ ... GSI_MAX_CPU_IRQ:
&gt; &gt; +		if (!liointc_domain)
&gt; &gt; +			return;
&gt; &gt; +		d = liointc_domain;
&gt; &gt; +		hw_irq = gsi - GSI_MIN_CPU_IRQ;
&gt; &gt; +		break;
&gt; &gt; +
&gt; &gt; +	case GSI_MIN_LPC_IRQ ... GSI_MAX_LPC_IRQ:
&gt; &gt; +		if (!pch_lpc_domain)
&gt; &gt; +			return;
&gt; &gt; +		d = pch_lpc_domain;
&gt; &gt; +		hw_irq = gsi - GSI_MIN_LPC_IRQ;
&gt; &gt; +		break;
&gt; &gt; +
&gt; &gt; +	case GSI_MIN_PCH_IRQ ... GSI_MAX_PCH_IRQ:
&gt; &gt; +		id = find_pch_pic(gsi);
&gt; &gt; +		if (id &lt; 0)
&gt; &gt; +			return;
&gt; &gt; +		if (!pch_pic_domain[id])
&gt; &gt; +			return;
&gt; &gt; +		d = pch_pic_domain[id];
&gt; &gt; +
&gt; &gt; +		hw_irq = gsi - acpi_pchpic[id]-&gt;gsi_base;
&gt; &gt; +		break;
&gt; &gt; +	}
&gt; &gt; +	irq = irq_find_mapping(d, hw_irq);
&gt; &gt; +	irq_dispose_mapping(irq);
&gt; &gt; +
&gt; &gt; +	return;
&gt; &gt; +}
&gt; &gt; +EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
&gt; &gt; +
&gt; &gt; +static int pci_mcfg_parse(struct acpi_table_header *header)
&gt; &gt; +{
&gt; &gt; +	struct acpi_table_mcfg *mcfg;
&gt; &gt; +	struct acpi_mcfg_allocation *mptr;
&gt; &gt; +	int i, n;
&gt; &gt; +
&gt; &gt; +	if (header-&gt;length &lt; sizeof(struct acpi_table_mcfg))
&gt; &gt; +		return -EINVAL;
&gt; &gt; +
&gt; &gt; +	n = (header-&gt;length - sizeof(struct acpi_table_mcfg)) /
&gt; &gt; +					sizeof(struct acpi_mcfg_allocation);
&gt; &gt; +	mcfg = (struct acpi_table_mcfg *)header;
&gt; &gt; +	mptr = (struct acpi_mcfg_allocation *) &amp;mcfg[1];
&gt; &gt; +
&gt; &gt; +	for (i = 0; i &lt; n; i++, mptr++)
&gt; &gt; +		vector_group[mptr-&gt;pci_segment].node = (mptr-&gt;address &gt;&gt; 44) &amp; 0xf;
&gt; &gt; +
&gt; &gt; +	return 0;
&gt; &gt; +}
&gt; 
&gt; Again, why can't you reuse drivers/acpi/pci_mcfg.c?
&gt; 
Yes, I really want to reuse code from pci_mcfg.c, but I found that pci_mmcfg_late_init() is called from acpi_init during subsys_initcall. vector_group entries here are
needed initialzed during irqchip_init flow before EIOINTC, PCH PIC and PCH MSI initialization as I descripted info 'Example of irqchip topology in a system with  two chipsets' in [PATCH RFC V2 00/10].

&gt; &gt; +
&gt; &gt; +void __init init_vector_parent_group(void)
&gt; &gt; +{
&gt; &gt; +	acpi_table_parse(ACPI_SIG_MCFG, pci_mcfg_parse);
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +void acpi_set_vector_parent(int node, struct irq_domain *parent)
&gt; &gt; +{
&gt; &gt; +	int i;
&gt; &gt; +
&gt; &gt; +	if (cpu_has_flatmode)
&gt; &gt; +		node = cpu_to_node(node * CORES_PER_EIO_NODE);
&gt; &gt; +
&gt; &gt; +	for (i = 0; i &lt; MAX_IO_PICS; i++) {
&gt; &gt; +		if (node == vector_group[i].node) {
&gt; &gt; +			vector_group[i].parent = parent;
&gt; &gt; +			return;
&gt; &gt; +		}
&gt; &gt; +	}
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +struct irq_domain *acpi_get_msi_parent(int index)
&gt; &gt; +{
&gt; &gt; +	return vector_group[index].parent;
&gt; &gt; +}
&gt; &gt; +
&gt; &gt; +struct irq_domain *acpi_get_pch_parent(int node)
&gt; &gt; +{
&gt; &gt; +	int i;
&gt; &gt; +
&gt; &gt; +	for (i = 0; i &lt; MAX_IO_PICS; i++) {
&gt; &gt; +		if (node == vector_group[i].node)
&gt; &gt; +			return vector_group[i].parent;
&gt; &gt; +	}
&gt; &gt; +	return NULL;
&gt; &gt; +}
&gt; &gt; diff --git a/drivers/irqchip/irq-loongarch-pic-common.h b/drivers/irqchip/irq-loongarch-pic-common.h
&gt; &gt; new file mode 100644
&gt; &gt; index 0000000..3815fc9
&gt; &gt; --- /dev/null
&gt; &gt; +++ b/drivers/irqchip/irq-loongarch-pic-common.h
&gt; &gt; @@ -0,0 +1,44 @@
&gt; &gt; +/* SPDX-License-Identifier: GPL-2.0-only */
&gt; &gt; +/*
&gt; &gt; + * Copyright (C) 2022 Loongson Limited, All Rights Reserved.
&gt; &gt; + */
&gt; &gt; +
&gt; &gt; +#ifndef _IRQ_LOONGARCH_PIC_COMMON_H
&gt; &gt; +#define _IRQ_LOONGARCH_PIC_COMMON_H
&gt; &gt; +
&gt; &gt; +#include <linux of.h="">
&gt; &gt; +#include <linux irqdomain.h="">
&gt; &gt; +
&gt; &gt; +struct acpi_vector_group {
&gt; &gt; +	int node;
&gt; &gt; +	struct irq_domain *parent;
&gt; &gt; +};
&gt; &gt; +
&gt; &gt; +/* IRQ number definitions */
&gt; &gt; +#define LOONGSON_LPC_IRQ_BASE		0
&gt; &gt; +#define LOONGSON_CPU_IRQ_BASE		16
&gt; &gt; +#define LOONGSON_PCH_IRQ_BASE		64
&gt; &gt; +
&gt; &gt; +#define GSI_MIN_LPC_IRQ		LOONGSON_LPC_IRQ_BASE
&gt; &gt; +#define GSI_MAX_LPC_IRQ		(LOONGSON_LPC_IRQ_BASE + 16 - 1)
&gt; &gt; +#define GSI_MIN_CPU_IRQ		LOONGSON_CPU_IRQ_BASE
&gt; &gt; +#define GSI_MAX_CPU_IRQ		(LOONGSON_CPU_IRQ_BASE + 48 - 1)
&gt; &gt; +#define GSI_MIN_PCH_IRQ		LOONGSON_PCH_IRQ_BASE
&gt; &gt; +#define GSI_MAX_PCH_IRQ		(LOONGSON_PCH_IRQ_BASE + 256 - 1)
&gt; &gt; +
&gt; &gt; +extern struct acpi_madt_bio_pic *acpi_pchpic[MAX_IO_PICS];
&gt; &gt; +extern struct irq_domain *liointc_domain;
&gt; &gt; +extern struct irq_domain *pch_lpc_domain;
&gt; &gt; +extern struct irq_domain *pch_msi_domain[MAX_IO_PICS];
&gt; &gt; +extern struct irq_domain *pch_pic_domain[MAX_IO_PICS];
&gt; &gt; +
&gt; &gt; +int liointc_acpi_init(struct irq_domain *parent, struct acpi_madt_lio_pic *acpi_liointc);
&gt; &gt; +int eiointc_acpi_init(struct irq_domain *parent, struct acpi_madt_eio_pic *acpi_eiointc);
&gt; &gt; +int htvec_acpi_init(struct irq_domain *parent, struct acpi_madt_ht_pic *acpi_htvec);
&gt; &gt; +int pch_lpc_acpi_init(struct irq_domain *parent, struct acpi_madt_lpc_pic *acpi_pchlpc);
&gt; &gt; +void init_vector_parent_group(void);
&gt; &gt; +void acpi_set_vector_parent(int node, struct irq_domain *parent);
&gt; &gt; +struct irq_domain *acpi_get_msi_parent(int index);
&gt; &gt; +struct irq_domain *acpi_get_pch_parent(int node);
&gt; &gt; +
&gt; &gt; +#endif /* _IRQ_LOONGARCH_PIC_COMMON_H */
&gt; &gt; -- 
&gt; &gt; 1.8.3.1
&gt; &gt; 
&gt; &gt; 
&gt; 
&gt; Thanks,
&gt; 
&gt; 	M.
&gt; 
&gt; -- 
&gt; Without deviation from the norm, progress is not possible.
</linux></linux></linux></linux></linux></asm></asm></linux></linux></linux></linux></linux></linux></lvjianmin@...ngson.cn></chenhuacai@...ngson.cn></lvjianmin@...ngson.cn></chenhuacai@...ngson.cn></jiaxun.yang@...goat.com></chenhuacai@...il.com></lixuefeng@...ngson.cn></tglx@...utronix.de></lvjianmin@...ngson.cn></maz@...nel.org>

本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。 
This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it. 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ