summaryrefslogtreecommitdiff
path: root/drivers/gpu/nova-core
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2025-12-18 16:50:49 +0100
committerDanilo Krummrich <dakr@kernel.org>2025-12-29 17:54:31 +0100
commit423706aa1c469bfcc3c27a9e8c464f6b88921db7 (patch)
tree8c934ae83ae6d808b587a7dd24b36dac2ce66b7e /drivers/gpu/nova-core
parentdb22fbc15a9cea7e3f74a53d36c381503b6ca43e (diff)
downloadlinux-423706aa1c469bfcc3c27a9e8c464f6b88921db7.tar.gz
linux-423706aa1c469bfcc3c27a9e8c464f6b88921db7.tar.bz2
linux-423706aa1c469bfcc3c27a9e8c464f6b88921db7.zip
gpu: nova-core: fw: move appropriate code into pin initializer
Relocate the code that technically fits in the pin initializer into the initializer itself. While, thanks to pin_init_scope(), it is also possible to keep it as is, moving appropriate code into the initializer has the advantage that it structures the dependencies of fields naturally. For instance, intermediate data that is only needed for a single field goes into the initializer block of this field, making it obvious that it is not needed by anything else. On the other hand, intermediate data that is needed for multiple fields to initialize remains above the initializer, naturally indicating that it is needed my multiple fields. Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com> Link: https://patch.msgid.link/20251218155239.25243-3-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'drivers/gpu/nova-core')
-rw-r--r--drivers/gpu/nova-core/firmware/gsp.rs34
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/gpu/nova-core/firmware/gsp.rs b/drivers/gpu/nova-core/firmware/gsp.rs
index e034268be3c5..da97814cf859 100644
--- a/drivers/gpu/nova-core/firmware/gsp.rs
+++ b/drivers/gpu/nova-core/firmware/gsp.rs
@@ -159,18 +159,9 @@ impl GspFirmware {
ver: &'a str,
) -> impl PinInit<Self, Error> + 'a {
pin_init::pin_init_scope(move || {
- let fw = super::request_firmware(dev, chipset, "gsp", ver)?;
+ let firmware = super::request_firmware(dev, chipset, "gsp", ver)?;
- let fw_section = elf::elf64_section(fw.data(), ".fwimage").ok_or(EINVAL)?;
-
- let sigs_section = match chipset.arch() {
- Architecture::Ampere => ".fwsignature_ga10x",
- Architecture::Ada => ".fwsignature_ad10x",
- _ => return Err(ENOTSUPP),
- };
- let signatures = elf::elf64_section(fw.data(), sigs_section)
- .ok_or(EINVAL)
- .and_then(|data| DmaObject::from_data(dev, data))?;
+ let fw_section = elf::elf64_section(firmware.data(), ".fwimage").ok_or(EINVAL)?;
let size = fw_section.len();
@@ -183,9 +174,6 @@ impl GspFirmware {
})
.map_err(|_| ENOMEM)?;
- let bl = super::request_firmware(dev, chipset, "bootloader", ver)?;
- let bootloader = RiscvFirmware::new(dev, &bl)?;
-
Ok(try_pin_init!(Self {
fw <- SGTable::new(dev, fw_vvec, DataDirection::ToDevice, GFP_KERNEL),
level2 <- {
@@ -227,8 +215,22 @@ impl GspFirmware {
DmaObject::from_data(dev, &level0_data)?
},
size,
- signatures,
- bootloader,
+ signatures: {
+ let sigs_section = match chipset.arch() {
+ Architecture::Ampere => ".fwsignature_ga10x",
+ Architecture::Ada => ".fwsignature_ad10x",
+ _ => return Err(ENOTSUPP),
+ };
+
+ elf::elf64_section(firmware.data(), sigs_section)
+ .ok_or(EINVAL)
+ .and_then(|data| DmaObject::from_data(dev, data))?
+ },
+ bootloader: {
+ let bl = super::request_firmware(dev, chipset, "bootloader", ver)?;
+
+ RiscvFirmware::new(dev, &bl)?
+ },
}))
})
}