-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add DWC2 cache maintenance routines for STM32 #2963
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: master
Are you sure you want to change the base?
Conversation
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
7b6b813
to
adb3c80
Compare
Looks like my HIL instance has license issue, I think we can add the env locally. |
Works great for me, both for CDC and UVC. Thanks ! In addition to |
Thanks for your test. |
Thanks @HiFiPhile for great Pr as usual. Though I am off for TET (Lunar New Year) and won't be able to review this in 2 weeks. Happy New Year 🎉 |
I don't think so. I'm using a custom RTOS which relies on its own set of headers, that's why. |
Happy new year also 🎊 |
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
d349c12
to
6c9a081
Compare
Signed-off-by: HiFiPhile <[email protected]>
{ | ||
__NONCACHEABLEBUFFER_BEGIN = .;/* create symbol for start of section */ | ||
KEEP(*(noncacheable)) | ||
__NONCACHEABLEBUFFER_END = .; /* create symbol for start of section */ |
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.
The comment is wrong. It should be end of section
.
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.
Thank you, it's copied from STM32CubeH7RS.
RW_NONCACHEABLE : | ||
{ | ||
__NONCACHEABLEBUFFER_BEGIN = .;/* create symbol for start of section */ | ||
KEEP(*(noncacheable)) |
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.
ST's latest default linker files for NUCLEO-H7S3L8 seem to use
KEEP(*(noncacheable)) | |
KEEP(*(noncacheable_buffer)) |
Across the board.
By default linker files, I mean these ones (also just for reference I think STM32H7S3L8HX_ROMxspi2.ld
is the preferred/recommended one for bootflash/OctoSPI setup on NUCLEO-H7S3L8):
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.
Looks like STM32CubeH7RS is using noncacheable_buffer
instead of noncacheable
across the board.
Not a big deal, although keeping alignment with the section name they use probably will help with compatibility.
#elif CFG_TUSB_MCU == OPT_MCU_STM32H7RS | ||
static mem_region_t uncached_regions[] = { | ||
// DTCM (although USB DMA can't transfer to/from DTCM) | ||
{.start = 0x20000000, .end = 0x2002FFFF}, |
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.
Since DMA can't access DTCM on H7 and H7RS. Might it be worth also defining the idiomatic ST noncacheable_buffer
region in here?
It could be grabbed from symbols something like:
extern int __NONCACHEABLEBUFFER_BEGIN;
extern int __NONCACHEABLEBUFFER_END;
uint32_t *start = (uint32_t*)&__NONCACHEABLEBUFFER_BEGIN;
uint32_t *end = (uint32_t*)&__NONCACHEABLEBUFFER_END;
Since noncacheable_buffer
should be set as non-cacheable in MPU configuration, I imagine the MPU probably doesn't actually do anything when you try to do cache maintenance on those sections, so it probably doesn't incur the same performance penalty as the cache maintanance operations has when buffers are located in cacheable memory, but I guess it's still costing a few cycles every transfer for those who are using noncacheable memory.
[Note: this comment operates on the assumption that my other comment below regarding is_cache_mem
is correct and there is a typo in the region start+end check.]
Co-authored-by: Joel Murphy <[email protected]>
Describe the PR
Now
#define CFG_TUD_DWC2_DMA_ENABLE 1
is enough.It's prefer to declare a non-cached region with MPU instead of rely on cache invalidate+clean, benchmark on STM32H7S3 and i.MX RT1170 shows frequent cache invalidate+clean really hurts performance.
** Need rebase after #2960
Benchmark code