[PATCH 2/2] kexec/ppc64: add support to parse ibm, dynamic-memory-v2 property

Hari Bathini hbathini at linux.vnet.ibm.com
Tue Feb 20 21:43:16 PST 2018



On Wednesday 21 February 2018 12:27 AM, Hari Bathini wrote:
>
>
> On Tuesday 20 February 2018 07:48 PM, Hari Bathini wrote:
>> Add support to parse the new 'ibm,dynamic-memory-v2' property in the
>> 'ibm,dynamic-reconfiguration-memory' node. This replaces the old
>> 'ibm,dynamic-memory' property and is enabled in the kernel with a
>> patch series that starts with commit 0c38ed6f6f0b ("powerpc/pseries:
>> Enable support of ibm,dynamic-memory-v2"). All LMBs that share the same
>> flags and are adjacent are grouped together in the newer version of the
>> property making it compact to represent larger memory configurations.
>>
>> Signed-off-by: Hari Bathini <hbathini at linux.vnet.ibm.com>
>> ---
>>   kexec/arch/ppc64/crashdump-ppc64.c |   23 +++++++--
>>   kexec/arch/ppc64/crashdump-ppc64.h |   16 +++++-
>>   kexec/arch/ppc64/kexec-ppc64.c     |   35 ++++++++++----
>>   kexec/fs2dt.c                      |   92 
>> ++++++++++++++++++++++--------------
>>   4 files changed, 112 insertions(+), 54 deletions(-)
>>
>> diff --git a/kexec/arch/ppc64/crashdump-ppc64.c 
>> b/kexec/arch/ppc64/crashdump-ppc64.c
>> index bc9f948..50e3853 100644
>> --- a/kexec/arch/ppc64/crashdump-ppc64.c
>> +++ b/kexec/arch/ppc64/crashdump-ppc64.c
>> @@ -39,6 +39,10 @@
>>   #define DEVTREE_CRASHKERNEL_BASE 
>> "/proc/device-tree/chosen/linux,crashkernel-base"
>>   #define DEVTREE_CRASHKERNEL_SIZE 
>> "/proc/device-tree/chosen/linux,crashkernel-size"
>>
>> +unsigned int num_of_lmb_sets;
>> +unsigned int is_dyn_mem_v2;
>> +uint64_t lmb_size;
>> +
>>   static struct crash_elf_info elf_info64 =
>>   {
>>       class: ELFCLASS64,
>> @@ -127,6 +131,7 @@ static int get_dyn_reconf_crash_memory_ranges(void)
>>   {
>>       uint64_t start, end;
>>       uint64_t startrange, endrange;
>> +    uint64_t size;
>>       char fname[128], buf[32];
>>       FILE *file;
>>       unsigned int i;
>> @@ -135,6 +140,8 @@ static int get_dyn_reconf_crash_memory_ranges(void)
>>
>>       strcpy(fname, "/proc/device-tree/");
>>       strcat(fname, 
>> "ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory");
>> +    if (is_dyn_mem_v2)
>> +        strcat(fname, "-v2");
>>       if ((file = fopen(fname, "r")) == NULL) {
>>           perror(fname);
>>           return -1;
>> @@ -142,8 +149,9 @@ static int get_dyn_reconf_crash_memory_ranges(void)
>>
>>       fseek(file, 4, SEEK_SET);
>>       startrange = endrange = 0;
>> -    for (i = 0; i < num_of_lmbs; i++) {
>> -        if ((n = fread(buf, 1, 24, file)) < 0) {
>> +    size = lmb_size;
>> +    for (i = 0; i < num_of_lmb_sets; i++) {
>> +        if ((n = fread(buf, 1, LMB_ENTRY_SIZE, file)) < 0) {
>>               perror(fname);
>>               fclose(file);
>>               return -1;
>> @@ -156,8 +164,15 @@ static int get_dyn_reconf_crash_memory_ranges(void)
>>               return -1;
>>           }
>>
>> -        start = be64_to_cpu(((uint64_t *)buf)[DRCONF_ADDR]);
>> -        end = start + lmb_size;
>> +        /*
>> +         * If the property is ibm,dynamic-memory-v2, the first 4 bytes
>> +         * tell the number of sequential LMBs in this entry.
>> +         */
>> +        if (is_dyn_mem_v2)
>> +            size = be32_to_cpu(((unsigned int *)buf)[0]) * lmb_size;
>> +
>> +        start = be64_to_cpu(*((uint64_t *)&buf[DRCONF_ADDR]));
>> +        end = start + size;
>>           if (start == 0 && end >= (BACKUP_SRC_END + 1))
>>               start = BACKUP_SRC_END + 1;
>>
>> diff --git a/kexec/arch/ppc64/crashdump-ppc64.h 
>> b/kexec/arch/ppc64/crashdump-ppc64.h
>> index 42ccc31..87beb39 100644
>> --- a/kexec/arch/ppc64/crashdump-ppc64.h
>> +++ b/kexec/arch/ppc64/crashdump-ppc64.h
>> @@ -34,10 +34,18 @@ extern unsigned int rtas_size;
>>   extern uint64_t opal_base;
>>   extern uint64_t opal_size;
>>
>> -uint64_t lmb_size;
>> -unsigned int num_of_lmbs;
>
> This might probably break compilation on other architectures like 
> arm64 & mips.
> Will check and post v2..
>

Actually, we are OK here as the macro 'HAVE_DYNAMIC_MEMORY' is defined 
only for PPC64 arch
and the above variables are used in the common code (kexec/fs2dt.c) only 
under this flag..

Thanks
Hari




More information about the kexec mailing list