Asahi Linux May Pursue Writing Apple Silicon GPU Driver In Rust

Written by Michael Larabel in Apple on 11 August 2022 at 01:55 PM EDT. 87 Comments
APPLE
When it comes to the Apple M1 and M2 support on Linux, one of the biggest obstacles to suitable daily use for end-users is the current lack of GPU acceleration. Reverse engineering has been happening for the Apple Silicon graphics processor, early experiments being carried out under macOS and Asahi's m1n1 environment, and the next step will be to start writing a Direct Rendering Manager (DRM) kernel driver. To some surprise, the feasibility of writing this DRM kernel GPU driver in the Rust programming language is being explored.

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.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week