Re: [PATCH] drm/tyr: use bitfield! for non-MMIO fields

From: Gary Guo

Date: Thu Sep 10 2026 - 23:11:40 EST


On Fri Sep 11, 2026 at 1:06 AM BST, Deborah Brouwer wrote:
> SectionFlags and MMU_MEMATTR_STAGE1 describe bitfields rather than
> hardware registers. Use bitfield! instead of register! so they aren't
> confused with actual registers.
>

I've sent
https://lore.kernel.org/dri-devel/20260910165734.80378-1-gary@xxxxxxxxxx/
already.

Best,
Gary

> Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
> ---
> drivers/gpu/drm/tyr/fw.rs | 11 ++++-------
> drivers/gpu/drm/tyr/regs.rs | 11 +++++------
> 2 files changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/tyr/fw.rs b/drivers/gpu/drm/tyr/fw.rs
> index 7edb5eff1707..8d11f888a9b9 100644
> --- a/drivers/gpu/drm/tyr/fw.rs
> +++ b/drivers/gpu/drm/tyr/fw.rs
> @@ -14,6 +14,7 @@
> //! [`Section`]: crate::fw::Section
>
> use kernel::{
> + bitfield,
> device::{
> Bound,
> Device, //
> @@ -27,7 +28,6 @@
> },
> num::Bounded,
> prelude::*,
> - register,
> str::CString,
> sync::{
> Arc,
> @@ -39,8 +39,7 @@
> use crate::{
> driver::{
> IoMem,
> - TyrDrmDevice,
> - TyrRegisters, //
> + TyrDrmDevice, //
> },
> fw::parser::{
> FwParser,
> @@ -101,11 +100,9 @@ fn from(value: CacheMode) -> Self {
> }
> }
>
> -register! {
> - base: TyrRegisters;
> -
> +bitfield! {
> #[allow(non_upper_case_globals)]
> - pub(super) SectionFlags(u32) @ 0x0 {
> + pub(super) struct SectionFlags(u32) {
> 0:0 read => bool;
> 1:1 write => bool;
> 2:2 exec => bool;
> diff --git a/drivers/gpu/drm/tyr/regs.rs b/drivers/gpu/drm/tyr/regs.rs
> index 0c419c4e1186..3377b8fc5029 100644
> --- a/drivers/gpu/drm/tyr/regs.rs
> +++ b/drivers/gpu/drm/tyr/regs.rs
> @@ -986,6 +986,7 @@ pub(crate) mod mmu_control {
> /// This array contains 16 instances of the MMU_AS_CONTROL register page.
> pub(crate) mod mmu_as_control {
> use kernel::{
> + bitfield,
> num::Bounded,
> prelude::*,
> register, //
> @@ -1130,14 +1131,12 @@ fn from(val: MemoryType) -> Self {
> }
> }
>
> - register! {
> - base: TyrRegisters;
> -
> + bitfield! {
> /// Stage 1 memory attributes (8-bit bitfield).
> ///
> - /// This is not an actual register, but a bitfield definition used by the MEMATTR
> - /// register. Each of the 8 bytes in MEMATTR follows this layout.
> - MMU_MEMATTR_STAGE1(u8) @ 0x0 {
> + /// This bitfield definition is used by the MEMATTR register.
> + /// Each of the 8 bytes in MEMATTR follows this layout.
> + struct MMU_MEMATTR_STAGE1(u8) {
> /// Inner cache write allocation policy.
> 0:0 alloc_w => bool;
> /// Inner cache read allocation policy.
>
> ---
> base-commit: 73e5616f3d197c1af5a04a481fe0f13aa3913bd1
> change-id: 20260910-b4-use-bitfield-512214360810
>
> Best regards,