aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-05-04 10:34:20 +0200
committerpennae <[email protected]>2023-05-05 19:08:16 +0200
commit09f078a1cc33781a01012ebc43e9d20cff53e2a3 (patch)
tree4b9506d04ca368cfeff08c92f7837b56e480b297 /embassy-rp
parent8ebe6e5f2029026594c703820c11d703da2c0334 (diff)
rp/pio: remove critical section in IrqFuture::poll
there's nothing this critical section protects against. both read and write-to-clear are atomic and don't interfere with other irq futures, only potentially with setting/clearing an irq flag from an arm core. neither have ever been synchronized, and both have the same observable effects under atomic writes and critical sections. (for both setting and clearing an irq flag observable differences could only happen if the set/clear happened after the poll read, but before the write. if it's a clear we observe the same effects as sequencing the clear entirely after the poll, and if it's a set we observe the same effects as sequencing the set entirely before the poll)
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/src/pio.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs
index 31273b5d8..c2c144c00 100644
--- a/embassy-rp/src/pio.rs
+++ b/embassy-rp/src/pio.rs
@@ -191,17 +191,10 @@ impl<'a, 'd, PIO: Instance> Future for IrqFuture<'a, 'd, PIO> {
191 //debug!("Poll {},{}", PIO::PIO_NO, SM); 191 //debug!("Poll {},{}", PIO::PIO_NO, SM);
192 192
193 // Check if IRQ flag is already set 193 // Check if IRQ flag is already set
194 if critical_section::with(|_| unsafe { 194 if unsafe { PIO::PIO.irq().read().0 & (1 << self.irq_no) != 0 } {
195 let irq_flags = PIO::PIO.irq(); 195 unsafe {
196 if irq_flags.read().0 & (1 << self.irq_no) != 0 { 196 PIO::PIO.irq().write(|m| m.0 = 1 << self.irq_no);
197 irq_flags.write(|m| {
198 m.0 = 1 << self.irq_no;
199 });
200 true
201 } else {
202 false
203 } 197 }
204 }) {
205 return Poll::Ready(()); 198 return Poll::Ready(());
206 } 199 }
207 200