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 140FDC71136 for ; Thu, 12 Jun 2025 10:54:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7351610E7C6; Thu, 12 Jun 2025 10:54:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Wl7wNucj"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id A672010E7C6; Thu, 12 Jun 2025 10:54:38 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F2A8D5C5AF4; Thu, 12 Jun 2025 10:52:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBADCC4CEEA; Thu, 12 Jun 2025 10:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749725677; bh=Svf2SlshRf4K2I3bpqEV/6RweQo/oo8/RGNKpTG7qDs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Wl7wNucjTNCstmT8lp0PPGX2AAqsrSfFv41JrNffe3eBnZlkiDeRDpgKVI5QWRn1f 4LvzOizaTV6LTjwMAahzYTkouypLbCtX6MLiD7iWkEcFLbA5GgL0584ayTrOwyJy6q GZ0xDOOQvhagfMadU4IYifKGs8zn3dPIPt8DF1KHuXLEae/LN+WkKdo6gqQMgRRlAm 0f40dVGAP/11T/OPQxjpMxL4/bnqJaNlUSnxCSLfCzpVK4/67JqW4Qhg3BxNGkU7kS UbFl4M6f2XJNpOAydXw/LO3zQXI6Bfab6qpFBLT14W+LFIOz/aoKNyZcRNHjTfqYdW erTQ3cyOhT+Tg== Message-ID: <6e97aa79-6d6f-497f-96d2-7568d6516682@kernel.org> Date: Thu, 12 Jun 2025 12:54:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 18/20] gpu: nova-core: add types for patching firmware binaries To: Alexandre Courbot Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Ben Skeggs , Joel Fernandes , Timur Tabi , Alistair Popple , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org References: <20250521-nova-frts-v4-0-05dfd4f39479@nvidia.com> <20250521-nova-frts-v4-18-05dfd4f39479@nvidia.com> From: Danilo Krummrich Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 6/12/25 9:19 AM, Alexandre Courbot wrote: > On Wed Jun 4, 2025 at 7:28 PM JST, Danilo Krummrich wrote: >> If we can't patch them when the object is created, i.e. in >> FirmwareDmaObject::new(), I think we should take self by value in >> FirmwareDmaObject::patch_signature() and return a SignedFirmwareDmaObject (which >> can just be a transparent wrapper) instead in order to let the type system prove >> that we did not forget to call patch_signature(). > > This one is a bit tricky. Signature patching is actually optional, > depending on whether there are signatures present at all (it might not > be the case on development setups). So involving the type system here > would require storing the result in an enum, and then match that enum > later in order to do the same thing in both cases - load the binary > as-is. > > So I guess I would rather leave this one as it currently is, unless > there is a better way I haven't thought about? In the end the idea is to ensure that we can't forget to call patch_signature(), so even if it's optional we could do what I mentioned above, just that patch_signature() might be a noop?