-
Notifications
You must be signed in to change notification settings - Fork 7.3k
arc: cache: Support region operations, SLC, and entire cache operations #86214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
yanir10
commented
Feb 24, 2025
- Added configurable support for L1 cache region operations, which offers improved performance over line operations.
- Added configurable support for SLC (system level cache).
- Added support for entire cache operations: flush_all, invd_all, flush_and_invd_all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just a few small remarks inline.
arch/arc/Kconfig
Outdated
@@ -370,6 +370,28 @@ endmenu | |||
config DCACHE_LINE_SIZE | |||
default 32 | |||
|
|||
config DCACHE_REGION_OPERATIONS | |||
bool "DCACHE region operations" | |||
depends on CACHE_MANAGEMENT && DCACHE && CPU_HS4X |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more ARC cores supporting region operations, let's remove the "CPU_HS4X" restriction but make the feature default n.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
arch/arc/Kconfig
Outdated
config SLC_LINE_SIZE | ||
int "SLC line size" | ||
depends on SLC | ||
default 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the hardware (design-time) the default L2 cache size is 128, not 64. (but ok to leave it 64 if you prefer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
arch/arc/core/cache.c
Outdated
@@ -39,6 +40,24 @@ size_t sys_cache_line_size; | |||
#define DC_CTRL_DIRECT_ACCESS 0x0 /* direct access mode */ | |||
#define DC_CTRL_INDIRECT_ACCESS 0x20 /* indirect access mode */ | |||
#define DC_CTRL_OP_SUCCEEDED 0x4 /* d-cache operation succeeded */ | |||
#define DC_CTRL_IM_MASK BIT(6) /* d-cache invalidate mode bit */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the BIT(n) style, but now both styles are mixed in this file. Could you please either change the existing defines, or adopt to the earlier style for the new ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to the earlier style
arch/arc/core/cache.c
Outdated
} | ||
} | ||
|
||
__maybe_unused void slc_flush_and_invalidate_region(void *start_addr_ptr, size_t size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason for this function to not be 'static'? (why here the 'maybe unused', and not for the other ones?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
arch/arc/core/cache.c
Outdated
|
||
return 0; | ||
} | ||
|
||
int arch_dcache_flush_and_invd_range(void *start_addr_ptr, size_t size) | ||
{ | ||
#if defined(CONFIG_DCACHE_REGION_OPERATIONS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function follows a different flow/structure. I assume it is because there was no (line based) implementation before. ok to leave it like this, but maybe for consistency you could add the line-based variant as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is because there was no line based implementation.
Added "dcache_flush_and_invalidate_lines"
*/ | ||
if (pae_exists()) { | ||
#if defined(CONFIG_DCACHE_REGION_OPERATIONS) | ||
dcache_high_addr_init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok to explicitly do this, but I believe the hardware reset value is also 0.
f2a2a7c
to
109e5f1
Compare
Thanks, this looks good now. But when internally discussing I was made aware of a possible issue: |
Added configurable support for L1 cache region operations, which offers improved performance over line operations. Added configurable support for SLC (system level cache). Added support for entire cache operations: flush_all, invd_all, flush_and_invd_all. Reviewed-by: Aaron Komisar <[email protected]> Signed-off-by: Yanir Levin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@evgeniy-paltsev @abrodkin can you help review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds configurable support for L1 cache region operations, SLC (system level cache), and entire cache operations, enabling improved cache management.
- Introduces new auxiliary register definitions for DC region operations.
- Adds new registers for SLC control, flush, invalidate, region operations, and build ID.
Files not reviewed (1)
- arch/arc/Kconfig: Language not supported
Comments suppressed due to low confidence (1)
include/zephyr/arch/arc/v2/aux_regs.h:188
- The hex value for _ARC_V2_SLC_BUILD (0xCE) appears inconsistent with the surrounding SLC register definitions in the 0x900 range. Please verify if this value is correct and intended.
#define _ARC_V2_SLC_BUILD 0xCE
Suggestion: prefix your kconfig with |