Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpu: nova-core: make Architecture behave as a u8 type

This allows Architecture to be passed into register!() and bitfield!()
macro calls. That in turn requires a default implementation for
Architecture.

This simplifies transforming BOOT0 (and later, BOOT42) register values
into GPU architectures.

Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Timur Tabi <ttabi@nvidia.com>
Suggested-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Message-ID: <20251115010923.1192144-3-jhubbard@nvidia.com>

authored by

John Hubbard and committed by
Alexandre Courbot
4d980333 df6137e2

+14 -1
+14 -1
drivers/gpu/nova-core/gpu.rs
··· 122 122 } 123 123 124 124 /// Enum representation of the GPU generation. 125 - #[derive(fmt::Debug)] 125 + /// 126 + /// TODO: remove the `Default` trait implementation, and the `#[default]` 127 + /// attribute, once the register!() macro (which creates Architecture items) no 128 + /// longer requires it for read-only fields. 129 + #[derive(fmt::Debug, Default, Copy, Clone)] 130 + #[repr(u8)] 126 131 pub(crate) enum Architecture { 132 + #[default] 127 133 Turing = 0x16, 128 134 Ampere = 0x17, 129 135 Ada = 0x19, ··· 145 139 0x19 => Ok(Self::Ada), 146 140 _ => Err(ENODEV), 147 141 } 142 + } 143 + } 144 + 145 + impl From<Architecture> for u8 { 146 + fn from(value: Architecture) -> Self { 147 + // CAST: `Architecture` is `repr(u8)`, so this cast is always lossless. 148 + value as u8 148 149 } 149 150 } 150 151