From: Peter Maydell <peter.maydell@linaro.org>
To: "Inès Varhol" <ines.varhol@telecom-paris.fr>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
"Arnaud Minier" <arnaud.minier@telecom-paris.fr>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH 2/3] hw/misc: In STM32L4x5 EXTI, handle direct line interrupts
Date: Mon, 20 May 2024 15:30:23 +0100 [thread overview]
Message-ID: <CAFEAcA_tPLe7_rzmzOds7wAEFaP7Npk_4WqoBACC6nUTWTBfGw@mail.gmail.com> (raw)
In-Reply-To: <20240512102013.211127-3-ines.varhol@telecom-paris.fr>
On Sun, 12 May 2024 at 11:20, Inès Varhol <ines.varhol@telecom-paris.fr> wrote:
>
> The previous implementation for EXTI interrupts only handled
> "configurable" interrupts, like those originating from STM32L4x5 SYSCFG
> (the only device currently connected to the EXTI up until now).
> In order to connect STM32L4x5 USART to the EXTI, this commit adds
> handling for direct interrupts (interrupts without configurable edge),
> as well as a comment that will be useful to connect other devices to the
> EXTI.
>
> Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
> ---
> hw/misc/stm32l4x5_exti.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/hw/misc/stm32l4x5_exti.c b/hw/misc/stm32l4x5_exti.c
> index eebefc6cd3..1817bbdad2 100644
> --- a/hw/misc/stm32l4x5_exti.c
> +++ b/hw/misc/stm32l4x5_exti.c
> @@ -106,6 +106,27 @@ static void stm32l4x5_exti_set_irq(void *opaque, int irq, int level)
> return;
> }
>
> + /* In case of a direct line interrupt */
> + if (extract32(exti_romask[bank], irq, 1)) {
> + if (level) {
> + qemu_irq_raise(s->irq[oirq]);
> + } else {
> + qemu_irq_lower(s->irq[oirq]);
> + }
You can say this more concisely as
qemu_set_irq(s->irq[oirq], level);
> + return;
> + }
> +
> + /*
> + * In case of a configurable interrupt
> + *
> + * Note that while the real EXTI uses edge detection to tell
> + * apart a line rising (the level changes from 0 to 1) and a line
> + * staying high (the level was 1 and is set to 1), the current
> + * implementation relies on the fact that this handler will only
> + * be called when there's a level change. That means that the
> + * devices creating a configurable interrupt (like STM32L4x5 GPIO)
> + * have to set their IRQs only on a change.
> + */
You cannot rely on this in QEMU's qemu_irq API. The set
function may be called multiple times with the same input
level value. If you need to detect rising edges then this
device needs to have a state field that records the current
value so it can compare the 'level' argument here against
what it was previously.
> if (((1 << irq) & s->rtsr[bank]) && level) {
> /* Rising Edge */
> s->pr[bank] |= 1 << irq;
> @@ -116,7 +137,7 @@ static void stm32l4x5_exti_set_irq(void *opaque, int irq, int level)
> qemu_irq_pulse(s->irq[oirq]);
> }
> /*
> - * In the following situations :
> + * In the following situations (for configurable interrupts) :
> * - falling edge but rising trigger selected
> * - rising edge but falling trigger selected
> * - no trigger selected
thanks
-- PMM
next prev parent reply other threads:[~2024-05-20 14:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-12 10:19 [PATCH 0/3] Connect STM32L4x5 USART devices to the EXTI Inès Varhol
2024-05-12 10:19 ` [PATCH 1/3] hw/misc: In STM32L4x5 EXTI, consolidate 2 constants Inès Varhol
2024-05-20 14:30 ` Peter Maydell
2024-05-12 10:19 ` [PATCH 2/3] hw/misc: In STM32L4x5 EXTI, handle direct line interrupts Inès Varhol
2024-05-20 14:30 ` Peter Maydell [this message]
2024-05-12 10:19 ` [PATCH 3/3] hw/arm: In STM32L4x5 SOC, connect USART devices to EXTI Inès Varhol
2024-05-20 14:31 ` Peter Maydell
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=CAFEAcA_tPLe7_rzmzOds7wAEFaP7Npk_4WqoBACC6nUTWTBfGw@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=arnaud.minier@telecom-paris.fr \
--cc=ines.varhol@telecom-paris.fr \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).