Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/loongson-pch-pic: Fix initialization of HT vector register

In an ACPI-based dual-bridge system, IRQ of each bridge's
PCH PIC sent to CPU is always a zero-based number, which
means that the IRQ on PCH PIC of each bridge is mapped into
vector range from 0 to 63 of upstream irqchip(e.g. EIOINTC).

EIOINTC N: [0 ... 63 | 64 ... 255]
-------- ----------
^ ^
| |
PCH PIC N |
PCH MSI N

For example, the IRQ vector number of sata controller on
PCH PIC of each bridge is 16, which is sent to upstream
irqchip of EIOINTC when an interrupt occurs, which will set
bit 16 of EIOINTC. Since hwirq of 16 on EIOINTC has been
mapped to a irq_desc for sata controller during hierarchy
irq allocation, the related mapped IRQ will be found through
irq_resolve_mapping() in the IRQ domain of EIOINTC.

So, the IRQ number set in HT vector register should be fixed
to be a zero-based number.

Cc: stable@vger.kernel.org
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Co-developed-by: liuyun <liuyun@loongson.cn>
Signed-off-by: liuyun <liuyun@loongson.cn>
Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230614115936.5950-2-lvjianmin@loongson.cn

authored by

Jianmin Lv and committed by
Marc Zyngier
f6796165 7877cb91

+2 -4
+2 -4
drivers/irqchip/irq-loongson-pch-pic.c
··· 401 401 int __init pch_pic_acpi_init(struct irq_domain *parent, 402 402 struct acpi_madt_bio_pic *acpi_pchpic) 403 403 { 404 - int ret, vec_base; 404 + int ret; 405 405 struct fwnode_handle *domain_handle; 406 406 407 407 if (find_pch_pic(acpi_pchpic->gsi_base) >= 0) 408 408 return 0; 409 - 410 - vec_base = acpi_pchpic->gsi_base - GSI_MIN_PCH_IRQ; 411 409 412 410 domain_handle = irq_domain_alloc_fwnode(&acpi_pchpic->address); 413 411 if (!domain_handle) { ··· 414 416 } 415 417 416 418 ret = pch_pic_init(acpi_pchpic->address, acpi_pchpic->size, 417 - vec_base, parent, domain_handle, acpi_pchpic->gsi_base); 419 + 0, parent, domain_handle, acpi_pchpic->gsi_base); 418 420 419 421 if (ret < 0) { 420 422 irq_domain_free_fwnode(domain_handle);