qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ppc/spapr: re-assert IRQs during event-scan if there are pending
@ 2020-10-15 21:03 Laurent Vivier
  2020-10-15 22:29 ` Greg Kurz
  2020-10-15 23:58 ` David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: Laurent Vivier @ 2020-10-15 21:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, qemu-ppc, David Gibson

If we hotplug a CPU during the first second of the kernel boot,
the IRQ can be sent to the kernel while the RTAS event handler
is not installed. The event is queued, but the kernel doesn't
collect it and ignores the new CPU.

As the code relies on edge-triggered IRQ, we can re-assert it
during the event-scan RTAS call if there are still pending
events (as it is already done in check-exception).

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/ppc/spapr_events.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 1069d0197b4f..1add53547ec3 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -1000,10 +1000,22 @@ static void event_scan(PowerPCCPU *cpu, SpaprMachineState *spapr,
                        target_ulong args,
                        uint32_t nret, target_ulong rets)
 {
+    int i;
     if (nargs != 4 || nret != 1) {
         rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
         return;
     }
+
+    for (i = 0; i < EVENT_CLASS_MAX; i++) {
+        if (rtas_event_log_contains(EVENT_CLASS_MASK(i))) {
+            const SpaprEventSource *source =
+                spapr_event_sources_get_source(spapr->event_sources, i);
+
+            g_assert(source->enabled);
+            qemu_irq_pulse(spapr_qirq(spapr, source->irq));
+        }
+    }
+
     rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
 }
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ppc/spapr: re-assert IRQs during event-scan if there are pending
  2020-10-15 21:03 [PATCH] ppc/spapr: re-assert IRQs during event-scan if there are pending Laurent Vivier
@ 2020-10-15 22:29 ` Greg Kurz
  2020-10-15 23:58 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kurz @ 2020-10-15 22:29 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-ppc, qemu-devel, David Gibson

On Thu, 15 Oct 2020 23:03:18 +0200
Laurent Vivier <lvivier@redhat.com> wrote:

> If we hotplug a CPU during the first second of the kernel boot,
> the IRQ can be sent to the kernel while the RTAS event handler
> is not installed. The event is queued, but the kernel doesn't
> collect it and ignores the new CPU.
> 
> As the code relies on edge-triggered IRQ, we can re-assert it
> during the event-scan RTAS call if there are still pending
> events (as it is already done in check-exception).
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---

Any BugId to share ?

>  hw/ppc/spapr_events.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
> index 1069d0197b4f..1add53547ec3 100644
> --- a/hw/ppc/spapr_events.c
> +++ b/hw/ppc/spapr_events.c
> @@ -1000,10 +1000,22 @@ static void event_scan(PowerPCCPU *cpu, SpaprMachineState *spapr,
>                         target_ulong args,
>                         uint32_t nret, target_ulong rets)
>  {
> +    int i;
>      if (nargs != 4 || nret != 1) {
>          rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
>          return;
>      }
> +
> +    for (i = 0; i < EVENT_CLASS_MAX; i++) {
> +        if (rtas_event_log_contains(EVENT_CLASS_MASK(i))) {
> +            const SpaprEventSource *source =
> +                spapr_event_sources_get_source(spapr->event_sources, i);
> +
> +            g_assert(source->enabled);
> +            qemu_irq_pulse(spapr_qirq(spapr, source->irq));
> +        }
> +    }
> +

This looks good but any reason for not putting this in a function called by
both event_scan() and check_exception() ?

Anyway, this can be done as a follow-up:

Reviewed-by: Greg Kurz <groug@kaod.org>

>      rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
>  }
>  



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ppc/spapr: re-assert IRQs during event-scan if there are pending
  2020-10-15 21:03 [PATCH] ppc/spapr: re-assert IRQs during event-scan if there are pending Laurent Vivier
  2020-10-15 22:29 ` Greg Kurz
@ 2020-10-15 23:58 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2020-10-15 23:58 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

On Thu, Oct 15, 2020 at 11:03:18PM +0200, Laurent Vivier wrote:
> If we hotplug a CPU during the first second of the kernel boot,
> the IRQ can be sent to the kernel while the RTAS event handler
> is not installed. The event is queued, but the kernel doesn't
> collect it and ignores the new CPU.
> 
> As the code relies on edge-triggered IRQ, we can re-assert it
> during the event-scan RTAS call if there are still pending
> events (as it is already done in check-exception).
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Applied to ppc-for-5.2.

> ---
>  hw/ppc/spapr_events.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
> index 1069d0197b4f..1add53547ec3 100644
> --- a/hw/ppc/spapr_events.c
> +++ b/hw/ppc/spapr_events.c
> @@ -1000,10 +1000,22 @@ static void event_scan(PowerPCCPU *cpu, SpaprMachineState *spapr,
>                         target_ulong args,
>                         uint32_t nret, target_ulong rets)
>  {
> +    int i;
>      if (nargs != 4 || nret != 1) {
>          rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
>          return;
>      }
> +
> +    for (i = 0; i < EVENT_CLASS_MAX; i++) {
> +        if (rtas_event_log_contains(EVENT_CLASS_MASK(i))) {
> +            const SpaprEventSource *source =
> +                spapr_event_sources_get_source(spapr->event_sources, i);
> +
> +            g_assert(source->enabled);
> +            qemu_irq_pulse(spapr_qirq(spapr, source->irq));
> +        }
> +    }
> +
>      rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
>  }
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-16  0:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15 21:03 [PATCH] ppc/spapr: re-assert IRQs during event-scan if there are pending Laurent Vivier
2020-10-15 22:29 ` Greg Kurz
2020-10-15 23:58 ` David Gibson

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).