Skip to content
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

DmaChannel::set_priority doesn't work anymore #3085

Closed
Dominaezzz opened this issue Feb 2, 2025 · 0 comments · Fixed by #3088
Closed

DmaChannel::set_priority doesn't work anymore #3085

Dominaezzz opened this issue Feb 2, 2025 · 0 comments · Fixed by #3088
Labels
bug Something isn't working peripheral:dma DMA Peripheral

Comments

@Dominaezzz
Copy link
Collaborator

Bug description

Since #2545 landed, it's no longer possible to set the priority on DMA channel, due to the lazy init semantics.
set_priority is ignored by the hardware due to the DMA peripheral being disabled/"in reset" until a driver is made with it.
There's also the additional consequence that even if set_priority worked, the setting would be cleared when all the DMA drivers are dropped, even though the channel peripheral object might still be alive, so the user won't even realise that this has happened.

To Reproduce

        let dma_channel = peripherals.DMA_CH0;

        let in_pri = unsafe { esp32c6::DMA::steal().ch(0).in_pri().read().rx_pri().bits() };
        defmt::println!("IN_PRI = {} (before setting)", in_pri);

        dma_channel.set_priority(DmaPriority::Priority3);

        let in_pri = unsafe { esp32c6::DMA::steal().ch(0).in_pri().read().rx_pri().bits() };
        defmt::println!("IN_PRI = {} (after setting)", in_pri);

        let pio =
            ParlIoTxOnly::new(ctx.parl_io, ctx.dma_channel, tx_descriptors, 10.MHz()).unwrap();

        let in_pri = unsafe { esp32c6::DMA::steal().ch(0).in_pri().read().rx_pri().bits() };
        defmt::println!("IN_PRI = {} (after driver is made)", in_pri);
IN_PRI = 0 (before setting)
IN_PRI = 0 (after setting)
IN_PRI = 0 (after driver is made)

To get anything other than zero, I either have to use the PAC like this, after the driver is made.

        unsafe { esp32c6::DMA::steal().ch(0).in_pri().write(|w| w.rx_pri().bits(3)) };

Or throwaway a channel to make the initialisation happen earlier.

        let lol = esp_hal::dma::Channel::new(peripherals.DMA_CH2);
        core::mem::forget(lol);

Expected behavior

Setting the priority should work and stick around until the channel peripheral itself is dropped.

I think the previous Dma::new should come back (only on GDMA chips) the semantics are much clearer with that imo
Makes it more obvious when the channels are alive or not.

Environment

  • Target device: ESP32-C6 (though this should apply to any GDMA chip)
  • Crate name and version: esp-hal 0.23.1 (though I used main at the time of writing)
@Dominaezzz Dominaezzz added bug Something isn't working status:needs-attention This should be prioritized labels Feb 2, 2025
@github-project-automation github-project-automation bot moved this to Todo in esp-rs Feb 2, 2025
@Dominaezzz Dominaezzz added the peripheral:dma DMA Peripheral label Feb 2, 2025
@MabezDev MabezDev removed the status:needs-attention This should be prioritized label Feb 3, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working peripheral:dma DMA Peripheral
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants