Skip to content

Commit df6137e

Browse files
johnhubbardGnurou
authored andcommitted
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>
1 parent 13f8598 commit df6137e

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

drivers/gpu/nova-core/gpu.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ pub(crate) struct Revision {
147147
minor: u8,
148148
}
149149

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 {
152152
Self {
153153
major: boot0.major_revision(),
154154
minor: boot0.minor_revision(),
@@ -162,20 +162,27 @@ impl fmt::Display for Revision {
162162
}
163163
}
164164

165-
/// Structure holding the metadata of the GPU.
165+
/// Structure holding a basic description of the GPU: `Chipset` and `Revision`.
166166
pub(crate) struct Spec {
167167
chipset: Chipset,
168-
/// The revision of the chipset.
169168
revision: Revision,
170169
}
171170

172171
impl Spec {
173172
fn new(bar: &Bar0) -> Result<Spec> {
174173
let boot0 = regs::NV_PMC_BOOT_0::read(bar);
175174

175+
Spec::try_from(boot0)
176+
}
177+
}
178+
179+
impl TryFrom<regs::NV_PMC_BOOT_0> for Spec {
180+
type Error = Error;
181+
182+
fn try_from(boot0: regs::NV_PMC_BOOT_0) -> Result<Self> {
176183
Ok(Self {
177184
chipset: boot0.chipset()?,
178-
revision: Revision::from_boot0(boot0),
185+
revision: boot0.into(),
179186
})
180187
}
181188
}

0 commit comments

Comments
 (0)