The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Yury Norov" <yury.norov@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "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>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Onur Özkan" <work@onurozkan.dev>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Alistair Popple" <apopple@nvidia.com>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	"Zhi Wang" <zhiw@nvidia.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH 2/3] rust: pci: return a bitfield type for dev_id
Date: Fri, 27 Nov 2026 13:44:02 +0100	[thread overview]
Message-ID: <DN603ORZA8KY.30W58KXH3Q8Y4@kernel.org> (raw)
In-Reply-To: <20261127-nova-gsp-dbd-v1-2-0fb5f7c2ce63@nvidia.com>

On Fri Nov 27, 2026 at 12:46 PM CET, Alexandre Courbot wrote:
> +bitfield! {
> +    /// Bus-Device-Function ID of a PCI device. Equivalent of C's `PCI_DEVID`.

Please make the reference to the C API a separate line.

Additional nit, I'm not sure I'd use "equivalent" as Bdf is a type that can do a
few more things.

> +    pub struct Bdf(u16) {
> +        /// Bus number.
> +        15:8 bus;
> +        /// Device number.
> +        7:3 device;
> +        /// Function number.
> +        2:0 function;
> +        /// Aggregation of `device` and `function`, which are commonly used together in code.
> +        7:0 devfn;
> +    }
> +}
> +
> +/// Formats the ID as `bus:device.function`, like the corresponding part of C's `pci_name()`.
> +impl fmt::Display for Bdf {
> +    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> +        write!(
> +            f,
> +            "{:02x}:{:02x}.{}",
> +            self.bus(),
> +            self.device(),
> +            self.function()
> +        )
> +    }
> +}
> +
>  /// Abstraction for the PCI device ID structure ([`struct pci_device_id`]).
>  ///
>  /// [`struct pci_device_id`]: https://docs.kernel.org/PCI/pci.html#c.pci_device_id
> @@ -700,10 +729,10 @@ pub fn revision_id(&self) -> u8 {
>  
>      /// Returns the PCI bus device/function.
>      #[inline]
> -    pub fn dev_id(&self) -> u16 {
> +    pub fn dev_id(&self) -> Bdf {

At a first glance I wasn't sure if the naming should align, i.e. whether Bdf
should be DevId instead, but I think this strikes a good balance: dev_id()
remains aligned with the C API and Bdf as a type is more on point than DevId.

With the above nit fixed,

Acked-by: Danilo Krummrich <dakr@kernel.org>

  reply	other threads:[~2026-11-27 12:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 11:46 [PATCH 0/3] gpu: nova-core: gsp: fix the PCI location sent to GSP-RM Alexandre Courbot
2026-11-27 11:46 ` [PATCH 1/3] rust: bitfield: add missing doccomments for associated constants Alexandre Courbot
2026-11-27 11:46 ` [PATCH 2/3] rust: pci: return a bitfield type for dev_id Alexandre Courbot
2026-11-27 12:44   ` Danilo Krummrich [this message]
2026-11-27 11:46 ` [PATCH 3/3] gpu: nova-core: gsp: send the PCI domain, bus and device to GSP-RM Alexandre Courbot

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=DN603ORZA8KY.30W58KXH3Q8Y4@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=work@onurozkan.dev \
    --cc=yury.norov@gmail.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