Re: [PATCH 2/2] arc: Fix xCCM size check

From: Alexey Brodkin
Date: Mon Jan 09 2017 - 10:18:00 EST


Hi Vineet,

On Thu, 2016-12-22 at 16:34 -0800, Vineet Gupta wrote:
> On 12/22/2016 06:09 AM, Alexey Brodkin wrote:
> >
> > CONFIG_ARC_ICCM_SZ in menuconfig is specified in kB while
> > "cpu->Xccm.sz" contains value in bytes thus direct comparison fails
> > leading to boot-time panic like that:
> > ----------------------->8---------------------
> > IDENTITYÂÂÂÂÂÂÂÂ: ARCVER [0x52] ARCNUM [0x1] CHIPID [ 0x0]
> > processor [1]ÂÂÂ: ARC HS38 R2.1 (ARCv2 ISA)
> > TimersÂÂÂÂÂÂÂÂÂÂ: Timer0 Timer1 Local-64-bit-Ctr (not used)
> > ISA ExtnÂÂÂÂÂÂÂÂ: atomic ll64 unalign (not used)
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ: mpy[opt 9] div_rem norm barrel-shift swap minmax swape
> > BPUÂÂÂÂÂÂÂÂÂÂÂÂÂ: full match, cache:2048, Predict Table:16384
> > MMU [v0]ÂÂÂÂÂÂÂÂ: 0k PAGE, JTLB 0 (0x0), uDTLB 0, uITLB 0
> > I-CacheÂÂÂÂÂÂÂÂÂ: N/A
> > D-CacheÂÂÂÂÂÂÂÂÂ: N/A
> > PeripheralsÂÂÂÂÂ: 0xf0000000, IO-Coherency (disabled)
> > Vector TableÂÂÂÂ: 0x80000000
> > FPUÂÂÂÂÂÂÂÂÂÂÂÂÂ: SP DP
> > DEBUGÂÂÂÂÂÂÂÂÂÂÂ: ActionPoint smaRT RTT
> > Extn [CCM]ÂÂÂÂÂÂ: DCCM @ e0000000, 256 KB / ICCM: @ 60000000, 256 KB
> > OS ABI [v4]ÂÂÂÂÂ: 64-bit data any register aligned
> > Extn [SMP]ÂÂÂÂÂÂ: ARConnect (v2): 2 cores with IPI IDU DEBUG GFRC
> > Kernel panic - not syncing: Linux built with incorrect DCCM Size
> >
> > ---[ end Kernel panic - not syncing: Linux built with incorrect DCCM Size
> > ----------------------->8---------------------
> >
> > Signed-off-by: Alexey Brodkin <abrodkin@xxxxxxxxxxxx>
> > Cc: Igor Guryanov <guryanov@xxxxxxxxxxxx>
> > Cc: stable@xxxxxxxxxxxxxxx
> > ---
> > Âarch/arc/kernel/setup.c | 4 ++--
> > Â1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
> > index ee574f37f365..601dab6fe5e0 100644
> > --- a/arch/arc/kernel/setup.c
> > +++ b/arch/arc/kernel/setup.c
> > @@ -333,12 +333,12 @@ static void arc_chk_core_config(void)
> > Â if ((unsigned int)__arc_dccm_base != cpu->dccm.base_addr)
> > Â panic("Linux built with incorrect DCCM Base address\n");
> > Â
> > - if (CONFIG_ARC_DCCM_SZ != cpu->dccm.sz)
> > + if (CONFIG_ARC_DCCM_SZ != TO_KB(cpu->dccm.sz))
>
> Could we just avoid this existing TO_KB non sense in multiple places by keeping
> the *ccm.sz unit consistent with CONFIG_ARC_*CCM_SZ ?
> so
> -ÂÂÂÂÂÂÂÂÂÂÂÂcpu->iccm.sz = 4096 << iccm.sz;ÂÂÂÂ/* 8K to 512K */
> +ÂÂÂÂÂÂÂÂÂÂÂÂcpu->iccm.sz = 4 << iccm.sz;ÂÂÂÂ/* 8K to 512K */
>
> Since we only want to keep ccm size to kb granularity
>
> And while at it, rename @sz placeholder in bcr_(i|d)ccm_arc(v2,compact) to sz_k

Well when I started to look at that I understood that in case of ARCv2 smallest
xCCM is 512 bytes which won't fit in our 1kB grained solution.

So it looks like instead of moving to "sz_k" we have to stay with what we have
and moreover add support of that 512 byte corner-case becase TO_KB(512) = 0.

-Alexey