From: Chao Liu <chao.liu.zevorn@gmail.com>
To: Jim Shu <jim.shu@sifive.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Weiwei Li <liwei1518@gmail.com>,
Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
Subject: Re: [PATCH 1/4] hw/intc: riscv_aplic: Fix level trigger IRQ in direct delivery mode
Date: Tue, 19 May 2026 05:56:55 +0800 [thread overview]
Message-ID: <aguLERu7U_cWgVLK@ChaodeMBP.bbrouter> (raw)
In-Reply-To: <20260428160103.3551125-2-jim.shu@sifive.com>
On Wed, Apr 29, 2026 at 12:01:00AM +0800, Jim Shu wrote:
> According to the AIA spec ch4.7 ("Precise effects on interrupt-pending
> bits"), pending bit of APLIC should be set/cleared whenever the
> rectified input value is high/low in the both level-trigger mode
> and direct delivery mode.
>
> Currently, QEMU APLIC only clears the pending bit when interrupt is
> claimed in APLIC, but not clears it when the rectified input value is
> low. (e.g. IRQ source signal is low in the LEVEL_HIGH/Level1 mode).
> The software may receive an additional IRQ if the peripheral
> triggers one after the software clears the APLIC IRQ but before it
> clears the peripheral's IRQ.
>
> Thus, we also clear the pending bit via the rectified input value in the
> level-trigger mode.
>
> This change doesn't affect MSI delivery mode. Calling
> riscv_aplic_msi_irq_update() when IRQ pending is low will do nothing.
>
> Signed-off-by: Jim Shu <jim.shu@sifive.com>
Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>
Thanks,
Chao
> ---
> hw/intc/riscv_aplic.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
> index 8f700431114..791e0b01b96 100644
> --- a/hw/intc/riscv_aplic.c
> +++ b/hw/intc/riscv_aplic.c
> @@ -591,14 +591,14 @@ static void riscv_aplic_request(void *opaque, int irq, int level)
> }
> break;
> case APLIC_SOURCECFG_SM_LEVEL_HIGH:
> - if ((level > 0) && !(state & APLIC_ISTATE_PENDING)) {
> - riscv_aplic_set_pending_raw(aplic, irq, true);
> + if ((level > 0) != !!(state & APLIC_ISTATE_PENDING)) {
> + riscv_aplic_set_pending_raw(aplic, irq, level > 0);
> update = true;
> }
> break;
> case APLIC_SOURCECFG_SM_LEVEL_LOW:
> - if ((level <= 0) && !(state & APLIC_ISTATE_PENDING)) {
> - riscv_aplic_set_pending_raw(aplic, irq, true);
> + if ((level <= 0) != !!(state & APLIC_ISTATE_PENDING)) {
> + riscv_aplic_set_pending_raw(aplic, irq, level <= 0);
> update = true;
> }
> break;
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-05-18 21:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 16:00 [PATCH 0/4] Minor fixes and enhancements of RISC-V AIA devices Jim Shu
2026-04-28 16:01 ` [PATCH 1/4] hw/intc: riscv_aplic: Fix level trigger IRQ in direct delivery mode Jim Shu
2026-05-18 12:20 ` Daniel Henrique Barboza
2026-05-18 21:56 ` Chao Liu [this message]
2026-04-28 16:01 ` [PATCH 2/4] hw/intc: riscv_aplic: Add reset API to APLIC Jim Shu
2026-05-18 12:20 ` Daniel Henrique Barboza
2026-04-28 16:01 ` [PATCH 3/4] hw/intc: riscv_imsic: Add reset API to IMSIC Jim Shu
2026-05-18 12:20 ` Daniel Henrique Barboza
2026-04-28 16:01 ` [PATCH 4/4] hw/intc: riscv_aplic: add trace events of APLIC read/write function Jim Shu
2026-05-18 12:20 ` Daniel Henrique Barboza
2026-05-19 4:46 ` [PATCH 0/4] Minor fixes and enhancements of RISC-V AIA devices Alistair Francis
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=aguLERu7U_cWgVLK@ChaodeMBP.bbrouter \
--to=chao.liu.zevorn@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=jim.shu@sifive.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/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.