[PATCH v3 12/16] powerpc/watchpoint: Use builtin ALIGN*() macros

Ravi Bangoria ravi.bangoria at linux.ibm.com
Fri Apr 24 13:24:14 AEST 2020


Hi Christophe,

>>           max_len = DAWR_MAX_LEN;
>>           /* DAWR region can't cross 512 bytes boundary */
>> -        if ((start_addr >> 9) != (end_addr >> 9))
>> +        if ((start_addr >> 9) != ((end_addr - 1) >> 9))
> 
> What about:
>      if (ALIGN(start_addr, SZ_512M) != ALIGN(end - 1, SZ_512M))

ok.

> 
>>               return -EINVAL;
>>       } else if (IS_ENABLED(CONFIG_PPC_8xx)) {
>>           /* 8xx can setup a range without limitation */
>> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
>> index aab82ab80dfa..06679adac447 100644
>> --- a/arch/powerpc/kernel/process.c
>> +++ b/arch/powerpc/kernel/process.c
>> @@ -800,12 +800,12 @@ static inline int set_breakpoint_8xx(struct arch_hw_breakpoint *brk)
>>       unsigned long lctrl1 = LCTRL1_CTE_GT | LCTRL1_CTF_LT | LCTRL1_CRWE_RW |
>>                      LCTRL1_CRWF_RW;
>>       unsigned long lctrl2 = LCTRL2_LW0EN | LCTRL2_LW0LADC | LCTRL2_SLW0EN;
>> -    unsigned long start_addr = brk->address & ~HW_BREAKPOINT_ALIGN;
>> -    unsigned long end_addr = (brk->address + brk->len - 1) | HW_BREAKPOINT_ALIGN;
>> +    unsigned long start_addr = ALIGN_DOWN(brk->address, HW_BREAKPOINT_SIZE);
>> +    unsigned long end_addr = ALIGN(brk->address + brk->len, HW_BREAKPOINT_SIZE);
>>       if (start_addr == 0)
>>           lctrl2 |= LCTRL2_LW0LA_F;
>> -    else if (end_addr == ~0U)
>> +    else if (end_addr - 1 == ~0U)
> 
> What about:
>      else if (end_addr == 0)

That's better.

Thanks,
Ravi


More information about the Linuxppc-dev mailing list