Asahi Linux May Pursue Writing Apple Silicon GPU Driver In Rust
Prominent Asahi Linux contributor Asahi Lina expressed the possibility of writing their new kernel GPU driver for the Apple AGX within the Rust programming language.
Linux on the Apple M1/M2 is currently limited to LLVMpipe CPU-based graphics acceleration.
Asahi Lina explained today on the mailing list:
These GPUs run firmware and have fairly complex shared memory data structures that need to be managed by the host, so I've been leaning towards Rust for its safety, better metaprogramming, and general expressiveness. I have a prototype driver written in Python (running in userspace from a remote host, long story), and having a higher-level language has been very helpful in reverse engineering the GPU and prototyping different ideas for how the driver should work.
I realize it's the early days of Rust on Linux and this is an ambitious challenge, but I'm willing to learn and the driver will take some time to stabilize to the point of being upstreamable either way (in particular the UAPI), so writing it in Rust feels like less of a gamble at this point than it used to be, given that it sounds like Rust will be merged in the next few kernel cycles at the latest.
This would be the first kernel GPU driver written in the Rust programming language. Given the actual driver code hasn't been written yet for the Rust driver, it remains to be seen whether the entire driver would be implemented in Rust or just the portions interacting with the binary firmware.
More brainstorming around this Apple GPU Linux kernel driver potentially being written in the Rust programming language can be found via the rust-for-linux mailing list.
In case you missed my review earlier this week, check out my initial Apple M2 Linux benchmarks.