@@ -494,12 +494,23 @@ static int __init dt_scan_mmu_pid_width(unsigned long node,
494494 return 1 ;
495495}
496496
497+ /*
498+ * Outside hotplug the kernel uses this value to map the kernel direct map
499+ * with radix. To be compatible with older kernels, let's keep this value
500+ * as 16M which is also SECTION_SIZE with SPARSEMEM. We can ideally map
501+ * things with 1GB size in the case where we don't support hotplug.
502+ */
503+ #ifndef CONFIG_MEMORY_HOTPLUG
504+ #define DEFAULT_MEMORY_BLOCK_SIZE SZ_16M
505+ #else
506+ #define DEFAULT_MEMORY_BLOCK_SIZE MIN_MEMORY_BLOCK_SIZE
507+ #endif
508+
497509static void update_memory_block_size (unsigned long * block_size , unsigned long mem_size )
498510{
499- unsigned long section_size = 1UL << SECTION_SIZE_BITS ;
500-
501- for (; * block_size > section_size ; * block_size >>= 2 ) {
511+ unsigned long min_memory_block_size = DEFAULT_MEMORY_BLOCK_SIZE ;
502512
513+ for (; * block_size > min_memory_block_size ; * block_size >>= 2 ) {
503514 if ((mem_size & * block_size ) == 0 )
504515 break ;
505516 }
@@ -529,7 +540,7 @@ static int __init probe_memory_block_size(unsigned long node, const char *uname,
529540 /*
530541 * Nothing in the device tree
531542 */
532- * block_size = MIN_MEMORY_BLOCK_SIZE ;
543+ * block_size = DEFAULT_MEMORY_BLOCK_SIZE ;
533544 else
534545 * block_size = of_read_number (prop , dt_root_size_cells );
535546 /*
@@ -580,8 +591,12 @@ static int __init probe_memory_block_size(unsigned long node, const char *uname,
580591 */
581592 compatible = of_get_flat_dt_prop (node , "compatible" , NULL );
582593 if (compatible && !strcmp (compatible , "ibm,coherent-device-memory" )) {
583- * block_size = SZ_256M ;
584- return 1 ;
594+ if (* block_size > SZ_256M )
595+ * block_size = SZ_256M ;
596+ /*
597+ * We keep 256M as the upper limit with GPU present.
598+ */
599+ return 0 ;
585600 }
586601 }
587602 /* continue looking for other memory device types */
0 commit comments