From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B634027713; Sun, 26 Oct 2025 15:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761492958; cv=none; b=DeJBAbmboIKv6hSurkPDqxFft2/1gvdk+njwjMC1+l0M4anbJDgOsgazErmFLHxGVGvgkLyU7Y2+hmCRp29Itq9d80mUSLqqCw2qyyczSJ1U5s/PQL1ZftUbbaVw8Mev2L9zrkX4YzQvOqWOp0jNRMQFYtlYrbbl0qndPjKTZGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761492958; c=relaxed/simple; bh=AlOh53yJfnPi5Z4IY9Rxr3C4zzHqodJBp4pikEkDgfg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DWSGNCaeaoQKv/vojxsuOpPYSCTfjoa/q5gUkA6uIRoGv1xxhLuKRlXvaI6KOFM/GPjrN8x6NbkMwwrimn34VIa2qNgHOdTC4eNN5haFyFSTF8Ys1xbhpnD19kd51j61vfqisYfxPucOj5zbA1Es9j7nuMuFIzhiZopYhtyyFvo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hztc6NOP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hztc6NOP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F55BC4CEE7; Sun, 26 Oct 2025 15:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761492958; bh=AlOh53yJfnPi5Z4IY9Rxr3C4zzHqodJBp4pikEkDgfg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=hztc6NOPIvrXOMobE+TKWvpHF18TDMgl3L9rIvJYwzEQ0Ef1RMYg6YNJEuKQiqR9B 0ryDixfkrxUCOfP53a20hx/ZmUboNuozZK96DI5NSv3fxgmGNGHegi7LnlZM/9YNw9 NYCr08SvtXhUdDjuUE6JHbkT5u+rmTLzLZJjGJxV1+xhHjfa2sj16BiTcRk569OKQW d59v+d1ZtKCAIHFEABZ3sC5Pvatd/DBiUU8fZGMV0yOGQe3VZUglT/uXI/jlpthyOd fp5nZ42rHDjADsHfob6AYGvD64l34/eJj7n7KilN+47d1tfn+pbd7t+Ylp/ycRzn9+ K054+H2ufX4xg== Message-ID: Date: Sun, 26 Oct 2025 16:35:52 +0100 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/7] gpu: nova-core: remove use of `as` for integer conversions To: Alexandre Courbot Cc: Alice Ryhl , David Airlie , Simona Vetter , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , John Hubbard , Alistair Popple , Joel Fernandes , Timur Tabi , Edwin Peer , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org References: <20251026-nova-as-v1-0-60c78726462d@nvidia.com> From: Danilo Krummrich Content-Language: en-US In-Reply-To: <20251026-nova-as-v1-0-60c78726462d@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/26/25 3:39 PM, Alexandre Courbot wrote: > This patchset tries to eradicate the use of `as` in nova-core, by using > existing means and introducing new ones. Thanks a lot for working on this cleanup! > The first 4 patches use the already-available `From` and `TryFrom` trait > where it is possible or advisable. > > The fifth patch introduces a new module that proposes conversion > functions for those that are infallible under the current build target. > This is done through a set of const functions, and the `FromAs` and > `IntoAs` extension traits which, as their names lightly suggest, offer > conversion for those types on which the `as` operator can be used > losslessly. > > This new module is put to use in the sixth patch. > > The idea was first suggested by Danilo, and I hope I captured it > properly. :) Yes, this is what I thought of. > As Danilo suggested, this could eventually find its place in the kernel > crate if the implementation is deemed to be fit, but for now let's > review and let it mature in nova-core. Yeah, I think this approach makes sense. Though, I think we want to move this to the kernel crate sooner than later, it's definitely something we want for core code and other drivers as well. Depending on the initial feedback, it might even make sense to do it right away. I won't have time for a thorough review, but at a first glance the patches all look good! Acked-by: Danilo Krummrich