lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3E006071-AB3A-4391-82CD-F9C9BEFE2386@nvidia.com>
Date: Wed, 12 Nov 2025 02:57:14 +0000
From: Joel Fernandes <joelagnelf@...dia.com>
To: Alexandre Courbot <acourbot@...dia.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"rust-for-linux@...r.kernel.org" <rust-for-linux@...r.kernel.org>,
	"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
	"dakr@...nel.org" <dakr@...nel.org>, Alistair Popple <apopple@...dia.com>,
	Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Boqun
 Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
	"bjorn3_gh@...tonmail.com" <bjorn3_gh@...tonmail.com>, Benno Lossin
	<lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl
	<aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, David Airlie
	<airlied@...il.com>, Simona Vetter <simona@...ll.ch>, Maarten Lankhorst
	<maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>,
	Thomas Zimmermann <tzimmermann@...e.de>, John Hubbard <jhubbard@...dia.com>,
	Timur Tabi <ttabi@...dia.com>, "joel@...lfernandes.org"
	<joel@...lfernandes.org>, "nouveau@...ts.freedesktop.org"
	<nouveau@...ts.freedesktop.org>, Nouveau
	<nouveau-bounces@...ts.freedesktop.org>, Alexandre Courbot
	<acourbot@...dia.com>
Subject: Re: [PATCH v2 07/12] nova-core: Implement the GSP sequencer



> On Nov 11, 2025, at 7:42 PM, Alexandre Courbot <acourbot@...dia.com> wrote:
> 
> On Wed Nov 12, 2025 at 8:02 AM JST, Joel Fernandes wrote:
>> On 11/10/2025 8:43 AM, Alexandre Courbot wrote:
>> [..]
>>> 
>>>> +            |cmd| {
>>>> +                self.current_offset += cmd.size_bytes();
>>>> +                self.cmds_processed += 1;
>>>> +                Some(Ok(cmd))
>>>> +            },
>>>> +        )
>>>> +    }
>>>> +}
>>>> +
>>>> +impl<'a, 'b> IntoIterator for &'b GspSequencer<'a> {
>>>> +    type Item = Result<GspSeqCmd>;
>>>> +    type IntoIter = GspSeqIter<'b>;
>>>> +
>>>> +    fn into_iter(self) -> Self::IntoIter {
>>>> +        let cmd_data = &self.seq_info.cmd_data[..];
>>>> +
>>>> +        GspSeqIter {
>>>> +            cmd_data,
>>>> +            current_offset: 0,
>>>> +            total_cmds: self.seq_info.info.cmdIndex,
>>>> +            cmds_processed: 0,
>>>> +            dev: self.dev,
>>>> +        }
>>>> +    }
>>>> +}
>>> 
>>> You can do without this implementation by just having an `iter` method
>>> returning the iterator where appropriate (in the current version this
>>> would be `GspSequencer`, but I suggest moving that to the
>>> `GspSequencerInfo/GspSequence`).
>>> 
>> 
>> If I do that, it becomes ugly on the caller side.
>> 
>> Caller side becomes:
>> for cmd_result in sequencer.seq_info.iter(&sequencer.dev) {
>> ..
>> }
>> 
>> instead of the current:
>> for cmd_result in sequencer {
>> ..
>> }
> 
> That's if you need `dev` for iteration. Since it is only used for
> logging error messages, I'd suggest doing without it and returning a
> distinct error code (or a dedicated error type that implements Display
> or Debug and converts to the kernel's Error) that the caller can then
> print, removing the need to pass `dev`.

True.

> 
>> 
>> Does it work for you if I remove IntoIterator and just have GspSequencer::iter()
>> return the iterator?
>> 
>> Then the caller becomes:
>> 
>> for cmd_result in sequencer.iter() {
>> ..
>> }
>> 
>> Although I think IntoIterator makes a lot of sense here too, and there are other
>> usages of it in rust kernel code. But the sequencer.iter() would work for me.
> 
> I guess it's a matter of personal taste, but I tend to prefer `iter`
> methods because they are more visible than an implementation on a
> reference type, and also because they allow us to have different kinds of
> iterators for the same type (not that this is useful here :)).

Ok, so I take it that you are ok with sequencer.iter() for the v4. The sequencer iterates through a collection of commands so that makes sense. But let me know if you are in disagreement about this.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ