Skip to content

For sufficiently large cyw43 PIO SPI transfers, sleep via async_context before entering busy wait.#2344

Open
esky-software wants to merge 3 commits into
raspberrypi:developfrom
esky-software:cyw43-pio-sleep-min
Open

For sufficiently large cyw43 PIO SPI transfers, sleep via async_context before entering busy wait.#2344
esky-software wants to merge 3 commits into
raspberrypi:developfrom
esky-software:cyw43-pio-sleep-min

Conversation

@esky-software
Copy link
Copy Markdown
Contributor

Fixes #2343

The function cyw43_spi_transfer() busy waits on the transfer DMA channel(s), even for large transfers.
This is far from optimal in an RTOS or other asynchronous environment.

We might use DMA interrupts to handle the completion of the transfer, but this would require some restructuring of the driver code.

More simply, we can estimate the duration of the transfer, and if it's larger than a threshold call cyw43_delay_us() to sleep via the async context before starting the busy wait for the end of the transfer.

Define CYW43_PIO_SLEEP_MIN_US as the threshold duration (microseconds) to enable the feature.

Comment thread src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c
@kilograham kilograham added this to the 2.2.0 milestone Mar 18, 2025
@kilograham kilograham modified the milestones: 2.2.0, 2.1.2 Mar 23, 2025
peterharperuk
peterharperuk previously approved these changes May 8, 2025
Copy link
Copy Markdown
Contributor

@peterharperuk peterharperuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seem like a good change and a good idea.

Comment thread src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c Outdated
@esky-software
Copy link
Copy Markdown
Contributor Author

Not sure why this shows as 'esky software dismissed peterharperuk's stale review...' with my update.
Did I do something wrongly?

@peterharperuk
Copy link
Copy Markdown
Contributor

It's a mystery - don't worry about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants