@@ -156,7 +156,7 @@ where
156
156
/// Requests acquiring the SPIS semaphore and waits until acquired.
157
157
#[ inline( always) ]
158
158
pub fn acquire ( & self ) -> & Self {
159
- self . enable ( ) ;
159
+ compiler_fence ( Ordering :: SeqCst ) ;
160
160
self . 0 . tasks_acquire . write ( |w| unsafe { w. bits ( 1 ) } ) ;
161
161
while self . 0 . events_acquired . read ( ) . bits ( ) == 0 { }
162
162
self
@@ -311,6 +311,7 @@ where
311
311
if maxcnt > EASY_DMA_SIZE {
312
312
return Err ( Error :: BufferTooLong ) ;
313
313
}
314
+ compiler_fence ( Ordering :: SeqCst ) ;
314
315
self . 0
315
316
. txd
316
317
. ptr
@@ -359,7 +360,7 @@ where
359
360
if ( tx_ptr as usize ) < SRAM_LOWER || ( tx_ptr as usize ) > SRAM_UPPER {
360
361
return Err ( Error :: DMABufferNotInDataMemory ) ;
361
362
}
362
-
363
+ compiler_fence ( Ordering :: SeqCst ) ;
363
364
self . 0
364
365
. txd
365
366
. ptr
@@ -406,13 +407,13 @@ struct Inner<T: Instance, B> {
406
407
impl < T : Instance , B > Transfer < T , B > {
407
408
/// Blocks until the transfer is done and returns the buffer.
408
409
pub fn wait ( mut self ) -> ( B , Spis < T > ) {
410
+ compiler_fence ( Ordering :: SeqCst ) ;
409
411
let inner = self
410
412
. inner
411
413
. take ( )
412
414
. unwrap_or_else ( || unsafe { core:: hint:: unreachable_unchecked ( ) } ) ;
413
415
while !inner. spis . is_done ( ) { }
414
416
inner. spis . acquire ( ) ;
415
- compiler_fence ( Ordering :: Acquire ) ;
416
417
( inner. buffer , inner. spis )
417
418
}
418
419
@@ -430,9 +431,9 @@ impl<T: Instance, B> Transfer<T, B> {
430
431
impl < T : Instance , B > Drop for Transfer < T , B > {
431
432
fn drop ( & mut self ) {
432
433
if let Some ( inner) = self . inner . as_mut ( ) {
434
+ compiler_fence ( Ordering :: SeqCst ) ;
433
435
while !inner. spis . is_done ( ) { }
434
436
inner. spis . disable ( ) ;
435
- compiler_fence ( Ordering :: Acquire ) ;
436
437
}
437
438
}
438
439
}
@@ -450,13 +451,13 @@ struct InnerSplit<T: Instance, TxB, RxB> {
450
451
impl < T : Instance , TxB , RxB > TransferSplit < T , TxB , RxB > {
451
452
/// Blocks until the transfer is done and returns the buffer.
452
453
pub fn wait ( mut self ) -> ( TxB , RxB , Spis < T > ) {
454
+ compiler_fence ( Ordering :: SeqCst ) ;
453
455
let inner = self
454
456
. inner
455
457
. take ( )
456
458
. unwrap_or_else ( || unsafe { core:: hint:: unreachable_unchecked ( ) } ) ;
457
459
while !inner. spis . is_done ( ) { }
458
460
inner. spis . acquire ( ) ;
459
- compiler_fence ( Ordering :: Acquire ) ;
460
461
( inner. tx_buffer , inner. rx_buffer , inner. spis )
461
462
}
462
463
@@ -474,9 +475,9 @@ impl<T: Instance, TxB, RxB> TransferSplit<T, TxB, RxB> {
474
475
impl < T : Instance , TxB , RxB > Drop for TransferSplit < T , TxB , RxB > {
475
476
fn drop ( & mut self ) {
476
477
if let Some ( inner) = self . inner . as_mut ( ) {
478
+ compiler_fence ( Ordering :: SeqCst ) ;
477
479
while !inner. spis . is_done ( ) { }
478
480
inner. spis . disable ( ) ;
479
- compiler_fence ( Ordering :: Acquire ) ;
480
481
}
481
482
}
482
483
}
0 commit comments