|
|
a19a21 |
From ad7aaf34400b1bbd41bbec182fd5895eaad50932 Mon Sep 17 00:00:00 2001
|
|
|
a19a21 |
From: Greg Kurz <gkurz@redhat.com>
|
|
|
a19a21 |
Date: Tue, 19 Jan 2021 15:09:51 -0500
|
|
|
a19a21 |
Subject: [PATCH 3/9] spapr: Don't use spapr_drc_needed() in CAS code
|
|
|
a19a21 |
|
|
|
a19a21 |
RH-Author: Greg Kurz <gkurz@redhat.com>
|
|
|
a19a21 |
Message-id: <20210119150954.1017058-4-gkurz@redhat.com>
|
|
|
a19a21 |
Patchwork-id: 100683
|
|
|
a19a21 |
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 3/6] spapr: Don't use spapr_drc_needed() in CAS code
|
|
|
a19a21 |
Bugzilla: 1901837
|
|
|
a19a21 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a19a21 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
a19a21 |
RH-Acked-by: David Gibson <dgibson@redhat.com>
|
|
|
a19a21 |
|
|
|
a19a21 |
From: Greg Kurz <groug@kaod.org>
|
|
|
a19a21 |
|
|
|
a19a21 |
We currently don't support hotplug of devices between boot and CAS. If
|
|
|
a19a21 |
this happens a CAS reboot is triggered. We detect this during CAS using
|
|
|
a19a21 |
the spapr_drc_needed() function which is essentially a VMStateDescription
|
|
|
a19a21 |
.needed callback. Even if the condition for CAS reboot happens to be the
|
|
|
a19a21 |
same as for DRC migration, it looks wrong to piggyback a migration helper
|
|
|
a19a21 |
for this.
|
|
|
a19a21 |
|
|
|
a19a21 |
Introduce a helper with slightly more explicit name and use it in both CAS
|
|
|
a19a21 |
and DRC migration code. Since a subsequent patch will enhance this helper
|
|
|
a19a21 |
to cover the case of hot unplug, let's go for spapr_drc_transient(). While
|
|
|
a19a21 |
here convert spapr_hotplugged_dev_before_cas() to the "transient" wording as
|
|
|
a19a21 |
well.
|
|
|
a19a21 |
|
|
|
a19a21 |
This doesn't change any behaviour.
|
|
|
a19a21 |
|
|
|
a19a21 |
Signed-off-by: Greg Kurz <groug@kaod.org>
|
|
|
a19a21 |
Message-Id: <158169248180.3465937.9531405453362718771.stgit@bahia.lan>
|
|
|
a19a21 |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
a19a21 |
(cherry picked from commit 4b63db1289a9e597bc151fa5e4d72f882cb6de1e)
|
|
|
a19a21 |
Signed-off-by: Greg Kurz <gkurz@redhat.com>
|
|
|
a19a21 |
Signed-off-by: Jon Maloy <jmaloy.redhat.com>
|
|
|
a19a21 |
---
|
|
|
a19a21 |
hw/ppc/spapr_drc.c | 20 ++++++++++++++------
|
|
|
a19a21 |
hw/ppc/spapr_hcall.c | 14 +++++++++-----
|
|
|
a19a21 |
include/hw/ppc/spapr_drc.h | 4 +++-
|
|
|
a19a21 |
3 files changed, 26 insertions(+), 12 deletions(-)
|
|
|
a19a21 |
|
|
|
a19a21 |
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
|
|
|
a19a21 |
index 62f1a42592..9b498d429e 100644
|
|
|
a19a21 |
--- a/hw/ppc/spapr_drc.c
|
|
|
a19a21 |
+++ b/hw/ppc/spapr_drc.c
|
|
|
a19a21 |
@@ -455,23 +455,31 @@ void spapr_drc_reset(SpaprDrc *drc)
|
|
|
a19a21 |
}
|
|
|
a19a21 |
}
|
|
|
a19a21 |
|
|
|
a19a21 |
-bool spapr_drc_needed(void *opaque)
|
|
|
a19a21 |
+bool spapr_drc_transient(SpaprDrc *drc)
|
|
|
a19a21 |
{
|
|
|
a19a21 |
- SpaprDrc *drc = (SpaprDrc *)opaque;
|
|
|
a19a21 |
SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
|
|
a19a21 |
|
|
|
a19a21 |
- /* If no dev is plugged in there is no need to migrate the DRC state */
|
|
|
a19a21 |
+ /*
|
|
|
a19a21 |
+ * If no dev is plugged in there is no need to migrate the DRC state
|
|
|
a19a21 |
+ * nor to reset the DRC at CAS.
|
|
|
a19a21 |
+ */
|
|
|
a19a21 |
if (!drc->dev) {
|
|
|
a19a21 |
return false;
|
|
|
a19a21 |
}
|
|
|
a19a21 |
|
|
|
a19a21 |
/*
|
|
|
a19a21 |
- * We need to migrate the state if it's not equal to the expected
|
|
|
a19a21 |
- * long-term state, which is the same as the coldplugged initial
|
|
|
a19a21 |
- * state */
|
|
|
a19a21 |
+ * We need to reset the DRC at CAS or to migrate the DRC state if it's
|
|
|
a19a21 |
+ * not equal to the expected long-term state, which is the same as the
|
|
|
a19a21 |
+ * coldplugged initial state.
|
|
|
a19a21 |
+ */
|
|
|
a19a21 |
return (drc->state != drck->ready_state);
|
|
|
a19a21 |
}
|
|
|
a19a21 |
|
|
|
a19a21 |
+static bool spapr_drc_needed(void *opaque)
|
|
|
a19a21 |
+{
|
|
|
a19a21 |
+ return spapr_drc_transient(opaque);
|
|
|
a19a21 |
+}
|
|
|
a19a21 |
+
|
|
|
a19a21 |
static const VMStateDescription vmstate_spapr_drc = {
|
|
|
a19a21 |
.name = "spapr_drc",
|
|
|
a19a21 |
.version_id = 1,
|
|
|
a19a21 |
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
|
|
|
a19a21 |
index 0f19be794c..d70e643752 100644
|
|
|
a19a21 |
--- a/hw/ppc/spapr_hcall.c
|
|
|
a19a21 |
+++ b/hw/ppc/spapr_hcall.c
|
|
|
a19a21 |
@@ -1640,20 +1640,24 @@ static uint32_t cas_check_pvr(SpaprMachineState *spapr, PowerPCCPU *cpu,
|
|
|
a19a21 |
return best_compat;
|
|
|
a19a21 |
}
|
|
|
a19a21 |
|
|
|
a19a21 |
-static bool spapr_hotplugged_dev_before_cas(void)
|
|
|
a19a21 |
+static bool spapr_transient_dev_before_cas(void)
|
|
|
a19a21 |
{
|
|
|
a19a21 |
- Object *drc_container, *obj;
|
|
|
a19a21 |
+ Object *drc_container;
|
|
|
a19a21 |
ObjectProperty *prop;
|
|
|
a19a21 |
ObjectPropertyIterator iter;
|
|
|
a19a21 |
|
|
|
a19a21 |
drc_container = container_get(object_get_root(), "/dr-connector");
|
|
|
a19a21 |
object_property_iter_init(&iter, drc_container);
|
|
|
a19a21 |
while ((prop = object_property_iter_next(&iter))) {
|
|
|
a19a21 |
+ SpaprDrc *drc;
|
|
|
a19a21 |
+
|
|
|
a19a21 |
if (!strstart(prop->type, "link<", NULL)) {
|
|
|
a19a21 |
continue;
|
|
|
a19a21 |
}
|
|
|
a19a21 |
- obj = object_property_get_link(drc_container, prop->name, NULL);
|
|
|
a19a21 |
- if (spapr_drc_needed(obj)) {
|
|
|
a19a21 |
+ drc = SPAPR_DR_CONNECTOR(object_property_get_link(drc_container,
|
|
|
a19a21 |
+ prop->name, NULL));
|
|
|
a19a21 |
+
|
|
|
a19a21 |
+ if (spapr_drc_transient(drc)) {
|
|
|
a19a21 |
return true;
|
|
|
a19a21 |
}
|
|
|
a19a21 |
}
|
|
|
a19a21 |
@@ -1812,7 +1816,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
|
|
|
a19a21 |
|
|
|
a19a21 |
spapr_irq_update_active_intc(spapr);
|
|
|
a19a21 |
|
|
|
a19a21 |
- if (spapr_hotplugged_dev_before_cas()) {
|
|
|
a19a21 |
+ if (spapr_transient_dev_before_cas()) {
|
|
|
a19a21 |
spapr->cas_reboot = true;
|
|
|
a19a21 |
}
|
|
|
a19a21 |
|
|
|
a19a21 |
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
|
|
|
a19a21 |
index 83f03cc577..7e09d57114 100644
|
|
|
a19a21 |
--- a/include/hw/ppc/spapr_drc.h
|
|
|
a19a21 |
+++ b/include/hw/ppc/spapr_drc.h
|
|
|
a19a21 |
@@ -269,7 +269,9 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask);
|
|
|
a19a21 |
|
|
|
a19a21 |
void spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp);
|
|
|
a19a21 |
void spapr_drc_detach(SpaprDrc *drc);
|
|
|
a19a21 |
-bool spapr_drc_needed(void *opaque);
|
|
|
a19a21 |
+
|
|
|
a19a21 |
+/* Returns true if a hot plug/unplug request is pending */
|
|
|
a19a21 |
+bool spapr_drc_transient(SpaprDrc *drc);
|
|
|
a19a21 |
|
|
|
a19a21 |
static inline bool spapr_drc_unplug_requested(SpaprDrc *drc)
|
|
|
a19a21 |
{
|
|
|
a19a21 |
--
|
|
|
a19a21 |
2.18.2
|
|
|
a19a21 |
|