diff options
| author | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
| commit | 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e (patch) | |
| tree | d57f3a63479a07b4e0cece029886e76e04feb984 /arch/s390/include/asm/mem_detect.h | |
| parent | 5dc63e56a9cf8df0b59c234a505a1653f1bdf885 (diff) | |
| parent | 53bea86b5712c7491bb3dae12e271666df0a308c (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.4 merge window.
Diffstat (limited to 'arch/s390/include/asm/mem_detect.h')
| -rw-r--r-- | arch/s390/include/asm/mem_detect.h | 39 | 
1 files changed, 31 insertions, 8 deletions
diff --git a/arch/s390/include/asm/mem_detect.h b/arch/s390/include/asm/mem_detect.h index a7c922a69050..f9e7354036d2 100644 --- a/arch/s390/include/asm/mem_detect.h +++ b/arch/s390/include/asm/mem_detect.h @@ -30,6 +30,7 @@ struct mem_detect_block {  struct mem_detect_info {  	u32 count;  	u8 info_source; +	unsigned long usable;  	struct mem_detect_block entries[MEM_INLINED_ENTRIES];  	struct mem_detect_block *entries_extended;  }; @@ -38,7 +39,7 @@ extern struct mem_detect_info mem_detect;  void add_mem_detect_block(u64 start, u64 end);  static inline int __get_mem_detect_block(u32 n, unsigned long *start, -					 unsigned long *end) +					 unsigned long *end, bool respect_usable_limit)  {  	if (n >= mem_detect.count) {  		*start = 0; @@ -53,21 +54,41 @@ static inline int __get_mem_detect_block(u32 n, unsigned long *start,  		*start = (unsigned long)mem_detect.entries_extended[n - MEM_INLINED_ENTRIES].start;  		*end = (unsigned long)mem_detect.entries_extended[n - MEM_INLINED_ENTRIES].end;  	} + +	if (respect_usable_limit && mem_detect.usable) { +		if (*start >= mem_detect.usable) +			return -1; +		if (*end > mem_detect.usable) +			*end = mem_detect.usable; +	}  	return 0;  }  /** - * for_each_mem_detect_block - early online memory range iterator + * for_each_mem_detect_usable_block - early online memory range iterator   * @i: an integer used as loop variable   * @p_start: ptr to unsigned long for start address of the range   * @p_end: ptr to unsigned long for end address of the range   * - * Walks over detected online memory ranges. + * Walks over detected online memory ranges below usable limit.   */ -#define for_each_mem_detect_block(i, p_start, p_end)			\ -	for (i = 0, __get_mem_detect_block(i, p_start, p_end);		\ -	     i < mem_detect.count;					\ -	     i++, __get_mem_detect_block(i, p_start, p_end)) +#define for_each_mem_detect_usable_block(i, p_start, p_end)		\ +	for (i = 0; !__get_mem_detect_block(i, p_start, p_end, true); i++) + +/* Walks over all detected online memory ranges disregarding usable limit. */ +#define for_each_mem_detect_block(i, p_start, p_end)		\ +	for (i = 0; !__get_mem_detect_block(i, p_start, p_end, false); i++) + +static inline unsigned long get_mem_detect_usable_total(void) +{ +	unsigned long start, end, total = 0; +	int i; + +	for_each_mem_detect_usable_block(i, &start, &end) +		total += end - start; + +	return total; +}  static inline void get_mem_detect_reserved(unsigned long *start,  					   unsigned long *size) @@ -84,8 +105,10 @@ static inline unsigned long get_mem_detect_end(void)  	unsigned long start;  	unsigned long end; +	if (mem_detect.usable) +		return mem_detect.usable;  	if (mem_detect.count) { -		__get_mem_detect_block(mem_detect.count - 1, &start, &end); +		__get_mem_detect_block(mem_detect.count - 1, &start, &end, false);  		return end;  	}  	return 0;  |