Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReturnCodes to UART HIL, change abort policy #1049

Closed
wants to merge 3 commits into from
Closed

Conversation

ppannuto
Copy link
Member

Pull Request Overview

This updates the UART HIL to allow methods to fail. Previously, they would silently drop errors internally. The console should also bubble these errors back to userland correctly now. There are probably some more cases where underlying implementations can catch and report more errors, but this at least allows them to do that in the future.

This also updates abort_receive to no longer guarantee the return of partial buffers. As noted in #1045, partial buffers causes problems for virtualization, as one client's abort request requires all other clients to abort in order to recover the partial buffer. This changes our ABI semantics slightly. I do not believe anything is relying on this behavior currently, and I believe that not guaranteeing partial buffers on abort is generally a better long-term interface.

Testing Strategy

Hail + various other printing apps.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make formatall.

@ppannuto ppannuto added kernel P-Significant This is a substancial change that requires review from all core developers. labels Jun 29, 2018
Copy link
Contributor

@bradjc bradjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HIL doesn't seem to say anything about what abort_receive will actually guarantee or not, which I think is fine. I would be concerned if it did match the PR description, because I think being able to implement receive_automatic in software is much more important than being able to virtualize the UART bus.

if buffer.len() <= i {
break;
self.tx_buffer.take().map_or_else(
|| panic!("Console internal consistency error"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crash in a capsule seems bad.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.., but before this was an error that was silently dropped, now it's noted. There are 28 other panic's in capsules as well, most similar consistency issues. I think that the console capsule could be re-architected a bit to make this case impossible, but that's a different PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't adding return codes give it a way to not be silently dropped but without crashing the entire system?

/// No error occurred and the command completed successfully
CommandComplete,
}

pub trait UART {
/// Set the client for this UART peripheral. The client will be
/// called when events finish.
fn set_client(&self, client: &'static Client);
fn set_client(&self, client: &'static Client) -> ReturnCode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would setting a client not succeed?

bradjc
bradjc previously approved these changes Jun 29, 2018
@ppannuto ppannuto added the blocked Waiting on something, like a different PR or a dependency. label Jul 4, 2018
This implements RFC #1035 for the UART HIL. It splits the hardware-specific
initialization (power, clock assignment, pin assignment) from the uart-specific
configuration (baud rate, parity, stop bits, flow control), which is now
controlled by a new `configure` method for the UART HIL.
@ppannuto
Copy link
Member Author

ppannuto commented Jul 5, 2018

This has been rebased on top of #1073 as they conflicted.

This PR also needs to more deeply consider and enumerate the possible types of failures for transmit and receive before it is ready to merge.

Also corrects the console driver to propogate errors when they occur.
/// active receive may complete before this call occurs, in which case the
/// `receive_callback` will be called with `CommandComplete` and this method
/// will return `EALREADY`.
fn abort_receive(&self) -> ReturnCode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description doesn't seem to match this comment. This doesn't say whether data will be returned or not.

In either case, returning what has been received so far was the entire purpose of adding this function. Without it, there is no way to implement a UART receiver that can take in variable length messages without doing it byte-by-byte.

@phil-levis
Copy link
Contributor

I'll work on this PR over the weekend, to redesign the UART HIL. Let's get it over with.

Copy link
Contributor

@phil-levis-google phil-levis-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be subsumed by the UART rewrite, so should we cancel it?

@ppannuto
Copy link
Member Author

Agreed. I think the high-level changes should be preserved, but we can cross that bridge with the new UART HIL.

@ppannuto ppannuto closed this Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Waiting on something, like a different PR or a dependency. kernel P-Significant This is a substancial change that requires review from all core developers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants