embassy/embassy-stm32/src
bors[bot] 41e90e22e2
Merge #1370
1370: stm32/i2c: fix races when using dma. r=Dirbaio a=xoviat

This change addresses two races:

1. It removes the `chunks_transferred` state variable that is modified inside the interrupt. Analysis of the code reveals that the only time the waker can be woken is when `chunks_transferred` is incremented. Therefore, waking is enough to signal the `poll_fn` that the `chunks_transferred` has incremented. Moving to `remaining_len` clarifies the code, since there is no need to track how many chunks are remaining.
2. It moves the start of the transfer until after the waker is registered, which could theoretically occur if the clock speed is very low, but probably never would even if this wasn't fixed.

There is another race that I noticed: between writes the waker may not yet be registered. In that case, the code would simply be stuck and the `poll_fn` would never be woken. There is no way to resolve this without broadening the scope of the analysis, and this will likely never occur. 

Co-authored-by: xoviat <xoviat@users.noreply.github.com>
2023-04-19 21:36:04 +00:00
..
adc Change ADC1 to ADC 2023-04-05 16:52:32 -05:00
can Add non blocking Bxcan constructor. 2022-09-21 22:29:57 -04:00
crc Rename Unborrowed -> PeripheralRef, Unborrow -> Peripheral 2022-07-23 14:00:19 +02:00
dma stm32/spi: add support for all word sizes. 2023-04-18 20:56:23 +02:00
eth stm32: add H5 support. 2023-04-06 18:59:37 +02:00
flash Add MAX_ERASE_SIZE const in build script, and use it in flash-wide implementation of embedded-storage traits 2023-04-18 15:49:33 +02:00
i2c Merge #1370 2023-04-19 21:36:04 +00:00
pwm stm32/pwm: add complementary pwm example 2023-04-05 18:07:07 -05:00
qspi stm32/dma: refactor. 2023-04-18 16:37:35 +02:00
rcc Merge #1360 #1361 2023-04-15 10:38:28 +00:00
rtc stm32/rtc: remove unused import 2023-04-16 19:32:15 -05:00
sdmmc stm32/dma: refactor. 2023-04-18 16:37:35 +02:00
spi stm32/spi: add new_txonly_nosck constructor, for neopixels, with an example in the stm32g0 directory. 2023-04-18 20:59:25 +02:00
subghz Implement time feature 2022-10-24 11:38:15 +03:00
timer Revert "Make advanced timer trait not require general purpose timer trait as the timers are too different." 2022-07-12 15:11:57 +03:00
usart stm32/dma: refactor. 2023-04-18 16:37:35 +02:00
usb stm32: add H5 support. 2023-04-06 18:59:37 +02:00
usb_otg stm32/otg: add U5 support. 2023-04-07 02:28:36 +02:00
wdg stm32: Fix watchdog division by zero for 256 prescaler, add watchdog example for H7 2022-11-10 15:56:28 +01:00
dac.rs Use RccPeripheral for DAC and add a hackfix for H7 2022-08-04 03:31:47 +03:00
dcmi.rs stm32/dma: add double buffered mode for DMA, update DCMI. 2023-04-18 16:41:24 +02:00
exti.rs stm32: add H5 support. 2023-04-06 18:59:37 +02:00
fmc.rs stm32: fix fmc-related build failures on some F4's 2023-02-13 02:22:06 +01:00
fmt.rs fmt: Add dunmy use to avoid "unused variable" errors when no log is enabled. 2021-06-07 03:21:37 +02:00
gpio.rs common/peripheral: do not require mut in PeripheralRef clone_unchecked. 2023-04-11 23:09:02 +02:00
interrupt.rs Update to critical-section 1.0, atomic-polyfill 1.0 2022-08-17 19:01:56 +02:00
lib.rs stm32/dma: refactor. 2023-04-18 16:37:35 +02:00
rng.rs rustfmt 2023-02-09 13:01:44 +02:00
time_driver.rs Help compiler with type inference 2022-10-24 11:31:54 +03:00
time.rs Make Hertz constructors const 2023-04-13 00:06:14 +02:00
traits.rs stm32/dma: refactor. 2023-04-18 16:37:35 +02:00