[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <19c557e5-5428-42a8-8317-62726b980eff@nvidia.com>
Date: Wed, 3 Dec 2025 23:27:15 -0800
From: John Hubbard <jhubbard@...dia.com>
To: Timur Tabi <ttabi@...dia.com>, "dakr@...nel.org" <dakr@...nel.org>
Cc: Alexandre Courbot <acourbot@...dia.com>,
"lossin@...nel.org" <lossin@...nel.org>,
"a.hindborg@...nel.org" <a.hindborg@...nel.org>,
"boqun.feng@...il.com" <boqun.feng@...il.com>,
"aliceryhl@...gle.com" <aliceryhl@...gle.com>, Zhi Wang <zhiw@...dia.com>,
"simona@...ll.ch" <simona@...ll.ch>,
"alex.gaynor@...il.com" <alex.gaynor@...il.com>,
"ojeda@...nel.org" <ojeda@...nel.org>, "tmgross@...ch.edu"
<tmgross@...ch.edu>,
"nouveau@...ts.freedesktop.org" <nouveau@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"rust-for-linux@...r.kernel.org" <rust-for-linux@...r.kernel.org>,
"bjorn3_gh@...tonmail.com" <bjorn3_gh@...tonmail.com>,
Edwin Peer <epeer@...dia.com>, "airlied@...il.com" <airlied@...il.com>,
Joel Fernandes <joelagnelf@...dia.com>,
"bhelgaas@...gle.com" <bhelgaas@...gle.com>,
"gary@...yguo.net" <gary@...yguo.net>, Alistair Popple <apopple@...dia.com>
Subject: Re: [PATCH 01/31] gpu: nova-core: print FB sizes, along with ranges
On 12/3/25 11:35 AM, Timur Tabi wrote:
> On Tue, 2025-12-02 at 21:58 -0800, John Hubbard wrote:
>> +impl fmt::Debug for FbRange {
>> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
>> + let size_mb = (self.0.end - self.0.start) >> 20;
>> + f.write_fmt(fmt!(
>> + "{:#x}..{:#x} ({} MB)",
>> + self.0.start,
>> + self.0.end,
>> + size_mb
>> + ))
>> + }
>> +}
>> +
>
> How about printing size_kb if size_mb == 0 or if it's not an even multiple of MB?
Good idea, I'll do that.
>
> Also, why not just add this function to Range<> instead of creating a new type?
Rust's orphan rules prevent implementing a foreign trait (Debug) on a
foreign type (Range<u64>). Both are defined in core, not in nova-core,
so the compiler won't allow it. The newtype pattern is the standard Rust
workaround for this: by wrapping Range<u64> in a local type FbRange, we
can implement whatever traits we need.
thanks,
--
John Hubbard
Powered by blists - more mailing lists