Skip to content
Snippets Groups Projects
  • Eugeniy Paltsev's avatar
    3cf23939
    ARC: cache: explicitly initialize "*_exists" variables · 3cf23939
    Eugeniy Paltsev authored
    
    dcache_exists, icache_exists, slc_exists and ioc_exists global
    variables in "arch/arc/lib/cache.c" remain uninitialized if
    SoC doesn't have corresponding HW.
    
    This happens because we use the next constructions for their
    definition and initialization:
    -------------------------->>---------------------
    int ioc_exists __section(".data");
    
    if (/* condition */)
    		ioc_exists = 1;
    -------------------------->>---------------------
    
    That's quite a non-trivial issue as one may think of it.
    The point is we intentionally put those variables in ".data" section
    so they might survive relocation (remember we initilaize them very early
    before relocation and continue to use after reloaction). While being
    non-initialized and not explicitly put in .data section they would end-up
    in ".bss" section which by definition is filled with zeroes.
    But since we place those variables in .data section we need to care
    about their proper initialization ourselves.
    
    Also while at it we change their type to "bool" as more appropriate.
    
    Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
    Signed-off-by: default avatarAlexey Brodkin <abrodkin@synopsys.com>
    3cf23939
    History
    ARC: cache: explicitly initialize "*_exists" variables
    Eugeniy Paltsev authored
    
    dcache_exists, icache_exists, slc_exists and ioc_exists global
    variables in "arch/arc/lib/cache.c" remain uninitialized if
    SoC doesn't have corresponding HW.
    
    This happens because we use the next constructions for their
    definition and initialization:
    -------------------------->>---------------------
    int ioc_exists __section(".data");
    
    if (/* condition */)
    		ioc_exists = 1;
    -------------------------->>---------------------
    
    That's quite a non-trivial issue as one may think of it.
    The point is we intentionally put those variables in ".data" section
    so they might survive relocation (remember we initilaize them very early
    before relocation and continue to use after reloaction). While being
    non-initialized and not explicitly put in .data section they would end-up
    in ".bss" section which by definition is filled with zeroes.
    But since we place those variables in .data section we need to care
    about their proper initialization ourselves.
    
    Also while at it we change their type to "bool" as more appropriate.
    
    Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
    Signed-off-by: default avatarAlexey Brodkin <abrodkin@synopsys.com>