Originally posted by marios
View Post
Announcement
Collapse
No announcement yet.
Asahi Linux May Pursue Writing Apple Silicon GPU Driver In Rust
Collapse
X
-
-
Originally posted by kpedersen View Post
Hah, Indeed. At this point, the Rust code will likely all be in an unsafe{} block anyway and twiddling raw bytes like drivers typically do will pretty much resemble C, so hopefully won't be hard to clean up into a proper implementation language.
Python -> Rust -> C. This is why we typically avoid web developers writing kernel modules. It has to keep getting rewritten from whatever popular prototyping language they chose.
- Likes 17
Comment
-
Originally posted by kpedersen View Post
Hah, Indeed. At this point, the Rust code will likely all be in an unsafe{} block anyway and twiddling raw bytes like drivers typically do will pretty much resemble C, so hopefully won't be hard to clean up into a proper implementation language.
See: the rust for linux project, RedoxOS, hubris, or any library written for rust support on an embedded platform like AVR, STM32, etc.
There are a few wrappers written using unsafe{} to handle the important bits (in this case calling C functions, living in the patches rust-for-linux is trying to get merged) so that the drivers themselves can be 100% safe rust. The rust driver needs to talk to the GPU? great, it can call the wrapper for PCIe access and thus use the underlying kernel PCIe infrastructure like any other driver written in C.
Originally posted by kpedersen View PostPython -> Rust -> C. This is why we typically avoid web developers writing kernel modules. It has to keep getting rewritten from whatever popular prototyping language they chose.
- Likes 19
Comment
-
Originally posted by mdedetrich View Posta modern day GPU driver requires a huge amount of concurrent/multithreaded data structures/logic where Rust excels and this is not code that will be in an unsafe block.
Originally posted by Developer12 View PostThe rust driver needs to talk to the GPU? great, it can call the wrapper for PCIe access and thus use the underlying kernel PCIe infrastructure like any other driver written in C..
But again, lets wait and see. Success or failure will be fairly obvious as to the answer and whatever happens the developer does sound capable.Last edited by kpedersen; 11 August 2022, 07:27 PM.
- Likes 2
Comment
-
Originally posted by kpedersen View PostAnd you don't think that will undermine Rusts safety accessing the C infrastructure directly like that? Just gonna be a bunch of binding layers gluing the unsafe API.
Because the Rust APIs provided by those bindings encode the invariants¹ required to safely call the C functions and syscalls directly in the signatures and are enforced by the compiler. That’s the same idea of hiding the unsafety behind safe abstractions in Rust-For-Linux bindings and in any embedded Rust project.
¹stuff like “the returned pointer is valid no longer than any of the input pointers A or B live”, “this pointer cannot be mutated in another thread”, “to call this function on this object you must be holding a valid guard obtained first by that call”, “this needs to be freed using that function”, “this function cannot be called twice on the same object”, “this has to contain valid unicode characters”, etc.
- Likes 16
Comment
-
Originally posted by Developer12 View Post
The investigation already happened. An apple M1 openGL driver already exists in python. The answer is basically zero, not that it even matters because asahi didn't use anything from powervr either way.
Comment
-
I started out in Slackware. Still use it. But I understand that in a production environment it is not the best of choices. So having a kernel with rust compiled into it is whizbang. But rolling back or upgrading the kernel entails make config.. then compiling and subsequent testing. To make sure all of the module options were properly configured into the kernel. For child programmers who have nothing more to do with their lives. That is fine. But if this is for real work purposes. With real users. You are in for some serious debugging, module configuration, compiling the kernel and testing. Then there are the reports you need to file explaining what the problem was and how you fixed it. Without admitting to the fact that you broke it in the first place.
Then it dawns on you maybe this was not such a great idea afterall.
it takes some real coding experts In kernel building to get this right. But you can not tell a kid that.
Comment
Comment