From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: lvivier@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org,
groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org,
David Gibson <david@gibson.dropbear.id.au>
Subject: [PULL 18/20] spapr: Don't use spapr_drc_needed() in CAS code
Date: Fri, 21 Feb 2020 14:36:48 +1100 [thread overview]
Message-ID: <20200221033650.444386-19-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20200221033650.444386-1-david@gibson.dropbear.id.au>
From: Greg Kurz <groug@kaod.org>
We currently don't support hotplug of devices between boot and CAS. If
this happens a CAS reboot is triggered. We detect this during CAS using
the spapr_drc_needed() function which is essentially a VMStateDescription
.needed callback. Even if the condition for CAS reboot happens to be the
same as for DRC migration, it looks wrong to piggyback a migration helper
for this.
Introduce a helper with slightly more explicit name and use it in both CAS
and DRC migration code. Since a subsequent patch will enhance this helper
to cover the case of hot unplug, let's go for spapr_drc_transient(). While
here convert spapr_hotplugged_dev_before_cas() to the "transient" wording as
well.
This doesn't change any behaviour.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <158169248180.3465937.9531405453362718771.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr_drc.c | 20 ++++++++++++++------
hw/ppc/spapr_hcall.c | 14 +++++++++-----
include/hw/ppc/spapr_drc.h | 4 +++-
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index fc62e04901..4c35ce7c5c 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -456,23 +456,31 @@ void spapr_drc_reset(SpaprDrc *drc)
}
}
-bool spapr_drc_needed(void *opaque)
+bool spapr_drc_transient(SpaprDrc *drc)
{
- SpaprDrc *drc = (SpaprDrc *)opaque;
SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
- /* If no dev is plugged in there is no need to migrate the DRC state */
+ /*
+ * If no dev is plugged in there is no need to migrate the DRC state
+ * nor to reset the DRC at CAS.
+ */
if (!drc->dev) {
return false;
}
/*
- * We need to migrate the state if it's not equal to the expected
- * long-term state, which is the same as the coldplugged initial
- * state */
+ * We need to reset the DRC at CAS or to migrate the DRC state if it's
+ * not equal to the expected long-term state, which is the same as the
+ * coldplugged initial state.
+ */
return (drc->state != drck->ready_state);
}
+static bool spapr_drc_needed(void *opaque)
+{
+ return spapr_drc_transient(opaque);
+}
+
static const VMStateDescription vmstate_spapr_drc = {
.name = "spapr_drc",
.version_id = 1,
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index b8bb66b5c0..6db3dbde9c 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1640,20 +1640,24 @@ static uint32_t cas_check_pvr(SpaprMachineState *spapr, PowerPCCPU *cpu,
return best_compat;
}
-static bool spapr_hotplugged_dev_before_cas(void)
+static bool spapr_transient_dev_before_cas(void)
{
- Object *drc_container, *obj;
+ Object *drc_container;
ObjectProperty *prop;
ObjectPropertyIterator iter;
drc_container = container_get(object_get_root(), "/dr-connector");
object_property_iter_init(&iter, drc_container);
while ((prop = object_property_iter_next(&iter))) {
+ SpaprDrc *drc;
+
if (!strstart(prop->type, "link<", NULL)) {
continue;
}
- obj = object_property_get_link(drc_container, prop->name, NULL);
- if (spapr_drc_needed(obj)) {
+ drc = SPAPR_DR_CONNECTOR(object_property_get_link(drc_container,
+ prop->name, NULL));
+
+ if (spapr_drc_transient(drc)) {
return true;
}
}
@@ -1830,7 +1834,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
spapr_irq_update_active_intc(spapr);
- if (spapr_hotplugged_dev_before_cas()) {
+ if (spapr_transient_dev_before_cas()) {
spapr->cas_reboot = true;
}
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index df3d958a66..21af8deac1 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -278,7 +278,9 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask);
void spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp);
void spapr_drc_detach(SpaprDrc *drc);
-bool spapr_drc_needed(void *opaque);
+
+/* Returns true if a hot plug/unplug request is pending */
+bool spapr_drc_transient(SpaprDrc *drc);
static inline bool spapr_drc_unplug_requested(SpaprDrc *drc)
{
--
2.24.1
next prev parent reply other threads:[~2020-02-21 3:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-21 3:36 [PULL 00/20] ppc-for-5.0 queue 20200221 David Gibson
2020-02-21 3:36 ` [PULL 01/20] spapr/rtas: Print message from "ibm,os-term" David Gibson
2020-02-21 3:36 ` [PULL 02/20] qtest: Fix rtas dependencies David Gibson
2020-02-21 3:36 ` [PULL 03/20] ppc/pnv: Fix PCI_EXPRESS dependency David Gibson
2020-02-21 3:36 ` [PULL 04/20] ppc: function to setup latest class options David Gibson
2020-02-21 3:36 ` [PULL 05/20] mem: move nvdimm_device_list to utilities David Gibson
2020-04-03 12:34 ` Peter Maydell
2020-02-21 3:36 ` [PULL 06/20] nvdimm: add uuid property to nvdimm David Gibson
2020-02-21 3:36 ` [PULL 07/20] spapr: Add NVDIMM device support David Gibson
2020-02-25 10:00 ` Peter Maydell
2020-02-26 12:13 ` Shivaprasad G Bhat
2020-02-21 3:36 ` [PULL 08/20] spapr: Add Hcalls to support PAPR NVDIMM device David Gibson
2020-02-21 3:36 ` [PULL 09/20] target/ppc/cpu.h: Remove duplicate includes David Gibson
2020-02-21 3:36 ` [PULL 10/20] pnv/phb3: Convert 1u to 1ull David Gibson
2020-02-21 3:36 ` [PULL 11/20] pnv/phb4: Fix error path in pnv_pec_realize() David Gibson
2020-02-21 3:36 ` [PULL 12/20] pnv/phb3: Add missing break statement David Gibson
2020-02-21 3:36 ` [PULL 13/20] spapr: Allow changing offset for -kernel image David Gibson
2020-02-21 3:36 ` [PULL 14/20] target/ppc: Fix typo in comments David Gibson
2020-02-21 3:36 ` [PULL 15/20] target/ppc/cpu.h: Move fpu related members closer in cpu env David Gibson
2020-02-21 3:36 ` [PULL 16/20] target/ppc/cpu.h: Clean up comments in the struct CPUPPCState definition David Gibson
2020-02-21 3:36 ` [PULL 17/20] ppc: free 'fdt' after reset the machine David Gibson
2020-02-21 3:36 ` David Gibson [this message]
2020-02-21 3:36 ` [PULL 19/20] spapr: Fix handling of unplugged devices during CAS and migration David Gibson
2020-02-21 3:36 ` [PULL 20/20] hw/ppc/virtex_ml507:fix leak of fdevice tree blob David Gibson
2020-02-21 15:18 ` [PULL 00/20] ppc-for-5.0 queue 20200221 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=20200221033650.444386-19-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=clg@kaod.org \
--cc=groug@kaod.org \
--cc=lvivier@redhat.com \
--cc=peter.maydell@linaro.org \
--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.