-
Notifications
You must be signed in to change notification settings - Fork 183
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
dma::WriteDma::write is unsound. #270
Comments
Thanks for the report, is this the same unsoundness that was discussed in rust-embedded/embedonomicon#64? I'm not sure what the best practice for DMA unsoundness is, I imagine not a whole lot of people use DMA so maybe yanking things causes more harm than good |
Thanks for helping me resolve this @thalesfragoso :)
@TheZoq2 I just wanted to mention that the SPI DMA is especially useful for working with large numbers of LEDs which I'd imagine is not an uncommon use case (this is our use case anyway). But I do agree that yanking might cause more harm than good either way. |
Oh yea, I use the SPI DMA for just that myself :) I haven't had time to read up on the specifics here, but I'd say wether or not to yank depends on how hard it is to run into this unsoundness. If it happens every time you use DMA, then we should probably yank, otherwise I guess it would depend on the severity |
Good point! We spent a couple of days investigating noisey SPI LEDs on our PCB prototype, trying to work out what was going on by using an oscilloscope to check all the clocks and data lines but could not find the issue. It turns out that the unsoundness somehow lead to an issue where writing to the SPI DMA would cause packet loss in our Ethernet, and similarly Ethernet activity would result in the LEDs lighting up in seemingly random ways. Here's the story I posted to the stm32-rs matrix last night for the record:
Following this, @thalesfragoso dug into the issue with me and we discovered that my After removing this type in favour of using a |
Oh wow, that sounds like a horrible bug to track down 😰. I'll try and have a look at this tomorrow evening Sidenote: Maybe that could explain why the backlight on one half of my keyboard flickers while pressing keys on the other half 🤔 |
I wonder if this could be addressed (in |
A friend of mine also suggested just that. I've got to admit I'm a bit out of my comfort zone with DMA soundness issues, but that might work. I think a better solution is to just use embedded-dma as suggested |
I think that would make things very inflexible, the new |
Yea, I agree that we should use embedded-dma.
Sounds good, I could do it but I think you have more DMA experience than me :) Though let me know if you can't find the time, it feels like we should try to get this done fairly quickly given the severity :D |
The trait
Static
doesn't provide the invariants necessary for a buffer to be safe to use with DMA, it actually doesn't provide any invariant at all, since it's public and safe to implement.The quickest solution would be to mark the trait as
unsafe
and document it. But a better solution would be to move this API to use the embedded-dma traits.This is all breaking changes and we should also discuss if we want to yank previous versions with this problem.
The text was updated successfully, but these errors were encountered: