public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Alexandre Courbot <acourbot@nvidia.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Joel Fernandes" <joelagnelf@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	"Shashank Sharma" <shashanks@nvidia.com>,
	"Zhi Wang" <zhiw@nvidia.com>, "David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	rust-for-linux@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpu: nova-core: fix three clippy::precedence warnings
Date: Fri, 3 Apr 2026 23:14:31 -0700	[thread overview]
Message-ID: <c23f9b20-5ef8-4952-ad80-265edc2874e5@nvidia.com> (raw)
In-Reply-To: <DHK4RWSLBFFK.2UL1M00W89TNL@nvidia.com>

On 4/3/26 10:45 PM, Alexandre Courbot wrote:
> On Sat Apr 4, 2026 at 11:58 AM JST, John Hubbard wrote:
>> Clippy warns when shifts and bitwise-OR are mixed without parentheses,
>> because the relative precedence of << and | is easy to misread. This was
>> causing 3 warnings in drm-rust-next.
> 
> These don't manifest for me (rustc 1.94.1), can you share more about the
> build context?

rustc 1.85.0

> 
>>
>> For read_sysmem_flush_page_ga100(), add explicit parentheses.
>>
>> For the PCI ROM header parsing, replace the manual byte-shifting with
>> u32::from_le_bytes(), which both fixes the warning and is clearer about
>> the intended byte order.
>>
>> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
>> ---
>>   drivers/gpu/nova-core/fb/hal/ga100.rs | 7 ++++---
>>   drivers/gpu/nova-core/vbios.rs        | 7 +------
>>   2 files changed, 5 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/gpu/nova-core/fb/hal/ga100.rs b/drivers/gpu/nova-core/fb/hal/ga100.rs
>> index 1c03783cddef..b5d0f04198f0 100644
>> --- a/drivers/gpu/nova-core/fb/hal/ga100.rs
>> +++ b/drivers/gpu/nova-core/fb/hal/ga100.rs
>> @@ -17,9 +17,10 @@
>>   struct Ga100;
>>   
>>   pub(super) fn read_sysmem_flush_page_ga100(bar: &Bar0) -> u64 {
>> -    u64::from(bar.read(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR).adr_39_08()) << FLUSH_SYSMEM_ADDR_SHIFT
>> -        | u64::from(bar.read(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI).adr_63_40())
>> -            << FLUSH_SYSMEM_ADDR_SHIFT_HI
>> +    (u64::from(bar.read(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR).adr_39_08())
>> +        << FLUSH_SYSMEM_ADDR_SHIFT)
>> +        | (u64::from(bar.read(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI).adr_63_40())
>> +            << FLUSH_SYSMEM_ADDR_SHIFT_HI)
>>   }
>>   
>>   pub(super) fn write_sysmem_flush_page_ga100(bar: &Bar0, addr: u64) {
>> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
>> index 3e3fa5b72524..ebda28e596c5 100644
>> --- a/drivers/gpu/nova-core/vbios.rs
>> +++ b/drivers/gpu/nova-core/vbios.rs
>> @@ -507,12 +507,7 @@ fn new(dev: &device::Device, data: &[u8]) -> Result<Self> {
>>   
>>           if data.len() >= 30 {
>>               // Read size_of_block at offset 0x1A.
>> -            size_of_block = Some(
>> -                u32::from(data[29]) << 24
>> -                    | u32::from(data[28]) << 16
>> -                    | u32::from(data[27]) << 8
>> -                    | u32::from(data[26]),
>> -            );
>> +            size_of_block = Some(u32::from_le_bytes([data[26], data[27], data[28], data[29]]));
> 
> This chunk looks like it should be its own patch as it is valuable
> regardless of the clippy warnings.

OK.

thanks,
-- 
John Hubbard


  reply	other threads:[~2026-04-04  6:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-04  2:58 [PATCH] gpu: nova-core: fix three clippy::precedence warnings John Hubbard
2026-04-04  5:45 ` Alexandre Courbot
2026-04-04  6:14   ` John Hubbard [this message]
2026-04-04 11:13 ` Miguel Ojeda
2026-04-04 11:29   ` Danilo Krummrich
2026-04-04 21:34     ` John Hubbard

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=c23f9b20-5ef8-4952-ad80-265edc2874e5@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=shashanks@nvidia.com \
    --cc=simona@ffwll.ch \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=zhiw@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