All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: Nikita Novikov <n.novikov@syntacore.com>, qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	Weiwei Li <liwei1518@gmail.com>,
	Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
Subject: Re: [PATCH 2/2] hw/intc/riscv_aplic: Factor out source_active() and remove duplicate checks
Date: Thu, 30 Oct 2025 10:19:45 -0300	[thread overview]
Message-ID: <8200a695-2f99-4d08-a245-7fa9ea0ebb9d@ventanamicro.com> (raw)
In-Reply-To: <20251029-n-novikov-aplic_aia_ro-v1-2-39fec74c918a@syntacore.com>



On 10/29/25 4:17 AM, Nikita Novikov wrote:
> Refactor the APLIC code to consolidate repeated conditions checking
> whether an interrupt source is valid, delegated, or inactive.
> 
> Signed-off-by: Nikita Novikov <n.novikov@syntacore.com>
> ---


Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>

>   hw/intc/riscv_aplic.c | 44 +++++++-------------------------------------
>   1 file changed, 7 insertions(+), 37 deletions(-)
> 
> diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
> index 8c3b16074cd3ca1bc3004cfaaa13f34b8860bd48..ccfbc9b4656f3e2a69eb5bcd1cee9e5762020351 100644
> --- a/hw/intc/riscv_aplic.c
> +++ b/hw/intc/riscv_aplic.c
> @@ -216,22 +216,13 @@ static inline bool riscv_aplic_source_active(RISCVAPLICState *aplic,
>   static bool riscv_aplic_irq_rectified_val(RISCVAPLICState *aplic,
>                                             uint32_t irq)
>   {
> -    uint32_t sourcecfg, sm, raw_input, irq_inverted;
> +    uint32_t sm, raw_input, irq_inverted;
>   
> -    if (!irq || aplic->num_irqs <= irq) {
> -        return false;
> -    }
> -
> -    sourcecfg = aplic->sourcecfg[irq];
> -    if (sourcecfg & APLIC_SOURCECFG_D) {
> -        return false;
> -    }
> -
> -    sm = sourcecfg & APLIC_SOURCECFG_SM_MASK;
> -    if (sm == APLIC_SOURCECFG_SM_INACTIVE) {
> +    if (!riscv_aplic_source_active(aplic, irq)) {
>           return false;
>       }
>   
> +    sm = aplic->sourcecfg[irq] & APLIC_SOURCECFG_SM_MASK;
>       raw_input = (aplic->state[irq] & APLIC_ISTATE_INPUT) ? 1 : 0;
>       irq_inverted = (sm == APLIC_SOURCECFG_SM_LEVEL_LOW ||
>                       sm == APLIC_SOURCECFG_SM_EDGE_FALL) ? 1 : 0;
> @@ -284,22 +275,13 @@ static void riscv_aplic_set_pending_raw(RISCVAPLICState *aplic,
>   static void riscv_aplic_set_pending(RISCVAPLICState *aplic,
>                                       uint32_t irq, bool pending)
>   {
> -    uint32_t sourcecfg, sm;
> +    uint32_t sm;
>   
> -    if ((irq <= 0) || (aplic->num_irqs <= irq)) {
> -        return;
> -    }
> -
> -    sourcecfg = aplic->sourcecfg[irq];
> -    if (sourcecfg & APLIC_SOURCECFG_D) {
> -        return;
> -    }
> -
> -    sm = sourcecfg & APLIC_SOURCECFG_SM_MASK;
> -    if (sm == APLIC_SOURCECFG_SM_INACTIVE) {
> +    if (!riscv_aplic_source_active(aplic, irq)) {
>           return;
>       }
>   
> +    sm = aplic->sourcecfg[irq] & APLIC_SOURCECFG_SM_MASK;
>       if ((sm == APLIC_SOURCECFG_SM_LEVEL_HIGH) ||
>           (sm == APLIC_SOURCECFG_SM_LEVEL_LOW)) {
>           if (!aplic->msimode) {
> @@ -370,19 +352,7 @@ static void riscv_aplic_set_enabled_raw(RISCVAPLICState *aplic,
>   static void riscv_aplic_set_enabled(RISCVAPLICState *aplic,
>                                       uint32_t irq, bool enabled)
>   {
> -    uint32_t sourcecfg, sm;
> -
> -    if ((irq <= 0) || (aplic->num_irqs <= irq)) {
> -        return;
> -    }
> -
> -    sourcecfg = aplic->sourcecfg[irq];
> -    if (sourcecfg & APLIC_SOURCECFG_D) {
> -        return;
> -    }
> -
> -    sm = sourcecfg & APLIC_SOURCECFG_SM_MASK;
> -    if (sm == APLIC_SOURCECFG_SM_INACTIVE) {
> +    if (!riscv_aplic_source_active(aplic, irq)) {
>           return;
>       }
>   
> 



  reply	other threads:[~2025-10-30 13:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29  7:17 [PATCH 0/2] hw/intc/riscv_aplic: Expand AIA target[i] source handling and refactor related code Nikita Novikov
2025-10-29  7:17 ` [PATCH 1/2] hw/intc/riscv_aplic: Expand inactive source handling for AIA target[i] Nikita Novikov
2025-10-30 13:19   ` Daniel Henrique Barboza
2025-11-12  0:55   ` Alistair Francis
2025-10-29  7:17 ` [PATCH 2/2] hw/intc/riscv_aplic: Factor out source_active() and remove duplicate checks Nikita Novikov
2025-10-30 13:19   ` Daniel Henrique Barboza [this message]
2025-11-12  0:57   ` Alistair Francis
2025-11-12  1:06 ` [PATCH 0/2] hw/intc/riscv_aplic: Expand AIA target[i] source handling and refactor related code 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=8200a695-2f99-4d08-a245-7fa9ea0ebb9d@ventanamicro.com \
    --to=dbarboza@ventanamicro.com \
    --cc=alistair.francis@wdc.com \
    --cc=liwei1518@gmail.com \
    --cc=n.novikov@syntacore.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.