rust: drm: Introduce the Tyr driver for Arm Mali GPUs
Subsystems (5)
Daniel Almeida
maintainerPATCH v3 1/1 rust: drm: Introduce the Tyr driver for Arm Mali GPUs
Add a Rust driver for ARM Mali CSF-based GPUs. It is a port of Panthor and therefore exposes Panthor's uAPI and name to userspace, and the product of a joint effort between Collabora, Arm and Google engineers.
The aim is to incrementally develop Tyr with the abstractions that are currently available until it is consider to be in parity with Panthor feature-wise.
The development of Tyr itself started in January, after a few failed attempts of converting Panthor piecewise through a mix of Rust and C code. There is a downstream branch that's much further ahead in terms of capabilities than this initial patch.
The downstream code is capable of booting the MCU, doing sync VM_BINDS through the work-in-progress GPUVM abstraction and also doing (trivial) submits through Asahi's drm_scheduler and dma_fence abstractions. So basically, most of what one would expect a modern GPU driver to do, except for power management and some other very important adjacent pieces. It is not at the point where submits can correctly deal with dependencies, or at the point where it can rotate access to the GPU hardware fairly through a software scheduler, but that is simply a matter of writing more code.
This first patch, however, only implements a subset of the current features available downstream, as the rest is not implementable without pulling in even more abstractions. In particular, a lot of things depend on properly mapping memory on a given VA range, which itself depends on the GPUVM abstraction that is currently work-in-progress. For this reason, we still cannot boot the MCU and thus, cannot do much for the moment.
This constitutes a change in the overall strategy that we have been using to develop Tyr so far. By submitting small parts of the driver upstream iteratively, we aim to:
a) evolve together with Nova and rvkms, hopefully reducing regressions due to upstream changes (that may break us because we were not there, in the first place)
b) prove any work-in-progress abstractions by having them run on a real driver and hardware and,
c) provide a reason to work on and review said abstractions by providing a user, which would be tyr itself.
Despite its limited feature-set, we offer IGT tests. It is only tested on the rk3588, so any other SoC is probably not going to work at all for now.
The skeleton is basically taken from Nova and also rust_platform_driver.rs.
Lastly, the name "Tyr" is inspired by Norse mythology, reflecting ARM's tradition of naming their GPUs after Nordic mythological figures and places.
---
The development of Tyr itself started in January, after a few failed attempts of converting Panthor piecewise through a mix of Rust and C code. We have a branch (tyr-next [0]) downstream that's much further ahead than this submission.
Briefly speaking, our downstream code is capable of booting the MCU, doing sync VM_BINDS through the work-in-progress GPUVM abstraction I've been submitting to the list - and also of doing (trivial) submits through Lina's drm_scheduler and dma_fence abstractions. So basically, most of what we expect a modern GPU driver to do, except for power management and some other very important adjacent pieces.
We are not at the point where submits can correctly deal with dependencies, or at the point where we can rotate access to the GPU hardware fairly through our own software scheduler, but that is simply a matter of writing more code. Unfortunately, other things have taken precedence lately.
At the current pace, I am fairly certain that we can achieve a working driver downstream in a couple of months, for a given definition of "working". In any case, reconciling this with upstream has been somewhat challenging recently, so this patch constitutes a change in the overall strategy that we have been using to develop Tyr so far.
By submitting small parts of the driver upstream iteratively, we aim to:
a) evolve together with Nova and rvkms, hopefully reducing regressions due to upstream changes (that may break us because we were not there, in the first place)
b) prove any work-in-progress abstractions by having them run on a real driver and hardware and,
c) provide a reason to work on and review said abstractions by providing a user, which would be tyr itself.
Unfortunately, without GPUVM support, there is not much that we can do on this first patch. This is because the firmware expect things to be mapped at precise VA ranges, so we simply cannot get it to boot with the current upstream code. This will be achieved by a subsequent patch.
This functionality can be attested by running our IGT suite at [1]. Again, note that the tests are meant for the downstream version of the driver, so anything other than the "query" tests will fail here.
As the abstractions above are in-flight, I provide a branch where they have been collected into [2]. Anyone is encouraged to test this if they feel like it, but be aware that it was only tested on the rk3588.
Lastly, I'd like to mention that this driver is a joint initiative between Collabora, Arm and Google. Everyone that has directly touched the source code so far has been acknowledged as an author through their respective co-developed-by tag. In particular, Alice Ryhl has been steadily helping out with all the necessary abstractions for a long time now, apart from the code that she has directly contributed to the driver itself.
I'd also like to give a special thanks to my colleague Boris Brezillon - who has been steering me through this new territory, and without whom this project would not have been possible at all.
[0]: https://gitlab.freedesktop.org/panfrost/linux/-/tree/tyr-next?ref_type=heads
[1]: https://gitlab.freedesktop.org/dwlsalmeida/igt-gpu-tools/-/tree/panthor?ref_type=heads
[2]: https://gitlab.freedesktop.org/panfrost/linux/-/tree/tyr?ref_type=heads
---
Changes in v3:
- Rebased on rust-drm
- Changed MAINTAINERS to add Alice as a co-maintainer
- Changed T: to point to the rust-drm tree
- Polished the commit message
- Removed the register code for AS registers and Doorbells (not used at
the moment, and will be eventually replaced with Nova's register!())
- Changed the DRM driver description to say "Arm Mali Tyr DRM driver"
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Added the "rust: drm:" prefix
- Rebased on top of drm-misc-next (6.17-rc1)
- Got rid of a lot of prerequisite-patch-ids, as most of them were merged
- Removed references to io_poll_timeout() in favor of fsleep(), as this will probably take a while to land
- Reword the commit log and the cover letter to remove stale sections
Thanks, Danilo {
- Added safety comments for Send and Sync in TyrData
- Added a TODO explaining how the above is merely temporary
- Switched from pr_err to dev_err
- Did not switch to dev_dbg!() because that does not work in Rust atm.
- Switched to Devres::access()/iomap_sized()/read/write
- Added a TODO in regs.rs to switch to the register!() macro when that's available
}
Thanks, Miguel {
- Switched to #[expect(dead_code)] where applicable
- Left a note in regs.rs saying why the above is not applicable there
- Fixed spelling (also thanks, Maira)
- Improved the safety comment for the "AsBytes" for GpuInfo: it is the same as the uAPI type (i.e.: both in fields and in the layout) and it is safe to implement AsBytes/FromBytes for all uAPI types.
- Changed the "author" key to "authors". Kept the "the Tyr authors" nomenclature.
- Added a missing space in uapi_helper.h
}
Thanks, Maira {
- Used the proper constant for the soft-reset command (Steven Price also mentioned this)
- Used OptionalClk instead of Clk as applicable (as per the DT)
- Fixed a typo
}
Thanks, Steven {
- Switched from _INT_ to _IRQ_ in regs.rs to match the arch names
- Changed the description to include the name "Tyr"
- Changed the major/minor to be the same ones as Panthor
- Fixed the layout of GpuInfo, which was indeed all over the place (major bug, thanks for finding this out)
- Added a TODO for GpuInfo::texture_features[1..3]
- Constrained AsRegister to 16 address spaces
- Rearranged the order of the code in regs.rs to have semantically similar items closer to each other
}
- Link to v1: https://lore.kernel.org/r/[email protected]
--- MAINTAINERS | 13 +++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/tyr/Kconfig | 17 ++++ drivers/gpu/drm/tyr/Makefile | 3 + drivers/gpu/drm/tyr/driver.rs | 205 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/tyr/file.rs | 57 +++++++++++ drivers/gpu/drm/tyr/gem.rs | 18 ++++ drivers/gpu/drm/tyr/gpu.rs | 219 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/tyr/regs.rs | 108 +++++++++++++++++++++ drivers/gpu/drm/tyr/tyr.rs | 22 +++++ rust/uapi/uapi_helper.h | 1 + 12 files changed, 666 insertions(+)
MAINTAINERS +13 -0
@@ -2086,6 +2086,19 @@ F: Documentation/devicetree/bindings/gpu/arm,mali-valhall-csf.yaml F: drivers/gpu/drm/panthor/ F: include/uapi/drm/panthor_drm.h +ARM MALI TYR DRM DRIVER +M: Daniel Almeida <[email protected]> +M: Alice Ryhl <[email protected]> +L: [email protected] +S: Supported +W: https://rust-for-linux.com/tyr-gpu-driver +W https://drm.pages.freedesktop.org/maintainer-tools/drm-rust.html +B: https://gitlab.freedesktop.org/panfrost/linux/-/issues +T: git https://gitlab.freedesktop.org/drm/rust/kernel.git +F: Documentation/devicetree/bindings/gpu/arm,mali-valhall-csf.yaml +F: drivers/gpu/drm/tyr/ +F: include/uapi/drm/panthor_drm.h + ARM MALI-DP DRM DRIVER M: Liviu Dudau <[email protected]> S: Supported
drivers/gpu/drm/Kconfig +2 -0
@@ -396,6 +396,8 @@ source "drivers/gpu/drm/sprd/Kconfig" source "drivers/gpu/drm/imagination/Kconfig" +source "drivers/gpu/drm/tyr/Kconfig" + config DRM_HYPERV tristate "DRM Support for Hyper-V synthetic video device" depends on DRM && PCI && HYPERV
drivers/gpu/drm/Makefile +1 -0
@@ -220,6 +220,7 @@ obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/ obj-$(CONFIG_DRM_LIMA) += lima/ obj-$(CONFIG_DRM_PANFROST) += panfrost/ obj-$(CONFIG_DRM_PANTHOR) += panthor/ +obj-$(CONFIG_DRM_TYR) += tyr/ obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/ obj-$(CONFIG_DRM_MCDE) += mcde/ obj-$(CONFIG_DRM_TIDSS) += tidss/
drivers/gpu/drm/tyr/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 or MIT + +config DRM_TYR + tristate "Tyr (Rust DRM support for ARM Mali CSF-based GPUs)" + depends on DRM=y + depends on RUST + depends on ARM || ARM64 || COMPILE_TEST + depends on !GENERIC_ATOMIC64 # for IOMMU_IO_PGTABLE_LPAE + help + Rust DRM driver for ARM Mali CSF-based GPUs. + + This driver is for Mali (or Immortalis) Valhall Gxxx GPUs. + + Note that the Mali-G68 and Mali-G78, while Valhall architecture, will + be supported with the panfrost driver as they are not CSF GPUs. + + if M is selected, the module will be called tyr.
drivers/gpu/drm/tyr/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 or MIT + +obj-$(CONFIG_DRM_TYR) += tyr.o
drivers/gpu/drm/tyr/driver.rs new file +205 -0
205 lines not on this page · raw message
drivers/gpu/drm/tyr/file.rs new file +57 -0
57 lines not on this page · raw message
drivers/gpu/drm/tyr/gem.rs new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0 or MIT + +use crate ::driver::TyrDevice ; +use crate ::driver::TyrDriver ; +use kernel::drm::gem; +use kernel::prelude::*; + +/// GEM Object inner driver data +#[pin_data] +pub (crate )struct TyrObject {} + +impl gem::DriverObject for TyrObject { +type Driver =TyrDriver ; + +fn new (_dev: &TyrDevice , _size:usize ) ->impl PinInit <Self ,Error > { +try_pin_init! (TyrObject {}) + } +}
drivers/gpu/drm/tyr/gpu.rs new file +219 -0
219 lines not on this page · raw message
drivers/gpu/drm/tyr/regs.rs new file +108 -0
108 lines not on this page · raw message
drivers/gpu/drm/tyr/tyr.rs new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 or MIT + +//! Arm Mali Tyr DRM driver. +//! +//! The name "Tyr" is inspired by Norse mythology, reflecting Arm's tradition of +//! naming their GPUs after Nordic mythological figures and places. + +use crate ::driver::TyrDriver ; + +mod driver; +mod file; +mod gem; +mod gpu; +mod regs; + +kernel::module_platform_driver! { +type :TyrDriver , + name:"tyr" , + authors: ["The Tyr driver authors" ], + description:"Arm Mali Tyr DRM driver" , + license:"Dual MIT/GPL" , +}
rust/uapi/uapi_helper.h +1 -0
@@ -9,6 +9,7 @@#include <uapi/asm-generic/ioctl.h> #include <uapi/drm/drm.h> #include <uapi/drm/nova_drm.h> +#include <uapi/drm/panthor_drm.h> #include <uapi/linux/mdio.h> #include <uapi/linux/mii.h> #include <uapi/linux/ethtool.h>
---
base-commit: d4dc08c530cbf71fb1c7cddb9d1e7e36bd62e22f
change-id: 20250627-tyr-683ec49113ba
Best regards,
Signature · 1 line
Daniel Almeida <[email protected]>
Danilo Krummrich
maintainerQuoted 6 lines · Daniel Almeida
drivers/gpu/drm/tyr/Kconfig new file +0
-0
drivers/gpu/drm/tyr/Kconfig line 8
Quoted 8 lines
drivers/gpu/drm/tyr/Kconfig new file +8
-0@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 or MIT + +config DRM_TYR + tristate "Tyr (Rust DRM support for ARM Mali CSF-based GPUs)" + depends on DRM=y + depends on RUST + depends on ARM || ARM64 || COMPILE_TEST + depends on !GENERIC_ATOMIC64 # for IOMMU_IO_PGTABLE_LPAE
For the Nova drivers I did add
default n
as long as the driver is work in progress.
drivers/gpu/drm/tyr/Kconfig line 17
Quoted 9 lines
drivers/gpu/drm/tyr/Kconfig new file +9
-0+ help + Rust DRM driver for ARM Mali CSF-based GPUs. + + This driver is for Mali (or Immortalis) Valhall Gxxx GPUs. + + Note that the Mali-G68 and Mali-G78, while Valhall architecture, will + be supported with the panfrost driver as they are not CSF GPUs. + + if M is selected, the module will be called tyr.
I also did add
This driver is work in progress and may not be functional.
to make it clear what people will get.
Daniel Almeida
maintainerQuoted 38 lines · Danilo Krummrich
Quoted 6 lines · Daniel Almeida
drivers/gpu/drm/tyr/Kconfig new file +0
-0drivers/gpu/drm/tyr/Kconfig line 8
Quoted 8 lines
drivers/gpu/drm/tyr/Kconfig new file +8
-0@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 or MIT + +config DRM_TYR + tristate "Tyr (Rust DRM support for ARM Mali CSF-based GPUs)" + depends on DRM=y + depends on RUST + depends on ARM || ARM64 || COMPILE_TEST + depends on !GENERIC_ATOMIC64 # for IOMMU_IO_PGTABLE_LPAEFor the Nova drivers I did add
default n
as long as the driver is work in progress.
drivers/gpu/drm/tyr/Kconfig line 17
Quoted 9 lines
drivers/gpu/drm/tyr/Kconfig new file +9
-0+ help + Rust DRM driver for ARM Mali CSF-based GPUs. + + This driver is for Mali (or Immortalis) Valhall Gxxx GPUs. + + Note that the Mali-G68 and Mali-G78, while Valhall architecture, will + be supported with the panfrost driver as they are not CSF GPUs. + + if M is selected, the module will be called tyr.I also did add
Quoted 3 lines
This driver is work in progress and may not be functional.
to make it clear what people will get.
Fair enough, perhaps a quick v4 then?
— Daniel
Danilo Krummrich
maintainerQuoted 1 line · Daniel Almeida
Fair enough, perhaps a quick v4 then?
In case this remains to be the only change you could also fix it up on apply.
Quoted 65 lines · On Wed, 10 Sep 2025 10:51:18 -0300 Daniel Almeida…
Add a Rust driver for ARM Mali CSF-based GPUs. It is a port of Panthor and therefore exposes Panthor's uAPI and name to userspace, and the product of a joint effort between Collabora, Arm and Google engineers.
The aim is to incrementally develop Tyr with the abstractions that are currently available until it is consider to be in parity with Panthor feature-wise.
The development of Tyr itself started in January, after a few failed attempts of converting Panthor piecewise through a mix of Rust and C code. There is a downstream branch that's much further ahead in terms of capabilities than this initial patch.
The downstream code is capable of booting the MCU, doing sync
VM_BINDSthrough the work-in-progress GPUVM abstraction and also doing (trivial) submits through Asahi'sdrm_scheduleranddma_fenceabstractions. So basically, most of what one would expect a modern GPU driver to do, except for power management and some other very important adjacent pieces. It is not at the point where submits can correctly deal with dependencies, or at the point where it can rotate access to the GPU hardware fairly through a software scheduler, but that is simply a matter of writing more code.This first patch, however, only implements a subset of the current features available downstream, as the rest is not implementable without pulling in even more abstractions. In particular, a lot of things depend on properly mapping memory on a given VA range, which itself depends on the GPUVM abstraction that is currently work-in-progress. For this reason, we still cannot boot the MCU and thus, cannot do much for the moment.
This constitutes a change in the overall strategy that we have been using to develop Tyr so far. By submitting small parts of the driver upstream iteratively, we aim to:
a) evolve together with Nova and rvkms, hopefully reducing regressions due to upstream changes (that may break us because we were not there, in the first place)
b) prove any work-in-progress abstractions by having them run on a real driver and hardware and,
c) provide a reason to work on and review said abstractions by providing a user, which would be tyr itself.
Despite its limited feature-set, we offer IGT tests. It is only tested on the rk3588, so any other SoC is probably not going to work at all for now.
The skeleton is basically taken from Nova and also
rust_platform_driver.rs.Lastly, the name "Tyr" is inspired by Norse mythology, reflecting ARM's tradition of naming their GPUs after Nordic mythological figures and places.
Co-developed-by Alice Ryhl <[email protected]>Signed-off-by Alice Ryhl <[email protected]>Co-developed-by Beata Michalska <[email protected]>Signed-off-by Beata Michalska <[email protected]>Co-developed-by Carsten Haitzler <[email protected]>Signed-off-by Carsten Haitzler <[email protected]>Co-developed-by Rob Herring <[email protected]>Signed-off-by Rob Herring <[email protected]>
Quoted 2 lines
Not that is really matters, but this is
Quoted 65 lines · Daniel Almeida
Add a Rust driver for ARM Mali CSF-based GPUs. It is a port of Panthor and therefore exposes Panthor's uAPI and name to userspace, and the product of a joint effort between Collabora, Arm and Google engineers.
The aim is to incrementally develop Tyr with the abstractions that are currently available until it is consider to be in parity with Panthor feature-wise.
The development of Tyr itself started in January, after a few failed attempts of converting Panthor piecewise through a mix of Rust and C code. There is a downstream branch that's much further ahead in terms of capabilities than this initial patch.
The downstream code is capable of booting the MCU, doing sync
VM_BINDSthrough the work-in-progress GPUVM abstraction and also doing (trivial) submits through Asahi'sdrm_scheduleranddma_fenceabstractions. So basically, most of what one would expect a modern GPU driver to do, except for power management and some other very important adjacent pieces. It is not at the point where submits can correctly deal with dependencies, or at the point where it can rotate access to the GPU hardware fairly through a software scheduler, but that is simply a matter of writing more code.This first patch, however, only implements a subset of the current features available downstream, as the rest is not implementable without pulling in even more abstractions. In particular, a lot of things depend on properly mapping memory on a given VA range, which itself depends on the GPUVM abstraction that is currently work-in-progress. For this reason, we still cannot boot the MCU and thus, cannot do much for the moment.
This constitutes a change in the overall strategy that we have been using to develop Tyr so far. By submitting small parts of the driver upstream iteratively, we aim to:
a) evolve together with Nova and rvkms, hopefully reducing regressions due to upstream changes (that may break us because we were not there, in the first place)
b) prove any work-in-progress abstractions by having them run on a real driver and hardware and,
c) provide a reason to work on and review said abstractions by providing a user, which would be tyr itself.
Despite its limited feature-set, we offer IGT tests. It is only tested on the rk3588, so any other SoC is probably not going to work at all for now.
The skeleton is basically taken from Nova and also
rust_platform_driver.rs.Lastly, the name "Tyr" is inspired by Norse mythology, reflecting ARM's tradition of naming their GPUs after Nordic mythological figures and places.
Co-developed-by Alice Ryhl <[email protected]>Signed-off-by Alice Ryhl <[email protected]>Co-developed-by Beata Michalska <[email protected]>Signed-off-by Beata Michalska <[email protected]>Co-developed-by Carsten Haitzler <[email protected]>Signed-off-by Carsten Haitzler <[email protected]>Co-developed-by Rob Herring <[email protected]>Signed-off-by Rob Herring <[email protected]>
Quoted 2 lines
[aliceryhl: minor Kconfig update on apply]
[aliceryhl: s/drm::device::/drm::/]
Applied to drm-rust-next. Thanks!