From: Eliot Courtney <ecourtney@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
Alice Ryhl <aliceryhl@google.com>,
Alexandre Courbot <acourbot@nvidia.com>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: John Hubbard <jhubbard@nvidia.com>,
Alistair Popple <apopple@nvidia.com>,
Timur Tabi <ttabi@nvidia.com>,
nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Eliot Courtney <ecourtney@nvidia.com>
Subject: [PATCH v2 3/6] gpu: nova-core: remove some dependencies on FalconDmaLoadTarget
Date: Sun, 29 Nov 2026 11:55:47 +0900 [thread overview]
Message-ID: <20261129-boot-rework2-v2-3-622f3560e18a@nvidia.com> (raw)
In-Reply-To: <20261129-boot-rework2-v2-0-622f3560e18a@nvidia.com>
In order to remove `FalconDmaLoadTarget`, remove usages of it in
`FwsecFirmwareWithBl` and `BootloaderDmemDescV2`. `FalconDmaLoadTarget`
ends up non-orthogonal with `FalconImage`, `FalconImemSegment`,
`FalconDmemSegment` which are added in a following change. These three
new types take over the job of denoting where code/data uploaded to a
falcon is stored and where it is sent to. This is part of making the
locations of where the falcon data/code is represented separate from how
it is sent to the falcon. `FalconDmaLoadTarget` conflates those two
things.
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/firmware/fwsec/bootloader.rs | 49 +++++++---------------
drivers/gpu/nova-core/firmware/gen_bootloader.rs | 42 ++++++++++---------
2 files changed, 38 insertions(+), 53 deletions(-)
diff --git a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
index 461e5e6f7899..1efcf7a8624d 100644
--- a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
+++ b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
@@ -19,7 +19,6 @@
falcon::{
gsp::Gsp,
Falcon,
- FalconDmaLoadable,
FalconFbifTarget, //
},
firmware::{
@@ -28,6 +27,7 @@
BootloaderDmemDescV2,
GenericBootloader, //
},
+ FalconUCodeDesc, //
},
gpu::Chipset,
num::FromSafeCast, //
@@ -52,61 +52,44 @@ pub(crate) fn new(
dev: &'a Device<device::Bound>,
chipset: Chipset,
) -> Result<Self> {
+ let desc = match &firmware.desc {
+ FalconUCodeDesc::V2(desc) => desc,
+ FalconUCodeDesc::V3(_) => return Err(EINVAL),
+ };
+
let bootloader = GenericBootloader::new(dev, chipset)?;
// `BootloaderDmemDescV2` expects the source to be a mirror image of the destination and
// uses the same offset parameter for both.
//
- // Thus, the start of the source object needs to be padded with the difference between the
- // destination and source offsets.
+ // Thus, the start of the source object needs to be padded with `imem_phys_base`, the IMEM
+ // offset at which the code is loaded.
//
// In practice, this is expected to always be zero but is required for code correctness.
- let (align_padding, firmware_dma) = {
- let align_padding = {
- let imem_sec = firmware.imem_sec_load_params();
-
- imem_sec
- .dst_start
- .checked_sub(imem_sec.src_start)
- .map(usize::from_safe_cast)
- .ok_or(EOVERFLOW)?
- };
+ let align_padding = usize::from_safe_cast(desc.imem_phys_base);
+ let firmware_dma = {
let mut firmware_obj = KVVec::zeroed(align_padding, GFP_KERNEL)?;
firmware_obj.extend_from_slice(firmware.ucode.0.as_slice(), GFP_KERNEL)?;
- (
- align_padding,
- Coherent::from_slice(dev, firmware_obj.as_slice(), GFP_KERNEL)?,
- )
+ Coherent::from_slice(dev, firmware_obj.as_slice(), GFP_KERNEL)?
};
let dmem_desc = {
- let imem_sec = firmware.imem_sec_load_params();
- let imem_ns = firmware.imem_ns_load_params().ok_or(EINVAL)?;
- let dmem = firmware.dmem_load_params();
-
// The bootloader does not have a data destination offset field and copies the data at
- // the start of DMEM, so it can only be used if the destination offset of the firmware
- // is 0.
- if dmem.dst_start != 0 {
+ // the start of DMEM, so it can only be used if `dmem_phys_base` is 0.
+ if desc.dmem_phys_base != 0 {
return Err(EINVAL);
}
- // Start of data section is the added padding + the DMEM `src_start` field.
+ // Start of data section is the added padding + the `dmem_offset` field.
let data_dma_base = firmware_dma
.dma_address()
.checked_add(u64::from_safe_cast(align_padding))
- .and_then(|offset| offset.checked_add(dmem.src_start.into()))
+ .and_then(|offset| offset.checked_add(desc.dmem_offset.into()))
.ok_or(EOVERFLOW)?;
- BootloaderDmemDescV2::new(
- &imem_ns,
- &imem_sec,
- &dmem,
- firmware_dma.dma_address(),
- data_dma_base,
- )
+ BootloaderDmemDescV2::new(desc, firmware_dma.dma_address(), data_dma_base)
};
Ok(Self {
diff --git a/drivers/gpu/nova-core/firmware/gen_bootloader.rs b/drivers/gpu/nova-core/firmware/gen_bootloader.rs
index cfc1b99c015c..5dea98220e9d 100644
--- a/drivers/gpu/nova-core/firmware/gen_bootloader.rs
+++ b/drivers/gpu/nova-core/firmware/gen_bootloader.rs
@@ -22,7 +22,6 @@
gsp::Gsp,
Falcon,
FalconBromParams,
- FalconDmaLoadTarget,
FalconFbifMemType,
FalconFbifTarget,
FalconFirmware,
@@ -30,9 +29,12 @@
FalconPioImemLoadTarget,
FalconPioLoadable, //
},
- firmware::tlv::{
- request_tlv, //
- Tlv,
+ firmware::{
+ tlv::{
+ request_tlv, //
+ Tlv,
+ },
+ FalconUCodeDescV2, //
},
gpu::Chipset,
num::FromSafeCast, //
@@ -91,29 +93,29 @@ impl BootloaderDmemDescV2 {
/// Creates the descriptor of an image whose code is at `code_dma_base` and whose data is at
/// `data_dma_base`.
///
- /// `imem_ns` and `imem_sec` locate the non-secure and secure code in the image, and `dmem`
- /// gives the size of its data. The code DMA object must be a mirror image of the target IMEM
- /// layout, because the bootloader uses the destination offset of each code segment as its
- /// source offset too.
- pub(crate) fn new(
- imem_ns: &FalconDmaLoadTarget,
- imem_sec: &FalconDmaLoadTarget,
- dmem: &FalconDmaLoadTarget,
- code_dma_base: u64,
- data_dma_base: u64,
- ) -> Self {
+ /// The code DMA object must be a mirror image of the target IMEM layout, because the
+ /// bootloader uses the destination offset of each code segment as its source offset too.
+ pub(super) fn new(desc: &FalconUCodeDescV2, code_dma_base: u64, data_dma_base: u64) -> Self {
+ // `imem_sec_base` is the *virtual* start address of the secure IMEM segment, so subtract
+ // `imem_virt_base` to get its physical offset.
+ let imem_sec_start = desc.imem_sec_base.saturating_sub(desc.imem_virt_base);
+
Self {
reserved: [0; 4],
signature: [0; 4],
ctx_dma: Self::FALCON_DMAIDX_PHYS_SYS_NCOH,
code_dma_base,
- non_sec_code_off: imem_ns.dst_start,
- non_sec_code_size: imem_ns.len,
- sec_code_off: imem_sec.dst_start,
- sec_code_size: imem_sec.len,
+ // Non-secure code always starts at offset 0 of the image, so it is loaded at
+ // `imem_phys_base`.
+ non_sec_code_off: desc.imem_phys_base,
+ // `imem_load_size` includes the size of the secure segment, so subtract it to
+ // get the correct amount of data to copy.
+ non_sec_code_size: desc.imem_load_size.saturating_sub(desc.imem_sec_size),
+ sec_code_off: desc.imem_phys_base.saturating_add(imem_sec_start),
+ sec_code_size: desc.imem_sec_size,
code_entry_point: 0,
data_dma_base,
- data_size: dmem.len,
+ data_size: desc.dmem_load_size,
argc: 0,
argv: 0,
}
--
2.56.1
next prev parent reply other threads:[~2026-11-29 2:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 2:55 [PATCH v2 0/6] gpu: nova-core: merge `load` and `boot` for falcons Eliot Courtney
2026-11-29 2:55 ` [PATCH v2 1/6] gpu: nova-core: falcon: program BROM and BOOTVEC in `boot` Eliot Courtney
2026-11-29 2:55 ` [PATCH v2 2/6] gpu: nova-core: use correct offset for imem in `BooterFirmware` Eliot Courtney
2026-11-29 2:55 ` Eliot Courtney [this message]
2026-11-29 2:55 ` [PATCH v2 4/6] gpu: nova-core: falcon: separate staging data for DMA from its location Eliot Courtney
2026-11-29 2:55 ` [PATCH v2 5/6] gpu: nova-core: falcon: add `FalconImage` for `FalconFirmware` trait Eliot Courtney
2026-11-29 2:55 ` [PATCH v2 6/6] gpu: nova-core: falcon: load the firmware image in Falcon::boot Eliot Courtney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261129-boot-rework2-v2-3-622f3560e18a@nvidia.com \
--to=ecourtney@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=simona@ffwll.ch \
--cc=ttabi@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®