All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Guo <dongtai.guo@linux.dev>
To: chenhuacai@kernel.org, jiaxun.yang@flygoat.com, tglx@kernel.org
Cc: linux-kernel@vger.kernel.org, George Guo <guodongtai@kylinos.cn>,
	stable@vger.kernel.org, Kexin Liu <liukexin@kylinos.cn>
Subject: [PATCH 1/1] irqchip/loongson-pch-pic: Fix vec_count reading for 32-bit and 64-bit
Date: Fri, 10 Apr 2026 09:30:53 +0800	[thread overview]
Message-ID: <20260410013053.3877-1-dongtai.guo@linux.dev> (raw)

From: George Guo <guodongtai@kylinos.cn>

Commit 0370a5e740f2 ("irqchip/loongson-pch-pic: Adjust irqchip driver for
32BIT/64BIT") changed vec_count reading from readq() to readl() to support
both 32-bit and 64-bit platforms. However, on virtual 64-bit platforms
(QEMU 8.2.0) this causes incorrect vec_count value, leading to panic:

WARNING: drivers/acpi/irq.c:63 at acpi_register_gsi+0xe8/0x108
Call Trace:
[<900000000024c634>] show_stack+0x64/0x188
[<9000000000245154>] dump_stack_lvl+0x6c/0x9c
[<900000000026cb38>] __warn+0x98/0x200
[<90000000016dc900>] __report_bug+0xa8/0x1c0
[<90000000016dcb0c>] report_bug+0x3c/0xc0
[<90000000017170b0>] do_bp+0x270/0x3c0
[<900000000024aba8>] handle_bp+0x128/0x1e0
[<9000000000def7a0>] acpi_register_gsi+0xe8/0x108
[<9000000000ddcc5c>] acpi_dev_resource_interrupt+0x2f4/0x348
[<9000000000e43ad0>] pnpacpi_allocated_resource+0xc8/0x398
[<9000000000e1d608>] acpi_walk_resource_buffer+0x88/0x168
[<9000000000e1dbec>] acpi_walk_resources+0x13c/0x178
[<9000000000e43df0>] pnpacpi_parse_allocated_resource+0x50/0xc8
[<9000000001778b00>] pnpacpi_add_device.isra.0+0x208/0x2e4
[<9000000001778c10>] pnpacpi_add_device_handler+0x34/0x54
[<9000000000e14fac>] acpi_ns_get_device_callback+0x15c/0x2c8
[<9000000000e14bc4>] acpi_ns_walk_namespace+0x134/0x2d0
[<9000000000e14e28>] acpi_get_devices+0xc8/0xf0
[<9000000001778878>] pnpacpi_init+0x68/0x9c
[<9000000000248e7c>] do_one_initcall+0x6c/0x4b0
[<9000000001731aa0>] do_initcalls+0x118/0x160
[<9000000001731ca4>] kernel_init_freeable+0x148/0x1a4
[<900000000171a294>] kernel_init+0x24/0x130
[<9000000001717358>] ret_from_kernel_thread+0x28/0x150
[<900000000024a24c>] ret_from_kernel_thread_asm+0xc/0xa0
GSI: No registered irqchip, giving up

Fix this by using readq() on 64-bit and readl() on 32-bit platforms.

Fixes: 0370a5e740f2 ("irqchip/loongson-pch-pic: Adjust irqchip driver for 32BIT/64BIT")
Cc: stable@vger.kernel.org
Tested-by: Kexin Liu <liukexin@kylinos.cn>
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 drivers/irqchip/irq-loongson-pch-pic.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-loongson-pch-pic.c b/drivers/irqchip/irq-loongson-pch-pic.c
index 98fc1770e2a5..eb25d482a4c5 100644
--- a/drivers/irqchip/irq-loongson-pch-pic.c
+++ b/drivers/irqchip/irq-loongson-pch-pic.c
@@ -343,7 +343,12 @@ static int pch_pic_init(phys_addr_t addr, unsigned long size, int vec_base,
 		priv->table[i] = PIC_UNDEF_VECTOR;
 
 	priv->ht_vec_base = vec_base;
-	priv->vec_count = ((readl(priv->base + 4) >> 16) & 0xff) + 1;
+
+	if (IS_ENABLED(CONFIG_64BIT))
+		priv->vec_count = ((readq(priv->base) >> 48) & 0xff) + 1;
+	else
+		priv->vec_count = ((readl(priv->base + 4) >> 16) & 0xff) + 1;
+
 	priv->gsi_base = gsi_base;
 
 	priv->pic_domain = irq_domain_create_hierarchy(parent_domain, 0,
-- 
2.43.0


             reply	other threads:[~2026-04-10  1:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10  1:30 George Guo [this message]
2026-04-10 15:02 ` [PATCH 1/1] irqchip/loongson-pch-pic: Fix vec_count reading for 32-bit and 64-bit Thomas Gleixner
2026-04-11  9:16   ` 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=20260410013053.3877-1-dongtai.guo@linux.dev \
    --to=dongtai.guo@linux.dev \
    --cc=chenhuacai@kernel.org \
    --cc=guodongtai@kylinos.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liukexin@kylinos.cn \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.