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: prepare Spec and Revision types for boot0/boot42

Allow a both Revision and Spec to be constructed directly from a
NV_PMC_BOOT_0 register.

Also, slightly enhance the comment about Spec, to be more precise.

Cc: Alexandre Courbot <acourbot@nvidia.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Timur Tabi <ttabi@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-2-jhubbard@nvidia.com>

authored by

John Hubbard and committed by
Alexandre Courbot
df6137e2 13f85988

+12 -5
+12 -5
drivers/gpu/nova-core/gpu.rs
··· 147 147 minor: u8, 148 148 } 149 149 150 - impl Revision { 151 - fn from_boot0(boot0: regs::NV_PMC_BOOT_0) -> Self { 150 + impl From<regs::NV_PMC_BOOT_0> for Revision { 151 + fn from(boot0: regs::NV_PMC_BOOT_0) -> Self { 152 152 Self { 153 153 major: boot0.major_revision(), 154 154 minor: boot0.minor_revision(), ··· 162 162 } 163 163 } 164 164 165 - /// Structure holding the metadata of the GPU. 165 + /// Structure holding a basic description of the GPU: `Chipset` and `Revision`. 166 166 pub(crate) struct Spec { 167 167 chipset: Chipset, 168 - /// The revision of the chipset. 169 168 revision: Revision, 170 169 } 171 170 ··· 172 173 fn new(bar: &Bar0) -> Result<Spec> { 173 174 let boot0 = regs::NV_PMC_BOOT_0::read(bar); 174 175 176 + Spec::try_from(boot0) 177 + } 178 + } 179 + 180 + impl TryFrom<regs::NV_PMC_BOOT_0> for Spec { 181 + type Error = Error; 182 + 183 + fn try_from(boot0: regs::NV_PMC_BOOT_0) -> Result<Self> { 175 184 Ok(Self { 176 185 chipset: boot0.chipset()?, 177 - revision: Revision::from_boot0(boot0), 186 + revision: boot0.into(), 178 187 }) 179 188 } 180 189 }