public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Joel Fernandes" <joelagnelf@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>, "Edwin Peer" <epeer@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	<nouveau@lists.freedesktop.org>, <rust-for-linux@vger.kernel.org>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v9 6/9] gpu: nova-core: add PIO support for loading firmware images
Date: Fri, 13 Feb 2026 15:47:01 +0100	[thread overview]
Message-ID: <DGDWZHY8XCLX.19DI18CI9QSPQ@kernel.org> (raw)
In-Reply-To: <20260212-turing_prep-v9-6-238520ad8799@nvidia.com>

On Thu Feb 12, 2026 at 9:26 AM CET, Alexandre Courbot wrote:
> +    fn try_as_pio_loadable(&self) -> Result<FalconDmaFirmwarePioAdapter<'_, Self>> {

[...]

> +        let dmem = {
> +            let params = self.dmem_load_params();
> +
> +            // SAFETY: we keep a reference to `self` for as long as this slice is alive, and the
> +            // device will not access this DMA object since we are using PIO.

How is this guaranteed by this function? I.e. how is it prevented that this
function is never called when the device acesses the DMA memory?

> +            let data = unsafe {
> +                self.as_slice(
> +                    usize::from_safe_cast(params.src_start),
> +                    usize::from_safe_cast(params.len),
> +                )?
> +            };
> +
> +            let dst_start = u16::try_from(params.dst_start).map_err(|_| EINVAL)?;
> +
> +            FalconPioDmemLoadTarget { data, dst_start }
> +        };
> +
> +        Ok(FalconDmaFirmwarePioAdapter {
> +            fw: self,
> +            imem_sec,
> +            imem_ns,
> +            dmem,
> +        })
> +    }
> +}

<snip>

> +/// Adapter type that makes any DMA-loadable firmware also loadable via PIO.
> +///
> +/// Created using [`FalconDmaLoadable::try_as_pio_loadable`].
> +pub(crate) struct FalconDmaFirmwarePioAdapter<'a, T: FalconDmaLoadable + ?Sized> {
> +    /// Reference to the DMA firmware.
> +    fw: &'a T,

In v6 [1] I wrote:

	> @@ -221,6 +286,8 @@ pub(crate) struct FwsecFirmware {
	>      desc: FalconUCodeDesc,
	>      /// GPU-accessible DMA object containing the firmware.
	>      ucode: FirmwareDmaObject<Self, Signed>,
	> +    /// Generic bootloader
	> +    gen_bootloader: Option<GenericBootloader>,

	I'm not convinced this is a good idea. We probably want a HAL here and
	have different FwsecFirmware types:

	One with a DMA object and one with a system memory object when the
	architecture uses PIO. In the latter case the object can have a
	GenericBootloader field, i.e.  this also gets us rid of the Option and
	all the subsequent 'if chipset < Chipset::GA102' checks and 'match
	gbl_fw' matches below.

So, I still wonder, why use an Adapter impl on top of DMA memory for PIO rather
than different base types with a common trait to avoid DMA allocations in the
PIO case altogether?

[1] https://lore.kernel.org/all/DFQBHVTTHZY8.13ASLCJ3FJP81@kernel.org/

  reply	other threads:[~2026-02-13 14:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-12  8:26 [PATCH v9 0/9] gpu: nova-core: add Turing support Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 1/9] gpu: nova-core: falcon: rename load parameters to reflect DMA dependency Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 2/9] gpu: nova-core: require DmaObject on FalconDmaLoadable, not FalconFirmware Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 3/9] gpu: nova-core: falcon: remove generic argument from dma_wr Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 4/9] gpu: nova-core: falcon: remove FalconFirmware's dependency on FalconDmaLoadable Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 5/9] gpu: nova-core: move brom_params and boot_addr to FalconFirmware Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 6/9] gpu: nova-core: add PIO support for loading firmware images Alexandre Courbot
2026-02-13 14:47   ` Danilo Krummrich [this message]
2026-02-22 10:57     ` Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 7/9] gpu: nova-core: make Chipset::arch() const Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 8/9] gpu: nova-core: add gen_bootloader firmware to ModInfoBuilder Alexandre Courbot
2026-02-12  8:26 ` [PATCH v9 9/9] gpu: nova-core: use the Generic Bootloader to boot FWSEC on Turing Alexandre Courbot
2026-02-24  2:31   ` Eliot Courtney
2026-02-27  4:21     ` Alexandre Courbot

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=DGDWZHY8XCLX.19DI18CI9QSPQ@kernel.org \
    --to=dakr@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=epeer@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=rust-for-linux@vger.kernel.org \
    --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