[U-Boot] [PATCH][v2] arch/powperpc: Fix start_align due to use of __ffs64() instead ffs64()

Return value of ffs64() different to that of __ffs64(), ffs64(0x80000000) = 0x20 __ffs64(0x80000000) = 0x1f, as result of this change -1 from start_align needs to be removed. Incorrect DDR law was created in case of B4860qds
Signed-off-by: Ashish Kumar Ashish.Kumar@nxp.com --- * Test on B4860qds and T1040 * 83xx platform not tested
arch/powerpc/cpu/mpc83xx/law.c | 4 ++-- arch/powerpc/cpu/mpc8xxx/law.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/cpu/mpc83xx/law.c b/arch/powerpc/cpu/mpc83xx/law.c index 262ae7f..ae9cba8 100644 --- a/arch/powerpc/cpu/mpc83xx/law.c +++ b/arch/powerpc/cpu/mpc83xx/law.c @@ -21,7 +21,7 @@ int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id) if (start == 0) start_align = 1ull << (LAW_SIZE_2G + 1); else - start_align = 1ull << (__ffs64(start) - 1); + start_align = 1ull << (__ffs64(start)); law_sz = min(start_align, sz); law_sz_enc = __ilog2_u64(law_sz) - 1;
@@ -41,7 +41,7 @@ int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id) if (sz) { start += law_sz;
- start_align = 1ull << (__ffs64(start) - 1); + start_align = 1ull << (__ffs64(start)); law_sz = min(start_align, sz); law_sz_enc = __ilog2_u64(law_sz) - 1; ecm = &immap->sysconf.ddrlaw[1]; diff --git a/arch/powerpc/cpu/mpc8xxx/law.c b/arch/powerpc/cpu/mpc8xxx/law.c index 24baad4..bd79297 100644 --- a/arch/powerpc/cpu/mpc8xxx/law.c +++ b/arch/powerpc/cpu/mpc8xxx/law.c @@ -188,7 +188,7 @@ int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id) if (start == 0) start_align = 1ull << (LAW_SIZE_32G + 1); else - start_align = 1ull << (__ffs64(start) - 1); + start_align = 1ull << (__ffs64(start)); law_sz = min(start_align, sz); law_sz_enc = __ilog2_u64(law_sz) - 1;
@@ -203,7 +203,7 @@ int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id) if (sz) { start += law_sz;
- start_align = 1ull << (__ffs64(start) - 1); + start_align = 1ull << (__ffs64(start)); law_sz = min(start_align, sz); law_sz_enc = __ilog2_u64(law_sz) - 1;

On 01/22/2016 02:20 AM, Ashish Kumar wrote:
Return value of ffs64() different to that of __ffs64(), ffs64(0x80000000) = 0x20 __ffs64(0x80000000) = 0x1f, as result of this change -1 from start_align needs to be removed. Incorrect DDR law was created in case of B4860qds
Signed-off-by: Ashish Kumar Ashish.Kumar@nxp.com
- Test on B4860qds and T1040
- 83xx platform not tested
Revised commit message as
Incorrect DDR law was created in case of B4860qds after commit 2d2f490d. Return value of ffs64() differs from __ffs64(), eg. ffs64(0x80000000) = 0x20 __ffs64(0x80000000) = 0x1f As a result of this change, callers need to adjust the expected return value by removing -1.
Applied to u-boot-mpc85xx master branch. Awaiting upstream.
Thanks.
York

On 01/22/2016 02:20 AM, Ashish Kumar wrote:
Return value of ffs64() different to that of __ffs64(), ffs64(0x80000000) = 0x20 __ffs64(0x80000000) = 0x1f, as result of this change -1 from start_align needs to be removed. Incorrect DDR law was created in case of B4860qds
Signed-off-by: Ashish Kumar Ashish.Kumar@nxp.com
- Test on B4860qds and T1040
- 83xx platform not tested
(resend)
Revised commit message as
Incorrect DDR law was created in case of B4860qds after commit 2d2f490d. Return value of ffs64() differs from __ffs64(), eg. ffs64(0x80000000) = 0x20 __ffs64(0x80000000) = 0x1f As a result of this change, callers need to adjust the expected return value by removing -1.
Applied to u-boot-mpc85xx master branch. Awaiting upstream.
Thanks.
York
participants (2)
-
Ashish Kumar
-
york sun