mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
have the core spinor routines automatically retry on failure
normally we never see these failures, but, as we are seeing flash wear-out on the CI machine the writes can take long enough that we get some concurrent requests. As a work-around, just automatically retry a few times before throwing the error back to the caller.
This commit is contained in:
parent
d63c452fb6
commit
0c7c90fb78
1 changed files with 38 additions and 22 deletions
|
|
@ -174,17 +174,25 @@ impl Spinor {
|
|||
// acquire a write lock on the unit
|
||||
#[cfg(not(test))]
|
||||
{
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::AcquireExclusive.to_usize().unwrap(),
|
||||
self.token[0] as usize,
|
||||
self.token[1] as usize,
|
||||
self.token[2] as usize,
|
||||
self.token[3] as usize,
|
||||
)
|
||||
).expect("couldn't send AcquireExclusive message to Spinor hardware!");
|
||||
if let xous::Result::Scalar1(result) = response {
|
||||
if result == 0 {
|
||||
return Err(SpinorError::BusyTryAgain)
|
||||
const RETRY_LIMIT: usize = 5;
|
||||
for i in 0..RETRY_LIMIT {
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::AcquireExclusive.to_usize().unwrap(),
|
||||
self.token[0] as usize,
|
||||
self.token[1] as usize,
|
||||
self.token[2] as usize,
|
||||
self.token[3] as usize,
|
||||
)
|
||||
).expect("couldn't send AcquireExclusive message to Spinor hardware!");
|
||||
if let xous::Result::Scalar1(result) = response {
|
||||
if result == 0 {
|
||||
if i == RETRY_LIMIT - 1 {
|
||||
return Err(SpinorError::BusyTryAgain)
|
||||
}
|
||||
xous::yield_slice();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -235,17 +243,25 @@ impl Spinor {
|
|||
// acquire a write lock on the unit
|
||||
#[cfg(not(test))]
|
||||
{
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::AcquireExclusive.to_usize().unwrap(),
|
||||
self.token[0] as usize,
|
||||
self.token[1] as usize,
|
||||
self.token[2] as usize,
|
||||
self.token[3] as usize,
|
||||
)
|
||||
).expect("couldn't send AcquireExclusive message to Spinor hardware!");
|
||||
if let xous::Result::Scalar1(result) = response {
|
||||
if result == 0 {
|
||||
return Err(SpinorError::BusyTryAgain)
|
||||
const RETRY_LIMIT: usize = 5;
|
||||
for i in 0..RETRY_LIMIT {
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::AcquireExclusive.to_usize().unwrap(),
|
||||
self.token[0] as usize,
|
||||
self.token[1] as usize,
|
||||
self.token[2] as usize,
|
||||
self.token[3] as usize,
|
||||
)
|
||||
).expect("couldn't send AcquireExclusive message to Spinor hardware!");
|
||||
if let xous::Result::Scalar1(result) = response {
|
||||
if result == 0 {
|
||||
if i == RETRY_LIMIT - 1 {
|
||||
return Err(SpinorError::BusyTryAgain)
|
||||
}
|
||||
xous::yield_slice();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue