From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4BC23EDF16E for ; Fri, 13 Feb 2026 14:47:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77CD910E102; Fri, 13 Feb 2026 14:47:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="qLGa0ZqO"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2C9F10E102; Fri, 13 Feb 2026 14:47:06 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 664FD42B35; Fri, 13 Feb 2026 14:47:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA6E9C116C6; Fri, 13 Feb 2026 14:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770994026; bh=PfUuTo2C22B502KfiidVcMpl6fd1ZJEdslkaqG2JgXo=; h=Date:To:From:Subject:Cc:References:In-Reply-To:From; b=qLGa0ZqOVOApBCBl9bS3iFM0WK0TiLYX01j2qDqzV+QxNd8Upska8blJ6snj7Kh1/ MyJIOCBf5Ucy1ct7yxtw9TsQK/927cYKtZghWawrDKmvR5oUct2EiruQKrLUOWeRiC GMk4q9+mVQiYoClAVfo/RfRwD9popMZL5ORrDYb4xus850SjWtcTOXdArG9hAn57FA LDRSSQSh6Eg9zlxsmFytnFptZAOT4bK972lTEIXUbUCkiYadROP8AphflKTdvg9CdK u9aNAv7ya/aP8cNrN8yStE17ZbQyCw9fp2KAFPKPx/33yVa4vDg0cumdpbNcISc78g 0lX4Em1fA84Bw== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 13 Feb 2026 15:47:01 +0100 Message-Id: To: "Alexandre Courbot" From: "Danilo Krummrich" Subject: Re: [PATCH v9 6/9] gpu: nova-core: add PIO support for loading firmware images Cc: "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "John Hubbard" , "Alistair Popple" , "Joel Fernandes" , "Timur Tabi" , "Edwin Peer" , "Eliot Courtney" , , , , References: <20260212-turing_prep-v9-0-238520ad8799@nvidia.com> <20260212-turing_prep-v9-6-238520ad8799@nvidia.com> In-Reply-To: <20260212-turing_prep-v9-6-238520ad8799@nvidia.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu Feb 12, 2026 at 9:26 AM CET, Alexandre Courbot wrote: > + fn try_as_pio_loadable(&self) -> Result> { [...] > + let dmem =3D { > + let params =3D 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 =3D unsafe { > + self.as_slice( > + usize::from_safe_cast(params.src_start), > + usize::from_safe_cast(params.len), > + )? > + }; > + > + let dst_start =3D u16::try_from(params.dst_start).map_err(|_= | EINVAL)?; > + > + FalconPioDmemLoadTarget { data, dst_start } > + }; > + > + Ok(FalconDmaFirmwarePioAdapter { > + fw: self, > + imem_sec, > + imem_ns, > + dmem, > + }) > + } > +} > +/// 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, > + /// Generic bootloader > + gen_bootloader: Option, 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 ra= ther than different base types with a common trait to avoid DMA allocations in t= he PIO case altogether? [1] https://lore.kernel.org/all/DFQBHVTTHZY8.13ASLCJ3FJP81@kernel.org/