rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Short Circuit simplest Rust driver that touches real hardware?
@ 2021-04-26 19:47 Sven Van Asbroeck
  2021-04-26 20:22 ` Miguel Ojeda
  2021-04-26 20:58 ` Geert Stappers
  0 siblings, 2 replies; 6+ messages in thread
From: Sven Van Asbroeck @ 2021-04-26 19:47 UTC (permalink / raw)
  To: rust-for-linux

(Is this the correct forum for this discussion? Should it go on
Rust-for-Linux's GitHub instead?)

Senior Linux people have expressed interest in seeing a Rust driver
that touches actual hardware. Nvme has been suggested as an excellent
candidate. But, that's going to be quite complex, and possibly a long
way off still.

Is there merit in "short circuiting" a Rust driver that touches actual
hardware? I.e. only do the minimum that's reasonably required, to
drive a trivial piece of hardware.

Suggestion:
1. implement `platform_device` in Rust, just enough to be `probe()`d
by the kernel, and receive a live `struct device *` - we should wrap
this pointer in a suitable Rust abstraction of course.
2. implement the simplest `IoMemBlock` in Rust. Since we have a live
`struct device *`, the `IoMemBlock` constructor can simply call
`devm_platform_get_and_ioremap_resource(our struct device *)` in C,
which will automatically use the right method to retrieve the `void
__iomem *`: devicetree, platform data, etc, we don't have to care.
3. use the `IoMemBlock` above to implement a trivial iomem-only driver
as a module. A few possible candidates:
* h/w random number generator in Raspberry Pi Zero: `brcm,bcm2835-rng`
* SoC thermal sensor in Raspberry Pi Zero: `brcm,bcm2835-thermal`
4. we don't have `hwrng` or `thermal_hwmon` devices in Rust yet, but
we could perhaps expose this as a `misc_device`, which is something we
already have. A single temp or randnum readout might do the trick.

The Raspberry Pi Zero can be purchased for $10. There is [QEMU
support](https://qemu.readthedocs.io/en/latest/system/arm/raspi.html)
for the peripherals above.

Feedback and ideas welcome !

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-27  8:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 19:47 [RFC] Short Circuit simplest Rust driver that touches real hardware? Sven Van Asbroeck
2021-04-26 20:22 ` Miguel Ojeda
2021-04-26 20:58 ` Geert Stappers
2021-04-26 21:11   ` Sven Van Asbroeck
2021-04-27  8:17     ` Geert Stappers
2021-04-27  6:49   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).