1
1
// SPDX-License-Identifier: GPL-2.0
2
+ #define boot_fmt (fmt ) "physmem: " fmt
2
3
#include <linux/processor.h>
3
4
#include <linux/errno.h>
4
5
#include <linux/init.h>
@@ -28,7 +29,7 @@ static struct physmem_range *__get_physmem_range_ptr(u32 n)
28
29
return & physmem_info .online [n ];
29
30
if (unlikely (!physmem_info .online_extended )) {
30
31
physmem_info .online_extended = (struct physmem_range * )physmem_alloc_range (
31
- RR_MEM_DETECT_EXTENDED , ENTRIES_EXTENDED_MAX , sizeof (long ), 0 ,
32
+ RR_MEM_DETECT_EXT , ENTRIES_EXTENDED_MAX , sizeof (long ), 0 ,
32
33
physmem_alloc_pos , true);
33
34
}
34
35
return & physmem_info .online_extended [n - MEM_INLINED_ENTRIES ];
@@ -207,11 +208,16 @@ unsigned long detect_max_physmem_end(void)
207
208
max_physmem_end = search_mem_end ();
208
209
physmem_info .info_source = MEM_DETECT_BIN_SEARCH ;
209
210
}
211
+ boot_debug ("Max physical memory: 0x%016lx (info source: %s)\n" , max_physmem_end ,
212
+ get_physmem_info_source ());
210
213
return max_physmem_end ;
211
214
}
212
215
213
216
void detect_physmem_online_ranges (unsigned long max_physmem_end )
214
217
{
218
+ unsigned long start , end ;
219
+ int i ;
220
+
215
221
if (!sclp_early_read_storage_info ()) {
216
222
physmem_info .info_source = MEM_DETECT_SCLP_STOR_INFO ;
217
223
} else if (physmem_info .info_source == MEM_DETECT_DIAG500_STOR_LIMIT ) {
@@ -226,12 +232,16 @@ void detect_physmem_online_ranges(unsigned long max_physmem_end)
226
232
} else if (max_physmem_end ) {
227
233
add_physmem_online_range (0 , max_physmem_end );
228
234
}
235
+ boot_debug ("Online memory ranges (info source: %s):\n" , get_physmem_info_source ());
236
+ for_each_physmem_online_range (i , & start , & end )
237
+ boot_debug (" online [%d]: 0x%016lx-0x%016lx\n" , i , start , end );
229
238
}
230
239
231
240
void physmem_set_usable_limit (unsigned long limit )
232
241
{
233
242
physmem_info .usable = limit ;
234
243
physmem_alloc_pos = limit ;
244
+ boot_debug ("Usable memory limit: 0x%016lx\n" , limit );
235
245
}
236
246
237
247
static void die_oom (unsigned long size , unsigned long align , unsigned long min , unsigned long max )
@@ -265,14 +275,23 @@ static void die_oom(unsigned long size, unsigned long align, unsigned long min,
265
275
disabled_wait ();
266
276
}
267
277
268
- void physmem_reserve (enum reserved_range_type type , unsigned long addr , unsigned long size )
278
+ static void _physmem_reserve (enum reserved_range_type type , unsigned long addr , unsigned long size )
269
279
{
270
280
physmem_info .reserved [type ].start = addr ;
271
281
physmem_info .reserved [type ].end = addr + size ;
272
282
}
273
283
284
+ void physmem_reserve (enum reserved_range_type type , unsigned long addr , unsigned long size )
285
+ {
286
+ _physmem_reserve (type , addr , size );
287
+ boot_debug ("%-14s 0x%016lx-0x%016lx %s\n" , "Reserve:" , addr , addr + size ,
288
+ get_rr_type_name (type ));
289
+ }
290
+
274
291
void physmem_free (enum reserved_range_type type )
275
292
{
293
+ boot_debug ("%-14s 0x%016lx-0x%016lx %s\n" , "Free:" , physmem_info .reserved [type ].start ,
294
+ physmem_info .reserved [type ].end , get_rr_type_name (type ));
276
295
physmem_info .reserved [type ].start = 0 ;
277
296
physmem_info .reserved [type ].end = 0 ;
278
297
}
@@ -339,15 +358,17 @@ unsigned long physmem_alloc_range(enum reserved_range_type type, unsigned long s
339
358
max = min (max , physmem_alloc_pos );
340
359
addr = __physmem_alloc_range (size , align , min , max , 0 , NULL , die_on_oom );
341
360
if (addr )
342
- physmem_reserve (type , addr , size );
361
+ _physmem_reserve (type , addr , size );
362
+ boot_debug ("%-14s 0x%016lx-0x%016lx %s\n" , "Alloc range:" , addr , addr + size ,
363
+ get_rr_type_name (type ));
343
364
return addr ;
344
365
}
345
366
346
367
unsigned long physmem_alloc (enum reserved_range_type type , unsigned long size ,
347
368
unsigned long align , bool die_on_oom )
348
369
{
349
370
struct reserved_range * range = & physmem_info .reserved [type ];
350
- struct reserved_range * new_range ;
371
+ struct reserved_range * new_range = NULL ;
351
372
unsigned int ranges_left ;
352
373
unsigned long addr ;
353
374
@@ -371,6 +392,10 @@ unsigned long physmem_alloc(enum reserved_range_type type, unsigned long size,
371
392
}
372
393
range -> end = addr + size ;
373
394
}
395
+ if (type != RR_VMEM ) {
396
+ boot_debug ("%-14s 0x%016lx-0x%016lx %-20s align 0x%lx split %d\n" , "Alloc topdown:" ,
397
+ addr , addr + size , get_rr_type_name (type ), align , !!new_range );
398
+ }
374
399
range -> start = addr ;
375
400
physmem_alloc_pos = addr ;
376
401
physmem_alloc_ranges = ranges_left ;
@@ -387,3 +412,19 @@ unsigned long get_physmem_alloc_pos(void)
387
412
{
388
413
return physmem_alloc_pos ;
389
414
}
415
+
416
+ void dump_physmem_reserved (void )
417
+ {
418
+ struct reserved_range * range ;
419
+ enum reserved_range_type t ;
420
+ unsigned long start , end ;
421
+
422
+ boot_debug ("Reserved memory ranges:\n" );
423
+ for_each_physmem_reserved_range (t , range , & start , & end ) {
424
+ if (end ) {
425
+ boot_debug ("%-14s 0x%016lx-0x%016lx @%012lx chain %012lx\n" ,
426
+ get_rr_type_name (t ), start , end , (unsigned long )range ,
427
+ (unsigned long )range -> chain );
428
+ }
429
+ }
430
+ }
0 commit comments