Skip to contentSkip to conversation

powerpc/drmem: Make lmb_size 64 bit

PATCH Superseded Aneesh Kumar K.V 5 participants 14 messages Aug 6, 2020 – Oct 7, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 powerpc/drmem: Make lmb_size 64 bit

Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.

This was found by code audit.

---
 arch/powerpc/include/asm/drmem.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/drmem.h +2 -2
index 17ccc6474ab6..d719cbac34b2 100644
@@ -21,7 +21,7 @@ struct drmem_lmb {
 struct drmem_lmb_info {
 	struct drmem_lmb        *lmbs;
 	int                     n_lmbs;
-	u32                     lmb_size;
+	u64                     lmb_size;
 };
 
 extern struct drmem_lmb_info *drmem_info;
@@ -67,7 +67,7 @@ struct of_drconf_cell_v2 {
 #define DRCONF_MEM_RESERVED	0x00000080
 #define DRCONF_MEM_HOTREMOVABLE	0x00000100
 
-static inline u32 drmem_lmb_size(void)
+static inline u64 drmem_lmb_size(void)
 {
 	return drmem_info->lmb_size;
 }
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 2/4 powerpc/mem: Store the dt_root_size/addr cell values for later usage

dt_root_addr_cells and dt_root_size_cells are __initdata variables. So make a copy of the same which can be used post init.

---
 arch/powerpc/include/asm/drmem.h | 2 ++
 arch/powerpc/kernel/prom.c       | 7 +++++++
 arch/powerpc/mm/numa.c           | 1 +
 3 files changed, 10 insertions(+)
arch/powerpc/include/asm/drmem.h +2 -0
index d719cbac34b2..ffb59caa88ee 100644
@@ -123,4 +123,6 @@ static inline void lmb_clear_nid(struct drmem_lmb *lmb)
 }
 #endif
 
+extern int mem_addr_cells, mem_size_cells;
+
 #endif /* _ASM_POWERPC_LMB_H */
arch/powerpc/kernel/prom.c +7 -0
index d8a2fb87ba0c..9a1701e85747 100644
@@ -73,6 +73,7 @@ u64 ppc64_rma_size;
 #endif
 static phys_addr_t first_memblock_size;
 static int __initdata boot_cpu_count;
+int mem_addr_cells, mem_size_cells;
 
 static int __init early_parse_mem(char *p)
 {
@@ -536,6 +537,12 @@ static int __init early_init_dt_scan_memory_ppc(unsigned long node,
 						const char *uname,
 						int depth, void *data)
 {
+	/*
+	 * Make a copy from __initdata variable
+	 */
+	mem_addr_cells = dt_root_addr_cells;
+	mem_size_cells = dt_root_size_cells;
+
 #ifdef CONFIG_PPC_PSERIES
 	if (depth == 1 &&
 	    strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) {
arch/powerpc/mm/numa.c +1 -0
index 058fee9a0835..77d41d9775d2 100644
@@ -368,6 +368,7 @@ static void __init get_n_mem_cells(int *n_addr_cells, int *n_size_cells)
 	of_node_put(memory);
 }
 
+/*  dt_mem_next_cell is __init  */
 static unsigned long read_n_cells(int n, const __be32 **buf)
 {
 	unsigned long result = 0;
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH v2 2/4] powerpc/mem: Store the dt_root_size/addr cell values for later usage

Quoted 3 lines · Aneesh Kumar K.V

dt_root_addr_cells and dt_root_size_cells are __initdata variables. So make a copy of the same which can be used post init.

This avoids doing the same thing at multiple places. So, thanks for the patch, Aneesh.

Looks good to me.

but nitpick below...

Quoted 12 lines
---
  arch/powerpc/include/asm/drmem.h | 2 ++
  arch/powerpc/kernel/prom.c       | 7 +++++++
  arch/powerpc/mm/numa.c           | 1 +
  3 files changed, 10 insertions(+)
arch/powerpc/include/asm/drmem.h +0 -0
index d719cbac34b2..ffb59caa88ee 100644

arch/powerpc/include/asm/drmem.h static inline void lmb_clear_nid(struct drmem_lmb *lmb) · line 126

Quoted 4 lines
arch/powerpc/include/asm/drmem.h +1 -0
@@ -123,4 +123,6 @@ static inline void lmb_clear_nid(struct drmem_lmb *lmb)
  }
  #endif
 
+extern int mem_addr_cells, mem_size_cells;

Should this be in include/asm/prom.h instead, given the definition comes from kernel/prom.c file?

Quoted 40 lines
arch/powerpc/include/asm/drmem.h +1 -0
+
  #endif /* _ASM_POWERPC_LMB_H */
arch/powerpc/kernel/prom.c +7 -0
index d8a2fb87ba0c..9a1701e85747 100644
@@ -73,6 +73,7 @@ u64 ppc64_rma_size;
  #endif
  static phys_addr_t first_memblock_size;
  static int __initdata boot_cpu_count;
+int mem_addr_cells, mem_size_cells;
 
  static int __init early_parse_mem(char *p)
  {
@@ -536,6 +537,12 @@ static int __init early_init_dt_scan_memory_ppc(unsigned long node,
  						const char *uname,
  						int depth, void *data)
  {
+	/*
+	 * Make a copy from __initdata variable
+	 */
+	mem_addr_cells = dt_root_addr_cells;
+	mem_size_cells = dt_root_size_cells;
+
  #ifdef CONFIG_PPC_PSERIES
  	if (depth == 1 &&
  	    strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) {
arch/powerpc/mm/numa.c +1 -0
index 058fee9a0835..77d41d9775d2 100644
@@ -368,6 +368,7 @@ static void __init get_n_mem_cells(int *n_addr_cells, int *n_size_cells)
  	of_node_put(memory);
  }
 
+/*  dt_mem_next_cell is __init  */
  static unsigned long read_n_cells(int n, const __be32 **buf)
  {
  	unsigned long result = 0;
#3 lore raw

Re: [PATCH v2 2/4] powerpc/mem: Store the dt_root_size/addr cell values for later usage

Quoted 21 lines · Hari Bathini
Quoted 3 lines · Aneesh Kumar K.V

dt_root_addr_cells and dt_root_size_cells are __initdata variables. So make a copy of the same which can be used post init.

This avoids doing the same thing at multiple places. So, thanks for the patch, Aneesh.

Looks good to me.

but nitpick below...

Quoted 7 lines

---
  arch/powerpc/include/asm/drmem.h | 2 ++
  arch/powerpc/kernel/prom.c       | 7 +++++++
  arch/powerpc/mm/numa.c           | 1 +

  3 files changed, 10 insertions(+)
Quoted 13 lines

arch/powerpc/include/asm/drmem.h static inline void lmb_clear_nid(struct drmem_lmb · line 126

Quoted 9 lines
arch/powerpc/include/asm/drmem.h +1 -0
index d719cbac34b2..ffb59caa88ee 100644
@@ -123,4 +123,6 @@ static inline void lmb_clear_nid(struct drmem_lmb 
 *lmb)
   }
   #endif
+extern int mem_addr_cells, mem_size_cells;

Should this be in include/asm/prom.h instead, given the definition comes from kernel/prom.c file?

We added the variable definition to prom.c because that is where we are doing early device tree scanning. But the users should not really be including prom.h. The variables are related drmem and hence I used drmem.h for include.

Quoted 40 lines
Quoted 40 lines
arch/powerpc/include/asm/drmem.h +1 -0
+
   #endif /* _ASM_POWERPC_LMB_H */
arch/powerpc/kernel/prom.c +7 -0
index d8a2fb87ba0c..9a1701e85747 100644
@@ -73,6 +73,7 @@ u64 ppc64_rma_size;
   #endif
   static phys_addr_t first_memblock_size;
   static int __initdata boot_cpu_count;
+int mem_addr_cells, mem_size_cells;
   static int __init early_parse_mem(char *p)
   {
@@ -536,6 +537,12 @@ static int __init 
 early_init_dt_scan_memory_ppc(unsigned long node,
                           const char *uname,
                           int depth, void *data)
   {
+    /*
+     * Make a copy from __initdata variable
+     */
+    mem_addr_cells = dt_root_addr_cells;
+    mem_size_cells = dt_root_size_cells;
+
   #ifdef CONFIG_PPC_PSERIES

      if (depth == 1 &&
          strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) {

arch/powerpc/mm/numa.c +1 -0
index 058fee9a0835..77d41d9775d2 100644
@@ -368,6 +368,7 @@ static void __init get_n_mem_cells(int 
 *n_addr_cells, int *n_size_cells)
       of_node_put(memory);
   }
+/*  dt_mem_next_cell is __init  */
   static unsigned long read_n_cells(int n, const __be32 **buf)
   {
       unsigned long result = 0;
#4 lore raw

PATCH v2 3/4 powerpc/memhotplug: Make lmb size 64bit

In reply to Aneesh Kumar K.V

Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.

This was found by code audit.

---
 .../platforms/pseries/hotplug-memory.c        | 37 +++++++++++--------
 1 file changed, 22 insertions(+), 15 deletions(-)
arch/powerpc/platforms/pseries/hotplug-memory.c +22 -15
index 5d545b78111f..1fe3204c843a 100644
@@ -277,7 +277,7 @@ static int dlpar_offline_lmb(struct drmem_lmb *lmb)
 	return dlpar_change_lmb_state(lmb, false);
 }
 
-static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size)
+static int pseries_remove_memblock(unsigned long base, unsigned long memblock_size)
 {
 	unsigned long block_sz, start_pfn;
 	int sections_per_block;
@@ -308,9 +308,9 @@ static int pseries_remove_memblock(unsigned long base, unsigned int memblock_siz
 
 static int pseries_remove_mem_node(struct device_node *np)
 {
-	const __be32 *regs;
+	const __be32 *prop;
 	unsigned long base;
-	unsigned int lmb_size;
+	unsigned long lmb_size;
 	int ret = -EINVAL;
 
 	/*
@@ -322,12 +322,16 @@ static int pseries_remove_mem_node(struct device_node *np)
 	/*
 	 * Find the base address and size of the memblock
 	 */
-	regs = of_get_property(np, "reg", NULL);
-	if (!regs)
+	prop = of_get_property(np, "reg", NULL);
+	if (!prop)
 		return ret;
 
-	base = be64_to_cpu(*(unsigned long *)regs);
-	lmb_size = be32_to_cpu(regs[3]);
+	/*
+	 * "reg" property represents (addr,size) tuple.
+	 */
+	base = of_read_number(prop, mem_addr_cells);
+	prop += mem_addr_cells;
+	lmb_size = of_read_number(prop, mem_size_cells);
 
 	pseries_remove_memblock(base, lmb_size);
 	return 0;
@@ -557,7 +561,7 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index)
 
 #else
 static inline int pseries_remove_memblock(unsigned long base,
-					  unsigned int memblock_size)
+					  unsigned long memblock_size)
 {
 	return -EOPNOTSUPP;
 }
@@ -878,9 +882,9 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 
 static int pseries_add_mem_node(struct device_node *np)
 {
-	const __be32 *regs;
+	const __be32 *prop;
 	unsigned long base;
-	unsigned int lmb_size;
+	unsigned long lmb_size;
 	int ret = -EINVAL;
 
 	/*
@@ -892,12 +896,15 @@ static int pseries_add_mem_node(struct device_node *np)
 	/*
 	 * Find the base and size of the memblock
 	 */
-	regs = of_get_property(np, "reg", NULL);
-	if (!regs)
+	prop = of_get_property(np, "reg", NULL);
+	if (!prop)
 		return ret;
-
-	base = be64_to_cpu(*(unsigned long *)regs);
-	lmb_size = be32_to_cpu(regs[3]);
+	/*
+	 * "reg" property represents (addr,size) tuple.
+	 */
+	base = of_read_number(prop, mem_addr_cells);
+	prop += mem_addr_cells;
+	lmb_size = of_read_number(prop, mem_size_cells);
 
 	/*
 	 * Update memory region to represent the memory add
Signature · 1 line
2.26.2
maintainer
#5 lore raw

Re: [PATCH v2 3/4] powerpc/memhotplug: Make lmb size 64bit

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8, v5.7.14, v5.4.57, v4.19.138, v4.14.193, v4.9.232, v4.4.232.

v5.8: Build OK!
v5.7.14: Build OK!
v5.4.57: Build OK!
v4.19.138: Failed to apply! Possible dependencies:
Unable to calculate

v4.14.193: Failed to apply! Possible dependencies:
Unable to calculate

v4.9.232: Failed to apply! Possible dependencies:
1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n")

v4.4.232: Failed to apply! Possible dependencies:
183deeea5871 ("powerpc/pseries: Consolidate CPU hotplug code to hotplug-cpu.c") 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 1dc759566636 ("powerpc/pseries: Use kernel hotplug queue for PowerVM hotplug events") 1f859adb9253 ("powerpc/pseries: Verify CPU doesn't exist before adding") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 4a4bdfea7cb7 ("powerpc/pseries: Refactor dlpar_add_lmb() code")
753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 9054619ef54a ("powerpc/pseries: Add pseries hotplug workqueue")
943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") 9dc512819e4b ("powerpc: Fix unused function warning 'lmb_to_memblock'") bdf5fc633804 ("powerpc/pseries: Update LMB associativity index during DLPAR add/remove") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") e9d764f80396 ("powerpc/pseries: Enable kernel CPU dlpar from sysfs") ec999072442a ("powerpc/pseries: Auto-online hotplugged memory")
f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n") fdb4f6e99ffa ("powerpc/pseries: Remove call to memblock_add()")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#6 lore raw

Re: [PATCH v2 3/4] powerpc/memhotplug: Make lmb size 64bit

In reply to Aneesh Kumar K.V

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.1, v5.7.15, v5.4.58, v4.19.139, v4.14.193, v4.9.232, v4.4.232.

v5.8.1: Build OK!
v5.7.15: Build OK!
v5.4.58: Build OK!
v4.19.139: Failed to apply! Possible dependencies:
Unable to calculate

v4.14.193: Failed to apply! Possible dependencies:
Unable to calculate

v4.9.232: Failed to apply! Possible dependencies:
1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n")

v4.4.232: Failed to apply! Possible dependencies:
183deeea5871 ("powerpc/pseries: Consolidate CPU hotplug code to hotplug-cpu.c") 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 1dc759566636 ("powerpc/pseries: Use kernel hotplug queue for PowerVM hotplug events") 1f859adb9253 ("powerpc/pseries: Verify CPU doesn't exist before adding") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 4a4bdfea7cb7 ("powerpc/pseries: Refactor dlpar_add_lmb() code")
753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 9054619ef54a ("powerpc/pseries: Add pseries hotplug workqueue")
943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") 9dc512819e4b ("powerpc: Fix unused function warning 'lmb_to_memblock'") bdf5fc633804 ("powerpc/pseries: Update LMB associativity index during DLPAR add/remove") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") e9d764f80396 ("powerpc/pseries: Enable kernel CPU dlpar from sysfs") ec999072442a ("powerpc/pseries: Auto-online hotplugged memory")
f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n") fdb4f6e99ffa ("powerpc/pseries: Remove call to memblock_add()")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
#7 lore raw

Re: [PATCH v2 3/4] powerpc/memhotplug: Make lmb size 64bit

In reply to Aneesh Kumar K.V
Quoted 8 lines · Aneesh Kumar K.V
arch/powerpc/platforms/pseries/hotplug-memory.c +2 -2
@@ -322,12 +322,16 @@ static int pseries_remove_mem_node(struct device_node *np)
 	/*
 	 * Find the base address and size of the memblock
 	 */
-	regs = of_get_property(np, "reg", NULL);
-	if (!regs)
+	prop = of_get_property(np, "reg", NULL);
+	if (!prop)

arch/powerpc/platforms/pseries/hotplug-memory.c static int pseries_remove_mem_node(struct device_node *np) · line 334

Quoted 10 lines
arch/powerpc/platforms/pseries/hotplug-memory.c +6 -2
 		return ret;
 
-	base = be64_to_cpu(*(unsigned long *)regs);
-	lmb_size = be32_to_cpu(regs[3]);
+	/*
+	 * "reg" property represents (addr,size) tuple.
+	 */
+	base = of_read_number(prop, mem_addr_cells);
+	prop += mem_addr_cells;
+	lmb_size = of_read_number(prop, mem_size_cells);

Would of_n_size_cells() and of_n_addr_cells() work here?

#8 lore raw

Re: [PATCH v2 3/4] powerpc/memhotplug: Make lmb size 64bit

Quoted 11 lines · Nathan Lynch
Quoted 10 lines · Aneesh Kumar K.V
arch/powerpc/platforms/pseries/hotplug-memory.c +2 -2
@@ -322,12 +322,16 @@ static int pseries_remove_mem_node(struct device_node *np)
 	/*
 	 * Find the base address and size of the memblock
 	 */
-	regs = of_get_property(np, "reg", NULL);
-	if (!regs)
+	prop = of_get_property(np, "reg", NULL);
+	if (!prop)
 		return ret;
 
Quoted 10 lines

arch/powerpc/platforms/pseries/hotplug-memory.c static int pseries_remove_mem_node(struct device_node *np) · line 334

Quoted 8 lines
arch/powerpc/platforms/pseries/hotplug-memory.c +6 -2
-	base = be64_to_cpu(*(unsigned long *)regs);
-	lmb_size = be32_to_cpu(regs[3]);
+	/*
+	 * "reg" property represents (addr,size) tuple.
+	 */
+	base = of_read_number(prop, mem_addr_cells);
+	prop += mem_addr_cells;
+	lmb_size = of_read_number(prop, mem_size_cells);

Would of_n_size_cells() and of_n_addr_cells() work here?

Yes that should work and be cleaner.

cheers

maintainer
#9 lore raw

Re: [PATCH v2 3/4] powerpc/memhotplug: Make lmb size 64bit

In reply to Aneesh Kumar K.V

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.2, v5.7.16, v5.4.59, v4.19.140, v4.14.193, v4.9.232, v4.4.232.

v5.8.2: Build OK!
v5.7.16: Build OK!
v5.4.59: Build OK!
v4.19.140: Failed to apply! Possible dependencies:
Unable to calculate

v4.14.193: Failed to apply! Possible dependencies:
Unable to calculate

v4.9.232: Failed to apply! Possible dependencies:
1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n")

v4.4.232: Failed to apply! Possible dependencies:
183deeea5871 ("powerpc/pseries: Consolidate CPU hotplug code to hotplug-cpu.c") 1a367063ca0c ("powerpc/pseries: Check memory device state before onlining/offlining") 1dc759566636 ("powerpc/pseries: Use kernel hotplug queue for PowerVM hotplug events") 1f859adb9253 ("powerpc/pseries: Verify CPU doesn't exist before adding") 25b587fba9a4 ("powerpc/pseries: Correct possible read beyond dlpar sysfs buffer") 333f7b76865b ("powerpc/pseries: Implement indexed-count hotplug memory add") 4a4bdfea7cb7 ("powerpc/pseries: Refactor dlpar_add_lmb() code")
753843471cbb ("powerpc/pseries: Implement indexed-count hotplug memory remove") 9054619ef54a ("powerpc/pseries: Add pseries hotplug workqueue")
943db62c316c ("powerpc/pseries: Revert 'Auto-online hotplugged memory'") 9dc512819e4b ("powerpc: Fix unused function warning 'lmb_to_memblock'") bdf5fc633804 ("powerpc/pseries: Update LMB associativity index during DLPAR add/remove") c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step") e70d59700fc3 ("powerpc/pseries: Introduce memory hotplug READD operation") e9d764f80396 ("powerpc/pseries: Enable kernel CPU dlpar from sysfs") ec999072442a ("powerpc/pseries: Auto-online hotplugged memory")
f84775c2d5d9 ("powerpc/pseries: Fix build break when MEMORY_HOTREMOVE=n") fdb4f6e99ffa ("powerpc/pseries: Remove call to memblock_add()")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
#10 lore raw

PATCH v2 4/4 powerpc/book3s64/radix: Make radix_mem_block_size 64bit

In reply to Aneesh Kumar K.V

Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.

Fixes af9d00e93a4f ("powerpc/mm/radix: Create separate mappings for hot-plugged memory")
---
 arch/powerpc/include/asm/book3s/64/mmu.h | 2 +-
 arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +1 -1
index 55442d45c597..1a0c9d09950f 100644
@@ -85,7 +85,7 @@ extern unsigned int mmu_base_pid;
 /*
  * memory block size used with radix translation.
  */
-extern unsigned int __ro_after_init radix_mem_block_size;
+extern unsigned long __ro_after_init radix_mem_block_size;
 
 #define PRTB_SIZE_SHIFT	(mmu_pid_bits + 4)
 #define PRTB_ENTRIES	(1ul << mmu_pid_bits)
arch/powerpc/mm/book3s64/radix_pgtable.c +1 -1
index 28c784976bed..ca76d9d6372a 100644
@@ -34,7 +34,7 @@
 
 unsigned int mmu_pid_bits;
 unsigned int mmu_base_pid;
-unsigned int radix_mem_block_size __ro_after_init;
+unsigned long radix_mem_block_size __ro_after_init;
 
 static __ref void *early_alloc_pgtable(unsigned long size, int nid,
 			unsigned long region_start, unsigned long region_end)
Signature · 1 line
2.26.2
maintainer
#11 lore raw
In reply to Aneesh Kumar K.V

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.1, v5.7.15, v5.4.58, v4.19.139, v4.14.193, v4.9.232, v4.4.232.

v5.8.1: Build OK!
v5.7.15: Build OK!
v5.4.58: Build OK!
v4.19.139: Build OK!
v4.14.193: Failed to apply! Possible dependencies:
22508f3dc985 ("powerpc/numa: Look up device node in of_get_usable_memory()") 2c77721552e5 ("powerpc: Move of_drconf_cell struct to asm/drmem.h") 35f80debaef0 ("powerpc/numa: Look up device node in of_get_assoc_arrays()") 514a9cb3316a ("powerpc/numa: Update numa code use walk_drmem_lmbs") 6195a5001f1d ("powerpc/pseries: Update memory hotplug code to use drmem LMB array") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") b6eca183e23e ("powerpc/kernel: Enables memory hot-remove after reboot on pseries guests") b88fc309d6ad ("powerpc/numa: Look up associativity array in of_drconf_to_nid_single")

v4.9.232: Failed to apply! Possible dependencies:
3a2df3798d4d ("powerpc/mm: Make switch_mm_irqs_off() out of line") 43ed84a891b7 ("powerpc/mm: Move pgdir setting into a helper")
5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") 5d451a87e5eb ("powerpc/64: Retrieve number of L1 cache sets from device-tree") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") 70cd4c10b290 ("KVM: PPC: Book3S HV: Fix software walk of guest process page tables") 9b081e10805c ("powerpc: port 64 bits pgtable_cache to 32 bits") a25bd72badfa ("powerpc/mm/radix: Workaround prefetch issue with KVM") bd067f83b084 ("powerpc/64: Fix naming of cache block vs. cache line") dbcbfee0c81c ("powerpc/64: More definitions for POWER9")
e2827fe5c156 ("powerpc/64: Clean up ppc64_caches using a struct per cache") f4329f2ecb14 ("powerpc/64s: Reduce exception alignment")

v4.4.232: Failed to apply! Possible dependencies:
11a6f6abd74a ("powerpc/mm: Move radix/hash common data structures to book3s64 headers") 26b6a3d9bb48 ("powerpc/mm: move pte headers to book3s directory") 3808a88985b4 ("powerpc: Move FW feature probing out of pseries probe()") 3dfcb315d81e ("powerpc/mm: make a separate copy for book3s")
5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") 5d31a96e6c01 ("powerpc/livepatch: Add livepatch stack to struct thread_info") 6574ba950bbe ("powerpc/kernel: Convert cpu_has_feature() to returning bool") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") a141cca3892b ("powerpc/mm: Add early_[cpu|mmu]_has_feature()")
a8ed87c92adf ("powerpc/mm/radix: Add MMU_FTR_RADIX")
b92a226e5284 ("powerpc: Move cpu_has_feature() to a separate file") da6a97bf12d5 ("powerpc: Move epapr_paravirt_early_init() to early_init_devtree()") f63e6d898760 ("powerpc/livepatch: Add livepatch header")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
Acked-by on v2 1/4
#12 lore raw
In reply to Aneesh Kumar K.V
Quoted 25 lines · Aneesh Kumar K.V

Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.

This was found by code audit.

---
 arch/powerpc/include/asm/drmem.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/drmem.h +1 -1
index 17ccc6474ab6..d719cbac34b2 100644
@@ -21,7 +21,7 @@ struct drmem_lmb {
 struct drmem_lmb_info {
 	struct drmem_lmb        *lmbs;
 	int                     n_lmbs;
-	u32                     lmb_size;
+	u64                     lmb_size;
 };
 
 extern struct drmem_lmb_info *drmem_info;

arch/powerpc/include/asm/drmem.h struct of_drconf_cell_v2 { · line 73

Quoted 8 lines
arch/powerpc/include/asm/drmem.h +1 -1
@@ -67,7 +67,7 @@ struct of_drconf_cell_v2 {
 #define DRCONF_MEM_RESERVED	0x00000080
 #define DRCONF_MEM_HOTREMOVABLE	0x00000100
 
-static inline u32 drmem_lmb_size(void)
+static inline u64 drmem_lmb_size(void)
 {
 	return drmem_info->lmb_size;
 }

Looks fine.

maintainer
#13 lore raw
In reply to Aneesh Kumar K.V

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.2, v5.7.16, v5.4.59, v4.19.140, v4.14.193, v4.9.232, v4.4.232.

v5.8.2: Build OK!
v5.7.16: Build OK!
v5.4.59: Build OK!
v4.19.140: Build OK!
v4.14.193: Failed to apply! Possible dependencies:
22508f3dc985 ("powerpc/numa: Look up device node in of_get_usable_memory()") 2c77721552e5 ("powerpc: Move of_drconf_cell struct to asm/drmem.h") 35f80debaef0 ("powerpc/numa: Look up device node in of_get_assoc_arrays()") 514a9cb3316a ("powerpc/numa: Update numa code use walk_drmem_lmbs") 6195a5001f1d ("powerpc/pseries: Update memory hotplug code to use drmem LMB array") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") b6eca183e23e ("powerpc/kernel: Enables memory hot-remove after reboot on pseries guests") b88fc309d6ad ("powerpc/numa: Look up associativity array in of_drconf_to_nid_single")

v4.9.232: Failed to apply! Possible dependencies:
3a2df3798d4d ("powerpc/mm: Make switch_mm_irqs_off() out of line") 43ed84a891b7 ("powerpc/mm: Move pgdir setting into a helper")
5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") 5d451a87e5eb ("powerpc/64: Retrieve number of L1 cache sets from device-tree") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") 70cd4c10b290 ("KVM: PPC: Book3S HV: Fix software walk of guest process page tables") 9b081e10805c ("powerpc: port 64 bits pgtable_cache to 32 bits") a25bd72badfa ("powerpc/mm/radix: Workaround prefetch issue with KVM") bd067f83b084 ("powerpc/64: Fix naming of cache block vs. cache line") dbcbfee0c81c ("powerpc/64: More definitions for POWER9")
e2827fe5c156 ("powerpc/64: Clean up ppc64_caches using a struct per cache") f4329f2ecb14 ("powerpc/64s: Reduce exception alignment")

v4.4.232: Failed to apply! Possible dependencies:
11a6f6abd74a ("powerpc/mm: Move radix/hash common data structures to book3s64 headers") 26b6a3d9bb48 ("powerpc/mm: move pte headers to book3s directory") 3808a88985b4 ("powerpc: Move FW feature probing out of pseries probe()") 3dfcb315d81e ("powerpc/mm: make a separate copy for book3s")
5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") 5d31a96e6c01 ("powerpc/livepatch: Add livepatch stack to struct thread_info") 6574ba950bbe ("powerpc/kernel: Convert cpu_has_feature() to returning bool") 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format") a141cca3892b ("powerpc/mm: Add early_[cpu|mmu]_has_feature()")
a8ed87c92adf ("powerpc/mm/radix: Add MMU_FTR_RADIX")
b92a226e5284 ("powerpc: Move cpu_has_feature() to a separate file") da6a97bf12d5 ("powerpc: Move epapr_paravirt_early_init() to early_init_devtree()") f63e6d898760 ("powerpc/livepatch: Add livepatch header")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha