All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@linux.ibm.com>
To: Matheus Ferst <matheus.ferst@eldorado.org.br>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: clg@kaod.org, danielhb413@gmail.com, david@gibson.dropbear.id.au,
	groug@kaod.org, fbarrat@linux.ibm.com, alex.bennee@linaro.org,
	Matheus Ferst <matheus.ferst@eldorado.org.br>
Subject: Re: [RFC PATCH 03/13] target/ppc: move interrupt masking out of ppc_hw_interrupt
Date: Mon, 15 Aug 2022 17:09:15 -0300	[thread overview]
Message-ID: <87a6856zh0.fsf@linux.ibm.com> (raw)
In-Reply-To: <20220815162020.2420093-4-matheus.ferst@eldorado.org.br>

Matheus Ferst <matheus.ferst@eldorado.org.br> writes:

> Move the interrupt masking logic to a new method, ppc_pending_interrupt,
> and only handle the interrupt processing in ppc_hw_interrupt.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
>  target/ppc/excp_helper.c | 228 ++++++++++++++++++++++++---------------
>  1 file changed, 141 insertions(+), 87 deletions(-)
>
> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c

<snip>

> @@ -1884,15 +1915,38 @@ bool ppc_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
>  {
>      PowerPCCPU *cpu = POWERPC_CPU(cs);
>      CPUPPCState *env = &cpu->env;
> +    int pending_interrupt;

I would give this a simpler name to avoid confusion with the other two
pending_interrupt terms.

>  
> -    if (interrupt_request & CPU_INTERRUPT_HARD) {
> -        ppc_hw_interrupt(env);
> -        if (env->pending_interrupts == 0) {
> -            cs->interrupt_request &= ~CPU_INTERRUPT_HARD;
> -        }
> -        return true;
> +    if ((interrupt_request & CPU_INTERRUPT_HARD) == 0) {
> +        return false;
>      }
> -    return false;
> +

It seems we're assuming that after this point we certainly have some
pending interrupt...

> +    pending_interrupt = ppc_pending_interrupt(env);
> +    if (pending_interrupt == 0) {

...but how then is this able to return 0? Could the function's name be
made a bit clearer? Maybe interrupt = ppc_next_pending_interrupt or
something to that effect.

> +        if (env->resume_as_sreset) {
> +            /*
> +             * This is a bug ! It means that has_work took us out of halt
> +             * without anything to deliver while in a PM state that requires
> +             * getting out via a 0x100
> +             *
> +             * This means we will incorrectly execute past the power management
> +             * instruction instead of triggering a reset.
> +             *
> +             * It generally means a discrepancy between the wakeup conditions in
> +             * the processor has_work implementation and the logic in this
> +             * function.
> +             */
> +            cpu_abort(env_cpu(env),
> +                      "Wakeup from PM state but interrupt Undelivered");

This condition is BookS only. Perhaps it would be better to move it
inside each of the processor-specific functions. And since you're
merging has_work with pending_interrupts, can't you solve that issue
earlier? Specifically the "has_work tooks us out of halt..." part.

> +        }
> +        return false;
> +    }
> +
> +    ppc_hw_interrupt(env, pending_interrupt);

Some verbs would be nice. ppc_deliver_interrupt?

> +    if (env->pending_interrupts == 0) {
> +        cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
> +    }
> +    return true;
>  }
>  
>  #endif /* !CONFIG_USER_ONLY */


  reply	other threads:[~2022-08-15 20:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 16:20 [RFC PATCH 00/13] PowerPC interrupt rework Matheus Ferst
2022-08-15 16:20 ` [RFC PATCH 01/13] target/ppc: define PPC_INTERRUPT_* values directly Matheus Ferst
2022-08-18  2:18   ` David Gibson
2022-08-15 16:20 ` [RFC PATCH 02/13] target/ppc: always use ppc_set_irq to set env->pending_interrupts Matheus Ferst
2022-08-15 16:20 ` [RFC PATCH 03/13] target/ppc: move interrupt masking out of ppc_hw_interrupt Matheus Ferst
2022-08-15 20:09   ` Fabiano Rosas [this message]
2022-08-17 13:42     ` Matheus K. Ferst
2022-08-19 14:18       ` Fabiano Rosas
2022-08-15 16:20 ` [RFC PATCH 04/13] target/ppc: prepare to split ppc_interrupt_pending by excp_model Matheus Ferst
2022-08-15 20:25   ` Fabiano Rosas
2022-08-17 13:42     ` Matheus K. Ferst
2022-08-15 16:20 ` [RFC PATCH 05/13] target/ppc: create an interrupt masking method for POWER9/POWER10 Matheus Ferst
2022-08-15 22:39   ` Fabiano Rosas
2022-08-17 13:43     ` Matheus K. Ferst
2022-08-15 16:20 ` [RFC PATCH 06/13] target/ppc: remove embedded interrupts from ppc_pending_interrupt_p9 Matheus Ferst
2022-08-15 21:23   ` Fabiano Rosas
2022-08-17 13:44     ` Matheus K. Ferst
2022-08-19 16:04       ` Fabiano Rosas
2022-08-15 16:20 ` [RFC PATCH 07/13] target/ppc: create an interrupt masking method for POWER8 Matheus Ferst
2022-08-15 16:20 ` [RFC PATCH 08/13] target/ppc: remove unused interrupts from ppc_pending_interrupt_p8 Matheus Ferst
2022-08-15 16:20 ` [RFC PATCH 09/13] target/ppc: create an interrupt masking method for POWER7 Matheus Ferst
2022-08-15 16:20 ` [RFC PATCH 10/13] target/ppc: remove unused interrupts from ppc_pending_interrupt_p7 Matheus Ferst
2022-08-15 16:20 ` [RFC PATCH 11/13] target/ppc: remove ppc_store_lpcr from CONFIG_USER_ONLY builds Matheus Ferst
2022-08-15 16:20 ` [RFC PATCH 12/13] target/ppc: introduce ppc_maybe_interrupt Matheus Ferst
2022-08-15 16:20 ` [RFC PATCH 13/13] target/ppc: unify cpu->has_work based on cs->interrupt_request Matheus Ferst
2022-08-15 20:02 ` [RFC PATCH 00/13] PowerPC interrupt rework Cédric Le Goater
2022-08-17 13:42   ` Matheus K. Ferst

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=87a6856zh0.fsf@linux.ibm.com \
    --to=farosas@linux.ibm.com \
    --cc=alex.bennee@linaro.org \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=fbarrat@linux.ibm.com \
    --cc=groug@kaod.org \
    --cc=matheus.ferst@eldorado.org.br \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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.