Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

bradjc
Copy link
Contributor

@bradjc bradjc commented Apr 8, 2021

Pull Request Overview

As part of #2462 this switches the analog comparator capsule to use a grant.

Testing Strategy

travis

TODO or Help Wanted

n/a

Documentation Updated

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

Formatting

  • Ran make prepush.

hudson-ayers
hudson-ayers previously approved these changes Apr 8, 2021
@bradjc
Copy link
Contributor Author

bradjc commented Apr 8, 2021

Good point. I think that is worth an extra check.

hudson-ayers
hudson-ayers previously approved these changes Apr 8, 2021
hudson-ayers
hudson-ayers previously approved these changes Apr 9, 2021
@phil-levis
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 10, 2021

Merge conflict.

alistair23
alistair23 previously approved these changes Apr 11, 2021
if match_or_empty_or_nonexistant {
self.current_process.set(appid);
} else {
return CommandReturn::failure(ErrorCode::NOMEM);
Copy link
Member

Choose a reason for hiding this comment

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

Intuitively I would've expected another ErrorCode, something like BUSY? NOMEM kind of fits here I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Historically that is the error that has been returned because there was no memory available to store the new process's request when grants were not being used.

Maybe we should use ErrorCode::RESERVE? I'm not that worried either way as I don't think userspace will actually use these and they should be virtualized anyway.

Copy link
Member

Choose a reason for hiding this comment

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

The explanation behind NOMEM makes sense, I'm happy to use that. I went through the other error codes and I agree, no other code seems to fit well.

I'll update #2518 for consistency's sake.

@lschuermann
Copy link
Member

lschuermann commented Apr 12, 2021

I've just run a minimal example of how this PR checks whether a nonvirtualized driver can be reserved by a process, compared to the implementation in #2518. This was only for curiosity's sake, and to see whether entering the Grant would have significant impact. These numbers are obtained on a rv32imc build with rustc 1.52.0-nightly (1705a7d64 2021-03-18) and this minimal example. I measured the system call end-to-end instruction count, that is # of instructions executed from the trap handler, until the mret returning to the process.

This is probably fine for non-virtualized drivers (given they aren't Tock's idiomatic way to write drivers). It does however seem to tell us that entering a Grant has a cost which one might want to look into optimizing, along with system call routing and switching to a process. Here is a more thorough investigation of the instructions spent on syscall routing.

lschuermann
lschuermann previously approved these changes Apr 14, 2021
@bradjc bradjc dismissed stale reviews from lschuermann, alistair23, and hudson-ayers via c353010 April 14, 2021 17:08
@bradjc bradjc force-pushed the grant-analog-comparator branch from 3d02227 to c353010 Compare April 14, 2021 17:08
@ppannuto
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 14, 2021

@bors bors bot merged commit 4a29f38 into master Apr 14, 2021
@bors bors bot deleted the grant-analog-comparator branch April 14, 2021 20:43
lschuermann added a commit to lschuermann/tock that referenced this pull request Apr 26, 2021
As part of tock#2462, this migrates the spi_peripheral
non-virtualized userspace driver to keep process state in a Grant
region. It adopts the mechanism to reserve a driver as introduced in
tock#2521.

Signed-off-by: Leon Schuermann <[email protected]>
lschuermann added a commit to lschuermann/tock that referenced this pull request Apr 26, 2021
As part of tock#2462, this migrates the sdcard non-virtualized
userspace driver to keep process state in a Grant region. It adopts
the mechanism to reserve a driver as introduced in tock#2521.

Signed-off-by: Leon Schuermann <[email protected]>
lschuermann added a commit to lschuermann/tock that referenced this pull request Apr 26, 2021
As part of tock#2462, this migrates the spi_controller
nonvirtualized userspace driver to keep process state in a Grant
region. It adopts the mechanism to reserve a driver as introduced in
tock#2521.

Signed-off-by: Leon Schuermann <[email protected]>
bors bot added a commit that referenced this pull request Apr 26, 2021
2559: capsules/spi_peripheral: migrate non-virtualized driver to Grants r=bradjc a=lschuermann

### Pull Request Overview

As part of #2462, this migrates the spi_peripheral non-virtualized userspace driver to keep process state in a Grant region. It adopts the mechanism to reserve a driver as introduced in #2521.

Signed-off-by: Leon Schuermann <[email protected]>

### Testing Strategy

This pull request was tested by compiling.


### TODO or Help Wanted

N/A


### Documentation Updated

- [x] ~Updated the relevant files in `/docs`,~ or no updates are required.

### Formatting

- [x] Ran `make prepush`.


2560: capsules/sdcard: migrate non-virtualized userspace driver to Grants r=bradjc a=lschuermann

### Pull Request Overview

As part of #2462, this migrates the sdcard non-virtualized userspace driver to keep process state in a Grant region. It adopts the mechanism to reserve a driver as introduced in #2521.

Signed-off-by: Leon Schuermann <[email protected]>

### Testing Strategy

This pull request was tested by compiling.

### TODO or Help Wanted

N/A

### Documentation Updated

- [x] ~Updated the relevant files in `/docs`,~ or no updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Leon Schuermann <[email protected]>
bors bot added a commit that referenced this pull request Apr 26, 2021
2547: capsules/i2c_master_slave_driver: use grant, enforce single process r=bradjc a=hudson-ayers

### Pull Request Overview

This pull request enforces that only a single process may (implicitly) reserve the nonvirtualized userspace driver. Also, the driver now store callbacks and appslices in grant regions.

This is one of the remaining capsules blocking #2462 .

One observation: repeatedly handling the possibility of a grant entrance (within a single function) failing is a pain. But I do not think it is possible for a grant entrance to fail after the first entrance -- the grant is already allocated at that point, and the process is present. So I omitted the error handling in `command()` after the first grant entrance.


### Testing Strategy

This pull request was tested by compiling.


### TODO or Help Wanted

N/A

### Documentation Updated

- [x] No updates are required.

### Formatting

- [x] Ran `make prepush`.


2558: capsules/spi_controller: migrate non-virtualized driver to Grants r=bradjc a=lschuermann

### Pull Request Overview

As part of #2462, this migrates the spi_controller nonvirtualized userspace driver to keep process state in a Grant region. It adopts the mechanism to reserve a driver as introduced in #2521.

Signed-off-by: Leon Schuermann <[email protected]>

### Testing Strategy

This pull request was tested by compiling.


### TODO or Help Wanted

N/A


### Documentation Updated

- [x] ~Updated the relevant files in `/docs`, or~ no updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Hudson Ayers <[email protected]>
Co-authored-by: Leon Schuermann <[email protected]>
bors bot added a commit that referenced this pull request May 5, 2021
2572: capsules/l3gd20: migrating non-virtualized driver to Grants r=hudson-ayers a=phil-levis

### Pull Request Overview

As part of #2462, this migrates the l3gd20 nonvirtualized userspace driver to keep process state in a Grant region. It adopts the mechanism to reserve a driver as introduced in #2521.

### Testing Strategy

This pull request was tested by compiling.


### TODO or Help Wanted

N/A


### Documentation Updated

- [x] Updated the relevant files in `/docs`, or no updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Philip Levis <[email protected]>
bors bot added a commit that referenced this pull request May 6, 2021
2575: capsules/ltc294x-grant: migrating non-virtualized driver to Grants  r=hudson-ayers a=phil-levis

### Pull Request Overview

As part of #2462, this migrates the ltc294x nonvirtualized userspace driver to keep process state in a Grant region. It adopts the mechanism to reserve a driver as introduced in #2521.

### Testing Strategy

This pull request was tested by compiling.


### TODO or Help Wanted

N/A


### Documentation Updated

- [x] Updated the relevant files in `/docs`, or no updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Philip Levis <[email protected]>
bors bot added a commit that referenced this pull request May 6, 2021
2574: capsules/lsm303agr: migrating non-virtualized driver to Grants r=hudson-ayers a=phil-levis

### Pull Request Overview

As part of #2462, this migrates the lsm303agr nonvirtualized userspace driver to keep process state in a Grant region. It adopts the mechanism to reserve a driver as introduced in #2521.

### Testing Strategy

This pull request was tested by compiling.


### TODO or Help Wanted

N/A

### Documentation Updated

- [x] Updated the relevant files in `/docs`, or no updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Philip Levis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants