Skip to content

Commit bcbdee2

Browse files
projectgusdpgeorge
authored andcommitted
rp2: Change to use TinyUSB dcd_event_handler hook.
This change: - Has a small code size reduction. - Should slightly improve overall performance. The old hook code seemed to use between 0.1% and 1.6% of the total CPU time doing no-op calls even when no USB work was required. - USB performance is mostly the same, there is a small increase in latency for some workloads that seems to because sometimes the hook usbd_task() is called at the right time to line up with the next USB host request. This only happened semi-randomly due to the timing of the hook. Improving the wakeup latency by switching rp2 to tickless WFE allows the usbd_task() to run in time for the next USB host request almost always, improving performance and more than offsetting this impact. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 2d363a2 commit bcbdee2

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

ports/rp2/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ target_compile_options(${MICROPY_TARGET} PRIVATE
406406

407407
target_link_options(${MICROPY_TARGET} PRIVATE
408408
-Wl,--defsym=__micropy_c_heap_size__=${MICROPY_C_HEAP_SIZE}
409+
-Wl,--wrap=dcd_event_handler
409410
)
410411

411412
set_source_files_properties(

ports/rp2/mpconfigport.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -250,23 +250,8 @@ extern void mp_thread_end_atomic_section(uint32_t);
250250
#define MICROPY_PY_LWIP_REENTER lwip_lock_acquire();
251251
#define MICROPY_PY_LWIP_EXIT lwip_lock_release();
252252

253-
#if MICROPY_HW_ENABLE_USBDEV
254-
#define MICROPY_HW_USBDEV_TASK_HOOK extern void usbd_task(void); usbd_task();
255-
#define MICROPY_VM_HOOK_COUNT (10)
256-
#define MICROPY_VM_HOOK_INIT static uint vm_hook_divisor = MICROPY_VM_HOOK_COUNT;
257-
#define MICROPY_VM_HOOK_POLL if (get_core_num() == 0 && --vm_hook_divisor == 0) { \
258-
vm_hook_divisor = MICROPY_VM_HOOK_COUNT; \
259-
MICROPY_HW_USBDEV_TASK_HOOK \
260-
}
261-
#define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
262-
#define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
263-
#else
264-
#define MICROPY_HW_USBDEV_TASK_HOOK
265-
#endif
266-
267253
#define MICROPY_EVENT_POLL_HOOK_FAST \
268254
do { \
269-
if (get_core_num() == 0) { MICROPY_HW_USBDEV_TASK_HOOK } \
270255
extern void mp_handle_pending(bool); \
271256
mp_handle_pending(true); \
272257
} while (0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy