Blame SOURCES/kvm-hw-ppc-clear-pending_events-on-machine-reset.patch

4a2fec
From 32a2cf9dfe251696b1d26b70723c5014e7ecbf45 Mon Sep 17 00:00:00 2001
4a2fec
From: David Gibson <dgibson@redhat.com>
4a2fec
Date: Wed, 4 Oct 2017 05:40:12 +0200
4a2fec
Subject: [PATCH 05/34] hw/ppc: clear pending_events on machine reset
4a2fec
4a2fec
RH-Author: David Gibson <dgibson@redhat.com>
4a2fec
Message-id: <20171004054014.14159-3-dgibson@redhat.com>
4a2fec
Patchwork-id: 76803
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 2/4] hw/ppc: clear pending_events on machine reset
4a2fec
Bugzilla: 1448344
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
4a2fec
4a2fec
The sPAPR machine isn't clearing up the pending events QTAILQ on
4a2fec
machine reboot. This allows for unprocessed hotplug/epow events
4a2fec
to persist in the queue after reset and, when reasserting the IRQs in
4a2fec
check_exception later on, these will be being processed by the OS.
4a2fec
4a2fec
This patch implements a new function called 'spapr_clear_pending_events'
4a2fec
that clears up the pending_events QTAILQ. This helper is then called
4a2fec
inside ppc_spapr_reset to clear up the events queue, preventing
4a2fec
old/deprecated events from persisting after a reset.
4a2fec
4a2fec
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
4a2fec
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4a2fec
(cherry picked from commit 56258174238eb25df629a53a96e1ac16a32dc7d4)
4a2fec
4a2fec
Signed-off-by: David Gibson <dgibson@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/ppc/spapr.c         |  1 +
4a2fec
 hw/ppc/spapr_events.c  | 11 +++++++++++
4a2fec
 include/hw/ppc/spapr.h |  1 +
4a2fec
 3 files changed, 13 insertions(+)
4a2fec
4a2fec
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
4a2fec
index 8d1cfcf..a419aa7 100644
4a2fec
--- a/hw/ppc/spapr.c
4a2fec
+++ b/hw/ppc/spapr.c
4a2fec
@@ -1393,6 +1393,7 @@ static void ppc_spapr_reset(void)
4a2fec
     }
4a2fec
 
4a2fec
     qemu_devices_reset();
4a2fec
+    spapr_clear_pending_events(spapr);
4a2fec
 
4a2fec
     /*
4a2fec
      * We place the device tree and RTAS just below either the top of the RMA,
4a2fec
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
4a2fec
index f952b78..66b8164 100644
4a2fec
--- a/hw/ppc/spapr_events.c
4a2fec
+++ b/hw/ppc/spapr_events.c
4a2fec
@@ -700,6 +700,17 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineState *spapr,
4a2fec
     rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
4a2fec
 }
4a2fec
 
4a2fec
+void spapr_clear_pending_events(sPAPRMachineState *spapr)
4a2fec
+{
4a2fec
+    sPAPREventLogEntry *entry = NULL;
4a2fec
+
4a2fec
+    QTAILQ_FOREACH(entry, &spapr->pending_events, next) {
4a2fec
+        QTAILQ_REMOVE(&spapr->pending_events, entry, next);
4a2fec
+        g_free(entry->extended_log);
4a2fec
+        g_free(entry);
4a2fec
+    }
4a2fec
+}
4a2fec
+
4a2fec
 void spapr_events_init(sPAPRMachineState *spapr)
4a2fec
 {
4a2fec
     QTAILQ_INIT(&spapr->pending_events);
4a2fec
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
4a2fec
index 2a303a7..5d161ec 100644
4a2fec
--- a/include/hw/ppc/spapr.h
4a2fec
+++ b/include/hw/ppc/spapr.h
4a2fec
@@ -662,6 +662,7 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr);
4a2fec
 int spapr_hpt_shift_for_ramsize(uint64_t ramsize);
4a2fec
 void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift,
4a2fec
                           Error **errp);
4a2fec
+void spapr_clear_pending_events(sPAPRMachineState *spapr);
4a2fec
 
4a2fec
 /* CPU and LMB DRC release callbacks. */
4a2fec
 void spapr_core_release(DeviceState *dev);
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec