Implement "Bound" device context
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest9 patches 17 repliesIn review
- v19 patches 0 repliesSuperseded
Changes in v2 from the cover letter
- add a safety requirement for impl_device_context_deref! (thanks to Benno for working this out)
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | rust: device: implement impl_device_context_deref!rust/ rust/ rust/ | +50 | 2 replies | |
| 2/9 | rust: device: implement impl_device_context_into_aref!rust/ rust/ rust/ | +24 | 1 reply | |
| 3/9 | rust: device: implement device context for Devicerust/ | +9 | 2 replies | |
| 4/9 | rust: platform: preserve device context in AsRefrust/ | +3 | 1 reply | |
| 5/9 | rust: pci: preserve device context in AsRefrust/ | +5 | 1 reply | |
| 6/9 | rust: device: implement Bound device contextrust/ | +15 | 7 replies | |
| 7/9 | rust: pci: move iomap_region() to impl Device<Bound>rust/ | +2 | 2 replies | |
| 8/9 | rust: devres: require a bound devicerust/ | +7 | 0 replies | |
| 9/9 | rust: dma: require a bound devicerust/ | +7 | 0 replies |
Reviews trailers per patch
7 of 9 patches have a Reviewed-by or Acked-by.
| Patch | Christian Schrefl | Benno Lossin |
|---|---|---|
| 1/9 | R-b | |
| 2/9 | R-b | |
| 3/9 | R-b | |
| 4/9 | R-b | |
| 5/9 | R-b | |
| 6/9 | R-b | |
| 7/9 | R-b | |
| 8/9 | ||
| 9/9 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/9] Implement "Bound" device context
Currently, we do not ensure that APIs that require a bound device instance can only be called with a bound device.
Examples of such APIs are Devres, dma::CoherentAllocation and pci::Device::iomap_region().
This patch series introduces the "Bound" device context such that we can ensure to only ever pass a bound device to APIs that require this precondition.
In order to get there, we need some prerequisites:
(1) Implement macros to consistently derive Deref implementations for the different device contexts. For instance, Device<Core> can be dereferenced to Device<Bound>, since all device references we get from "core" bus callbacks are guaranteed to be from a bound device. Device<Bound> can always be dereferenced to Device (i.e. Device<Normal>), since the "Normal" device context has no specific requirements.
(2) Implement device context support for the generic Device type. Some APIs such as Devres and dma::CoherentAllocation work with generic devices.
(3) Preserve device context generics in bus specific device' AsRef implementation, such that we can derive the device context when converting from a bus specific device reference to a generic device reference.
With this, Devres::new(), for instance, can take a &Device<Bound> argument and hence ensure that it can't be called with a Device reference that is not guaranteed to be bound to a driver.
A branch containing the patches can be found in [1].
[1] https://web.git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=rust/device-bound
Changes in v2:
- add a safety requirement for impl_device_context_deref! (thanks to Benno for working this out)
Danilo Krummrich (9):
rust: device: implement impl_device_context_deref!
rust: device: implement impl_device_context_into_aref!
rust: device: implement device context for Device
rust: platform: preserve device context in AsRef
rust: pci: preserve device context in AsRef
rust: device: implement Bound device context
rust: pci: move iomap_region() to impl Device<Bound>
rust: devres: require a bound device
rust: dma: require a bound device
rust/kernel/device.rs | 90 ++++++++++++++++++++++++++++++++++++++++- rust/kernel/devres.rs | 17 ++++---- rust/kernel/dma.rs | 14 +++---- rust/kernel/pci.rs | 33 +++++---------- rust/kernel/platform.rs | 32 ++++----------- 5 files changed, 121 insertions(+), 65 deletions(-)
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
Signature · 1 line
2.49.0