All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org, groug@kaod.org
Cc: David Gibson <david@gibson.dropbear.id.au>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: [PULL 07/22] spapr: Fix DR properties of the root node
Date: Wed,  6 Jan 2021 14:38:01 +1100	[thread overview]
Message-ID: <20210106033816.232598-8-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20210106033816.232598-1-david@gibson.dropbear.id.au>

From: Greg Kurz <groug@kaod.org>

Section 13.5.2 of LoPAPR mandates various DR related indentifiers
for all hot-pluggable entities to be exposed in the "ibm,drc-indexes",
"ibm,drc-power-domains", "ibm,drc-names" and "ibm,drc-types" properties
of their parent node. These properties are created with spapr_dt_drc().

PHBs and LMBs are both children of the machine. Their DR identifiers
are thus supposed to be exposed in the afore mentioned properties of
the root node.

When PHB hot-plug support was added, an extra call to spapr_dt_drc()
was introduced: this overwrites the existing properties, previously
populated with the LMB identifiers, and they end up containing only
PHB identifiers. This went unseen so far because linux doesn't care,
but this is still not conformant with LoPAPR.

Fortunately spapr_dt_drc() is able to handle multiple DR entity types
at the same time. Use that to handle DR indentifiers for PHBs and LMBs
with a single call to spapr_dt_drc(). While here also account for PMEM
DR identifiers, which were forgotten when NVDIMM hot-plug support was
added. Also add an assert to prevent further misuse of spapr_dt_drc().

With -m 1G,maxmem=2G,slots=8 passed on the QEMU command line we get:

Without this patch:

/proc/device-tree/ibm,drc-indexes
		 0000001f 20000001 20000002 20000003
		 20000000 20000005 20000006 20000007
		 20000004 20000009 20000008 20000010
		 20000011 20000012 20000013 20000014
		 20000015 20000016 20000017 20000018
		 20000019 2000000a 2000000b 2000000c
		 2000000d 2000000e 2000000f 2000001a
		 2000001b 2000001c 2000001d 2000001e

These are the DRC indexes for the 31 possible PHBs.

With this patch:

/proc/device-tree/ibm,drc-indexes
		 0000002b 90000000 90000001 90000002
		 90000003 90000004 90000005 90000006
		 90000007 20000001 20000002 20000003
		 20000000 20000005 20000006 20000007
		 20000004 20000009 20000008 20000010
		 20000011 20000012 20000013 20000014
		 20000015 20000016 20000017 20000018
		 20000019 2000000a 2000000b 2000000c
		 2000000d 2000000e 2000000f 2000001a
		 2000001b 2000001c 2000001d 2000001e
		 80000004 80000005 80000006 80000007

And now we also have the 4 ((2G - 1G) / 256M) LMBs and the
8 (slots) PMEMs.

Fixes: 3998ccd09298 ("spapr: populate PHB DRC entries for root DT node")
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160794479566.35245.17809158217760761558.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c     | 21 ++++++++++++---------
 hw/ppc/spapr_drc.c |  6 ++++++
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 08f57f9164..68a3ceb927 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1120,6 +1120,7 @@ void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space)
     MachineState *machine = MACHINE(spapr);
     MachineClass *mc = MACHINE_GET_CLASS(machine);
     SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
+    uint32_t root_drc_type_mask = 0;
     int ret;
     void *fdt;
     SpaprPhbState *phb;
@@ -1194,8 +1195,18 @@ void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space)
 
     spapr_dt_cpus(fdt, spapr);
 
+    /* ibm,drc-indexes and friends */
     if (smc->dr_lmb_enabled) {
-        _FDT(spapr_dt_drc(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_LMB));
+        root_drc_type_mask |= SPAPR_DR_CONNECTOR_TYPE_LMB;
+    }
+    if (smc->dr_phb_enabled) {
+        root_drc_type_mask |= SPAPR_DR_CONNECTOR_TYPE_PHB;
+    }
+    if (mc->nvdimm_supported) {
+        root_drc_type_mask |= SPAPR_DR_CONNECTOR_TYPE_PMEM;
+    }
+    if (root_drc_type_mask) {
+        _FDT(spapr_dt_drc(fdt, 0, NULL, root_drc_type_mask));
     }
 
     if (mc->has_hotpluggable_cpus) {
@@ -1233,14 +1244,6 @@ void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space)
         }
     }
 
-    if (smc->dr_phb_enabled) {
-        ret = spapr_dt_drc(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_PHB);
-        if (ret < 0) {
-            error_report("Couldn't set up PHB DR device tree properties");
-            exit(1);
-        }
-    }
-
     /* NVDIMM devices */
     if (mc->nvdimm_supported) {
         spapr_dt_persistent_memory(spapr, fdt);
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index f991cf89a0..fc7e321fcd 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -832,6 +832,12 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask)
     GString *drc_names, *drc_types;
     int ret;
 
+    /*
+     * This should really be only called once per node since it overwrites
+     * the OF properties if they already exist.
+     */
+    g_assert(!fdt_get_property(fdt, offset, "ibm,drc-indexes", NULL));
+
     /* the first entry of each properties is a 32-bit integer encoding
      * the number of elements in the array. we won't know this until
      * we complete the iteration through all the matching DRCs, but
-- 
2.29.2



  parent reply	other threads:[~2021-01-06  3:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06  3:37 [PULL 00/22] ppc-for-6.0 queue 20210106 David Gibson
2021-01-06  3:37 ` [PULL 01/22] hw/ppc/ppc4xx_devs: Make code style fixes to UIC code David Gibson
2021-01-06  3:37 ` [PULL 02/22] ppc: Convert PPC UIC to a QOM device David Gibson
2021-01-06  3:37 ` [PULL 03/22] hw/ppc/virtex_ml507: Drop use of ppcuic_init() David Gibson
2021-01-06  3:37 ` [PULL 04/22] hw/ppc/ppc440_bamboo: " David Gibson
2021-01-06  3:37 ` [PULL 05/22] spapr: DRC lookup cannot fail David Gibson
2021-01-06  3:38 ` [PULL 06/22] spapr/xive: Make spapr_xive_pic_print_info() static David Gibson
2021-01-06  3:38 ` David Gibson [this message]
2021-01-06  3:38 ` [PULL 08/22] spapr: Allow memory unplug to always succeed David Gibson
2021-01-06  3:38 ` [PULL 09/22] spapr: Fix buffer overflow in spapr_numa_associativity_init() David Gibson
2021-01-06  3:38 ` [PULL 10/22] spapr: Call spapr_drc_reset() for all DRCs at CAS David Gibson
2021-01-06  3:38 ` [PULL 11/22] spapr: Fix reset of transient DR connectors David Gibson
2021-01-06  3:38 ` [PULL 12/22] spapr: Introduce spapr_drc_reset_all() David Gibson
2021-01-06  3:38 ` [PULL 13/22] spapr: Use spapr_drc_reset_all() at machine reset David Gibson
2021-01-06  3:38 ` [PULL 14/22] spapr: Add drc_ prefix to the DRC realize and unrealize functions David Gibson
2021-01-06  3:38 ` [PULL 15/22] ppc: Fix build with --without-default-devices David Gibson
2021-01-06  3:38 ` [PULL 16/22] ppc: Simplify reverse dependencies of POWERNV and PSERIES on XICS and XIVE David Gibson
2021-01-06  3:38 ` [PULL 17/22] pnv: Fix reverse dependency on PCI express root ports David Gibson
2021-01-06  3:38 ` [PULL 18/22] ppc4xx: Move common dependency on serial to common option David Gibson
2021-01-06  3:38 ` [PULL 19/22] sam460ex: Remove FDT_PPC dependency from KConfig David Gibson
2021-01-06  3:38 ` [PULL 20/22] ppc440_pcix: Improve comment for IRQ mapping David Gibson
2021-01-06  3:38 ` [PULL 21/22] ppc440_pcix: Fix register write trace event David Gibson
2021-01-06  3:38 ` [PULL 22/22] ppc440_pcix: Fix up pci config access David Gibson
2021-01-06  6:12 ` [PULL 00/22] ppc-for-6.0 queue 20210106 BALATON Zoltan via
2021-01-06 13:30 ` Peter Maydell
2021-01-06 15:29   ` BALATON Zoltan via

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=20210106033816.232598-8-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --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.