* [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled
@ 2023-08-28 7:46 Aneesh Kumar K.V
2023-08-28 7:46 ` [PATCH 2/2] powerpc/mm/book3s64: Use 256M as the upper limit with coherent device memory attached Aneesh Kumar K.V
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2023-08-28 7:46 UTC (permalink / raw)
To: linuxppc-dev, mpe, npiggin, christophe.leroy
Cc: Aneesh Kumar K.V, foraker1, Reza Arbab
With CONFIG_SPARSEMEM disabled the below kernel build error is observed.
arch/powerpc/mm/init_64.c:477:38: error: use of undeclared identifier 'SECTION_SIZE_BITS'
CONFIG_MEMORY_HOTPLUG depends on CONFIG_SPARSEMEM and it is more clear
to describe the code dependency in terms of MEMORY_HOTPLUG. Outside
memory hotplug the kernel uses memory_block_size for kernel directmap.
Instead of depending on SECTION_SIZE_BITS to compute the direct map
page size, add a new #define which defaults to 16M(same as existing
SECTION_SIZE)
Fixes: 4d15721177d5 ("powerpc/mm: Cleanup memory block size probing")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/init_64.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index fcda46c2b8df..e3d7379ef480 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -472,12 +472,23 @@ static int __init dt_scan_mmu_pid_width(unsigned long node,
return 1;
}
+/*
+ * Outside hotplug the kernel uses this value to map the kernel direct map
+ * with radix. To be compatible with older kernels, let's keep this value
+ * as 16M which is also SECTION_SIZE with SPARSEMEM. We can ideally map
+ * things with 1GB size in the case where we don't support hotplug.
+ */
+#ifndef CONFIG_MEMORY_HOTPLUG
+#define DEFAULT_MEMORY_BLOCK_SIZE SZ_16M
+#else
+#define DEFAULT_MEMORY_BLOCK_SIZE MIN_MEMORY_BLOCK_SIZE
+#endif
+
static void update_memory_block_size(unsigned long *block_size, unsigned long mem_size)
{
- unsigned long section_size = 1UL << SECTION_SIZE_BITS;
-
- for (; *block_size > section_size; *block_size >>= 2) {
+ unsigned long min_memory_block_size = DEFAULT_MEMORY_BLOCK_SIZE;
+ for (; *block_size > min_memory_block_size; *block_size >>= 2) {
if ((mem_size & *block_size) == 0)
break;
}
@@ -507,7 +518,7 @@ static int __init probe_memory_block_size(unsigned long node, const char *uname,
/*
* Nothing in the device tree
*/
- *block_size = MIN_MEMORY_BLOCK_SIZE;
+ *block_size = DEFAULT_MEMORY_BLOCK_SIZE;
else
*block_size = of_read_number(prop, dt_root_size_cells);
/*
--
2.41.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] powerpc/mm/book3s64: Use 256M as the upper limit with coherent device memory attached
2023-08-28 7:46 [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled Aneesh Kumar K.V
@ 2023-08-28 7:46 ` Aneesh Kumar K.V
2023-08-28 7:47 ` [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled Aneesh Kumar K V
2023-08-31 4:02 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2023-08-28 7:46 UTC (permalink / raw)
To: linuxppc-dev, mpe, npiggin, christophe.leroy
Cc: Aneesh Kumar K.V, foraker1, Reza Arbab
commit 4d15721177d5 ("powerpc/mm: Cleanup memory block size probing")
used 256MB as the memory block size when we have
ibm,coherent-device-memory device tree node present. Instead of
returning with 256MB memory block size, continue to check the rest of the memory
regions and make sure we can still map them using a 256MB memory block size.
Fixes: 4d15721177d5 ("powerpc/mm: Cleanup memory block size probing")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/init_64.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index e3d7379ef480..a8557867ece0 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -569,8 +569,12 @@ static int __init probe_memory_block_size(unsigned long node, const char *uname,
*/
compatible = of_get_flat_dt_prop(node, "compatible", NULL);
if (compatible && !strcmp(compatible, "ibm,coherent-device-memory")) {
- *block_size = SZ_256M;
- return 1;
+ if (*block_size > SZ_256M)
+ *block_size = SZ_256M;
+ /*
+ * We keep 256M as the upper limit with GPU present.
+ */
+ return 0;
}
}
/* continue looking for other memory device types */
--
2.41.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled
2023-08-28 7:46 [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled Aneesh Kumar K.V
2023-08-28 7:46 ` [PATCH 2/2] powerpc/mm/book3s64: Use 256M as the upper limit with coherent device memory attached Aneesh Kumar K.V
@ 2023-08-28 7:47 ` Aneesh Kumar K V
2023-08-31 4:02 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Aneesh Kumar K V @ 2023-08-28 7:47 UTC (permalink / raw)
To: linuxppc-dev, mpe, npiggin, christophe.leroy; +Cc: foraker1, Reza Arbab
On 8/28/23 1:16 PM, Aneesh Kumar K.V wrote:
> With CONFIG_SPARSEMEM disabled the below kernel build error is observed.
>
> arch/powerpc/mm/init_64.c:477:38: error: use of undeclared identifier 'SECTION_SIZE_BITS'
>
> CONFIG_MEMORY_HOTPLUG depends on CONFIG_SPARSEMEM and it is more clear
> to describe the code dependency in terms of MEMORY_HOTPLUG. Outside
> memory hotplug the kernel uses memory_block_size for kernel directmap.
> Instead of depending on SECTION_SIZE_BITS to compute the direct map
> page size, add a new #define which defaults to 16M(same as existing
> SECTION_SIZE)
>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202308251532.k9PpWEAD-lkp@intel.com/
> Fixes: 4d15721177d5 ("powerpc/mm: Cleanup memory block size probing")
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> ---
> arch/powerpc/mm/init_64.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
> index fcda46c2b8df..e3d7379ef480 100644
> --- a/arch/powerpc/mm/init_64.c
> +++ b/arch/powerpc/mm/init_64.c
> @@ -472,12 +472,23 @@ static int __init dt_scan_mmu_pid_width(unsigned long node,
> return 1;
> }
>
> +/*
> + * Outside hotplug the kernel uses this value to map the kernel direct map
> + * with radix. To be compatible with older kernels, let's keep this value
> + * as 16M which is also SECTION_SIZE with SPARSEMEM. We can ideally map
> + * things with 1GB size in the case where we don't support hotplug.
> + */
> +#ifndef CONFIG_MEMORY_HOTPLUG
> +#define DEFAULT_MEMORY_BLOCK_SIZE SZ_16M
> +#else
> +#define DEFAULT_MEMORY_BLOCK_SIZE MIN_MEMORY_BLOCK_SIZE
> +#endif
> +
> static void update_memory_block_size(unsigned long *block_size, unsigned long mem_size)
> {
> - unsigned long section_size = 1UL << SECTION_SIZE_BITS;
> -
> - for (; *block_size > section_size; *block_size >>= 2) {
> + unsigned long min_memory_block_size = DEFAULT_MEMORY_BLOCK_SIZE;
>
> + for (; *block_size > min_memory_block_size; *block_size >>= 2) {
> if ((mem_size & *block_size) == 0)
> break;
> }
> @@ -507,7 +518,7 @@ static int __init probe_memory_block_size(unsigned long node, const char *uname,
> /*
> * Nothing in the device tree
> */
> - *block_size = MIN_MEMORY_BLOCK_SIZE;
> + *block_size = DEFAULT_MEMORY_BLOCK_SIZE;
> else
> *block_size = of_read_number(prop, dt_root_size_cells);
> /*
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled
2023-08-28 7:46 [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled Aneesh Kumar K.V
2023-08-28 7:46 ` [PATCH 2/2] powerpc/mm/book3s64: Use 256M as the upper limit with coherent device memory attached Aneesh Kumar K.V
2023-08-28 7:47 ` [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled Aneesh Kumar K V
@ 2023-08-31 4:02 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2023-08-31 4:02 UTC (permalink / raw)
To: linuxppc-dev, npiggin, christophe.leroy, Aneesh Kumar K.V
Cc: foraker1, Reza Arbab
On Mon, 28 Aug 2023 13:16:57 +0530, Aneesh Kumar K.V wrote:
> With CONFIG_SPARSEMEM disabled the below kernel build error is observed.
>
> arch/powerpc/mm/init_64.c:477:38: error: use of undeclared identifier 'SECTION_SIZE_BITS'
>
> CONFIG_MEMORY_HOTPLUG depends on CONFIG_SPARSEMEM and it is more clear
> to describe the code dependency in terms of MEMORY_HOTPLUG. Outside
> memory hotplug the kernel uses memory_block_size for kernel directmap.
> Instead of depending on SECTION_SIZE_BITS to compute the direct map
> page size, add a new #define which defaults to 16M(same as existing
> SECTION_SIZE)
>
> [...]
Applied to powerpc/next.
[1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled
https://git.kernel.org/powerpc/c/f1424755db913c5971686537381588261cdfd1ee
[2/2] powerpc/mm/book3s64: Use 256M as the upper limit with coherent device memory attached
https://git.kernel.org/powerpc/c/4c33bf147249ebbf3dded016996a8a24c5737254
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-31 4:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-28 7:46 [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled Aneesh Kumar K.V
2023-08-28 7:46 ` [PATCH 2/2] powerpc/mm/book3s64: Use 256M as the upper limit with coherent device memory attached Aneesh Kumar K.V
2023-08-28 7:47 ` [PATCH 1/2] powerpc/mm/book3s64: Fix build error with SPARSEMEM disabled Aneesh Kumar K V
2023-08-31 4:02 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).