-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1887: sched: Add a watchdog r=bradjc a=alistair23 ### Pull Request Overview As part of #1882 we started talking about safe waits (#1552). I have a PR with some initial safe wait support (#1886) in that we can be interrupted while looping on a hardware condition. The idea here is that while entering low power mode we can skip the infinite loop if we get an interrupt. #1886 doesn't address a large number of loops in the driver capsules as they don't have access to `Chip` so it's more difficult to wait on interrupts. The harder part is what to do when a wait "fails". What happens when returning to full power fails to occur in a specific time, what happens when a bus fails to respond in a reasonable amount of time? How do we gracefully handle this and continue running in some capacity. This PR starts to implement a watchdog functionality. This is not instead of a safe wait (in lots of cases a safe wait would be more graceful) but is generally to help avoid infinite loops and help debugging. It is also something that has come up to help make Tock more reliable. It is up to `Chips` and boards to handle the watchdog interrupt and decided how to act. Currently we tickle the watch dog when iterating on each process and at the start of each kernel loop. ### Testing Strategy None ### TODO or Help Wanted Feedback ### Documentation Updated - [X] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [X] Ran `make format`. - [X] Fixed errors surfaced by `make clippy`. Co-authored-by: Alistair Francis <alistair.francis@wdc.com> Co-authored-by: Brad Campbell <bradjc5@gmail.com>
- Loading branch information
Showing
15 changed files
with
98 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! Interface for configuring a watchdog | ||
|
||
/// A trait for implementing a watchdog in the kernel. | ||
/// This trait is called from the `kernel_loop()` code to setup | ||
/// and maintain the watchdog timer. | ||
/// It is up to the specific `Chip` how it will handle watchdog interrupts. | ||
pub trait WatchDog { | ||
/// This function must enable the watchdog timer and configure it to | ||
/// trigger regulary. The period of the timer is left to the implementation | ||
/// to decide. The implementation must ensure that it doesn't trigger too | ||
/// early (when we haven't hung for example) or too late as to not catch | ||
/// faults. | ||
/// After calling this function the watchdog must be running. | ||
fn setup(&self) {} | ||
|
||
/// This function must tickle the watchdog to reset the timer. | ||
/// If the watchdog was previously suspended then this should also | ||
/// resume the timer. | ||
fn tickle(&self) {} | ||
|
||
/// Suspends the watchdog timer. After calling this the timer should not | ||
/// fire until after `tickle()` has been called. This function is called | ||
/// before sleeping. | ||
fn suspend(&self) {} | ||
|
||
/// Resumes the watchdog timer. After calling this the timer should be | ||
/// running again. This is called after returning from sleep, after | ||
/// `suspend()` was called. | ||
fn resume(&self) { | ||
self.tickle(); | ||
} | ||
} | ||
|
||
/// Implement default WatchDog trait for unit. | ||
impl WatchDog for () {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters