-
Notifications
You must be signed in to change notification settings - Fork 1k
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
DWC2 DMA support #2576
base: master
Are you sure you want to change the base?
DWC2 DMA support #2576
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
9cafcdd
to
97251e4
Compare
@@ -67,18 +67,6 @@ | |||
// Debug level for DWC2 | |||
#define DWC2_DEBUG 2 | |||
|
|||
#ifndef dcache_clean | |||
#define dcache_clean(_addr, _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.
dcache code should be removed and add MPU suggestion to make usb ram non cacheable:
- Not all internal buffers are aligned to cache line size and has size of multiple cache line size, speculative read or cache eviction of adjacent variables could lead to racing with DMA.
- Frequent cache clean invalidate hurt performance
- In most cases Cortex-M7 recommend use DTCM where cache is not used
static inline bool dma_enabled(uint8_t rhport) | ||
{ | ||
// DMA doesn't support fifo transfer | ||
#ifdef TUD_AUDIO_PREFER_RING_BUFFER |
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.
Don't want to depend on class driver but maybe it's the simplest way.
@@ -351,6 +382,12 @@ static void bus_reset(uint8_t rhport) { | |||
// Setup the control endpoint 0 | |||
_allocated_fifo_words_tx = 16; | |||
|
|||
// DMA needs extra space for processing | |||
if(dma_enabled(rhport)) { | |||
uint16_t reserved = _dwc2_controller[rhport].ep_fifo_size / 4- dwc2->ghwcfg3_bm.total_fifo_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.
Kernel use dwc2->ghwcfg3_bm.total_fifo_size
it should be reliable.
We can even remove _dwc2_controller[rhport].ep_fifo_size
and use this field instead, except GD32VF103 looks strange.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Just tested the fix in 02ec486 and it solved the issue on my end as well 👍 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Hi @HiFiPhile , |
thank you very much @HiFiPhile again for another great PR. sorry for super late response, I am doing more test with this, seems like it have some issue with my h743 eval which uses external HS PHY. That is ok, I am doing more testing and reading hopefully we could fix and merge this soon. |
Thanks for testing, it's the combination I'm missing.
@roma-jam In short I'm using GPIO toggle in ISR and in event queue processing, then take the averaged sum of 10 cycles. |
Describe the PR
Add Internal DMA support to DWC2.
Status
cdc_ual_ports
audio_4_channel_mic
video_capture_2ch
FS w/wo DMA
FS w/wo DMA
FS + HS w/wo DMA
HS w/wo DMA
cdc_msc_freertos
audio_4_channel_mic_freertos
hid_composite_freertos
FS w/wo DMA
Benchmark
STM32F723E-DISCO
IAR 9.50 High-Balanced
I-Cache enabled
Method used in #920, all buffers set to 2048b.