All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2
@ 2017-12-01 16:46 Nathan Fontenot
  2017-12-01 16:46 ` [PATCH V3 1/9] powerpc/numa: Look up device node in of_get_assoc_arrays() Nathan Fontenot
                   ` (9 more replies)
  0 siblings, 10 replies; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:46 UTC (permalink / raw)
  To: linuxppc-dev

This patch set provides a series of updates to de-couple the LMB
information provided in the device tree property from the device
tree property format. This eases the ability to support a new
format for the dynamic memory property, ibm,dynamic-memory-v2.

This series of patches consolidates the routines for parsing the
LMB device tree properties into a new file, powerpc/mm/drmem.c,
and provides the ability to retrieve LMB information without having
to know the backing device tree format.

To do this, a set of routines are introduced that will walk the
device tree property and make a call back for each LMB represented
in the device tree. These are to be used by init routines during
boot, currently in prom.c and numa.c.

A late_initcall is used to allocate and initialize a LMB array to
provide a common data structure of per-LMB data. This array provides
a data structure to retrieve LMB information without knowing the
backing tree format. This is used in numa.c and pseries/hotplug-memory.c.

This is a big design change from the first two version of the patch set
that attempted to allocate the LMB array with bootmem very early.
Testing showed that this allocation can fail which pushed the change
to the current design.

To support memory hotplug needing to update the device tree, a
common routine is introduced to create a new copy of the device
tree property in the proper format.

The first three patches update the of_get_assoc_arrays(),
of_get_usable_memory(), and of_drconf_to_nid_single() routines
to do device tree lookups for information they need instead of having
the nodes/properties passed in. These are updates needed for later
changes.

The fourth patch adds the walk_drmem_lmbs_early() routine to provide
parsing of the flattened device tree and make a per-LMB call back,
used in prom.c

The fifth patch provides a walk_drmem_lmbs() routine to parse the
device tree and provide a per-LMB call back, used in numa.c. This
also allocates and initializes the LMB array, and updates numa.c
to use the array.

The sixth patch updates pseries hotplug code new LMB array data 
instead of parsing the device tree directly and introduces the
common routine to create a new device tree property.

The seventh patch moves the of_drconf_cell struct to drmem.h where it
fits better than prom.h

The eighth patch introduces support for the ibm,dynamic-memory-v2
property format by updating the new drmem.c code to be able to parse
and create this new device tree format.

The last patch in the series updates the architecture vector to indicate
support for ibm,dynamic-memory-v2.

-Nathan
---

Nathan Fontenot (9):
      powerpc/numa: Look up device node in of_get_assoc_arrays()
      powerpc/numa: Look up device node in of_get_usable_memory()
      powerpc/numa: Look up associativity array in of_drconf_to_nid_single
      powerpc/mm: Separate ibm,dynamic-memory data from DT format
      powerpc/numa: Update numa code use walk_drmem_lmbs
      powerpc/pseries: Update memory hotplug code to use drmem LMB array
      powerpc: Move of_drconf_cell struct to asm/drmem.h
      powerpc/drmem: Add support for ibm,dynamic-memory-v2 property
      powerpc: Enable support of ibm,dynamic-memory-v2


 arch/powerpc/include/asm/drmem.h                |  100 ++++
 arch/powerpc/include/asm/firmware.h             |    3 
 arch/powerpc/include/asm/prom.h                 |   17 -
 arch/powerpc/kernel/prom.c                      |  114 ++---
 arch/powerpc/kernel/prom_init.c                 |    1 
 arch/powerpc/mm/Makefile                        |    2 
 arch/powerpc/mm/drmem.c                         |  438 +++++++++++++++++++
 arch/powerpc/mm/numa.c                          |  252 +++--------
 arch/powerpc/platforms/pseries/firmware.c       |    1 
 arch/powerpc/platforms/pseries/hotplug-memory.c |  522 +++++++++--------------
 10 files changed, 864 insertions(+), 586 deletions(-)
 create mode 100644 arch/powerpc/include/asm/drmem.h
 create mode 100644 arch/powerpc/mm/drmem.c

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

* [PATCH V3 1/9] powerpc/numa: Look up device node in of_get_assoc_arrays()
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
@ 2017-12-01 16:46 ` Nathan Fontenot
  2018-01-17 13:30   ` [V3, " Michael Ellerman
  2017-12-01 16:46 ` [PATCH V3 2/9] powerpc/numa: Look up device node in of_get_usable_memory() Nathan Fontenot
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:46 UTC (permalink / raw)
  To: linuxppc-dev

Look up the device node for the associativity array property instead
of having it passed in as a parameter. This changes precedes an update
in which the calling routines for of_get_assoc_arrays() will not have
the device node pointer to pass in.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 arch/powerpc/mm/numa.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index adb6364f4091..a0214aa2dd78 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -466,19 +466,27 @@ struct assoc_arrays {
  * indicating the size of each associativity array, followed by a list
  * of N associativity arrays.
  */
-static int of_get_assoc_arrays(struct device_node *memory,
-			       struct assoc_arrays *aa)
+static int of_get_assoc_arrays(struct assoc_arrays *aa)
 {
+	struct device_node *memory;
 	const __be32 *prop;
 	u32 len;
 
+	memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
+	if (!memory)
+		return -1;
+
 	prop = of_get_property(memory, "ibm,associativity-lookup-arrays", &len);
-	if (!prop || len < 2 * sizeof(unsigned int))
+	if (!prop || len < 2 * sizeof(unsigned int)) {
+		of_node_put(memory);
 		return -1;
+	}
 
 	aa->n_arrays = of_read_number(prop++, 1);
 	aa->array_sz = of_read_number(prop++, 1);
 
+	of_node_put(memory);
+
 	/* Now that we know the number of arrays and size of each array,
 	 * revalidate the size of the property read in.
 	 */
@@ -661,7 +669,7 @@ static void __init parse_drconf_memory(struct device_node *memory)
 	if (!lmb_size)
 		return;
 
-	rc = of_get_assoc_arrays(memory, &aa);
+	rc = of_get_assoc_arrays(&aa);
 	if (rc)
 		return;
 
@@ -996,7 +1004,7 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
 	if (!lmb_size)
 		return -1;
 
-	rc = of_get_assoc_arrays(memory, &aa);
+	rc = of_get_assoc_arrays(&aa);
 	if (rc)
 		return -1;
 

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

* [PATCH V3 2/9] powerpc/numa: Look up device node in of_get_usable_memory()
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
  2017-12-01 16:46 ` [PATCH V3 1/9] powerpc/numa: Look up device node in of_get_assoc_arrays() Nathan Fontenot
@ 2017-12-01 16:46 ` Nathan Fontenot
  2017-12-01 16:46 ` [PATCH V3 3/9] powerpc/numa: Look up associativity array in of_drconf_to_nid_single Nathan Fontenot
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:46 UTC (permalink / raw)
  To: linuxppc-dev

Look up the device node for the usable memory property instead
of having it passed in as a parameter. This changes precedes an update
in which the calling routines for of_get_usable_memory() will not have
the device node pointer to pass in.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 arch/powerpc/mm/numa.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index a0214aa2dd78..baba6403488b 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -184,11 +184,19 @@ static const __be32 *of_get_associativity(struct device_node *dev)
  * it exists (the property exists only in kexec/kdump kernels,
  * added by kexec-tools)
  */
-static const __be32 *of_get_usable_memory(struct device_node *memory)
+static const __be32 *of_get_usable_memory(void)
 {
+	struct device_node *memory;
 	const __be32 *prop;
 	u32 len;
+
+	memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
+	if (!memory)
+		return NULL;
+
 	prop = of_get_property(memory, "linux,drconf-usable-memory", &len);
+	of_node_put(memory);
+
 	if (!prop || len < sizeof(unsigned int))
 		return NULL;
 	return prop;
@@ -674,7 +682,7 @@ static void __init parse_drconf_memory(struct device_node *memory)
 		return;
 
 	/* check if this is a kexec/kdump kernel */
-	usm = of_get_usable_memory(memory);
+	usm = of_get_usable_memory();
 	if (usm != NULL)
 		is_kexec_kdump = 1;
 

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

* [PATCH V3 3/9] powerpc/numa: Look up associativity array in of_drconf_to_nid_single
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
  2017-12-01 16:46 ` [PATCH V3 1/9] powerpc/numa: Look up device node in of_get_assoc_arrays() Nathan Fontenot
  2017-12-01 16:46 ` [PATCH V3 2/9] powerpc/numa: Look up device node in of_get_usable_memory() Nathan Fontenot
@ 2017-12-01 16:46 ` Nathan Fontenot
  2017-12-01 16:47 ` [PATCH V3 4/9] powerpc/mm: Separate ibm, dynamic-memory data from DT format Nathan Fontenot
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:46 UTC (permalink / raw)
  To: linuxppc-dev

Look up the associativity arrays in of_drconf_to_nid_single when
deriving the nid for a LMB instead of having it passed in as a
parameter.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 arch/powerpc/mm/numa.c |   40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index baba6403488b..d25278adaead 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -509,26 +509,30 @@ static int of_get_assoc_arrays(struct assoc_arrays *aa)
  * This is like of_node_to_nid_single() for memory represented in the
  * ibm,dynamic-reconfiguration-memory node.
  */
-static int of_drconf_to_nid_single(struct of_drconf_cell *drmem,
-				   struct assoc_arrays *aa)
+static int of_drconf_to_nid_single(struct of_drconf_cell *drmem)
 {
+	struct assoc_arrays aa = { .arrays = NULL };
 	int default_nid = 0;
 	int nid = default_nid;
-	int index;
+	int rc, index;
+
+	rc = of_get_assoc_arrays(&aa);
+	if (rc)
+		return default_nid;
 
-	if (min_common_depth > 0 && min_common_depth <= aa->array_sz &&
+	if (min_common_depth > 0 && min_common_depth <= aa.array_sz &&
 	    !(drmem->flags & DRCONF_MEM_AI_INVALID) &&
-	    drmem->aa_index < aa->n_arrays) {
-		index = drmem->aa_index * aa->array_sz + min_common_depth - 1;
-		nid = of_read_number(&aa->arrays[index], 1);
+	    drmem->aa_index < aa.n_arrays) {
+		index = drmem->aa_index * aa.array_sz + min_common_depth - 1;
+		nid = of_read_number(&aa.arrays[index], 1);
 
 		if (nid == 0xffff || nid >= MAX_NUMNODES)
 			nid = default_nid;
 
 		if (nid > 0) {
-			index = drmem->aa_index * aa->array_sz;
+			index = drmem->aa_index * aa.array_sz;
 			initialize_distance_lookup_table(nid,
-							&aa->arrays[index]);
+							&aa.arrays[index]);
 		}
 	}
 
@@ -664,10 +668,9 @@ static inline int __init read_usm_ranges(const __be32 **usm)
 static void __init parse_drconf_memory(struct device_node *memory)
 {
 	const __be32 *uninitialized_var(dm), *usm;
-	unsigned int n, rc, ranges, is_kexec_kdump = 0;
+	unsigned int n, ranges, is_kexec_kdump = 0;
 	unsigned long lmb_size, base, size, sz;
 	int nid;
-	struct assoc_arrays aa = { .arrays = NULL };
 
 	n = of_get_drconf_memory(memory, &dm);
 	if (!n)
@@ -677,10 +680,6 @@ static void __init parse_drconf_memory(struct device_node *memory)
 	if (!lmb_size)
 		return;
 
-	rc = of_get_assoc_arrays(&aa);
-	if (rc)
-		return;
-
 	/* check if this is a kexec/kdump kernel */
 	usm = of_get_usable_memory();
 	if (usm != NULL)
@@ -711,7 +710,7 @@ static void __init parse_drconf_memory(struct device_node *memory)
 				base = read_n_cells(n_mem_addr_cells, &usm);
 				size = read_n_cells(n_mem_size_cells, &usm);
 			}
-			nid = of_drconf_to_nid_single(&drmem, &aa);
+			nid = of_drconf_to_nid_single(&drmem);
 			fake_numa_create_new_node(
 				((base + size) >> PAGE_SHIFT),
 					   &nid);
@@ -999,9 +998,8 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
 				     unsigned long scn_addr)
 {
 	const __be32 *dm;
-	unsigned int drconf_cell_cnt, rc;
+	unsigned int drconf_cell_cnt;
 	unsigned long lmb_size;
-	struct assoc_arrays aa;
 	int nid = -1;
 
 	drconf_cell_cnt = of_get_drconf_memory(memory, &dm);
@@ -1012,10 +1010,6 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
 	if (!lmb_size)
 		return -1;
 
-	rc = of_get_assoc_arrays(&aa);
-	if (rc)
-		return -1;
-
 	for (; drconf_cell_cnt != 0; --drconf_cell_cnt) {
 		struct of_drconf_cell drmem;
 
@@ -1031,7 +1025,7 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
 		    || (scn_addr >= (drmem.base_addr + lmb_size)))
 			continue;
 
-		nid = of_drconf_to_nid_single(&drmem, &aa);
+		nid = of_drconf_to_nid_single(&drmem);
 		break;
 	}
 

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

* [PATCH V3 4/9] powerpc/mm: Separate ibm, dynamic-memory data from DT format
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
                   ` (2 preceding siblings ...)
  2017-12-01 16:46 ` [PATCH V3 3/9] powerpc/numa: Look up associativity array in of_drconf_to_nid_single Nathan Fontenot
@ 2017-12-01 16:47 ` Nathan Fontenot
  2017-12-01 16:47 ` [PATCH V3 5/9] powerpc/numa: Update numa code use walk_drmem_lmbs Nathan Fontenot
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:47 UTC (permalink / raw)
  To: linuxppc-dev

We currently have code to parse the dynamic reconfiguration LMB
information from the ibm,dynamic-meory device tree property in
multiple locations; numa.c, prom.c, and pseries/hotplug-memory.c.
In anticipation of adding support for a version 2 of the
ibm,dynamic-memory property this patch aims to separate the device
tree information from the device tree format.

Doing this requires a two step process to avoid a possibly very large
bootmem allocation early in boot. During initial boot, new routines
are provided to walk the device tree property and make a call-back
for each LMB.

The second step (introduced in later patches) will allocate an
array of LMB information that can be used directly without needing
to know the DT format.

This approach provides the benefit of consolidating the device tree
property parsing to a single location and (eventually) providing
a common data structure for retrieving LMB information.

This patch introduces a routine to walk the ibm,dynamic-memory
property in the flattened device tree and updates the prom.c code
to use this to initialize memory.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---

Updates for V3: Converted from doing a bootmem allocation early in
boot for the LMB array to providing a routine to walk the memory
property and provide a callback for each LMB.

Updates for V2: Correct build break for non-pseries builds.

 arch/powerpc/include/asm/drmem.h |   48 ++++++++++++++++
 arch/powerpc/kernel/prom.c       |  114 ++++++++++++++++----------------------
 arch/powerpc/mm/Makefile         |    2 -
 arch/powerpc/mm/drmem.c          |   76 +++++++++++++++++++++++++
 4 files changed, 173 insertions(+), 67 deletions(-)
 create mode 100644 arch/powerpc/include/asm/drmem.h
 create mode 100644 arch/powerpc/mm/drmem.c

diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
new file mode 100644
index 000000000000..c7fc5c4d8a7c
--- /dev/null
+++ b/arch/powerpc/include/asm/drmem.h
@@ -0,0 +1,48 @@
+/*
+ * drmem.h: Power specific logical memory block representation
+ *
+ * Copyright 2017 IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _ASM_POWERPC_LMB_H
+#define _ASM_POWERPC_LMB_H
+
+struct drmem_lmb {
+	u64     base_addr;
+	u32     drc_index;
+	u32     aa_index;
+	u32     flags;
+};
+
+struct drmem_lmb_info {
+	struct drmem_lmb        *lmbs;
+	int                     n_lmbs;
+	u32                     lmb_size;
+};
+
+extern struct drmem_lmb_info *drmem_info;
+
+#define for_each_drmem_lmb_in_range(lmb, start, end)		\
+	for ((lmb) = (start); (lmb) <= (end); (lmb)++)
+
+#define for_each_drmem_lmb(lmb)					\
+	for_each_drmem_lmb_in_range((lmb),			\
+		&drmem_info->lmbs[0],				\
+		&drmem_info->lmbs[drmem_info->n_lmbs - 1])
+
+static inline u32 drmem_lmb_size(void)
+{
+	return drmem_info->lmb_size;
+}
+
+#ifdef CONFIG_PPC_PSERIES
+void __init walk_drmem_lmbs_early(unsigned long node,
+			void (*func)(struct drmem_lmb *, const __be32 **));
+#endif
+#endif
+
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index b15bae265c90..b800f1acc4fc 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -59,6 +59,7 @@
 #include <asm/epapr_hcalls.h>
 #include <asm/firmware.h>
 #include <asm/dt_cpu_ftrs.h>
+#include <asm/drmem.h>
 
 #include <mm/mmu_decl.h>
 
@@ -455,92 +456,73 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node,
 
 #ifdef CONFIG_PPC_PSERIES
 /*
- * Interpret the ibm,dynamic-memory property in the
- * /ibm,dynamic-reconfiguration-memory node.
+ * Interpret the ibm dynamic reconfiguration memory LMBs.
  * This contains a list of memory blocks along with NUMA affinity
  * information.
  */
-static int __init early_init_dt_scan_drconf_memory(unsigned long node)
+static void __init early_init_drmem_lmb(struct drmem_lmb *lmb,
+					const __be32 **usm)
 {
-	const __be32 *dm, *ls, *usm;
-	int l;
-	unsigned long n, flags;
-	u64 base, size, memblock_size;
-	unsigned int is_kexec_kdump = 0, rngs;
-
-	ls = of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
-	if (ls == NULL || l < dt_root_size_cells * sizeof(__be32))
-		return 0;
-	memblock_size = dt_mem_next_cell(dt_root_size_cells, &ls);
+	u64 base, size;
+	int is_kexec_kdump = 0, rngs;
 
-	dm = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l);
-	if (dm == NULL || l < sizeof(__be32))
-		return 0;
+	base = lmb->base_addr;
+	size = drmem_lmb_size();
+	rngs = 1;
 
-	n = of_read_number(dm++, 1);	/* number of entries */
-	if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(__be32))
-		return 0;
+	/* skip this block if the reserved bit is set in flags
+	 * or if the block is not assigned to this partition.
+	 */
+	if ((lmb->flags & DRCONF_MEM_RESERVED) ||
+	    !(lmb->flags & DRCONF_MEM_ASSIGNED))
+		return;
 
-	/* check if this is a kexec/kdump kernel. */
-	usm = of_get_flat_dt_prop(node, "linux,drconf-usable-memory",
-						 &l);
-	if (usm != NULL)
+	if (*usm)
 		is_kexec_kdump = 1;
 
-	for (; n != 0; --n) {
-		base = dt_mem_next_cell(dt_root_addr_cells, &dm);
-		flags = of_read_number(&dm[3], 1);
-		/* skip DRC index, pad, assoc. list index, flags */
-		dm += 4;
-		/* skip this block if the reserved bit is set in flags
-		   or if the block is not assigned to this partition */
-		if ((flags & DRCONF_MEM_RESERVED) ||
-				!(flags & DRCONF_MEM_ASSIGNED))
-			continue;
-		size = memblock_size;
-		rngs = 1;
+	if (is_kexec_kdump) {
+		/*
+		 * For each memblock in ibm,dynamic-memory, a
+		 * corresponding entry in linux,drconf-usable-memory
+		 * property contains a counter 'p' followed by 'p'
+		 * (base, size) duple. Now read the counter from
+		 * linux,drconf-usable-memory property
+		 */
+		rngs = dt_mem_next_cell(dt_root_size_cells, usm);
+		if (!rngs) /* there are no (base, size) duple */
+			return;
+	}
+
+	do {
 		if (is_kexec_kdump) {
-			/*
-			 * For each memblock in ibm,dynamic-memory, a corresponding
-			 * entry in linux,drconf-usable-memory property contains
-			 * a counter 'p' followed by 'p' (base, size) duple.
-			 * Now read the counter from
-			 * linux,drconf-usable-memory property
-			 */
-			rngs = dt_mem_next_cell(dt_root_size_cells, &usm);
-			if (!rngs) /* there are no (base, size) duple */
+			base = dt_mem_next_cell(dt_root_addr_cells, usm);
+			size = dt_mem_next_cell(dt_root_size_cells, usm);
+		}
+
+		if (iommu_is_off) {
+			if (base >= 0x80000000ul)
 				continue;
+			if ((base + size) > 0x80000000ul)
+				size = 0x80000000ul - base;
 		}
-		do {
-			if (is_kexec_kdump) {
-				base = dt_mem_next_cell(dt_root_addr_cells,
-							 &usm);
-				size = dt_mem_next_cell(dt_root_size_cells,
-							 &usm);
-			}
-			if (iommu_is_off) {
-				if (base >= 0x80000000ul)
-					continue;
-				if ((base + size) > 0x80000000ul)
-					size = 0x80000000ul - base;
-			}
-			memblock_add(base, size);
-		} while (--rngs);
-	}
-	memblock_dump_all();
-	return 0;
+
+		DBG("Adding: %llx -> %llx\n", base, size);
+		memblock_add(base, size);
+	} while (--rngs);
 }
-#else
-#define early_init_dt_scan_drconf_memory(node)	0
 #endif /* CONFIG_PPC_PSERIES */
 
 static int __init early_init_dt_scan_memory_ppc(unsigned long node,
 						const char *uname,
 						int depth, void *data)
 {
+#ifdef CONFIG_PPC_PSERIES
 	if (depth == 1 &&
-	    strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0)
-		return early_init_dt_scan_drconf_memory(node);
+	    strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) {
+		walk_drmem_lmbs_early(node, early_init_drmem_lmb);
+		return 0;
+	}
+#endif
 	
 	return early_init_dt_scan_memory(node, uname, depth, data);
 }
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index 76a6b057d454..8d271bfe2d94 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -9,7 +9,7 @@ ccflags-$(CONFIG_PPC64)	:= $(NO_MINIMAL_TOC)
 
 obj-y				:= fault.o mem.o pgtable.o mmap.o \
 				   init_$(BITS).o pgtable_$(BITS).o \
-				   init-common.o mmu_context.o
+				   init-common.o mmu_context.o drmem.o
 obj-$(CONFIG_PPC_MMU_NOHASH)	+= mmu_context_nohash.o tlb_nohash.o \
 				   tlb_nohash_low.o
 obj-$(CONFIG_PPC_BOOK3E)	+= tlb_low_$(BITS)e.o
diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
new file mode 100644
index 000000000000..f8ee0f355405
--- /dev/null
+++ b/arch/powerpc/mm/drmem.c
@@ -0,0 +1,76 @@
+/*
+ * Dynamic reconfiguration memory support
+ *
+ * Copyright 2017 IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#define pr_fmt(fmt) "drmem: " fmt
+
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/memblock.h>
+#include <asm/prom.h>
+#include <asm/drmem.h>
+
+static struct drmem_lmb_info __drmem_info;
+struct drmem_lmb_info *drmem_info = &__drmem_info;
+
+#ifdef CONFIG_PPC_PSERIES
+static void __init read_drconf_v1_cell(struct drmem_lmb *lmb,
+				       const __be32 **prop)
+{
+	const __be32 *p = *prop;
+
+	lmb->base_addr = dt_mem_next_cell(dt_root_addr_cells, &p);
+	lmb->drc_index = of_read_number(p++, 1);
+
+	p++; /* skip reserved field */
+
+	lmb->aa_index = of_read_number(p++, 1);
+	lmb->flags = of_read_number(p++, 1);
+
+	*prop = p;
+}
+
+static void __init __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *usm,
+			void (*func)(struct drmem_lmb *, const __be32 **))
+{
+	struct drmem_lmb lmb;
+	u32 i, n_lmbs;
+
+	n_lmbs = of_read_number(prop++, 1);
+
+	for (i = 0; i < n_lmbs; i++) {
+		read_drconf_v1_cell(&lmb, &prop);
+		func(&lmb, &usm);
+	}
+}
+
+void __init walk_drmem_lmbs_early(unsigned long node,
+			void (*func)(struct drmem_lmb *, const __be32 **))
+{
+	const __be32 *prop, *usm;
+	int len;
+
+	prop = of_get_flat_dt_prop(node, "ibm,lmb-size", &len);
+	if (!prop || len < dt_root_size_cells * sizeof(__be32))
+		return;
+
+	drmem_info->lmb_size = dt_mem_next_cell(dt_root_size_cells, &prop);
+
+	usm = of_get_flat_dt_prop(node, "linux,drconf-usable-memory", &len);
+
+	prop = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &len);
+	if (prop)
+		__walk_drmem_v1_lmbs(prop, usm, func);
+
+	memblock_dump_all();
+}
+
+#endif

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

* [PATCH V3 5/9] powerpc/numa: Update numa code use walk_drmem_lmbs
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
                   ` (3 preceding siblings ...)
  2017-12-01 16:47 ` [PATCH V3 4/9] powerpc/mm: Separate ibm, dynamic-memory data from DT format Nathan Fontenot
@ 2017-12-01 16:47 ` Nathan Fontenot
  2017-12-01 16:47 ` [PATCH V3 6/9] powerpc/pseries: Update memory hotplug code to use drmem LMB array Nathan Fontenot
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:47 UTC (permalink / raw)
  To: linuxppc-dev

Update code in powerpc/numa.c to use the walk_drmem_lmbs()
routine instead of parsing the device tree directly. This is
in anticipation of introducing a new ibm,dynamic-memory-v2
property with a different format. This will allow the numa code
to use a single initialization routine per-LMB irregardless of
the device tree format.

Additionally, to support additional routines in numa.c that need
to look up LMB information, an late_init routine is added to drmem.c
to allocate the array of LMB information. This LMB array will provide
per-LMB information to separate the LMB data from the device tree
format.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---

Updates for V3: Convert numa.c to use walk_drmem_lmbs routine and
add the late init call for allocating the LMB array.

Updates for V2: Removed unused device node paramter to
numa_setup_drmem_lmbs() and hot_add_drconf_scn_to_nid().

 arch/powerpc/include/asm/drmem.h |    4 +
 arch/powerpc/mm/drmem.c          |  100 +++++++++++++++++
 arch/powerpc/mm/numa.c           |  222 +++++++++-----------------------------
 3 files changed, 154 insertions(+), 172 deletions(-)

diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
index c7fc5c4d8a7c..679da30a1bea 100644
--- a/arch/powerpc/include/asm/drmem.h
+++ b/arch/powerpc/include/asm/drmem.h
@@ -40,6 +40,10 @@ static inline u32 drmem_lmb_size(void)
 	return drmem_info->lmb_size;
 }
 
+u64 drmem_lmb_memory_max(void);
+void __init walk_drmem_lmbs(struct device_node *dn,
+			void (*func)(struct drmem_lmb *, const __be32 **));
+
 #ifdef CONFIG_PPC_PSERIES
 void __init walk_drmem_lmbs_early(unsigned long node,
 			void (*func)(struct drmem_lmb *, const __be32 **));
diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
index f8ee0f355405..5888ac3ca8a9 100644
--- a/arch/powerpc/mm/drmem.c
+++ b/arch/powerpc/mm/drmem.c
@@ -21,7 +21,14 @@
 static struct drmem_lmb_info __drmem_info;
 struct drmem_lmb_info *drmem_info = &__drmem_info;
 
-#ifdef CONFIG_PPC_PSERIES
+u64 drmem_lmb_memory_max(void)
+{
+	struct drmem_lmb *last_lmb;
+
+	last_lmb = &drmem_info->lmbs[drmem_info->n_lmbs - 1];
+	return last_lmb->base_addr + drmem_lmb_size();
+}
+
 static void __init read_drconf_v1_cell(struct drmem_lmb *lmb,
 				       const __be32 **prop)
 {
@@ -52,6 +59,7 @@ static void __init __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *usm,
 	}
 }
 
+#ifdef CONFIG_PPC_PSERIES
 void __init walk_drmem_lmbs_early(unsigned long node,
 			void (*func)(struct drmem_lmb *, const __be32 **))
 {
@@ -74,3 +82,93 @@ void __init walk_drmem_lmbs_early(unsigned long node,
 }
 
 #endif
+
+static int __init init_drmem_lmb_size(struct device_node *dn)
+{
+	const __be32 *prop;
+	int len;
+
+	if (drmem_info->lmb_size)
+		return 0;
+
+	prop = of_get_property(dn, "ibm,lmb-size", &len);
+	if (!prop || len < dt_root_size_cells * sizeof(__be32)) {
+		pr_info("Could not determine LMB size\n");
+		return -1;
+	}
+
+	drmem_info->lmb_size = dt_mem_next_cell(dt_root_size_cells, &prop);
+	return 0;
+}
+
+/*
+ * Returns the property linux,drconf-usable-memory if
+ * it exists (the property exists only in kexec/kdump kernels,
+ * added by kexec-tools)
+ */
+static const __be32 *of_get_usable_memory(struct device_node *dn)
+{
+	const __be32 *prop;
+	u32 len;
+
+	prop = of_get_property(dn, "linux,drconf-usable-memory", &len);
+	if (!prop || len < sizeof(unsigned int))
+		return NULL;
+
+	return prop;
+}
+
+void __init walk_drmem_lmbs(struct device_node *dn,
+			    void (*func)(struct drmem_lmb *, const __be32 **))
+{
+	const __be32 *prop, *usm;
+
+	if (init_drmem_lmb_size(dn))
+		return;
+
+	usm = of_get_usable_memory(dn);
+
+	prop = of_get_property(dn, "ibm,dynamic-memory", NULL);
+	if (prop)
+		__walk_drmem_v1_lmbs(prop, usm, func);
+}
+
+static void __init init_drmem_v1_lmbs(const __be32 *prop)
+{
+	struct drmem_lmb *lmb;
+
+	drmem_info->n_lmbs = of_read_number(prop++, 1);
+
+	drmem_info->lmbs = kcalloc(drmem_info->n_lmbs, sizeof(*lmb),
+				   GFP_KERNEL);
+	if (!drmem_info->lmbs)
+		return;
+
+	for_each_drmem_lmb(lmb)
+		read_drconf_v1_cell(lmb, &prop);
+}
+
+static int __init drmem_init(void)
+{
+	struct device_node *dn;
+	const __be32 *prop;
+
+	dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
+	if (!dn) {
+		pr_info("No dynamic reconfiguration memory found\n");
+		return 0;
+	}
+
+	if (init_drmem_lmb_size(dn)) {
+		of_node_put(dn);
+		return 0;
+	}
+
+	prop = of_get_property(dn, "ibm,dynamic-memory", NULL);
+	if (prop)
+		init_drmem_v1_lmbs(prop);
+
+	of_node_put(dn);
+	return 0;
+}
+late_initcall(drmem_init);
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index d25278adaead..0e573f9b9d38 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -40,6 +40,7 @@
 #include <asm/hvcall.h>
 #include <asm/setup.h>
 #include <asm/vdso.h>
+#include <asm/drmem.h>
 
 static int numa_enabled = 1;
 
@@ -179,29 +180,6 @@ static const __be32 *of_get_associativity(struct device_node *dev)
 	return of_get_property(dev, "ibm,associativity", NULL);
 }
 
-/*
- * Returns the property linux,drconf-usable-memory if
- * it exists (the property exists only in kexec/kdump kernels,
- * added by kexec-tools)
- */
-static const __be32 *of_get_usable_memory(void)
-{
-	struct device_node *memory;
-	const __be32 *prop;
-	u32 len;
-
-	memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
-	if (!memory)
-		return NULL;
-
-	prop = of_get_property(memory, "linux,drconf-usable-memory", &len);
-	of_node_put(memory);
-
-	if (!prop || len < sizeof(unsigned int))
-		return NULL;
-	return prop;
-}
-
 int __node_distance(int a, int b)
 {
 	int i;
@@ -395,69 +373,6 @@ static unsigned long read_n_cells(int n, const __be32 **buf)
 	return result;
 }
 
-/*
- * Read the next memblock list entry from the ibm,dynamic-memory property
- * and return the information in the provided of_drconf_cell structure.
- */
-static void read_drconf_cell(struct of_drconf_cell *drmem, const __be32 **cellp)
-{
-	const __be32 *cp;
-
-	drmem->base_addr = read_n_cells(n_mem_addr_cells, cellp);
-
-	cp = *cellp;
-	drmem->drc_index = of_read_number(cp, 1);
-	drmem->reserved = of_read_number(&cp[1], 1);
-	drmem->aa_index = of_read_number(&cp[2], 1);
-	drmem->flags = of_read_number(&cp[3], 1);
-
-	*cellp = cp + 4;
-}
-
-/*
- * Retrieve and validate the ibm,dynamic-memory property of the device tree.
- *
- * The layout of the ibm,dynamic-memory property is a number N of memblock
- * list entries followed by N memblock list entries.  Each memblock list entry
- * contains information as laid out in the of_drconf_cell struct above.
- */
-static int of_get_drconf_memory(struct device_node *memory, const __be32 **dm)
-{
-	const __be32 *prop;
-	u32 len, entries;
-
-	prop = of_get_property(memory, "ibm,dynamic-memory", &len);
-	if (!prop || len < sizeof(unsigned int))
-		return 0;
-
-	entries = of_read_number(prop++, 1);
-
-	/* Now that we know the number of entries, revalidate the size
-	 * of the property read in to ensure we have everything
-	 */
-	if (len < (entries * (n_mem_addr_cells + 4) + 1) * sizeof(unsigned int))
-		return 0;
-
-	*dm = prop;
-	return entries;
-}
-
-/*
- * Retrieve and validate the ibm,lmb-size property for drconf memory
- * from the device tree.
- */
-static u64 of_get_lmb_size(struct device_node *memory)
-{
-	const __be32 *prop;
-	u32 len;
-
-	prop = of_get_property(memory, "ibm,lmb-size", &len);
-	if (!prop || len < sizeof(unsigned int))
-		return 0;
-
-	return read_n_cells(n_mem_size_cells, &prop);
-}
-
 struct assoc_arrays {
 	u32	n_arrays;
 	u32	array_sz;
@@ -509,7 +424,7 @@ static int of_get_assoc_arrays(struct assoc_arrays *aa)
  * This is like of_node_to_nid_single() for memory represented in the
  * ibm,dynamic-reconfiguration-memory node.
  */
-static int of_drconf_to_nid_single(struct of_drconf_cell *drmem)
+static int of_drconf_to_nid_single(struct drmem_lmb *lmb)
 {
 	struct assoc_arrays aa = { .arrays = NULL };
 	int default_nid = 0;
@@ -521,16 +436,16 @@ static int of_drconf_to_nid_single(struct of_drconf_cell *drmem)
 		return default_nid;
 
 	if (min_common_depth > 0 && min_common_depth <= aa.array_sz &&
-	    !(drmem->flags & DRCONF_MEM_AI_INVALID) &&
-	    drmem->aa_index < aa.n_arrays) {
-		index = drmem->aa_index * aa.array_sz + min_common_depth - 1;
+	    !(lmb->flags & DRCONF_MEM_AI_INVALID) &&
+	    lmb->aa_index < aa.n_arrays) {
+		index = lmb->aa_index * aa.array_sz + min_common_depth - 1;
 		nid = of_read_number(&aa.arrays[index], 1);
 
 		if (nid == 0xffff || nid >= MAX_NUMNODES)
 			nid = default_nid;
 
 		if (nid > 0) {
-			index = drmem->aa_index * aa.array_sz;
+			index = lmb->aa_index * aa.array_sz;
 			initialize_distance_lookup_table(nid,
 							&aa.arrays[index]);
 		}
@@ -665,62 +580,47 @@ static inline int __init read_usm_ranges(const __be32 **usm)
  * Extract NUMA information from the ibm,dynamic-reconfiguration-memory
  * node.  This assumes n_mem_{addr,size}_cells have been set.
  */
-static void __init parse_drconf_memory(struct device_node *memory)
+static void __init numa_setup_drmem_lmb(struct drmem_lmb *lmb,
+					const __be32 **usm)
 {
-	const __be32 *uninitialized_var(dm), *usm;
-	unsigned int n, ranges, is_kexec_kdump = 0;
-	unsigned long lmb_size, base, size, sz;
+	unsigned int ranges, is_kexec_kdump = 0;
+	unsigned long base, size, sz;
 	int nid;
 
-	n = of_get_drconf_memory(memory, &dm);
-	if (!n)
-		return;
-
-	lmb_size = of_get_lmb_size(memory);
-	if (!lmb_size)
+	/* skip this block if the reserved bit is set in flags (0x80)
+	 * or if the block is not assigned to this partition (0x8)
+	 */
+	if ((lmb->flags & DRCONF_MEM_RESERVED)
+	    || !(lmb->flags & DRCONF_MEM_ASSIGNED))
 		return;
 
-	/* check if this is a kexec/kdump kernel */
-	usm = of_get_usable_memory();
-	if (usm != NULL)
+	if (*usm)
 		is_kexec_kdump = 1;
 
-	for (; n != 0; --n) {
-		struct of_drconf_cell drmem;
+	base = lmb->base_addr;
+	size = drmem_lmb_size();
+	ranges = 1;
 
-		read_drconf_cell(&drmem, &dm);
-
-		/* skip this block if the reserved bit is set in flags (0x80)
-		   or if the block is not assigned to this partition (0x8) */
-		if ((drmem.flags & DRCONF_MEM_RESERVED)
-		    || !(drmem.flags & DRCONF_MEM_ASSIGNED))
-			continue;
-
-		base = drmem.base_addr;
-		size = lmb_size;
-		ranges = 1;
+	if (is_kexec_kdump) {
+		ranges = read_usm_ranges(usm);
+		if (!ranges) /* there are no (base, size) duple */
+			return;
+	}
 
+	do {
 		if (is_kexec_kdump) {
-			ranges = read_usm_ranges(&usm);
-			if (!ranges) /* there are no (base, size) duple */
-				continue;
+			base = read_n_cells(n_mem_addr_cells, usm);
+			size = read_n_cells(n_mem_size_cells, usm);
 		}
-		do {
-			if (is_kexec_kdump) {
-				base = read_n_cells(n_mem_addr_cells, &usm);
-				size = read_n_cells(n_mem_size_cells, &usm);
-			}
-			nid = of_drconf_to_nid_single(&drmem);
-			fake_numa_create_new_node(
-				((base + size) >> PAGE_SHIFT),
-					   &nid);
-			node_set_online(nid);
-			sz = numa_enforce_memory_limit(base, size);
-			if (sz)
-				memblock_set_node(base, sz,
-						  &memblock.memory, nid);
-		} while (--ranges);
-	}
+
+		nid = of_drconf_to_nid_single(lmb);
+		fake_numa_create_new_node(((base + size) >> PAGE_SHIFT),
+					  &nid);
+		node_set_online(nid);
+		sz = numa_enforce_memory_limit(base, size);
+		if (sz)
+			memblock_set_node(base, sz, &memblock.memory, nid);
+	} while (--ranges);
 }
 
 static int __init parse_numa_properties(void)
@@ -815,8 +715,10 @@ static int __init parse_numa_properties(void)
 	 * ibm,dynamic-reconfiguration-memory node.
 	 */
 	memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
-	if (memory)
-		parse_drconf_memory(memory);
+	if (memory) {
+		walk_drmem_lmbs(memory, numa_setup_drmem_lmb);
+		of_node_put(memory);
+	}
 
 	return 0;
 }
@@ -994,38 +896,26 @@ early_param("topology_updates", early_topology_updates);
  * memory represented in the device tree by the property
  * ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory.
  */
-static int hot_add_drconf_scn_to_nid(struct device_node *memory,
-				     unsigned long scn_addr)
+static int hot_add_drconf_scn_to_nid(unsigned long scn_addr)
 {
-	const __be32 *dm;
-	unsigned int drconf_cell_cnt;
+	struct drmem_lmb *lmb;
 	unsigned long lmb_size;
 	int nid = -1;
 
-	drconf_cell_cnt = of_get_drconf_memory(memory, &dm);
-	if (!drconf_cell_cnt)
-		return -1;
-
-	lmb_size = of_get_lmb_size(memory);
-	if (!lmb_size)
-		return -1;
-
-	for (; drconf_cell_cnt != 0; --drconf_cell_cnt) {
-		struct of_drconf_cell drmem;
-
-		read_drconf_cell(&drmem, &dm);
+	lmb_size = drmem_lmb_size();
 
+	for_each_drmem_lmb(lmb) {
 		/* skip this block if it is reserved or not assigned to
 		 * this partition */
-		if ((drmem.flags & DRCONF_MEM_RESERVED)
-		    || !(drmem.flags & DRCONF_MEM_ASSIGNED))
+		if ((lmb->flags & DRCONF_MEM_RESERVED)
+		    || !(lmb->flags & DRCONF_MEM_ASSIGNED))
 			continue;
 
-		if ((scn_addr < drmem.base_addr)
-		    || (scn_addr >= (drmem.base_addr + lmb_size)))
+		if ((scn_addr < lmb->base_addr)
+		    || (scn_addr >= (lmb->base_addr + lmb_size)))
 			continue;
 
-		nid = of_drconf_to_nid_single(&drmem);
+		nid = of_drconf_to_nid_single(lmb);
 		break;
 	}
 
@@ -1090,7 +980,7 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
 
 	memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
 	if (memory) {
-		nid = hot_add_drconf_scn_to_nid(memory, scn_addr);
+		nid = hot_add_drconf_scn_to_nid(scn_addr);
 		of_node_put(memory);
 	} else {
 		nid = hot_add_node_scn_to_nid(scn_addr);
@@ -1106,11 +996,7 @@ static u64 hot_add_drconf_memory_max(void)
 {
 	struct device_node *memory = NULL;
 	struct device_node *dn = NULL;
-	unsigned int drconf_cell_cnt = 0;
-	u64 lmb_size = 0;
-	const __be32 *dm = NULL;
 	const __be64 *lrdr = NULL;
-	struct of_drconf_cell drmem;
 
 	dn = of_find_node_by_path("/rtas");
 	if (dn) {
@@ -1122,14 +1008,8 @@ static u64 hot_add_drconf_memory_max(void)
 
 	memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
 	if (memory) {
-		drconf_cell_cnt = of_get_drconf_memory(memory, &dm);
-		lmb_size = of_get_lmb_size(memory);
-
-		/* Advance to the last cell, each cell has 6 32 bit integers */
-		dm += (drconf_cell_cnt - 1) * 6;
-		read_drconf_cell(&drmem, &dm);
 		of_node_put(memory);
-		return drmem.base_addr + lmb_size;
+		return drmem_lmb_memory_max();
 	}
 	return 0;
 }

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

* [PATCH V3 6/9] powerpc/pseries: Update memory hotplug code to use drmem LMB array
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
                   ` (4 preceding siblings ...)
  2017-12-01 16:47 ` [PATCH V3 5/9] powerpc/numa: Update numa code use walk_drmem_lmbs Nathan Fontenot
@ 2017-12-01 16:47 ` Nathan Fontenot
  2017-12-01 16:47 ` [PATCH V3 7/9] powerpc: Move of_drconf_cell struct to asm/drmem.h Nathan Fontenot
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:47 UTC (permalink / raw)
  To: linuxppc-dev

Update the pseries memory hotplug code to use the newly added
dynamic reconfiguration LMB array. Doing this is required for the
upcoming support of version 2 of the dynamic reconfiguration
device tree property.

In addition, making this change cleans up the code that parses the
LMB information as we no longer need to worry about device tree
format. This allows us to discard one of the first steps on memory
hotplug where we make a working copy of the device tree property and
convert the entire property to cpu format. Instead we just use the
LMB array directly while holding the memory hotplug lock.

This patch also moves the updating of the device tree property to
powerpc/mm/drmem.c. This allows to the hotplug code to work without
needing to know the device tree format and provides a single
routine for updating the device tree property. This new routine
will handle determination of the proper device tree format and
generate a properly formatted device tree property.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---

Updates for V2: Correct build issues with uninitialized variables

 arch/powerpc/include/asm/drmem.h                |   18 +
 arch/powerpc/mm/drmem.c                         |   80 ++++
 arch/powerpc/platforms/pseries/hotplug-memory.c |  516 +++++++++--------------
 3 files changed, 296 insertions(+), 318 deletions(-)

diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
index 679da30a1bea..96d7a908146f 100644
--- a/arch/powerpc/include/asm/drmem.h
+++ b/arch/powerpc/include/asm/drmem.h
@@ -40,9 +40,27 @@ static inline u32 drmem_lmb_size(void)
 	return drmem_info->lmb_size;
 }
 
+#define DRMEM_LMB_RESERVED	0x80000000
+
+static inline void drmem_mark_lmb_reserved(struct drmem_lmb *lmb)
+{
+	lmb->flags |= DRMEM_LMB_RESERVED;
+}
+
+static inline void drmem_remove_lmb_reservation(struct drmem_lmb *lmb)
+{
+	lmb->flags &= ~DRMEM_LMB_RESERVED;
+}
+
+static inline bool drmem_lmb_reserved(struct drmem_lmb *lmb)
+{
+	return lmb->flags & DRMEM_LMB_RESERVED;
+}
+
 u64 drmem_lmb_memory_max(void);
 void __init walk_drmem_lmbs(struct device_node *dn,
 			void (*func)(struct drmem_lmb *, const __be32 **));
+int drmem_update_dt(void);
 
 #ifdef CONFIG_PPC_PSERIES
 void __init walk_drmem_lmbs_early(unsigned long node,
diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
index 5888ac3ca8a9..e9cf79eb1257 100644
--- a/arch/powerpc/mm/drmem.c
+++ b/arch/powerpc/mm/drmem.c
@@ -29,6 +29,86 @@ u64 drmem_lmb_memory_max(void)
 	return last_lmb->base_addr + drmem_lmb_size();
 }
 
+static u32 drmem_lmb_flags(struct drmem_lmb *lmb)
+{
+	/* Return the value of the lmb flags field minus the reserved
+	 * bit used internally for hotplug processing.
+	 */
+	return lmb->flags & ~DRMEM_LMB_RESERVED;
+}
+
+static struct property *clone_property(struct property *prop, u32 prop_sz)
+{
+	struct property *new_prop;
+
+	new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL);
+	if (!new_prop)
+		return NULL;
+
+	new_prop->name = kstrdup(prop->name, GFP_KERNEL);
+	new_prop->value = kzalloc(prop_sz, GFP_KERNEL);
+	if (!new_prop->name || !new_prop->value) {
+		kfree(new_prop->name);
+		kfree(new_prop->value);
+		kfree(new_prop);
+		return NULL;
+	}
+
+	new_prop->length = prop_sz;
+#if defined(CONFIG_OF_DYNAMIC)
+	of_property_set_flag(new_prop, OF_DYNAMIC);
+#endif
+	return new_prop;
+}
+
+static int drmem_update_dt_v1(struct device_node *memory,
+			      struct property *prop)
+{
+	struct property *new_prop;
+	struct of_drconf_cell *dr_cell;
+	struct drmem_lmb *lmb;
+	u32 *p;
+
+	new_prop = clone_property(prop, prop->length);
+	if (!new_prop)
+		return -1;
+
+	p = new_prop->value;
+	*p++ = cpu_to_be32(drmem_info->n_lmbs);
+
+	dr_cell = (struct of_drconf_cell *)p;
+
+	for_each_drmem_lmb(lmb) {
+		dr_cell->base_addr = cpu_to_be64(lmb->base_addr);
+		dr_cell->drc_index = cpu_to_be32(lmb->drc_index);
+		dr_cell->aa_index = cpu_to_be32(lmb->aa_index);
+		dr_cell->flags = cpu_to_be32(drmem_lmb_flags(lmb));
+
+		dr_cell++;
+	}
+
+	of_update_property(memory, new_prop);
+	return 0;
+}
+
+int drmem_update_dt(void)
+{
+	struct device_node *memory;
+	struct property *prop;
+	int rc = -1;
+
+	memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
+	if (!memory)
+		return -1;
+
+	prop = of_find_property(memory, "ibm,dynamic-memory", NULL);
+	if (prop)
+		rc = drmem_update_dt_v1(memory, prop);
+
+	of_node_put(memory);
+	return rc;
+}
+
 static void __init read_drconf_v1_cell(struct drmem_lmb *lmb,
 				       const __be32 **prop)
 {
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 1d48ab424bd9..2043bc2b77b3 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -23,6 +23,7 @@
 #include <asm/prom.h>
 #include <asm/sparsemem.h>
 #include <asm/fadump.h>
+#include <asm/drmem.h>
 #include "pseries.h"
 
 static bool rtas_hp_event;
@@ -100,100 +101,6 @@ static struct property *dlpar_clone_property(struct property *prop,
 	return new_prop;
 }
 
-static struct property *dlpar_clone_drconf_property(struct device_node *dn)
-{
-	struct property *prop, *new_prop;
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
-	int i;
-
-	prop = of_find_property(dn, "ibm,dynamic-memory", NULL);
-	if (!prop)
-		return NULL;
-
-	new_prop = dlpar_clone_property(prop, prop->length);
-	if (!new_prop)
-		return NULL;
-
-	/* Convert the property to cpu endian-ness */
-	p = new_prop->value;
-	*p = be32_to_cpu(*p);
-
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-
-	for (i = 0; i < num_lmbs; i++) {
-		lmbs[i].base_addr = be64_to_cpu(lmbs[i].base_addr);
-		lmbs[i].drc_index = be32_to_cpu(lmbs[i].drc_index);
-		lmbs[i].aa_index = be32_to_cpu(lmbs[i].aa_index);
-		lmbs[i].flags = be32_to_cpu(lmbs[i].flags);
-	}
-
-	return new_prop;
-}
-
-static void dlpar_update_drconf_property(struct device_node *dn,
-					 struct property *prop)
-{
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
-	int i;
-
-	/* Convert the property back to BE */
-	p = prop->value;
-	num_lmbs = *p;
-	*p = cpu_to_be32(*p);
-	p++;
-
-	lmbs = (struct of_drconf_cell *)p;
-	for (i = 0; i < num_lmbs; i++) {
-		lmbs[i].base_addr = cpu_to_be64(lmbs[i].base_addr);
-		lmbs[i].drc_index = cpu_to_be32(lmbs[i].drc_index);
-		lmbs[i].aa_index = cpu_to_be32(lmbs[i].aa_index);
-		lmbs[i].flags = cpu_to_be32(lmbs[i].flags);
-	}
-
-	rtas_hp_event = true;
-	of_update_property(dn, prop);
-	rtas_hp_event = false;
-}
-
-static int dlpar_update_device_tree_lmb(struct of_drconf_cell *lmb)
-{
-	struct device_node *dn;
-	struct property *prop;
-	struct of_drconf_cell *lmbs;
-	u32 *p, num_lmbs;
-	int i;
-
-	dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
-	if (!dn)
-		return -ENODEV;
-
-	prop = dlpar_clone_drconf_property(dn);
-	if (!prop) {
-		of_node_put(dn);
-		return -ENODEV;
-	}
-
-	p = prop->value;
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-
-	for (i = 0; i < num_lmbs; i++) {
-		if (lmbs[i].drc_index == lmb->drc_index) {
-			lmbs[i].flags = lmb->flags;
-			lmbs[i].aa_index = lmb->aa_index;
-
-			dlpar_update_drconf_property(dn, prop);
-			break;
-		}
-	}
-
-	of_node_put(dn);
-	return 0;
-}
-
 static u32 find_aa_index(struct device_node *dr_node,
 			 struct property *ala_prop, const u32 *lmb_assoc)
 {
@@ -256,7 +163,7 @@ static u32 find_aa_index(struct device_node *dr_node,
 	return aa_index;
 }
 
-static u32 lookup_lmb_associativity_index(struct of_drconf_cell *lmb)
+static u32 lookup_lmb_associativity_index(struct drmem_lmb *lmb)
 {
 	struct device_node *parent, *lmb_node, *dr_node;
 	struct property *ala_prop;
@@ -299,9 +206,9 @@ static u32 lookup_lmb_associativity_index(struct of_drconf_cell *lmb)
 	return aa_index;
 }
 
-static int dlpar_add_device_tree_lmb(struct of_drconf_cell *lmb)
+static int dlpar_add_device_tree_lmb(struct drmem_lmb *lmb)
 {
-	int aa_index;
+	int rc, aa_index;
 
 	lmb->flags |= DRCONF_MEM_ASSIGNED;
 
@@ -313,17 +220,29 @@ static int dlpar_add_device_tree_lmb(struct of_drconf_cell *lmb)
 	}
 
 	lmb->aa_index = aa_index;
-	return dlpar_update_device_tree_lmb(lmb);
+
+	rtas_hp_event = true;
+	rc = drmem_update_dt();
+	rtas_hp_event = false;
+
+	return rc;
 }
 
-static int dlpar_remove_device_tree_lmb(struct of_drconf_cell *lmb)
+static int dlpar_remove_device_tree_lmb(struct drmem_lmb *lmb)
 {
+	int rc;
+
 	lmb->flags &= ~DRCONF_MEM_ASSIGNED;
 	lmb->aa_index = 0xffffffff;
-	return dlpar_update_device_tree_lmb(lmb);
+
+	rtas_hp_event = true;
+	rc = drmem_update_dt();
+	rtas_hp_event = false;
+
+	return rc;
 }
 
-static struct memory_block *lmb_to_memblock(struct of_drconf_cell *lmb)
+static struct memory_block *lmb_to_memblock(struct drmem_lmb *lmb)
 {
 	unsigned long section_nr;
 	struct mem_section *mem_sect;
@@ -336,7 +255,36 @@ static struct memory_block *lmb_to_memblock(struct of_drconf_cell *lmb)
 	return mem_block;
 }
 
-static int dlpar_change_lmb_state(struct of_drconf_cell *lmb, bool online)
+static int get_lmb_range(u32 drc_index, int n_lmbs,
+			 struct drmem_lmb **start_lmb,
+			 struct drmem_lmb **end_lmb)
+{
+	struct drmem_lmb *lmb, *start, *end;
+	struct drmem_lmb *last_lmb;
+
+	start = NULL;
+	for_each_drmem_lmb(lmb) {
+		if (lmb->drc_index == drc_index) {
+			start = lmb;
+			break;
+		}
+	}
+
+	if (!start)
+		return -EINVAL;
+
+	end = &start[n_lmbs - 1];
+
+	last_lmb = &drmem_info->lmbs[drmem_info->n_lmbs - 1];
+	if (end > last_lmb)
+		return -EINVAL;
+
+	*start_lmb = start;
+	*end_lmb = end;
+	return 0;
+}
+
+static int dlpar_change_lmb_state(struct drmem_lmb *lmb, bool online)
 {
 	struct memory_block *mem_block;
 	int rc;
@@ -357,13 +305,13 @@ static int dlpar_change_lmb_state(struct of_drconf_cell *lmb, bool online)
 	return rc;
 }
 
-static int dlpar_online_lmb(struct of_drconf_cell *lmb)
+static int dlpar_online_lmb(struct drmem_lmb *lmb)
 {
 	return dlpar_change_lmb_state(lmb, true);
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-static int dlpar_offline_lmb(struct of_drconf_cell *lmb)
+static int dlpar_offline_lmb(struct drmem_lmb *lmb)
 {
 	return dlpar_change_lmb_state(lmb, false);
 }
@@ -426,7 +374,7 @@ static int pseries_remove_mem_node(struct device_node *np)
 	return 0;
 }
 
-static bool lmb_is_removable(struct of_drconf_cell *lmb)
+static bool lmb_is_removable(struct drmem_lmb *lmb)
 {
 	int i, scns_per_block;
 	int rc = 1;
@@ -458,9 +406,9 @@ static bool lmb_is_removable(struct of_drconf_cell *lmb)
 	return rc ? true : false;
 }
 
-static int dlpar_add_lmb(struct of_drconf_cell *);
+static int dlpar_add_lmb(struct drmem_lmb *);
 
-static int dlpar_remove_lmb(struct of_drconf_cell *lmb)
+static int dlpar_remove_lmb(struct drmem_lmb *lmb)
 {
 	unsigned long block_sz;
 	int nid, rc;
@@ -484,28 +432,25 @@ static int dlpar_remove_lmb(struct of_drconf_cell *lmb)
 	return 0;
 }
 
-static int dlpar_memory_remove_by_count(u32 lmbs_to_remove,
-					struct property *prop)
+static int dlpar_memory_remove_by_count(u32 lmbs_to_remove)
 {
-	struct of_drconf_cell *lmbs;
+	struct drmem_lmb *lmb;
 	int lmbs_removed = 0;
 	int lmbs_available = 0;
-	u32 num_lmbs, *p;
-	int i, rc;
+	int rc;
 
 	pr_info("Attempting to hot-remove %d LMB(s)\n", lmbs_to_remove);
 
 	if (lmbs_to_remove == 0)
 		return -EINVAL;
 
-	p = prop->value;
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-
 	/* Validate that there are enough LMBs to satisfy the request */
-	for (i = 0; i < num_lmbs; i++) {
-		if (lmb_is_removable(&lmbs[i]))
+	for_each_drmem_lmb(lmb) {
+		if (lmb_is_removable(lmb))
 			lmbs_available++;
+
+		if (lmbs_available == lmbs_to_remove)
+			break;
 	}
 
 	if (lmbs_available < lmbs_to_remove) {
@@ -514,45 +459,47 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_remove,
 		return -EINVAL;
 	}
 
-	for (i = 0; i < num_lmbs && lmbs_removed < lmbs_to_remove; i++) {
-		rc = dlpar_remove_lmb(&lmbs[i]);
+	for_each_drmem_lmb(lmb) {
+		rc = dlpar_remove_lmb(lmb);
 		if (rc)
 			continue;
 
-		lmbs_removed++;
-
 		/* Mark this lmb so we can add it later if all of the
 		 * requested LMBs cannot be removed.
 		 */
-		lmbs[i].reserved = 1;
+		drmem_mark_lmb_reserved(lmb);
+
+		lmbs_removed++;
+		if (lmbs_removed == lmbs_to_remove)
+			break;
 	}
 
 	if (lmbs_removed != lmbs_to_remove) {
 		pr_err("Memory hot-remove failed, adding LMB's back\n");
 
-		for (i = 0; i < num_lmbs; i++) {
-			if (!lmbs[i].reserved)
+		for_each_drmem_lmb(lmb) {
+			if (!drmem_lmb_reserved(lmb))
 				continue;
 
-			rc = dlpar_add_lmb(&lmbs[i]);
+			rc = dlpar_add_lmb(lmb);
 			if (rc)
 				pr_err("Failed to add LMB back, drc index %x\n",
-				       lmbs[i].drc_index);
+				       lmb->drc_index);
 
-			lmbs[i].reserved = 0;
+			drmem_remove_lmb_reservation(lmb);
 		}
 
 		rc = -EINVAL;
 	} else {
-		for (i = 0; i < num_lmbs; i++) {
-			if (!lmbs[i].reserved)
+		for_each_drmem_lmb(lmb) {
+			if (!drmem_lmb_reserved(lmb))
 				continue;
 
-			dlpar_release_drc(lmbs[i].drc_index);
+			dlpar_release_drc(lmb->drc_index);
 			pr_info("Memory at %llx was hot-removed\n",
-				lmbs[i].base_addr);
+				lmb->base_addr);
 
-			lmbs[i].reserved = 0;
+			drmem_remove_lmb_reservation(lmb);
 		}
 		rc = 0;
 	}
@@ -560,26 +507,21 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_remove,
 	return rc;
 }
 
-static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
+static int dlpar_memory_remove_by_index(u32 drc_index)
 {
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
+	struct drmem_lmb *lmb;
 	int lmb_found;
-	int i, rc;
+	int rc;
 
 	pr_info("Attempting to hot-remove LMB, drc index %x\n", drc_index);
 
-	p = prop->value;
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-
 	lmb_found = 0;
-	for (i = 0; i < num_lmbs; i++) {
-		if (lmbs[i].drc_index == drc_index) {
+	for_each_drmem_lmb(lmb) {
+		if (lmb->drc_index == drc_index) {
 			lmb_found = 1;
-			rc = dlpar_remove_lmb(&lmbs[i]);
+			rc = dlpar_remove_lmb(lmb);
 			if (!rc)
-				dlpar_release_drc(lmbs[i].drc_index);
+				dlpar_release_drc(lmb->drc_index);
 
 			break;
 		}
@@ -590,35 +532,30 @@ static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
 
 	if (rc)
 		pr_info("Failed to hot-remove memory at %llx\n",
-			lmbs[i].base_addr);
+			lmb->base_addr);
 	else
-		pr_info("Memory at %llx was hot-removed\n", lmbs[i].base_addr);
+		pr_info("Memory at %llx was hot-removed\n", lmb->base_addr);
 
 	return rc;
 }
 
-static int dlpar_memory_readd_by_index(u32 drc_index, struct property *prop)
+static int dlpar_memory_readd_by_index(u32 drc_index)
 {
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
+	struct drmem_lmb *lmb;
 	int lmb_found;
-	int i, rc;
+	int rc;
 
 	pr_info("Attempting to update LMB, drc index %x\n", drc_index);
 
-	p = prop->value;
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-
 	lmb_found = 0;
-	for (i = 0; i < num_lmbs; i++) {
-		if (lmbs[i].drc_index == drc_index) {
+	for_each_drmem_lmb(lmb) {
+		if (lmb->drc_index == drc_index) {
 			lmb_found = 1;
-			rc = dlpar_remove_lmb(&lmbs[i]);
+			rc = dlpar_remove_lmb(lmb);
 			if (!rc) {
-				rc = dlpar_add_lmb(&lmbs[i]);
+				rc = dlpar_add_lmb(lmb);
 				if (rc)
-					dlpar_release_drc(lmbs[i].drc_index);
+					dlpar_release_drc(lmb->drc_index);
 			}
 			break;
 		}
@@ -629,20 +566,18 @@ static int dlpar_memory_readd_by_index(u32 drc_index, struct property *prop)
 
 	if (rc)
 		pr_info("Failed to update memory at %llx\n",
-			lmbs[i].base_addr);
+			lmb->base_addr);
 	else
-		pr_info("Memory at %llx was updated\n", lmbs[i].base_addr);
+		pr_info("Memory at %llx was updated\n", lmb->base_addr);
 
 	return rc;
 }
 
-static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index,
-				     struct property *prop)
+static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index)
 {
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
-	int i, rc, start_lmb_found;
-	int lmbs_available = 0, start_index = 0, end_index;
+	struct drmem_lmb *lmb, *start_lmb, *end_lmb;
+	int lmbs_available = 0;
+	int rc;
 
 	pr_info("Attempting to hot-remove %u LMB(s) at %x\n",
 		lmbs_to_remove, drc_index);
@@ -650,29 +585,13 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index,
 	if (lmbs_to_remove == 0)
 		return -EINVAL;
 
-	p = prop->value;
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-	start_lmb_found = 0;
-
-	/* Navigate to drc_index */
-	while (start_index < num_lmbs) {
-		if (lmbs[start_index].drc_index == drc_index) {
-			start_lmb_found = 1;
-			break;
-		}
-
-		start_index++;
-	}
-
-	if (!start_lmb_found)
+	rc = get_lmb_range(drc_index, lmbs_to_remove, &start_lmb, &end_lmb);
+	if (rc)
 		return -EINVAL;
 
-	end_index = start_index + lmbs_to_remove;
-
 	/* Validate that there are enough LMBs to satisfy the request */
-	for (i = start_index; i < end_index; i++) {
-		if (lmbs[i].flags & DRCONF_MEM_RESERVED)
+	for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
+		if (lmb->flags & DRCONF_MEM_RESERVED)
 			break;
 
 		lmbs_available++;
@@ -681,42 +600,43 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index,
 	if (lmbs_available < lmbs_to_remove)
 		return -EINVAL;
 
-	for (i = start_index; i < end_index; i++) {
-		if (!(lmbs[i].flags & DRCONF_MEM_ASSIGNED))
+	for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
+		if (!(lmb->flags & DRCONF_MEM_ASSIGNED))
 			continue;
 
-		rc = dlpar_remove_lmb(&lmbs[i]);
+		rc = dlpar_remove_lmb(lmb);
 		if (rc)
 			break;
 
-		lmbs[i].reserved = 1;
+		drmem_mark_lmb_reserved(lmb);
 	}
 
 	if (rc) {
 		pr_err("Memory indexed-count-remove failed, adding any removed LMBs\n");
 
-		for (i = start_index; i < end_index; i++) {
-			if (!lmbs[i].reserved)
+
+		for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
+			if (!drmem_lmb_reserved(lmb))
 				continue;
 
-			rc = dlpar_add_lmb(&lmbs[i]);
+			rc = dlpar_add_lmb(lmb);
 			if (rc)
 				pr_err("Failed to add LMB, drc index %x\n",
-				       be32_to_cpu(lmbs[i].drc_index));
+				       lmb->drc_index);
 
-			lmbs[i].reserved = 0;
+			drmem_remove_lmb_reservation(lmb);
 		}
 		rc = -EINVAL;
 	} else {
-		for (i = start_index; i < end_index; i++) {
-			if (!lmbs[i].reserved)
+		for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
+			if (!drmem_lmb_reserved(lmb))
 				continue;
 
-			dlpar_release_drc(lmbs[i].drc_index);
+			dlpar_release_drc(lmb->drc_index);
 			pr_info("Memory at %llx (drc index %x) was hot-removed\n",
-				lmbs[i].base_addr, lmbs[i].drc_index);
+				lmb->base_addr, lmb->drc_index);
 
-			lmbs[i].reserved = 0;
+			drmem_remove_lmb_reservation(lmb);
 		}
 	}
 
@@ -737,32 +657,30 @@ static inline int dlpar_memory_remove(struct pseries_hp_errorlog *hp_elog)
 {
 	return -EOPNOTSUPP;
 }
-static int dlpar_remove_lmb(struct of_drconf_cell *lmb)
+static int dlpar_remove_lmb(struct drmem_lmb *lmb)
 {
 	return -EOPNOTSUPP;
 }
-static int dlpar_memory_remove_by_count(u32 lmbs_to_remove,
-					struct property *prop)
+static int dlpar_memory_remove_by_count(u32 lmbs_to_remove)
 {
 	return -EOPNOTSUPP;
 }
-static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
+static int dlpar_memory_remove_by_index(u32 drc_index)
 {
 	return -EOPNOTSUPP;
 }
-static int dlpar_memory_readd_by_index(u32 drc_index, struct property *prop)
+static int dlpar_memory_readd_by_index(u32 drc_index)
 {
 	return -EOPNOTSUPP;
 }
 
-static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index,
-				     struct property *prop)
+static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index)
 {
 	return -EOPNOTSUPP;
 }
 #endif /* CONFIG_MEMORY_HOTREMOVE */
 
-static int dlpar_add_lmb(struct of_drconf_cell *lmb)
+static int dlpar_add_lmb(struct drmem_lmb *lmb)
 {
 	unsigned long block_sz;
 	int nid, rc;
@@ -801,77 +719,79 @@ static int dlpar_add_lmb(struct of_drconf_cell *lmb)
 	return rc;
 }
 
-static int dlpar_memory_add_by_count(u32 lmbs_to_add, struct property *prop)
+static int dlpar_memory_add_by_count(u32 lmbs_to_add)
 {
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
+	struct drmem_lmb *lmb;
 	int lmbs_available = 0;
 	int lmbs_added = 0;
-	int i, rc;
+	int rc;
 
 	pr_info("Attempting to hot-add %d LMB(s)\n", lmbs_to_add);
 
 	if (lmbs_to_add == 0)
 		return -EINVAL;
 
-	p = prop->value;
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-
 	/* Validate that there are enough LMBs to satisfy the request */
-	for (i = 0; i < num_lmbs; i++) {
-		if (!(lmbs[i].flags & DRCONF_MEM_ASSIGNED))
+	for_each_drmem_lmb(lmb) {
+		if (!(lmb->flags & DRCONF_MEM_ASSIGNED))
 			lmbs_available++;
+
+		if (lmbs_available == lmbs_to_add)
+			break;
 	}
 
 	if (lmbs_available < lmbs_to_add)
 		return -EINVAL;
 
-	for (i = 0; i < num_lmbs && lmbs_to_add != lmbs_added; i++) {
-		if (lmbs[i].flags & DRCONF_MEM_ASSIGNED)
+	for_each_drmem_lmb(lmb) {
+		if (lmb->flags & DRCONF_MEM_ASSIGNED)
 			continue;
 
-		rc = dlpar_acquire_drc(lmbs[i].drc_index);
+		rc = dlpar_acquire_drc(lmb->drc_index);
 		if (rc)
 			continue;
 
-		rc = dlpar_add_lmb(&lmbs[i]);
+		rc = dlpar_add_lmb(lmb);
 		if (rc) {
-			dlpar_release_drc(lmbs[i].drc_index);
+			dlpar_release_drc(lmb->drc_index);
 			continue;
 		}
 
-		lmbs_added++;
-
 		/* Mark this lmb so we can remove it later if all of the
 		 * requested LMBs cannot be added.
 		 */
-		lmbs[i].reserved = 1;
+		drmem_mark_lmb_reserved(lmb);
+
+		lmbs_added++;
+		if (lmbs_added == lmbs_to_add)
+			break;
 	}
 
 	if (lmbs_added != lmbs_to_add) {
 		pr_err("Memory hot-add failed, removing any added LMBs\n");
 
-		for (i = 0; i < num_lmbs; i++) {
-			if (!lmbs[i].reserved)
+		for_each_drmem_lmb(lmb) {
+			if (!drmem_lmb_reserved(lmb))
 				continue;
 
-			rc = dlpar_remove_lmb(&lmbs[i]);
+			rc = dlpar_remove_lmb(lmb);
 			if (rc)
 				pr_err("Failed to remove LMB, drc index %x\n",
-				       be32_to_cpu(lmbs[i].drc_index));
+				       lmb->drc_index);
 			else
-				dlpar_release_drc(lmbs[i].drc_index);
+				dlpar_release_drc(lmb->drc_index);
+
+			drmem_remove_lmb_reservation(lmb);
 		}
 		rc = -EINVAL;
 	} else {
-		for (i = 0; i < num_lmbs; i++) {
-			if (!lmbs[i].reserved)
+		for_each_drmem_lmb(lmb) {
+			if (!drmem_lmb_reserved(lmb))
 				continue;
 
 			pr_info("Memory at %llx (drc index %x) was hot-added\n",
-				lmbs[i].base_addr, lmbs[i].drc_index);
-			lmbs[i].reserved = 0;
+				lmb->base_addr, lmb->drc_index);
+			drmem_remove_lmb_reservation(lmb);
 		}
 		rc = 0;
 	}
@@ -879,28 +799,22 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add, struct property *prop)
 	return rc;
 }
 
-static int dlpar_memory_add_by_index(u32 drc_index, struct property *prop)
+static int dlpar_memory_add_by_index(u32 drc_index)
 {
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
-	int i, lmb_found;
-	int rc;
+	struct drmem_lmb *lmb;
+	int rc, lmb_found;
 
 	pr_info("Attempting to hot-add LMB, drc index %x\n", drc_index);
 
-	p = prop->value;
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-
 	lmb_found = 0;
-	for (i = 0; i < num_lmbs; i++) {
-		if (lmbs[i].drc_index == drc_index) {
+	for_each_drmem_lmb(lmb) {
+		if (lmb->drc_index == drc_index) {
 			lmb_found = 1;
-			rc = dlpar_acquire_drc(lmbs[i].drc_index);
+			rc = dlpar_acquire_drc(lmb->drc_index);
 			if (!rc) {
-				rc = dlpar_add_lmb(&lmbs[i]);
+				rc = dlpar_add_lmb(lmb);
 				if (rc)
-					dlpar_release_drc(lmbs[i].drc_index);
+					dlpar_release_drc(lmb->drc_index);
 			}
 
 			break;
@@ -914,18 +828,16 @@ static int dlpar_memory_add_by_index(u32 drc_index, struct property *prop)
 		pr_info("Failed to hot-add memory, drc index %x\n", drc_index);
 	else
 		pr_info("Memory at %llx (drc index %x) was hot-added\n",
-			lmbs[i].base_addr, drc_index);
+			lmb->base_addr, drc_index);
 
 	return rc;
 }
 
-static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index,
-				  struct property *prop)
+static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index)
 {
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
-	int i, rc, start_lmb_found;
-	int lmbs_available = 0, start_index = 0, end_index;
+	struct drmem_lmb *lmb, *start_lmb, *end_lmb;
+	int lmbs_available = 0;
+	int rc;
 
 	pr_info("Attempting to hot-add %u LMB(s) at index %x\n",
 		lmbs_to_add, drc_index);
@@ -933,29 +845,13 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index,
 	if (lmbs_to_add == 0)
 		return -EINVAL;
 
-	p = prop->value;
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-	start_lmb_found = 0;
-
-	/* Navigate to drc_index */
-	while (start_index < num_lmbs) {
-		if (lmbs[start_index].drc_index == drc_index) {
-			start_lmb_found = 1;
-			break;
-		}
-
-		start_index++;
-	}
-
-	if (!start_lmb_found)
+	rc = get_lmb_range(drc_index, lmbs_to_add, &start_lmb, &end_lmb);
+	if (rc)
 		return -EINVAL;
 
-	end_index = start_index + lmbs_to_add;
-
 	/* Validate that the LMBs in this range are not reserved */
-	for (i = start_index; i < end_index; i++) {
-		if (lmbs[i].flags & DRCONF_MEM_RESERVED)
+	for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
+		if (lmb->flags & DRCONF_MEM_RESERVED)
 			break;
 
 		lmbs_available++;
@@ -964,46 +860,48 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index,
 	if (lmbs_available < lmbs_to_add)
 		return -EINVAL;
 
-	for (i = start_index; i < end_index; i++) {
-		if (lmbs[i].flags & DRCONF_MEM_ASSIGNED)
+	for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
+		if (lmb->flags & DRCONF_MEM_ASSIGNED)
 			continue;
 
-		rc = dlpar_acquire_drc(lmbs[i].drc_index);
+		rc = dlpar_acquire_drc(lmb->drc_index);
 		if (rc)
 			break;
 
-		rc = dlpar_add_lmb(&lmbs[i]);
+		rc = dlpar_add_lmb(lmb);
 		if (rc) {
-			dlpar_release_drc(lmbs[i].drc_index);
+			dlpar_release_drc(lmb->drc_index);
 			break;
 		}
 
-		lmbs[i].reserved = 1;
+		drmem_mark_lmb_reserved(lmb);
 	}
 
 	if (rc) {
 		pr_err("Memory indexed-count-add failed, removing any added LMBs\n");
 
-		for (i = start_index; i < end_index; i++) {
-			if (!lmbs[i].reserved)
+		for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
+			if (!drmem_lmb_reserved(lmb))
 				continue;
 
-			rc = dlpar_remove_lmb(&lmbs[i]);
+			rc = dlpar_remove_lmb(lmb);
 			if (rc)
 				pr_err("Failed to remove LMB, drc index %x\n",
-				       be32_to_cpu(lmbs[i].drc_index));
+				       lmb->drc_index);
 			else
-				dlpar_release_drc(lmbs[i].drc_index);
+				dlpar_release_drc(lmb->drc_index);
+
+			drmem_remove_lmb_reservation(lmb);
 		}
 		rc = -EINVAL;
 	} else {
-		for (i = start_index; i < end_index; i++) {
-			if (!lmbs[i].reserved)
+		for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
+			if (!drmem_lmb_reserved(lmb))
 				continue;
 
 			pr_info("Memory at %llx (drc index %x) was hot-added\n",
-				lmbs[i].base_addr, lmbs[i].drc_index);
-			lmbs[i].reserved = 0;
+				lmb->base_addr, lmb->drc_index);
+			drmem_remove_lmb_reservation(lmb);
 		}
 	}
 
@@ -1012,37 +910,23 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index,
 
 int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 {
-	struct device_node *dn;
-	struct property *prop;
 	u32 count, drc_index;
 	int rc;
 
 	lock_device_hotplug();
 
-	dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
-	if (!dn) {
-		rc = -EINVAL;
-		goto dlpar_memory_out;
-	}
-
-	prop = dlpar_clone_drconf_property(dn);
-	if (!prop) {
-		rc = -EINVAL;
-		goto dlpar_memory_out;
-	}
-
 	switch (hp_elog->action) {
 	case PSERIES_HP_ELOG_ACTION_ADD:
 		if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) {
 			count = hp_elog->_drc_u.drc_count;
-			rc = dlpar_memory_add_by_count(count, prop);
+			rc = dlpar_memory_add_by_count(count);
 		} else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
 			drc_index = hp_elog->_drc_u.drc_index;
-			rc = dlpar_memory_add_by_index(drc_index, prop);
+			rc = dlpar_memory_add_by_index(drc_index);
 		} else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_IC) {
 			count = hp_elog->_drc_u.ic.count;
 			drc_index = hp_elog->_drc_u.ic.index;
-			rc = dlpar_memory_add_by_ic(count, drc_index, prop);
+			rc = dlpar_memory_add_by_ic(count, drc_index);
 		} else {
 			rc = -EINVAL;
 		}
@@ -1051,14 +935,14 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 	case PSERIES_HP_ELOG_ACTION_REMOVE:
 		if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) {
 			count = hp_elog->_drc_u.drc_count;
-			rc = dlpar_memory_remove_by_count(count, prop);
+			rc = dlpar_memory_remove_by_count(count);
 		} else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
 			drc_index = hp_elog->_drc_u.drc_index;
-			rc = dlpar_memory_remove_by_index(drc_index, prop);
+			rc = dlpar_memory_remove_by_index(drc_index);
 		} else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_IC) {
 			count = hp_elog->_drc_u.ic.count;
 			drc_index = hp_elog->_drc_u.ic.index;
-			rc = dlpar_memory_remove_by_ic(count, drc_index, prop);
+			rc = dlpar_memory_remove_by_ic(count, drc_index);
 		} else {
 			rc = -EINVAL;
 		}
@@ -1066,7 +950,7 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 		break;
 	case PSERIES_HP_ELOG_ACTION_READD:
 		drc_index = hp_elog->_drc_u.drc_index;
-		rc = dlpar_memory_readd_by_index(drc_index, prop);
+		rc = dlpar_memory_readd_by_index(drc_index);
 		break;
 	default:
 		pr_err("Invalid action (%d) specified\n", hp_elog->action);
@@ -1074,10 +958,6 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 		break;
 	}
 
-	dlpar_free_property(prop);
-
-dlpar_memory_out:
-	of_node_put(dn);
 	unlock_device_hotplug();
 	return rc;
 }

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

* [PATCH V3 7/9] powerpc: Move of_drconf_cell struct to asm/drmem.h
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
                   ` (5 preceding siblings ...)
  2017-12-01 16:47 ` [PATCH V3 6/9] powerpc/pseries: Update memory hotplug code to use drmem LMB array Nathan Fontenot
@ 2017-12-01 16:47 ` Nathan Fontenot
  2017-12-01 16:47 ` [PATCH V3 8/9] powerpc/drmem: Add support for ibm, dynamic-memory-v2 property Nathan Fontenot
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:47 UTC (permalink / raw)
  To: linuxppc-dev

Now that the powerpc code parses dynamic reconfiguration memory
LMB information from the LMB array and not the device tree
directly we can move the of_drconf_cell struct to drmem.h where
it fits better.

In addition, the struct is renamed to of_drconf_cell_v1 in
anticipation of upcoming support for version 2 of the dynamic
reconfiguration property and the members are typed as __be*
values to reflect how they exist in the device tree.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/drmem.h                |   18 ++++++++++++++++++
 arch/powerpc/include/asm/prom.h                 |   16 ----------------
 arch/powerpc/mm/drmem.c                         |    4 ++--
 arch/powerpc/platforms/pseries/hotplug-memory.c |    6 +++---
 4 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
index 96d7a908146f..afa7dce89a67 100644
--- a/arch/powerpc/include/asm/drmem.h
+++ b/arch/powerpc/include/asm/drmem.h
@@ -35,6 +35,24 @@ extern struct drmem_lmb_info *drmem_info;
 		&drmem_info->lmbs[0],				\
 		&drmem_info->lmbs[drmem_info->n_lmbs - 1])
 
+/* The of_drconf_cell_v1 struct defines the layout of the LMB data
+ * specified in the ibm,dynamic-memory device tree property.
+ * The property itself is a 32-bit value specifying the number of
+ * LMBs followed by an array of of_drconf_cell_v1 entries, one
+ * per LMB.
+ */
+struct of_drconf_cell_v1 {
+	__be64	base_addr;
+	__be32	drc_index;
+	__be32	reserved;
+	__be32	aa_index;
+	__be32	flags;
+};
+
+#define DRCONF_MEM_ASSIGNED	0x00000008
+#define DRCONF_MEM_AI_INVALID	0x00000040
+#define DRCONF_MEM_RESERVED	0x00000080
+
 static inline u32 drmem_lmb_size(void)
 {
 	return drmem_info->lmb_size;
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 825bd5998701..f0a30a003bd8 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -80,22 +80,6 @@ extern void of_instantiate_rtc(void);
 
 extern int of_get_ibm_chip_id(struct device_node *np);
 
-/* The of_drconf_cell struct defines the layout of the LMB array
- * specified in the device tree property
- * ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory
- */
-struct of_drconf_cell {
-	u64	base_addr;
-	u32	drc_index;
-	u32	reserved;
-	u32	aa_index;
-	u32	flags;
-};
-
-#define DRCONF_MEM_ASSIGNED	0x00000008
-#define DRCONF_MEM_AI_INVALID	0x00000040
-#define DRCONF_MEM_RESERVED	0x00000080
-
 /*
  * There are two methods for telling firmware what our capabilities are.
  * Newer machines have an "ibm,client-architecture-support" method on the
diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
index e9cf79eb1257..5fe3944ebf28 100644
--- a/arch/powerpc/mm/drmem.c
+++ b/arch/powerpc/mm/drmem.c
@@ -65,7 +65,7 @@ static int drmem_update_dt_v1(struct device_node *memory,
 			      struct property *prop)
 {
 	struct property *new_prop;
-	struct of_drconf_cell *dr_cell;
+	struct of_drconf_cell_v1 *dr_cell;
 	struct drmem_lmb *lmb;
 	u32 *p;
 
@@ -76,7 +76,7 @@ static int drmem_update_dt_v1(struct device_node *memory,
 	p = new_prop->value;
 	*p++ = cpu_to_be32(drmem_info->n_lmbs);
 
-	dr_cell = (struct of_drconf_cell *)p;
+	dr_cell = (struct of_drconf_cell_v1 *)p;
 
 	for_each_drmem_lmb(lmb) {
 		dr_cell->base_addr = cpu_to_be64(lmb->base_addr);
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 2043bc2b77b3..c1578f54c626 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -996,7 +996,7 @@ static int pseries_add_mem_node(struct device_node *np)
 
 static int pseries_update_drconf_memory(struct of_reconfig_data *pr)
 {
-	struct of_drconf_cell *new_drmem, *old_drmem;
+	struct of_drconf_cell_v1 *new_drmem, *old_drmem;
 	unsigned long memblock_size;
 	u32 entries;
 	__be32 *p;
@@ -1019,11 +1019,11 @@ static int pseries_update_drconf_memory(struct of_reconfig_data *pr)
 	 * of_drconf_cell's.
 	 */
 	entries = be32_to_cpu(*p++);
-	old_drmem = (struct of_drconf_cell *)p;
+	old_drmem = (struct of_drconf_cell_v1 *)p;
 
 	p = (__be32 *)pr->prop->value;
 	p++;
-	new_drmem = (struct of_drconf_cell *)p;
+	new_drmem = (struct of_drconf_cell_v1 *)p;
 
 	for (i = 0; i < entries; i++) {
 		if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) &&

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

* [PATCH V3 8/9] powerpc/drmem: Add support for ibm, dynamic-memory-v2 property
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
                   ` (6 preceding siblings ...)
  2017-12-01 16:47 ` [PATCH V3 7/9] powerpc: Move of_drconf_cell struct to asm/drmem.h Nathan Fontenot
@ 2017-12-01 16:47 ` Nathan Fontenot
  2018-01-17 13:30   ` [V3, " Michael Ellerman
  2017-12-01 16:48 ` [PATCH V3 9/9] powerpc: Enable support of ibm,dynamic-memory-v2 Nathan Fontenot
  2017-12-04  5:13 ` [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Michael Ellerman
  9 siblings, 1 reply; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:47 UTC (permalink / raw)
  To: linuxppc-dev

The Power Hypervisor has introduced a new device tree format for
the property describing the dynamic reconfiguration LMBs for a system,
ibm,dynamic-memory-v2. This new format condenses the size of the
property, especially on large memory systems, by reporting sets
of LMBs that have the same properties (flags and associativity array
index).

This patch updates the powerpc/mm/drmem.c code to provide routines
that can parse the new device tree format during the walk_drmem_lmb*
routines used during boot, the creation of the LMB array, and updating
the device tree to create a new property in the proper format for
ibm,dynamic-memory-v2.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

---

Updates for V3: Provide parsing routines for ibm,dynamic-memory-v2
to be called from the walk_drmem_lmb* routines.

 arch/powerpc/include/asm/drmem.h |   12 ++
 arch/powerpc/mm/drmem.c          |  192 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 200 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
index afa7dce89a67..47a701263b03 100644
--- a/arch/powerpc/include/asm/drmem.h
+++ b/arch/powerpc/include/asm/drmem.h
@@ -49,6 +49,18 @@ struct of_drconf_cell_v1 {
 	__be32	flags;
 };
 
+/* Version 2 of the ibm,dynamic-memory property is defined as a
+ * 32-bit value specifying the number of LMB sets followed by an
+ * array of of_drconf_cell_v2 entries, one per LMB set.
+ */
+struct of_drconf_cell_v2 {
+	u32	seq_lmbs;
+	u64	base_addr;
+	u32	drc_index;
+	u32	aa_index;
+	u32	flags;
+} __packed;
+
 #define DRCONF_MEM_ASSIGNED	0x00000008
 #define DRCONF_MEM_AI_INVALID	0x00000040
 #define DRCONF_MEM_RESERVED	0x00000080
diff --git a/arch/powerpc/mm/drmem.c b/arch/powerpc/mm/drmem.c
index 5fe3944ebf28..31dbe14f1d96 100644
--- a/arch/powerpc/mm/drmem.c
+++ b/arch/powerpc/mm/drmem.c
@@ -91,6 +91,84 @@ static int drmem_update_dt_v1(struct device_node *memory,
 	return 0;
 }
 
+static void init_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell,
+				struct drmem_lmb *lmb)
+{
+	dr_cell->base_addr = cpu_to_be64(lmb->base_addr);
+	dr_cell->drc_index = cpu_to_be32(lmb->drc_index);
+	dr_cell->aa_index = cpu_to_be32(lmb->aa_index);
+	dr_cell->flags = cpu_to_be32(lmb->flags);
+}
+
+static int drmem_update_dt_v2(struct device_node *memory,
+			      struct property *prop)
+{
+	struct property *new_prop;
+	struct of_drconf_cell_v2 *dr_cell;
+	struct drmem_lmb *lmb, *prev_lmb;
+	u32 lmb_sets, prop_sz, seq_lmbs;
+	u32 *p;
+
+	/* First pass, determine how many LMB sets are needed. */
+	lmb_sets = 0;
+	prev_lmb = NULL;
+	for_each_drmem_lmb(lmb) {
+		if (!prev_lmb) {
+			prev_lmb = lmb;
+			lmb_sets++;
+			continue;
+		}
+
+		if (prev_lmb->aa_index != lmb->aa_index ||
+		    prev_lmb->flags != lmb->flags)
+			lmb_sets++;
+
+		prev_lmb = lmb;
+	}
+
+	prop_sz = lmb_sets * sizeof(*dr_cell) + sizeof(__be32);
+	new_prop = clone_property(prop, prop_sz);
+	if (!new_prop)
+		return -1;
+
+	p = new_prop->value;
+	*p++ = cpu_to_be32(lmb_sets);
+
+	dr_cell = (struct of_drconf_cell_v2 *)p;
+
+	/* Second pass, populate the LMB set data */
+	prev_lmb = NULL;
+	seq_lmbs = 0;
+	for_each_drmem_lmb(lmb) {
+		if (prev_lmb == NULL) {
+			/* Start of first LMB set */
+			prev_lmb = lmb;
+			init_drconf_v2_cell(dr_cell, lmb);
+			seq_lmbs++;
+			continue;
+		}
+
+		if (prev_lmb->aa_index != lmb->aa_index ||
+		    prev_lmb->flags != lmb->flags) {
+			/* end of one set, start of another */
+			dr_cell->seq_lmbs = cpu_to_be32(seq_lmbs);
+			dr_cell++;
+
+			init_drconf_v2_cell(dr_cell, lmb);
+			seq_lmbs = 1;
+		} else {
+			seq_lmbs++;
+		}
+
+		prev_lmb = lmb;
+	}
+
+	/* close out last LMB set */
+	dr_cell->seq_lmbs = cpu_to_be32(seq_lmbs);
+	of_update_property(memory, new_prop);
+	return 0;
+}
+
 int drmem_update_dt(void)
 {
 	struct device_node *memory;
@@ -102,8 +180,13 @@ int drmem_update_dt(void)
 		return -1;
 
 	prop = of_find_property(memory, "ibm,dynamic-memory", NULL);
-	if (prop)
+	if (prop) {
 		rc = drmem_update_dt_v1(memory, prop);
+	} else {
+		prop = of_find_property(memory, "ibm,dynamic-memory-v2", NULL);
+		if (prop)
+			rc = drmem_update_dt_v2(memory, prop);
+	}
 
 	of_node_put(memory);
 	return rc;
@@ -139,6 +222,47 @@ static void __init __walk_drmem_v1_lmbs(const __be32 *prop, const __be32 *usm,
 	}
 }
 
+static void __init read_drconf_v2_cell(struct of_drconf_cell_v2 *dr_cell,
+				       const __be32 **prop)
+{
+	const __be32 *p = *prop;
+
+	dr_cell->seq_lmbs = of_read_number(p++, 1);
+	dr_cell->base_addr = dt_mem_next_cell(dt_root_addr_cells, &p);
+	dr_cell->drc_index = of_read_number(p++, 1);
+	dr_cell->aa_index = of_read_number(p++, 1);
+	dr_cell->flags = of_read_number(p++, 1);
+
+	*prop = p;
+}
+
+static void __init __walk_drmem_v2_lmbs(const __be32 *prop, const __be32 *usm,
+			void (*func)(struct drmem_lmb *, const __be32 **))
+{
+	struct of_drconf_cell_v2 dr_cell;
+	struct drmem_lmb lmb;
+	u32 i, j, lmb_sets;
+
+	lmb_sets = of_read_number(prop++, 1);
+
+	for (i = 0; i < lmb_sets; i++) {
+		read_drconf_v2_cell(&dr_cell, &prop);
+
+		for (j = 0; j < dr_cell.seq_lmbs; j++) {
+			lmb.base_addr = dr_cell.base_addr;
+			dr_cell.base_addr += drmem_lmb_size();
+
+			lmb.drc_index = dr_cell.drc_index;
+			dr_cell.drc_index++;
+
+			lmb.aa_index = dr_cell.aa_index;
+			lmb.flags = dr_cell.flags;
+
+			func(&lmb, &usm);
+		}
+	}
+}
+
 #ifdef CONFIG_PPC_PSERIES
 void __init walk_drmem_lmbs_early(unsigned long node,
 			void (*func)(struct drmem_lmb *, const __be32 **))
@@ -155,8 +279,14 @@ void __init walk_drmem_lmbs_early(unsigned long node,
 	usm = of_get_flat_dt_prop(node, "linux,drconf-usable-memory", &len);
 
 	prop = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &len);
-	if (prop)
+	if (prop) {
 		__walk_drmem_v1_lmbs(prop, usm, func);
+	} else {
+		prop = of_get_flat_dt_prop(node, "ibm,dynamic-memory-v2",
+					   &len);
+		if (prop)
+			__walk_drmem_v2_lmbs(prop, usm, func);
+	}
 
 	memblock_dump_all();
 }
@@ -209,8 +339,13 @@ void __init walk_drmem_lmbs(struct device_node *dn,
 	usm = of_get_usable_memory(dn);
 
 	prop = of_get_property(dn, "ibm,dynamic-memory", NULL);
-	if (prop)
+	if (prop) {
 		__walk_drmem_v1_lmbs(prop, usm, func);
+	} else {
+		prop = of_get_property(dn, "ibm,dynamic-memory-v2", NULL);
+		if (prop)
+			__walk_drmem_v2_lmbs(prop, usm, func);
+	}
 }
 
 static void __init init_drmem_v1_lmbs(const __be32 *prop)
@@ -228,6 +363,50 @@ static void __init init_drmem_v1_lmbs(const __be32 *prop)
 		read_drconf_v1_cell(lmb, &prop);
 }
 
+static void __init init_drmem_v2_lmbs(const __be32 *prop)
+{
+	struct drmem_lmb *lmb;
+	struct of_drconf_cell_v2 dr_cell;
+	const __be32 *p;
+	u32 i, j, lmb_sets;
+	int lmb_index;
+
+	lmb_sets = of_read_number(prop++, 1);
+
+	/* first pass, calculate the number of LMBs */
+	p = prop;
+	for (i = 0; i < lmb_sets; i++) {
+		read_drconf_v2_cell(&dr_cell, &p);
+		drmem_info->n_lmbs += dr_cell.seq_lmbs;
+	}
+
+	drmem_info->lmbs = kcalloc(drmem_info->n_lmbs, sizeof(*lmb),
+				   GFP_KERNEL);
+	if (!drmem_info->lmbs)
+		return;
+
+	/* second pass, read in the LMB information */
+	lmb_index = 0;
+	p = prop;
+
+	for (i = 0; i < lmb_sets; i++) {
+		read_drconf_v2_cell(&dr_cell, &p);
+
+		for (j = 0; j < dr_cell.seq_lmbs; j++) {
+			lmb = &drmem_info->lmbs[lmb_index++];
+
+			lmb->base_addr = dr_cell.base_addr;
+			dr_cell.base_addr += drmem_info->lmb_size;
+
+			lmb->drc_index = dr_cell.drc_index;
+			dr_cell.drc_index++;
+
+			lmb->aa_index = dr_cell.aa_index;
+			lmb->flags = dr_cell.flags;
+		}
+	}
+}
+
 static int __init drmem_init(void)
 {
 	struct device_node *dn;
@@ -245,8 +424,13 @@ static int __init drmem_init(void)
 	}
 
 	prop = of_get_property(dn, "ibm,dynamic-memory", NULL);
-	if (prop)
+	if (prop) {
 		init_drmem_v1_lmbs(prop);
+	} else {
+		prop = of_get_property(dn, "ibm,dynamic-memory-v2", NULL);
+		if (prop)
+			init_drmem_v2_lmbs(prop);
+	}
 
 	of_node_put(dn);
 	return 0;

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

* [PATCH V3 9/9] powerpc: Enable support of ibm,dynamic-memory-v2
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
                   ` (7 preceding siblings ...)
  2017-12-01 16:47 ` [PATCH V3 8/9] powerpc/drmem: Add support for ibm, dynamic-memory-v2 property Nathan Fontenot
@ 2017-12-01 16:48 ` Nathan Fontenot
  2018-01-17 13:30   ` [V3,9/9] " Michael Ellerman
  2017-12-04  5:13 ` [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Michael Ellerman
  9 siblings, 1 reply; 17+ messages in thread
From: Nathan Fontenot @ 2017-12-01 16:48 UTC (permalink / raw)
  To: linuxppc-dev

Add required bits to the architecture vector to enable support
of the ibm,dynamic-memory-v2 device tree property.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/firmware.h       |    3 ++-
 arch/powerpc/include/asm/prom.h           |    1 +
 arch/powerpc/kernel/prom_init.c           |    1 +
 arch/powerpc/platforms/pseries/firmware.c |    1 +
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index 8645897472b1..832df61f30ef 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -51,6 +51,7 @@
 #define FW_FEATURE_BEST_ENERGY	ASM_CONST(0x0000000080000000)
 #define FW_FEATURE_TYPE1_AFFINITY ASM_CONST(0x0000000100000000)
 #define FW_FEATURE_PRRN		ASM_CONST(0x0000000200000000)
+#define FW_FEATURE_DRMEM_V2	ASM_CONST(0x0000000400000000)
 
 #ifndef __ASSEMBLY__
 
@@ -67,7 +68,7 @@ enum {
 		FW_FEATURE_CMO | FW_FEATURE_VPHN | FW_FEATURE_XCMO |
 		FW_FEATURE_SET_MODE | FW_FEATURE_BEST_ENERGY |
 		FW_FEATURE_TYPE1_AFFINITY | FW_FEATURE_PRRN |
-		FW_FEATURE_HPT_RESIZE,
+		FW_FEATURE_HPT_RESIZE | FW_FEATURE_DRMEM_V2,
 	FW_FEATURE_PSERIES_ALWAYS = 0,
 	FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL,
 	FW_FEATURE_POWERNV_ALWAYS = 0,
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index f0a30a003bd8..9f27866e3126 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -143,6 +143,7 @@ extern int of_get_ibm_chip_id(struct device_node *np);
 #define OV5_PFO_HW_842		0x1140	/* PFO Compression Accelerator */
 #define OV5_PFO_HW_ENCR		0x1120	/* PFO Encryption Accelerator */
 #define OV5_SUB_PROCESSORS	0x1501	/* 1,2,or 4 Sub-Processors supported */
+#define OV5_DRMEM_V2		0x1680	/* ibm,dynamic-reconfiguration-v2 */
 #define OV5_XIVE_SUPPORT	0x17C0	/* XIVE Exploitation Support Mask */
 #define OV5_XIVE_LEGACY		0x1700	/* XIVE legacy mode Only */
 #define OV5_XIVE_EXPLOIT	0x1740	/* XIVE exploitation mode Only */
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 02190e90c7ae..acf4b2e0530c 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -869,6 +869,7 @@ struct ibm_arch_vec __cacheline_aligned ibm_architecture_vec = {
 		.reserved2 = 0,
 		.reserved3 = 0,
 		.subprocessors = 1,
+		.byte22 = OV5_FEAT(OV5_DRMEM_V2),
 		.intarch = 0,
 		.mmu = 0,
 		.hash_ext = 0,
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
index 63cc82ad58ac..aac3ea2911b2 100644
--- a/arch/powerpc/platforms/pseries/firmware.c
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -114,6 +114,7 @@ static __initdata struct vec5_fw_feature
 vec5_fw_features_table[] = {
 	{FW_FEATURE_TYPE1_AFFINITY,	OV5_TYPE1_AFFINITY},
 	{FW_FEATURE_PRRN,		OV5_PRRN},
+	{FW_FEATURE_DRMEM_V2,		OV5_DRMEM_V2},
 };
 
 static void __init fw_vec5_feature_init(const char *vec5, unsigned long len)

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

* Re: [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2
  2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
                   ` (8 preceding siblings ...)
  2017-12-01 16:48 ` [PATCH V3 9/9] powerpc: Enable support of ibm,dynamic-memory-v2 Nathan Fontenot
@ 2017-12-04  5:13 ` Michael Ellerman
  2018-02-14 21:30   ` Tyrel Datwyler
  9 siblings, 1 reply; 17+ messages in thread
From: Michael Ellerman @ 2017-12-04  5:13 UTC (permalink / raw)
  To: Nathan Fontenot, linuxppc-dev

Nathan Fontenot <nfont@linux.vnet.ibm.com> writes:

> This patch set provides a series of updates to de-couple the LMB
> information provided in the device tree property from the device
> tree property format. This eases the ability to support a new
> format for the dynamic memory property, ibm,dynamic-memory-v2.

Something in here is still blowing up for me in a KVM guest:

    OF stdout device is: /vdevice/vty@71000000
    Preparing to boot Linux version 4.14.0-rc2-gcc6x-g9e1fc7e (kerkins@alpine1-p1) (gcc version 6.4.1 20171202 (Custom 6328ca9eaa476138)) #1 SMP Sun Dec 3 21:45:32 AEDT 2017
    Detected machine type: 0000000000000101
    command line: 
    Max number of cores passed to firmware: 256 (NR_CPUS = 2048)
    Calling ibm,client-architecture-support... done
    memory layout at init:
      memory_limit : 0000000000000000 (16 MB aligned)
      alloc_bottom : 00000000015c0000
      alloc_top    : 0000000030000000
      alloc_top_hi : 0000000100000000
      rmo_top      : 0000000030000000
      ram_top      : 0000000100000000
    instantiating rtas at 0x000000002fff0000... done
    prom_hold_cpus: skipped
    copying OF device tree...
    Building dt strings...
    Building dt structure...
    Device tree strings 0x00000000017d0000 -> 0x00000000017d09d8
    Device tree struct  0x00000000017e0000 -> 0x00000000017f0000
    Quiescing Open Firmware ...
    Booting Linux via __start() @ 0x0000000000400000 ...
    [    0.000000] bootconsole [udbg0] enabled
    [    0.000000] Allocated 2883584 bytes for 2048 pacas at c00000000fd40000
    [    0.000000] hash-mmu: Page sizes from device-tree:
    [    0.000000] hash-mmu: base_shift=12: shift=12, sllp=0x0000, avpnm=0x00000000, tlbiel=1, penc=0
    [    0.000000] hash-mmu: base_shift=16: shift=16, sllp=0x0110, avpnm=0x00000000, tlbiel=1, penc=1
    [    0.000000]  -> fw_vec5_feature_init()
    [    0.000000]  <- fw_vec5_feature_init()
    [    0.000000]  -> fw_hypertas_feature_init()
    [    0.000000]  <- fw_hypertas_feature_init()
    [    0.000000] Page orders: linear mapping = 16, virtual = 16, io = 16, vmemmap = 16
    [    0.000000] Using 1TB segments
    [    0.000000] hash-mmu: Initializing hash mmu with SLB
    [    0.000000] Linux version 4.14.0-rc2-gcc6x-g9e1fc7e (kerkins@alpine1-p1) (gcc version 6.4.1 20171202 (Custom 6328ca9eaa476138)) #1 SMP Sun Dec 3 21:45:32 AEDT 2017
    [    0.000000] Found initrd at 0xc0000000015c0000:0xc00000000178d70b
    [    0.000000] Machine is LPAR !
    [    0.000000]  -> pseries_init()
    [    0.000000]  -> fw_cmo_feature_init()
    [    0.000000] CMO not available
    [    0.000000]  <- fw_cmo_feature_init()
    [    0.000000]  <- pseries_init()
    [    0.000000] Using pSeries machine description
    [    0.000000] Partition configured for 16 cpus.
    [    0.000000] CPU maps initialized for 8 threads per core
    [    0.000000]  (thread shift is 3)
    [    0.000000] Freed 2818048 bytes for unused pacas
    [    0.000000] -----------------------------------------------------
    [    0.000000] ppc64_pft_size    = 0x19
    [    0.000000] phys_mem_size     = 0x100000000
    [    0.000000] dcache_bsize      = 0x80
    [    0.000000] icache_bsize      = 0x80
    [    0.000000] cpu_features      = 0x17dc7aec18500249
    [    0.000000]   possible        = 0xdfdfffff18500649
    [    0.000000]   always          = 0x0000000018100040
    [    0.000000] cpu_user_features = 0xdc0065c2 0xef000000
    [    0.000000] mmu_features      = 0x78006001
    [    0.000000] firmware_features = 0x00000001405a440b
    [    0.000000] htab_hash_mask    = 0x3ffff
    [    0.000000] -----------------------------------------------------
    [    0.000000] numa:   NODE_DATA [mem 0xfff6a300-0xfff73fff]
    [    0.000000]  -> smp_init_pSeries()
    [    0.000000]  <- smp_init_pSeries()
    [    0.000000] PCI host bridge /pci@800000020000000  ranges:
    [    0.000000]   IO 0x0000010080000000..0x000001008000ffff -> 0x0000000000000000
    [    0.000000]  MEM 0x00000100a0000000..0x000001101fffffff -> 0x0000000080000000 
    [    0.000000] PPC64 nvram contains 65536 bytes
    [    0.000000] Top of RAM: 0x100000000, Total RAM: 0x100000000
    [    0.000000] Memory hole size: 0MB
    [    0.000000] Zone ranges:
    [    0.000000]   DMA      [mem 0x0000000000000000-0x00000000ffffffff]
    [    0.000000]   DMA32    empty
    [    0.000000]   Normal   empty
    [    0.000000] Movable zone start for each node
    [    0.000000] Early memory node ranges
    [    0.000000]   node   0: [mem 0x0000000000000000-0x00000000ffffffff]
    [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ffffffff]
    [    0.000000] On node 0 totalpages: 65536
    [    0.000000]   DMA zone: 64 pages used for memmap
    [    0.000000]   DMA zone: 0 pages reserved
    [    0.000000]   DMA zone: 65536 pages, LIFO batch:1
    [    0.000000] percpu: Embedded 4 pages/cpu @c0000000ffb00000 s167064 r0 d95080 u262144
    [    0.000000] pcpu-alloc: s167064 r0 d95080 u262144 alloc=1*1048576
    [    0.000000] pcpu-alloc: [0] 00 01 02 03 [0] 04 05 06 07 
    [    0.000000] pcpu-alloc: [0] 08 09 10 11 [0] 12 13 14 15 
    [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 65472
    [    0.000000] Policy zone: DMA
    [    0.000000] Kernel command line: 
    [    0.000000] PID hash table entries: 4096 (order: -1, 32768 bytes)
    [    0.000000] Memory: 4163840K/4194304K available (11008K kernel code, 1664K rwdata, 2752K rodata, 1152K init, 1414K bss, 30464K reserved, 0K cma-reserved)
    [    0.000000] SLUB: HWalign=128, Order=0-3, MinObjects=0, CPUs=16, Nodes=1
    [    0.000000] ftrace: allocating 28124 entries in 11 pages
    [    0.000000] Hierarchical RCU implementation.
    [    0.000000] 	RCU event tracing is enabled.
    [    0.000000] 	RCU restricting CPUs from NR_CPUS=2048 to nr_cpu_ids=16.
    [    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=16
    [    0.000000] NR_IRQS: 512, nr_irqs: 512, preallocated irqs: 16
    [    0.000000] pic: no ISA interrupt controller
    [    0.000000] time_init: decrementer frequency = 512.000000 MHz
    [    0.000000] time_init: processor frequency   = 3425.000000 MHz
    [    0.000001] clocksource: timebase: mask: 0xffffffffffffffff max_cycles: 0x761537d007, max_idle_ns: 440795202126 ns
    [    0.001138] clocksource: timebase mult[1f40000] shift[24] registered
    [    0.001818] clockevent: decrementer mult[83126e98] shift[32] cpu[0]
    [    0.002539] Console: colour dummy device 80x25
    [    0.003018] console [hvc0] enabled
    [    0.003018] console [hvc0] enabled
    [    0.003411] bootconsole [udbg0] disabled
    [    0.003411] bootconsole [udbg0] disabled
    [    0.003875] pid_max: default: 32768 minimum: 301
    [    0.004217] Dentry cache hash table entries: 524288 (order: 6, 4194304 bytes)
    [    0.004394] Inode-cache hash table entries: 262144 (order: 5, 2097152 bytes)
    [    0.004461] Mount-cache hash table entries: 8192 (order: 0, 65536 bytes)
    [    0.004514] Mountpoint-cache hash table entries: 8192 (order: 0, 65536 bytes)
    [    0.006022] EEH: pSeries platform initialized
    [    0.006102] POWER8 performance monitor hardware support registered
    [    0.006156] power8-pmu: PMAO restore workaround active.
    [    0.006211] Hierarchical SRCU implementation.
    [    0.006394] smp: Bringing up secondary CPUs ...
    [    0.020141] smp: Brought up 1 node, 16 CPUs
    [    0.020514] numa: Node 0 CPUs: 0-15
    [    0.020685] Using standard scheduler topology
    [    0.024234] devtmpfs: initialized
    [    0.024965] random: get_random_u32 called from bucket_table_alloc+0x144/0x360 with crng_init=0
    [    0.028242] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
    [    0.029834] futex hash table entries: 4096 (order: 3, 524288 bytes)
    [    0.030024] kworker/u32:0 (106) used greatest stack depth: 12272 bytes left
    [    0.032033] NET: Registered protocol family 16
    [    0.032563] EEH: No capable adapters found
    [    0.034455] cpuidle: using governor menu
    [    0.036083] random: fast init done
    [    0.042279] RTAS daemon started
    [    0.042915] pstore: using zlib compression
    [    0.043109] pstore: Registered nvram as persistent store backend
    Linux ppc64le
    #1 SMP Sun Dec 3[    0.045751] rtas_msi: Registering RTAS MSI callbacks.
    [    0.058501] PCI: Probing PCI hardware
    [    0.058823] no ibm,pcie-link-speed-stats property
    [    0.059114] PCI host bridge to bus 0000:00
    [    0.059378] pci_bus 0000:00: root bus resource [io  0x10000-0x1ffff] (bus address [0x0000-0xffff])
    [    0.059880] pci_bus 0000:00: root bus resource [mem 0x100a0000000-0x1101fffffff] (bus address [0x80000000-0xfffffffff])
    [    0.060473] pci_bus 0000:00: root bus resource [bus 00-ff]
    [    0.060686] pci_dma_bus_setup_pSeriesLP: setting up bus /pci@800000020000000
    [    0.061048]   parent is /pci@800000020000000, iommu_table: 0x          (null)
    [    0.065074] IOMMU table initialized, virtual merging enabled
    [    0.065428]   created table: c0000000fe201000
    [    0.065681] PCI: Probing PCI hardware done
    [    0.086830] vgaarb: loaded
    [    0.087716] SCSI subsystem initialized
    [    0.088766] libata version 3.00 loaded.
    [    0.090210] usbcore: registered new interface driver usbfs
    [    0.090675] usbcore: registered new interface driver hub
    [    0.091411] usbcore: registered new device driver usb
    [    0.092023] pps_core: LinuxPPS API ver. 1 registered
    [    0.092418] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
    [    0.093119] PTP clock support registered
    [    0.094681] clocksource: Switched to clocksource timebase
    [    0.106055] hugetlbfs: disabling because there are no supported hugepage sizes
    [    0.111204] NET: Registered protocol family 2
    [    0.112104] TCP established hash table entries: 32768 (order: 2, 262144 bytes)
    [    0.112810] TCP bind hash table entries: 32768 (order: 3, 524288 bytes)
    [    0.113369] TCP: Hash tables configured (established 32768 bind 32768)
    [    0.113993] UDP hash table entries: 2048 (order: 0, 65536 bytes)
    [    0.114583] UDP-Lite hash table entries: 2048 (order: 0, 65536 bytes)
    [    0.115133] NET: Registered protocol family 1
    [    0.115852] RPC: Registered named UNIX socket transport module.
    [    0.116376] RPC: Registered udp transport module.
    [    0.116779] RPC: Registered tcp transport module.
    [    0.117176] RPC: Registered tcp NFSv4.1 backchannel transport module.
    [    0.117735] PCI: CLS 0 bytes, default 128
    [    0.118123] Trying to unpack rootfs image as initramfs...
    [    0.145121] Freeing initrd memory: 1792K
    [    0.151187] audit: initializing netlink subsys (disabled)
    [    0.152291] audit: type=2000 audit(1512304166.130:1): state=initialized audit_enabled=0 res=1
    [    0.153746] workingset: timestamp_bits=38 max_order=16 bucket_order=0
    [    0.161309] NFS: Registering the id_resolver key type
    [    0.161796] Key type id_resolver registered
    [    0.162029] Key type id_legacy registered
    [    0.162826] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
    [    0.163638] io scheduler noop registered
    [    0.164114] io scheduler deadline registered
    [    0.164758] io scheduler cfq registered (default)
    [    0.165354] io scheduler mq-deadline registered
    [    0.165713] io scheduler kyber registered
    [    0.166959] atomic64_test: passed
    [    0.197910] __vio_register_driver: driver hvc_console registering
    [    0.199239] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
    [    0.203789] brd: module loaded
    [    0.209646] loop: module loaded
    [    0.209921] ipr: IBM Power RAID SCSI Device Driver version: 2.6.4 (March 14, 2017)
    [    0.210454] __vio_register_driver: driver ibmvscsi registering
    [    0.214828] ibmvscsi 71000003: SRP_VERSION: 16.a
    [    0.215752] ibmvscsi 71000003: Maximum ID: 64 Maximum LUN: 32 Maximum Channel: 3
    [    0.216463] scsi host0: IBM POWER Virtual SCSI Adapter 1.5.9
    [    0.217445] ibmvscsi 71000003: partner initialization complete
    [    0.217950] ibmvscsi 71000003: host srp version: 16.a, host partition qemu (0), OS 2, max io 2097152
    [    0.218617] ibmvscsi 71000003: sent SRP login
    [    0.218902] ibmvscsi 71000003: SRP_LOGIN succeeded
    [    0.257469] scsi 0:0:2:0: CD-ROM            QEMU     QEMU CD-ROM      2.5+ PQ: 0 ANSI: 5
    [    0.448382] sr 0:0:2:0: [sr0] scsi3-mmc drive: 16x/50x cd/rw xa/form2 cdda tray
    [    0.448992] cdrom: Uniform CD-ROM driver Revision: 3.20
    [    0.449673] sr 0:0:2:0: Attached scsi CD-ROM sr0
    [    0.450738] sr 0:0:2:0: Attached scsi generic sg0 type 5
    [    0.451472] libphy: Fixed MDIO Bus: probed
    [    0.452068] ibmveth: IBM Power Virtual Ethernet Driver 1.06
    [    0.452411] __vio_register_driver: driver ibmveth registering
    [    0.453225] e100: Intel(R) PRO/100 Network Driver, 3.5.24-k2-NAPI
    [    0.454141] e100: Copyright(c) 1999-2006 Intel Corporation
    [    0.454537] e1000: Intel(R) PRO/1000 Network Driver - version 7.3.21-k8-NAPI
    [    0.455441] e1000: Copyright (c) 1999-2006 Intel Corporation.
    [    0.455920] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
    [    0.456616] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
    [    0.457115] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
    [    0.457528] ehci-pci: EHCI PCI platform driver
    [    0.457917] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
    [    0.458868] ohci-pci: OHCI PCI platform driver
    [    0.459673] rtc-generic rtc-generic: rtc core: registered rtc-generic as rtc0
    [    0.460373] i2c /dev entries driver
    [    0.460995] IR NEC protocol handler initialized
    [    0.461537] IR RC5(x/sz) protocol handler initialized
    [    0.461921] IR RC6 protocol handler initialized
    [    0.462304] IR JVC protocol handler initialized
    [    0.462679] IR Sony protocol handler initialized
    [    0.463061] IR SANYO protocol handler initialized
    [    0.463427] IR Sharp protocol handler initialized
    [    0.463811] IR MCE Keyboard/mouse protocol handler initialized
    [    0.464284] IR XMP protocol handler initialized
    [    0.464901] device-mapper: uevent: version 1.0.3
    [    0.465724] device-mapper: ioctl: 4.36.0-ioctl (2017-06-09) initialised: dm-devel@redhat.com
    [    0.466797] pseries_idle_driver registered
    [    0.467761] usbcore: registered new interface driver usbhid
    [    0.468401] usbhid: USB HID core driver
    [    0.469142] ipip: IPv4 and MPLS over IPv4 tunneling driver
    [    0.469558] NET: Registered protocol family 17
    [    0.470202] Key type dns_resolver registered
    [    0.470535] Unable to handle kernel paging request for data at address 0x00000010
    [    0.471030] Faulting instruction address: 0xc000000000d92d04
    [    0.471440] Oops: Kernel access of bad area, sig: 11 [#1]
    [    0.471760] LE SMP NR_CPUS=2048 NUMA pSeries
    [    0.472081] Modules linked in:
    [    0.472319] CPU: 7 PID: 1 Comm: swapper/0 Not tainted 4.14.0-rc2-gcc6x-g9e1fc7e #1
    [    0.472811] task: c0000000fea80000 task.stack: c0000000feb00000
    [    0.473215] NIP:  c000000000d92d04 LR: c000000000d92cfc CTR: 0000000000000000
    [    0.473706] REGS: c0000000feb038d0 TRAP: 0380   Not tainted  (4.14.0-rc2-gcc6x-g9e1fc7e)
    [    0.474203] MSR:  8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE>  CR: 84000248  XER: 20000000
    [    0.474901] CFAR: c000000000deb200 SOFTE: 1 
    [    0.474901] GPR00: c000000000d92cfc c0000000feb03b50 c000000000fca600 0000000000000000 
    [    0.474901] GPR04: c0000000feb03b70 0000000000000000 000000000000002f 0000000000000022 
    [    0.474901] GPR08: 0000000000000000 c0000000017e35a8 0000000000000000 0000000000000220 
    [    0.474901] GPR12: 0000000000000000 c00000000fd42680 c00000000000d778 0000000000000000 
    [    0.474901] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
    [    0.474901] GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
    [    0.474901] GPR24: 0000000000000000 c000000000d66f60 c000000000d838a4 c000000000dfd918 
    [    0.474901] GPR28: 0000000000000007 c0000000fffffc30 c0000000feb03bf0 0000000000000010 
    [    0.479304] NIP [c000000000d92d04] read_drconf_v1_cell+0x50/0x9c
    [    0.479705] LR [c000000000d92cfc] read_drconf_v1_cell+0x48/0x9c
    [    0.480104] Call Trace:
    [    0.480244] [c0000000feb03b50] [c000000000d92cfc] read_drconf_v1_cell+0x48/0x9c (unreliable)
    [    0.480907] [c0000000feb03b90] [c000000000d931a4] drmem_init+0x13c/0x2ec
    [    0.481352] [c0000000feb03c40] [c00000000000d50c] do_one_initcall+0x6c/0x1d0
    [    0.481897] [c0000000feb03d00] [c000000000d84600] kernel_init_freeable+0x27c/0x358
    [    0.482428] [c0000000feb03dc0] [c00000000000d79c] kernel_init+0x2c/0x160
    [    0.482872] [c0000000feb03e30] [c00000000000bae0] ret_from_kernel_thread+0x5c/0x7c
    [    0.483416] Instruction dump:
    [    0.483667] 7c7f1b78 60000000 60000000 7c240b78 3d22ffe5 39296414 e95e0000 e8690002 
    [    0.484216] f9440021 48058495 60000000 e9210020 <f87f0000> 39090004 38e90008 39490010 
    [    0.484926] ---[ end trace 5aca0f2a87d33521 ]---
    [    0.496557] 
    [    1.496724] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
    [    1.496724] 
    [    1.505124] Rebooting in 10 seconds..


cheers

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

* Re: [V3, 1/9] powerpc/numa: Look up device node in of_get_assoc_arrays()
  2017-12-01 16:46 ` [PATCH V3 1/9] powerpc/numa: Look up device node in of_get_assoc_arrays() Nathan Fontenot
@ 2018-01-17 13:30   ` Michael Ellerman
  0 siblings, 0 replies; 17+ messages in thread
From: Michael Ellerman @ 2018-01-17 13:30 UTC (permalink / raw)
  To: Nathan Fontenot, linuxppc-dev

On Fri, 2017-12-01 at 16:46:35 UTC, Nathan Fontenot wrote:
> Look up the device node for the associativity array property instead
> of having it passed in as a parameter. This changes precedes an update
> in which the calling routines for of_get_assoc_arrays() will not have
> the device node pointer to pass in.
> 
> Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/35f80debaef07bdaeffbbb20a6e999

cheers

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

* Re: [V3, 8/9] powerpc/drmem: Add support for ibm, dynamic-memory-v2 property
  2017-12-01 16:47 ` [PATCH V3 8/9] powerpc/drmem: Add support for ibm, dynamic-memory-v2 property Nathan Fontenot
@ 2018-01-17 13:30   ` Michael Ellerman
  0 siblings, 0 replies; 17+ messages in thread
From: Michael Ellerman @ 2018-01-17 13:30 UTC (permalink / raw)
  To: Nathan Fontenot, linuxppc-dev

On Fri, 2017-12-01 at 16:47:53 UTC, Nathan Fontenot wrote:
> The Power Hypervisor has introduced a new device tree format for
> the property describing the dynamic reconfiguration LMBs for a system,
> ibm,dynamic-memory-v2. This new format condenses the size of the
> property, especially on large memory systems, by reporting sets
> of LMBs that have the same properties (flags and associativity array
> index).
> 
> This patch updates the powerpc/mm/drmem.c code to provide routines
> that can parse the new device tree format during the walk_drmem_lmb*
> routines used during boot, the creation of the LMB array, and updating
> the device tree to create a new property in the proper format for
> ibm,dynamic-memory-v2.
> 
> Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2b31e3aec1dbaae5f0a6f0e485fcb1

cheers

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

* Re: [V3,9/9] powerpc: Enable support of ibm,dynamic-memory-v2
  2017-12-01 16:48 ` [PATCH V3 9/9] powerpc: Enable support of ibm,dynamic-memory-v2 Nathan Fontenot
@ 2018-01-17 13:30   ` Michael Ellerman
  0 siblings, 0 replies; 17+ messages in thread
From: Michael Ellerman @ 2018-01-17 13:30 UTC (permalink / raw)
  To: Nathan Fontenot, linuxppc-dev

On Fri, 2017-12-01 at 16:48:03 UTC, Nathan Fontenot wrote:
> Add required bits to the architecture vector to enable support
> of the ibm,dynamic-memory-v2 device tree property.
> 
> Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/0c38ed6f6f0b78a404fe46767d2150

cheers

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

* Re: [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2
  2017-12-04  5:13 ` [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Michael Ellerman
@ 2018-02-14 21:30   ` Tyrel Datwyler
  2018-02-14 21:50     ` Nathan Fontenot
  2018-02-14 23:21     ` Michael Ellerman
  0 siblings, 2 replies; 17+ messages in thread
From: Tyrel Datwyler @ 2018-02-14 21:30 UTC (permalink / raw)
  To: Michael Ellerman, Nathan Fontenot, linuxppc-dev; +Cc: Cyril Bur

On 12/03/2017 09:13 PM, Michael Ellerman wrote:
> Nathan Fontenot <nfont@linux.vnet.ibm.com> writes:
> 
>> This patch set provides a series of updates to de-couple the LMB
>> information provided in the device tree property from the device
>> tree property format. This eases the ability to support a new
>> format for the dynamic memory property, ibm,dynamic-memory-v2.
> 
> Something in here is still blowing up for me in a KVM guest:

So, it looks like this series was applied despite observing this KVM guest crash. Cyril posted yesterday to the list about hitting this same issue with 4.16-rc1.

-Tyrel

> 
>     OF stdout device is: /vdevice/vty@71000000
>     Preparing to boot Linux version 4.14.0-rc2-gcc6x-g9e1fc7e (kerkins@alpine1-p1) (gcc version 6.4.1 20171202 (Custom 6328ca9eaa476138)) #1 SMP Sun Dec 3 21:45:32 AEDT 2017
>     Detected machine type: 0000000000000101
>     command line: 
>     Max number of cores passed to firmware: 256 (NR_CPUS = 2048)
>     Calling ibm,client-architecture-support... done
>     memory layout at init:
>       memory_limit : 0000000000000000 (16 MB aligned)
>       alloc_bottom : 00000000015c0000
>       alloc_top    : 0000000030000000
>       alloc_top_hi : 0000000100000000
>       rmo_top      : 0000000030000000
>       ram_top      : 0000000100000000
>     instantiating rtas at 0x000000002fff0000... done
>     prom_hold_cpus: skipped
>     copying OF device tree...
>     Building dt strings...
>     Building dt structure...
>     Device tree strings 0x00000000017d0000 -> 0x00000000017d09d8
>     Device tree struct  0x00000000017e0000 -> 0x00000000017f0000
>     Quiescing Open Firmware ...
>     Booting Linux via __start() @ 0x0000000000400000 ...
>     [    0.000000] bootconsole [udbg0] enabled
>     [    0.000000] Allocated 2883584 bytes for 2048 pacas at c00000000fd40000
>     [    0.000000] hash-mmu: Page sizes from device-tree:
>     [    0.000000] hash-mmu: base_shift=12: shift=12, sllp=0x0000, avpnm=0x00000000, tlbiel=1, penc=0
>     [    0.000000] hash-mmu: base_shift=16: shift=16, sllp=0x0110, avpnm=0x00000000, tlbiel=1, penc=1
>     [    0.000000]  -> fw_vec5_feature_init()
>     [    0.000000]  <- fw_vec5_feature_init()
>     [    0.000000]  -> fw_hypertas_feature_init()
>     [    0.000000]  <- fw_hypertas_feature_init()
>     [    0.000000] Page orders: linear mapping = 16, virtual = 16, io = 16, vmemmap = 16
>     [    0.000000] Using 1TB segments
>     [    0.000000] hash-mmu: Initializing hash mmu with SLB
>     [    0.000000] Linux version 4.14.0-rc2-gcc6x-g9e1fc7e (kerkins@alpine1-p1) (gcc version 6.4.1 20171202 (Custom 6328ca9eaa476138)) #1 SMP Sun Dec 3 21:45:32 AEDT 2017
>     [    0.000000] Found initrd at 0xc0000000015c0000:0xc00000000178d70b
>     [    0.000000] Machine is LPAR !
>     [    0.000000]  -> pseries_init()
>     [    0.000000]  -> fw_cmo_feature_init()
>     [    0.000000] CMO not available
>     [    0.000000]  <- fw_cmo_feature_init()
>     [    0.000000]  <- pseries_init()
>     [    0.000000] Using pSeries machine description
>     [    0.000000] Partition configured for 16 cpus.
>     [    0.000000] CPU maps initialized for 8 threads per core
>     [    0.000000]  (thread shift is 3)
>     [    0.000000] Freed 2818048 bytes for unused pacas
>     [    0.000000] -----------------------------------------------------
>     [    0.000000] ppc64_pft_size    = 0x19
>     [    0.000000] phys_mem_size     = 0x100000000
>     [    0.000000] dcache_bsize      = 0x80
>     [    0.000000] icache_bsize      = 0x80
>     [    0.000000] cpu_features      = 0x17dc7aec18500249
>     [    0.000000]   possible        = 0xdfdfffff18500649
>     [    0.000000]   always          = 0x0000000018100040
>     [    0.000000] cpu_user_features = 0xdc0065c2 0xef000000
>     [    0.000000] mmu_features      = 0x78006001
>     [    0.000000] firmware_features = 0x00000001405a440b
>     [    0.000000] htab_hash_mask    = 0x3ffff
>     [    0.000000] -----------------------------------------------------
>     [    0.000000] numa:   NODE_DATA [mem 0xfff6a300-0xfff73fff]
>     [    0.000000]  -> smp_init_pSeries()
>     [    0.000000]  <- smp_init_pSeries()
>     [    0.000000] PCI host bridge /pci@800000020000000  ranges:
>     [    0.000000]   IO 0x0000010080000000..0x000001008000ffff -> 0x0000000000000000
>     [    0.000000]  MEM 0x00000100a0000000..0x000001101fffffff -> 0x0000000080000000 
>     [    0.000000] PPC64 nvram contains 65536 bytes
>     [    0.000000] Top of RAM: 0x100000000, Total RAM: 0x100000000
>     [    0.000000] Memory hole size: 0MB
>     [    0.000000] Zone ranges:
>     [    0.000000]   DMA      [mem 0x0000000000000000-0x00000000ffffffff]
>     [    0.000000]   DMA32    empty
>     [    0.000000]   Normal   empty
>     [    0.000000] Movable zone start for each node
>     [    0.000000] Early memory node ranges
>     [    0.000000]   node   0: [mem 0x0000000000000000-0x00000000ffffffff]
>     [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ffffffff]
>     [    0.000000] On node 0 totalpages: 65536
>     [    0.000000]   DMA zone: 64 pages used for memmap
>     [    0.000000]   DMA zone: 0 pages reserved
>     [    0.000000]   DMA zone: 65536 pages, LIFO batch:1
>     [    0.000000] percpu: Embedded 4 pages/cpu @c0000000ffb00000 s167064 r0 d95080 u262144
>     [    0.000000] pcpu-alloc: s167064 r0 d95080 u262144 alloc=1*1048576
>     [    0.000000] pcpu-alloc: [0] 00 01 02 03 [0] 04 05 06 07 
>     [    0.000000] pcpu-alloc: [0] 08 09 10 11 [0] 12 13 14 15 
>     [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 65472
>     [    0.000000] Policy zone: DMA
>     [    0.000000] Kernel command line: 
>     [    0.000000] PID hash table entries: 4096 (order: -1, 32768 bytes)
>     [    0.000000] Memory: 4163840K/4194304K available (11008K kernel code, 1664K rwdata, 2752K rodata, 1152K init, 1414K bss, 30464K reserved, 0K cma-reserved)
>     [    0.000000] SLUB: HWalign=128, Order=0-3, MinObjects=0, CPUs=16, Nodes=1
>     [    0.000000] ftrace: allocating 28124 entries in 11 pages
>     [    0.000000] Hierarchical RCU implementation.
>     [    0.000000] 	RCU event tracing is enabled.
>     [    0.000000] 	RCU restricting CPUs from NR_CPUS=2048 to nr_cpu_ids=16.
>     [    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=16
>     [    0.000000] NR_IRQS: 512, nr_irqs: 512, preallocated irqs: 16
>     [    0.000000] pic: no ISA interrupt controller
>     [    0.000000] time_init: decrementer frequency = 512.000000 MHz
>     [    0.000000] time_init: processor frequency   = 3425.000000 MHz
>     [    0.000001] clocksource: timebase: mask: 0xffffffffffffffff max_cycles: 0x761537d007, max_idle_ns: 440795202126 ns
>     [    0.001138] clocksource: timebase mult[1f40000] shift[24] registered
>     [    0.001818] clockevent: decrementer mult[83126e98] shift[32] cpu[0]
>     [    0.002539] Console: colour dummy device 80x25
>     [    0.003018] console [hvc0] enabled
>     [    0.003018] console [hvc0] enabled
>     [    0.003411] bootconsole [udbg0] disabled
>     [    0.003411] bootconsole [udbg0] disabled
>     [    0.003875] pid_max: default: 32768 minimum: 301
>     [    0.004217] Dentry cache hash table entries: 524288 (order: 6, 4194304 bytes)
>     [    0.004394] Inode-cache hash table entries: 262144 (order: 5, 2097152 bytes)
>     [    0.004461] Mount-cache hash table entries: 8192 (order: 0, 65536 bytes)
>     [    0.004514] Mountpoint-cache hash table entries: 8192 (order: 0, 65536 bytes)
>     [    0.006022] EEH: pSeries platform initialized
>     [    0.006102] POWER8 performance monitor hardware support registered
>     [    0.006156] power8-pmu: PMAO restore workaround active.
>     [    0.006211] Hierarchical SRCU implementation.
>     [    0.006394] smp: Bringing up secondary CPUs ...
>     [    0.020141] smp: Brought up 1 node, 16 CPUs
>     [    0.020514] numa: Node 0 CPUs: 0-15
>     [    0.020685] Using standard scheduler topology
>     [    0.024234] devtmpfs: initialized
>     [    0.024965] random: get_random_u32 called from bucket_table_alloc+0x144/0x360 with crng_init=0
>     [    0.028242] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
>     [    0.029834] futex hash table entries: 4096 (order: 3, 524288 bytes)
>     [    0.030024] kworker/u32:0 (106) used greatest stack depth: 12272 bytes left
>     [    0.032033] NET: Registered protocol family 16
>     [    0.032563] EEH: No capable adapters found
>     [    0.034455] cpuidle: using governor menu
>     [    0.036083] random: fast init done
>     [    0.042279] RTAS daemon started
>     [    0.042915] pstore: using zlib compression
>     [    0.043109] pstore: Registered nvram as persistent store backend
>     Linux ppc64le
>     #1 SMP Sun Dec 3[    0.045751] rtas_msi: Registering RTAS MSI callbacks.
>     [    0.058501] PCI: Probing PCI hardware
>     [    0.058823] no ibm,pcie-link-speed-stats property
>     [    0.059114] PCI host bridge to bus 0000:00
>     [    0.059378] pci_bus 0000:00: root bus resource [io  0x10000-0x1ffff] (bus address [0x0000-0xffff])
>     [    0.059880] pci_bus 0000:00: root bus resource [mem 0x100a0000000-0x1101fffffff] (bus address [0x80000000-0xfffffffff])
>     [    0.060473] pci_bus 0000:00: root bus resource [bus 00-ff]
>     [    0.060686] pci_dma_bus_setup_pSeriesLP: setting up bus /pci@800000020000000
>     [    0.061048]   parent is /pci@800000020000000, iommu_table: 0x          (null)
>     [    0.065074] IOMMU table initialized, virtual merging enabled
>     [    0.065428]   created table: c0000000fe201000
>     [    0.065681] PCI: Probing PCI hardware done
>     [    0.086830] vgaarb: loaded
>     [    0.087716] SCSI subsystem initialized
>     [    0.088766] libata version 3.00 loaded.
>     [    0.090210] usbcore: registered new interface driver usbfs
>     [    0.090675] usbcore: registered new interface driver hub
>     [    0.091411] usbcore: registered new device driver usb
>     [    0.092023] pps_core: LinuxPPS API ver. 1 registered
>     [    0.092418] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
>     [    0.093119] PTP clock support registered
>     [    0.094681] clocksource: Switched to clocksource timebase
>     [    0.106055] hugetlbfs: disabling because there are no supported hugepage sizes
>     [    0.111204] NET: Registered protocol family 2
>     [    0.112104] TCP established hash table entries: 32768 (order: 2, 262144 bytes)
>     [    0.112810] TCP bind hash table entries: 32768 (order: 3, 524288 bytes)
>     [    0.113369] TCP: Hash tables configured (established 32768 bind 32768)
>     [    0.113993] UDP hash table entries: 2048 (order: 0, 65536 bytes)
>     [    0.114583] UDP-Lite hash table entries: 2048 (order: 0, 65536 bytes)
>     [    0.115133] NET: Registered protocol family 1
>     [    0.115852] RPC: Registered named UNIX socket transport module.
>     [    0.116376] RPC: Registered udp transport module.
>     [    0.116779] RPC: Registered tcp transport module.
>     [    0.117176] RPC: Registered tcp NFSv4.1 backchannel transport module.
>     [    0.117735] PCI: CLS 0 bytes, default 128
>     [    0.118123] Trying to unpack rootfs image as initramfs...
>     [    0.145121] Freeing initrd memory: 1792K
>     [    0.151187] audit: initializing netlink subsys (disabled)
>     [    0.152291] audit: type=2000 audit(1512304166.130:1): state=initialized audit_enabled=0 res=1
>     [    0.153746] workingset: timestamp_bits=38 max_order=16 bucket_order=0
>     [    0.161309] NFS: Registering the id_resolver key type
>     [    0.161796] Key type id_resolver registered
>     [    0.162029] Key type id_legacy registered
>     [    0.162826] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
>     [    0.163638] io scheduler noop registered
>     [    0.164114] io scheduler deadline registered
>     [    0.164758] io scheduler cfq registered (default)
>     [    0.165354] io scheduler mq-deadline registered
>     [    0.165713] io scheduler kyber registered
>     [    0.166959] atomic64_test: passed
>     [    0.197910] __vio_register_driver: driver hvc_console registering
>     [    0.199239] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
>     [    0.203789] brd: module loaded
>     [    0.209646] loop: module loaded
>     [    0.209921] ipr: IBM Power RAID SCSI Device Driver version: 2.6.4 (March 14, 2017)
>     [    0.210454] __vio_register_driver: driver ibmvscsi registering
>     [    0.214828] ibmvscsi 71000003: SRP_VERSION: 16.a
>     [    0.215752] ibmvscsi 71000003: Maximum ID: 64 Maximum LUN: 32 Maximum Channel: 3
>     [    0.216463] scsi host0: IBM POWER Virtual SCSI Adapter 1.5.9
>     [    0.217445] ibmvscsi 71000003: partner initialization complete
>     [    0.217950] ibmvscsi 71000003: host srp version: 16.a, host partition qemu (0), OS 2, max io 2097152
>     [    0.218617] ibmvscsi 71000003: sent SRP login
>     [    0.218902] ibmvscsi 71000003: SRP_LOGIN succeeded
>     [    0.257469] scsi 0:0:2:0: CD-ROM            QEMU     QEMU CD-ROM      2.5+ PQ: 0 ANSI: 5
>     [    0.448382] sr 0:0:2:0: [sr0] scsi3-mmc drive: 16x/50x cd/rw xa/form2 cdda tray
>     [    0.448992] cdrom: Uniform CD-ROM driver Revision: 3.20
>     [    0.449673] sr 0:0:2:0: Attached scsi CD-ROM sr0
>     [    0.450738] sr 0:0:2:0: Attached scsi generic sg0 type 5
>     [    0.451472] libphy: Fixed MDIO Bus: probed
>     [    0.452068] ibmveth: IBM Power Virtual Ethernet Driver 1.06
>     [    0.452411] __vio_register_driver: driver ibmveth registering
>     [    0.453225] e100: Intel(R) PRO/100 Network Driver, 3.5.24-k2-NAPI
>     [    0.454141] e100: Copyright(c) 1999-2006 Intel Corporation
>     [    0.454537] e1000: Intel(R) PRO/1000 Network Driver - version 7.3.21-k8-NAPI
>     [    0.455441] e1000: Copyright (c) 1999-2006 Intel Corporation.
>     [    0.455920] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
>     [    0.456616] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
>     [    0.457115] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
>     [    0.457528] ehci-pci: EHCI PCI platform driver
>     [    0.457917] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
>     [    0.458868] ohci-pci: OHCI PCI platform driver
>     [    0.459673] rtc-generic rtc-generic: rtc core: registered rtc-generic as rtc0
>     [    0.460373] i2c /dev entries driver
>     [    0.460995] IR NEC protocol handler initialized
>     [    0.461537] IR RC5(x/sz) protocol handler initialized
>     [    0.461921] IR RC6 protocol handler initialized
>     [    0.462304] IR JVC protocol handler initialized
>     [    0.462679] IR Sony protocol handler initialized
>     [    0.463061] IR SANYO protocol handler initialized
>     [    0.463427] IR Sharp protocol handler initialized
>     [    0.463811] IR MCE Keyboard/mouse protocol handler initialized
>     [    0.464284] IR XMP protocol handler initialized
>     [    0.464901] device-mapper: uevent: version 1.0.3
>     [    0.465724] device-mapper: ioctl: 4.36.0-ioctl (2017-06-09) initialised: dm-devel@redhat.com
>     [    0.466797] pseries_idle_driver registered
>     [    0.467761] usbcore: registered new interface driver usbhid
>     [    0.468401] usbhid: USB HID core driver
>     [    0.469142] ipip: IPv4 and MPLS over IPv4 tunneling driver
>     [    0.469558] NET: Registered protocol family 17
>     [    0.470202] Key type dns_resolver registered
>     [    0.470535] Unable to handle kernel paging request for data at address 0x00000010
>     [    0.471030] Faulting instruction address: 0xc000000000d92d04
>     [    0.471440] Oops: Kernel access of bad area, sig: 11 [#1]
>     [    0.471760] LE SMP NR_CPUS=2048 NUMA pSeries
>     [    0.472081] Modules linked in:
>     [    0.472319] CPU: 7 PID: 1 Comm: swapper/0 Not tainted 4.14.0-rc2-gcc6x-g9e1fc7e #1
>     [    0.472811] task: c0000000fea80000 task.stack: c0000000feb00000
>     [    0.473215] NIP:  c000000000d92d04 LR: c000000000d92cfc CTR: 0000000000000000
>     [    0.473706] REGS: c0000000feb038d0 TRAP: 0380   Not tainted  (4.14.0-rc2-gcc6x-g9e1fc7e)
>     [    0.474203] MSR:  8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE>  CR: 84000248  XER: 20000000
>     [    0.474901] CFAR: c000000000deb200 SOFTE: 1 
>     [    0.474901] GPR00: c000000000d92cfc c0000000feb03b50 c000000000fca600 0000000000000000 
>     [    0.474901] GPR04: c0000000feb03b70 0000000000000000 000000000000002f 0000000000000022 
>     [    0.474901] GPR08: 0000000000000000 c0000000017e35a8 0000000000000000 0000000000000220 
>     [    0.474901] GPR12: 0000000000000000 c00000000fd42680 c00000000000d778 0000000000000000 
>     [    0.474901] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
>     [    0.474901] GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
>     [    0.474901] GPR24: 0000000000000000 c000000000d66f60 c000000000d838a4 c000000000dfd918 
>     [    0.474901] GPR28: 0000000000000007 c0000000fffffc30 c0000000feb03bf0 0000000000000010 
>     [    0.479304] NIP [c000000000d92d04] read_drconf_v1_cell+0x50/0x9c
>     [    0.479705] LR [c000000000d92cfc] read_drconf_v1_cell+0x48/0x9c
>     [    0.480104] Call Trace:
>     [    0.480244] [c0000000feb03b50] [c000000000d92cfc] read_drconf_v1_cell+0x48/0x9c (unreliable)
>     [    0.480907] [c0000000feb03b90] [c000000000d931a4] drmem_init+0x13c/0x2ec
>     [    0.481352] [c0000000feb03c40] [c00000000000d50c] do_one_initcall+0x6c/0x1d0
>     [    0.481897] [c0000000feb03d00] [c000000000d84600] kernel_init_freeable+0x27c/0x358
>     [    0.482428] [c0000000feb03dc0] [c00000000000d79c] kernel_init+0x2c/0x160
>     [    0.482872] [c0000000feb03e30] [c00000000000bae0] ret_from_kernel_thread+0x5c/0x7c
>     [    0.483416] Instruction dump:
>     [    0.483667] 7c7f1b78 60000000 60000000 7c240b78 3d22ffe5 39296414 e95e0000 e8690002 
>     [    0.484216] f9440021 48058495 60000000 e9210020 <f87f0000> 39090004 38e90008 39490010 
>     [    0.484926] ---[ end trace 5aca0f2a87d33521 ]---
>     [    0.496557] 
>     [    1.496724] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
>     [    1.496724] 
>     [    1.505124] Rebooting in 10 seconds..
> 
> 
> cheers
> 

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

* Re: [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2
  2018-02-14 21:30   ` Tyrel Datwyler
@ 2018-02-14 21:50     ` Nathan Fontenot
  2018-02-14 23:21     ` Michael Ellerman
  1 sibling, 0 replies; 17+ messages in thread
From: Nathan Fontenot @ 2018-02-14 21:50 UTC (permalink / raw)
  To: Tyrel Datwyler, Michael Ellerman, linuxppc-dev; +Cc: Cyril Bur

On 02/14/2018 03:30 PM, Tyrel Datwyler wrote:
> On 12/03/2017 09:13 PM, Michael Ellerman wrote:
>> Nathan Fontenot <nfont@linux.vnet.ibm.com> writes:
>>
>>> This patch set provides a series of updates to de-couple the LMB
>>> information provided in the device tree property from the device
>>> tree property format. This eases the ability to support a new
>>> format for the dynamic memory property, ibm,dynamic-memory-v2.
>>
>> Something in here is still blowing up for me in a KVM guest:
> 
> So, it looks like this series was applied despite observing this KVM guest crash. Cyril posted yesterday to the list about hitting this same issue with 4.16-rc1.
> 
> -Tyrel
> 

Yes, Michael pointed out that he hit this on his system but I have never
been able to replicate this error.

Now that others are seeing it any help I could get on re-creating the failure
would be appreciated.

-Nathan

>>
>>     OF stdout device is: /vdevice/vty@71000000
>>     Preparing to boot Linux version 4.14.0-rc2-gcc6x-g9e1fc7e (kerkins@alpine1-p1) (gcc version 6.4.1 20171202 (Custom 6328ca9eaa476138)) #1 SMP Sun Dec 3 21:45:32 AEDT 2017
>>     Detected machine type: 0000000000000101
>>     command line: 
>>     Max number of cores passed to firmware: 256 (NR_CPUS = 2048)
>>     Calling ibm,client-architecture-support... done
>>     memory layout at init:
>>       memory_limit : 0000000000000000 (16 MB aligned)
>>       alloc_bottom : 00000000015c0000
>>       alloc_top    : 0000000030000000
>>       alloc_top_hi : 0000000100000000
>>       rmo_top      : 0000000030000000
>>       ram_top      : 0000000100000000
>>     instantiating rtas at 0x000000002fff0000... done
>>     prom_hold_cpus: skipped
>>     copying OF device tree...
>>     Building dt strings...
>>     Building dt structure...
>>     Device tree strings 0x00000000017d0000 -> 0x00000000017d09d8
>>     Device tree struct  0x00000000017e0000 -> 0x00000000017f0000
>>     Quiescing Open Firmware ...
>>     Booting Linux via __start() @ 0x0000000000400000 ...
>>     [    0.000000] bootconsole [udbg0] enabled
>>     [    0.000000] Allocated 2883584 bytes for 2048 pacas at c00000000fd40000
>>     [    0.000000] hash-mmu: Page sizes from device-tree:
>>     [    0.000000] hash-mmu: base_shift=12: shift=12, sllp=0x0000, avpnm=0x00000000, tlbiel=1, penc=0
>>     [    0.000000] hash-mmu: base_shift=16: shift=16, sllp=0x0110, avpnm=0x00000000, tlbiel=1, penc=1
>>     [    0.000000]  -> fw_vec5_feature_init()
>>     [    0.000000]  <- fw_vec5_feature_init()
>>     [    0.000000]  -> fw_hypertas_feature_init()
>>     [    0.000000]  <- fw_hypertas_feature_init()
>>     [    0.000000] Page orders: linear mapping = 16, virtual = 16, io = 16, vmemmap = 16
>>     [    0.000000] Using 1TB segments
>>     [    0.000000] hash-mmu: Initializing hash mmu with SLB
>>     [    0.000000] Linux version 4.14.0-rc2-gcc6x-g9e1fc7e (kerkins@alpine1-p1) (gcc version 6.4.1 20171202 (Custom 6328ca9eaa476138)) #1 SMP Sun Dec 3 21:45:32 AEDT 2017
>>     [    0.000000] Found initrd at 0xc0000000015c0000:0xc00000000178d70b
>>     [    0.000000] Machine is LPAR !
>>     [    0.000000]  -> pseries_init()
>>     [    0.000000]  -> fw_cmo_feature_init()
>>     [    0.000000] CMO not available
>>     [    0.000000]  <- fw_cmo_feature_init()
>>     [    0.000000]  <- pseries_init()
>>     [    0.000000] Using pSeries machine description
>>     [    0.000000] Partition configured for 16 cpus.
>>     [    0.000000] CPU maps initialized for 8 threads per core
>>     [    0.000000]  (thread shift is 3)
>>     [    0.000000] Freed 2818048 bytes for unused pacas
>>     [    0.000000] -----------------------------------------------------
>>     [    0.000000] ppc64_pft_size    = 0x19
>>     [    0.000000] phys_mem_size     = 0x100000000
>>     [    0.000000] dcache_bsize      = 0x80
>>     [    0.000000] icache_bsize      = 0x80
>>     [    0.000000] cpu_features      = 0x17dc7aec18500249
>>     [    0.000000]   possible        = 0xdfdfffff18500649
>>     [    0.000000]   always          = 0x0000000018100040
>>     [    0.000000] cpu_user_features = 0xdc0065c2 0xef000000
>>     [    0.000000] mmu_features      = 0x78006001
>>     [    0.000000] firmware_features = 0x00000001405a440b
>>     [    0.000000] htab_hash_mask    = 0x3ffff
>>     [    0.000000] -----------------------------------------------------
>>     [    0.000000] numa:   NODE_DATA [mem 0xfff6a300-0xfff73fff]
>>     [    0.000000]  -> smp_init_pSeries()
>>     [    0.000000]  <- smp_init_pSeries()
>>     [    0.000000] PCI host bridge /pci@800000020000000  ranges:
>>     [    0.000000]   IO 0x0000010080000000..0x000001008000ffff -> 0x0000000000000000
>>     [    0.000000]  MEM 0x00000100a0000000..0x000001101fffffff -> 0x0000000080000000 
>>     [    0.000000] PPC64 nvram contains 65536 bytes
>>     [    0.000000] Top of RAM: 0x100000000, Total RAM: 0x100000000
>>     [    0.000000] Memory hole size: 0MB
>>     [    0.000000] Zone ranges:
>>     [    0.000000]   DMA      [mem 0x0000000000000000-0x00000000ffffffff]
>>     [    0.000000]   DMA32    empty
>>     [    0.000000]   Normal   empty
>>     [    0.000000] Movable zone start for each node
>>     [    0.000000] Early memory node ranges
>>     [    0.000000]   node   0: [mem 0x0000000000000000-0x00000000ffffffff]
>>     [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ffffffff]
>>     [    0.000000] On node 0 totalpages: 65536
>>     [    0.000000]   DMA zone: 64 pages used for memmap
>>     [    0.000000]   DMA zone: 0 pages reserved
>>     [    0.000000]   DMA zone: 65536 pages, LIFO batch:1
>>     [    0.000000] percpu: Embedded 4 pages/cpu @c0000000ffb00000 s167064 r0 d95080 u262144
>>     [    0.000000] pcpu-alloc: s167064 r0 d95080 u262144 alloc=1*1048576
>>     [    0.000000] pcpu-alloc: [0] 00 01 02 03 [0] 04 05 06 07 
>>     [    0.000000] pcpu-alloc: [0] 08 09 10 11 [0] 12 13 14 15 
>>     [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 65472
>>     [    0.000000] Policy zone: DMA
>>     [    0.000000] Kernel command line: 
>>     [    0.000000] PID hash table entries: 4096 (order: -1, 32768 bytes)
>>     [    0.000000] Memory: 4163840K/4194304K available (11008K kernel code, 1664K rwdata, 2752K rodata, 1152K init, 1414K bss, 30464K reserved, 0K cma-reserved)
>>     [    0.000000] SLUB: HWalign=128, Order=0-3, MinObjects=0, CPUs=16, Nodes=1
>>     [    0.000000] ftrace: allocating 28124 entries in 11 pages
>>     [    0.000000] Hierarchical RCU implementation.
>>     [    0.000000] 	RCU event tracing is enabled.
>>     [    0.000000] 	RCU restricting CPUs from NR_CPUS=2048 to nr_cpu_ids=16.
>>     [    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=16
>>     [    0.000000] NR_IRQS: 512, nr_irqs: 512, preallocated irqs: 16
>>     [    0.000000] pic: no ISA interrupt controller
>>     [    0.000000] time_init: decrementer frequency = 512.000000 MHz
>>     [    0.000000] time_init: processor frequency   = 3425.000000 MHz
>>     [    0.000001] clocksource: timebase: mask: 0xffffffffffffffff max_cycles: 0x761537d007, max_idle_ns: 440795202126 ns
>>     [    0.001138] clocksource: timebase mult[1f40000] shift[24] registered
>>     [    0.001818] clockevent: decrementer mult[83126e98] shift[32] cpu[0]
>>     [    0.002539] Console: colour dummy device 80x25
>>     [    0.003018] console [hvc0] enabled
>>     [    0.003018] console [hvc0] enabled
>>     [    0.003411] bootconsole [udbg0] disabled
>>     [    0.003411] bootconsole [udbg0] disabled
>>     [    0.003875] pid_max: default: 32768 minimum: 301
>>     [    0.004217] Dentry cache hash table entries: 524288 (order: 6, 4194304 bytes)
>>     [    0.004394] Inode-cache hash table entries: 262144 (order: 5, 2097152 bytes)
>>     [    0.004461] Mount-cache hash table entries: 8192 (order: 0, 65536 bytes)
>>     [    0.004514] Mountpoint-cache hash table entries: 8192 (order: 0, 65536 bytes)
>>     [    0.006022] EEH: pSeries platform initialized
>>     [    0.006102] POWER8 performance monitor hardware support registered
>>     [    0.006156] power8-pmu: PMAO restore workaround active.
>>     [    0.006211] Hierarchical SRCU implementation.
>>     [    0.006394] smp: Bringing up secondary CPUs ...
>>     [    0.020141] smp: Brought up 1 node, 16 CPUs
>>     [    0.020514] numa: Node 0 CPUs: 0-15
>>     [    0.020685] Using standard scheduler topology
>>     [    0.024234] devtmpfs: initialized
>>     [    0.024965] random: get_random_u32 called from bucket_table_alloc+0x144/0x360 with crng_init=0
>>     [    0.028242] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
>>     [    0.029834] futex hash table entries: 4096 (order: 3, 524288 bytes)
>>     [    0.030024] kworker/u32:0 (106) used greatest stack depth: 12272 bytes left
>>     [    0.032033] NET: Registered protocol family 16
>>     [    0.032563] EEH: No capable adapters found
>>     [    0.034455] cpuidle: using governor menu
>>     [    0.036083] random: fast init done
>>     [    0.042279] RTAS daemon started
>>     [    0.042915] pstore: using zlib compression
>>     [    0.043109] pstore: Registered nvram as persistent store backend
>>     Linux ppc64le
>>     #1 SMP Sun Dec 3[    0.045751] rtas_msi: Registering RTAS MSI callbacks.
>>     [    0.058501] PCI: Probing PCI hardware
>>     [    0.058823] no ibm,pcie-link-speed-stats property
>>     [    0.059114] PCI host bridge to bus 0000:00
>>     [    0.059378] pci_bus 0000:00: root bus resource [io  0x10000-0x1ffff] (bus address [0x0000-0xffff])
>>     [    0.059880] pci_bus 0000:00: root bus resource [mem 0x100a0000000-0x1101fffffff] (bus address [0x80000000-0xfffffffff])
>>     [    0.060473] pci_bus 0000:00: root bus resource [bus 00-ff]
>>     [    0.060686] pci_dma_bus_setup_pSeriesLP: setting up bus /pci@800000020000000
>>     [    0.061048]   parent is /pci@800000020000000, iommu_table: 0x          (null)
>>     [    0.065074] IOMMU table initialized, virtual merging enabled
>>     [    0.065428]   created table: c0000000fe201000
>>     [    0.065681] PCI: Probing PCI hardware done
>>     [    0.086830] vgaarb: loaded
>>     [    0.087716] SCSI subsystem initialized
>>     [    0.088766] libata version 3.00 loaded.
>>     [    0.090210] usbcore: registered new interface driver usbfs
>>     [    0.090675] usbcore: registered new interface driver hub
>>     [    0.091411] usbcore: registered new device driver usb
>>     [    0.092023] pps_core: LinuxPPS API ver. 1 registered
>>     [    0.092418] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
>>     [    0.093119] PTP clock support registered
>>     [    0.094681] clocksource: Switched to clocksource timebase
>>     [    0.106055] hugetlbfs: disabling because there are no supported hugepage sizes
>>     [    0.111204] NET: Registered protocol family 2
>>     [    0.112104] TCP established hash table entries: 32768 (order: 2, 262144 bytes)
>>     [    0.112810] TCP bind hash table entries: 32768 (order: 3, 524288 bytes)
>>     [    0.113369] TCP: Hash tables configured (established 32768 bind 32768)
>>     [    0.113993] UDP hash table entries: 2048 (order: 0, 65536 bytes)
>>     [    0.114583] UDP-Lite hash table entries: 2048 (order: 0, 65536 bytes)
>>     [    0.115133] NET: Registered protocol family 1
>>     [    0.115852] RPC: Registered named UNIX socket transport module.
>>     [    0.116376] RPC: Registered udp transport module.
>>     [    0.116779] RPC: Registered tcp transport module.
>>     [    0.117176] RPC: Registered tcp NFSv4.1 backchannel transport module.
>>     [    0.117735] PCI: CLS 0 bytes, default 128
>>     [    0.118123] Trying to unpack rootfs image as initramfs...
>>     [    0.145121] Freeing initrd memory: 1792K
>>     [    0.151187] audit: initializing netlink subsys (disabled)
>>     [    0.152291] audit: type=2000 audit(1512304166.130:1): state=initialized audit_enabled=0 res=1
>>     [    0.153746] workingset: timestamp_bits=38 max_order=16 bucket_order=0
>>     [    0.161309] NFS: Registering the id_resolver key type
>>     [    0.161796] Key type id_resolver registered
>>     [    0.162029] Key type id_legacy registered
>>     [    0.162826] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
>>     [    0.163638] io scheduler noop registered
>>     [    0.164114] io scheduler deadline registered
>>     [    0.164758] io scheduler cfq registered (default)
>>     [    0.165354] io scheduler mq-deadline registered
>>     [    0.165713] io scheduler kyber registered
>>     [    0.166959] atomic64_test: passed
>>     [    0.197910] __vio_register_driver: driver hvc_console registering
>>     [    0.199239] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
>>     [    0.203789] brd: module loaded
>>     [    0.209646] loop: module loaded
>>     [    0.209921] ipr: IBM Power RAID SCSI Device Driver version: 2.6.4 (March 14, 2017)
>>     [    0.210454] __vio_register_driver: driver ibmvscsi registering
>>     [    0.214828] ibmvscsi 71000003: SRP_VERSION: 16.a
>>     [    0.215752] ibmvscsi 71000003: Maximum ID: 64 Maximum LUN: 32 Maximum Channel: 3
>>     [    0.216463] scsi host0: IBM POWER Virtual SCSI Adapter 1.5.9
>>     [    0.217445] ibmvscsi 71000003: partner initialization complete
>>     [    0.217950] ibmvscsi 71000003: host srp version: 16.a, host partition qemu (0), OS 2, max io 2097152
>>     [    0.218617] ibmvscsi 71000003: sent SRP login
>>     [    0.218902] ibmvscsi 71000003: SRP_LOGIN succeeded
>>     [    0.257469] scsi 0:0:2:0: CD-ROM            QEMU     QEMU CD-ROM      2.5+ PQ: 0 ANSI: 5
>>     [    0.448382] sr 0:0:2:0: [sr0] scsi3-mmc drive: 16x/50x cd/rw xa/form2 cdda tray
>>     [    0.448992] cdrom: Uniform CD-ROM driver Revision: 3.20
>>     [    0.449673] sr 0:0:2:0: Attached scsi CD-ROM sr0
>>     [    0.450738] sr 0:0:2:0: Attached scsi generic sg0 type 5
>>     [    0.451472] libphy: Fixed MDIO Bus: probed
>>     [    0.452068] ibmveth: IBM Power Virtual Ethernet Driver 1.06
>>     [    0.452411] __vio_register_driver: driver ibmveth registering
>>     [    0.453225] e100: Intel(R) PRO/100 Network Driver, 3.5.24-k2-NAPI
>>     [    0.454141] e100: Copyright(c) 1999-2006 Intel Corporation
>>     [    0.454537] e1000: Intel(R) PRO/1000 Network Driver - version 7.3.21-k8-NAPI
>>     [    0.455441] e1000: Copyright (c) 1999-2006 Intel Corporation.
>>     [    0.455920] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
>>     [    0.456616] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
>>     [    0.457115] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
>>     [    0.457528] ehci-pci: EHCI PCI platform driver
>>     [    0.457917] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
>>     [    0.458868] ohci-pci: OHCI PCI platform driver
>>     [    0.459673] rtc-generic rtc-generic: rtc core: registered rtc-generic as rtc0
>>     [    0.460373] i2c /dev entries driver
>>     [    0.460995] IR NEC protocol handler initialized
>>     [    0.461537] IR RC5(x/sz) protocol handler initialized
>>     [    0.461921] IR RC6 protocol handler initialized
>>     [    0.462304] IR JVC protocol handler initialized
>>     [    0.462679] IR Sony protocol handler initialized
>>     [    0.463061] IR SANYO protocol handler initialized
>>     [    0.463427] IR Sharp protocol handler initialized
>>     [    0.463811] IR MCE Keyboard/mouse protocol handler initialized
>>     [    0.464284] IR XMP protocol handler initialized
>>     [    0.464901] device-mapper: uevent: version 1.0.3
>>     [    0.465724] device-mapper: ioctl: 4.36.0-ioctl (2017-06-09) initialised: dm-devel@redhat.com
>>     [    0.466797] pseries_idle_driver registered
>>     [    0.467761] usbcore: registered new interface driver usbhid
>>     [    0.468401] usbhid: USB HID core driver
>>     [    0.469142] ipip: IPv4 and MPLS over IPv4 tunneling driver
>>     [    0.469558] NET: Registered protocol family 17
>>     [    0.470202] Key type dns_resolver registered
>>     [    0.470535] Unable to handle kernel paging request for data at address 0x00000010
>>     [    0.471030] Faulting instruction address: 0xc000000000d92d04
>>     [    0.471440] Oops: Kernel access of bad area, sig: 11 [#1]
>>     [    0.471760] LE SMP NR_CPUS=2048 NUMA pSeries
>>     [    0.472081] Modules linked in:
>>     [    0.472319] CPU: 7 PID: 1 Comm: swapper/0 Not tainted 4.14.0-rc2-gcc6x-g9e1fc7e #1
>>     [    0.472811] task: c0000000fea80000 task.stack: c0000000feb00000
>>     [    0.473215] NIP:  c000000000d92d04 LR: c000000000d92cfc CTR: 0000000000000000
>>     [    0.473706] REGS: c0000000feb038d0 TRAP: 0380   Not tainted  (4.14.0-rc2-gcc6x-g9e1fc7e)
>>     [    0.474203] MSR:  8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE>  CR: 84000248  XER: 20000000
>>     [    0.474901] CFAR: c000000000deb200 SOFTE: 1 
>>     [    0.474901] GPR00: c000000000d92cfc c0000000feb03b50 c000000000fca600 0000000000000000 
>>     [    0.474901] GPR04: c0000000feb03b70 0000000000000000 000000000000002f 0000000000000022 
>>     [    0.474901] GPR08: 0000000000000000 c0000000017e35a8 0000000000000000 0000000000000220 
>>     [    0.474901] GPR12: 0000000000000000 c00000000fd42680 c00000000000d778 0000000000000000 
>>     [    0.474901] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
>>     [    0.474901] GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 
>>     [    0.474901] GPR24: 0000000000000000 c000000000d66f60 c000000000d838a4 c000000000dfd918 
>>     [    0.474901] GPR28: 0000000000000007 c0000000fffffc30 c0000000feb03bf0 0000000000000010 
>>     [    0.479304] NIP [c000000000d92d04] read_drconf_v1_cell+0x50/0x9c
>>     [    0.479705] LR [c000000000d92cfc] read_drconf_v1_cell+0x48/0x9c
>>     [    0.480104] Call Trace:
>>     [    0.480244] [c0000000feb03b50] [c000000000d92cfc] read_drconf_v1_cell+0x48/0x9c (unreliable)
>>     [    0.480907] [c0000000feb03b90] [c000000000d931a4] drmem_init+0x13c/0x2ec
>>     [    0.481352] [c0000000feb03c40] [c00000000000d50c] do_one_initcall+0x6c/0x1d0
>>     [    0.481897] [c0000000feb03d00] [c000000000d84600] kernel_init_freeable+0x27c/0x358
>>     [    0.482428] [c0000000feb03dc0] [c00000000000d79c] kernel_init+0x2c/0x160
>>     [    0.482872] [c0000000feb03e30] [c00000000000bae0] ret_from_kernel_thread+0x5c/0x7c
>>     [    0.483416] Instruction dump:
>>     [    0.483667] 7c7f1b78 60000000 60000000 7c240b78 3d22ffe5 39296414 e95e0000 e8690002 
>>     [    0.484216] f9440021 48058495 60000000 e9210020 <f87f0000> 39090004 38e90008 39490010 
>>     [    0.484926] ---[ end trace 5aca0f2a87d33521 ]---
>>     [    0.496557] 
>>     [    1.496724] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
>>     [    1.496724] 
>>     [    1.505124] Rebooting in 10 seconds..
>>
>>
>> cheers
>>
> 

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

* Re: [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2
  2018-02-14 21:30   ` Tyrel Datwyler
  2018-02-14 21:50     ` Nathan Fontenot
@ 2018-02-14 23:21     ` Michael Ellerman
  1 sibling, 0 replies; 17+ messages in thread
From: Michael Ellerman @ 2018-02-14 23:21 UTC (permalink / raw)
  To: Tyrel Datwyler, Nathan Fontenot, linuxppc-dev; +Cc: Cyril Bur

Tyrel Datwyler <tyreld@linux.vnet.ibm.com> writes:

> On 12/03/2017 09:13 PM, Michael Ellerman wrote:
>> Nathan Fontenot <nfont@linux.vnet.ibm.com> writes:
>> 
>>> This patch set provides a series of updates to de-couple the LMB
>>> information provided in the device tree property from the device
>>> tree property format. This eases the ability to support a new
>>> format for the dynamic memory property, ibm,dynamic-memory-v2.
>> 
>> Something in here is still blowing up for me in a KVM guest:
>
> So, it looks like this series was applied despite observing this KVM
> guest crash.

The crash has gone away for me, I do that KVM guest test on every push.

So I applied the series, but yeah you're right that was probably silly
of me.

cheers

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

end of thread, other threads:[~2018-02-14 23:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-01 16:46 [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Nathan Fontenot
2017-12-01 16:46 ` [PATCH V3 1/9] powerpc/numa: Look up device node in of_get_assoc_arrays() Nathan Fontenot
2018-01-17 13:30   ` [V3, " Michael Ellerman
2017-12-01 16:46 ` [PATCH V3 2/9] powerpc/numa: Look up device node in of_get_usable_memory() Nathan Fontenot
2017-12-01 16:46 ` [PATCH V3 3/9] powerpc/numa: Look up associativity array in of_drconf_to_nid_single Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 4/9] powerpc/mm: Separate ibm, dynamic-memory data from DT format Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 5/9] powerpc/numa: Update numa code use walk_drmem_lmbs Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 6/9] powerpc/pseries: Update memory hotplug code to use drmem LMB array Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 7/9] powerpc: Move of_drconf_cell struct to asm/drmem.h Nathan Fontenot
2017-12-01 16:47 ` [PATCH V3 8/9] powerpc/drmem: Add support for ibm, dynamic-memory-v2 property Nathan Fontenot
2018-01-17 13:30   ` [V3, " Michael Ellerman
2017-12-01 16:48 ` [PATCH V3 9/9] powerpc: Enable support of ibm,dynamic-memory-v2 Nathan Fontenot
2018-01-17 13:30   ` [V3,9/9] " Michael Ellerman
2017-12-04  5:13 ` [PATCH V3 0/9] powerpc: Support for ibm,dynamic-memory-v2 Michael Ellerman
2018-02-14 21:30   ` Tyrel Datwyler
2018-02-14 21:50     ` Nathan Fontenot
2018-02-14 23:21     ` Michael Ellerman

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.