Commit Graph

2 Commits

Author SHA1 Message Date
Iuliana Prodan b4165baeb3 refactor is_cached() to avoid buggy compiler optimization
For imx, is_cached() is implemented based on _memmap_cacheattr_reset.
This keeps the attributes for a 512MB region, therefore
we have the following address ranges:
 Address range       - hex digit
 0        - 1FFFFFFF - 0
 20000000 - 3FFFFFFF - 1
 40000000 - 5FFFFFFF - 2
 60000000 - 7FFFFFFF - 3
 80000000 - 9FFFFFFF - 4
 A0000000 - BFFFFFFF - 5
 C0000000 - DFFFFFFF - 6
 E0000000 - FFFFFFFF - 7

While testing on i.MX8ULP we discovered that addresses from
(0 – 1FFFFFFF) range where not correctly marked as cacheable,
because the compiler is optimizing the code incorrectly.

With macros, is_cached(address) expands to
(((((uint32_t)(&_memmap_cacheattr_reset_8ulp)) >> \
 ((((((uintptr_t)((void *)address) >> 29) & 0x7)) << 2))) \
 & 0xF) == 1)
When using _memmap_cacheattr_reset_8ulp = 0x22222221
and address = 0x1A801000 is_cached(0x1A801000)
should be true, but instead is false.

We want to avoid this buggy compiler optimization.
So we replaced the macros from cache.h with functions.

To make this generic, I created a cache_attr.c file in
src/arch/xtensa/drivers/ and a config option
- COMPILER_WORKAROUND_CACHE_ATTR, which must be selected
if the workaround is needed.

Also, we replaced the call to glb_addr_attr() from glb_is_cached()
with a function pointer that is initialized in
src/arch/xtensa/drivers/cache_attr.c.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2021-08-12 15:04:41 +01:00
Anas Nashif d486a9ff98 kconfig: allow SOF Kconfig to be included in other projects
When the SOF Kconfig is included in other projects, the main menu should
not be that of SOF, rather it should be of the project including SOF.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-08-04 12:34:39 +01:00