mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Courbot <acourbot@nvidia.com>
To: "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>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"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>
Cc: 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,
	Alexandre Courbot <acourbot@nvidia.com>
Subject: [PATCH 3/3] gpu: nova-core: gsp: send the PCI domain, bus and device to GSP-RM
Date: Fri, 27 Nov 2026 20:46:18 +0900	[thread overview]
Message-ID: <20261127-nova-gsp-dbd-v1-3-0fb5f7c2ce63@nvidia.com> (raw)
In-Reply-To: <20261127-nova-gsp-dbd-v1-0-0fb5f7c2ce63@nvidia.com>

From: John Hubbard <jhubbard@nvidia.com>

Open RM sends the PCI location of the GPU to GSP-RM as one word, which
gpuEncodeDomainBusDevice() builds: the domain in bits 63:32, the bus
number in bits 15:8 and the device number in bits 7:0.

Nova-core's system-info command sends the PCI device ID in that word
instead: the bus number, the device number and the function number, with
no domain. The two words are equal only for a GPU at device 0, function
0 of domain 0, so GSP-RM receives a wrong location for a GPU anywhere
else.

Send the domain, the bus number and the device number instead, in the
layout that Open RM uses.

Fixes: edcb134264f7 ("gpu: nova-core: gsp: Add SetSystemInfo command")
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Co-developed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/gsp/fw/commands.rs | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-core/gsp/fw/commands.rs
index 37b89e62387f..a1a5e0d5569e 100644
--- a/drivers/gpu/nova-core/gsp/fw/commands.rs
+++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
@@ -88,7 +88,7 @@ pub(crate) fn init<'a>(
             gpuPhysAddr: dev.resource_start(0)?,
             gpuPhysFbAddr: dev.resource_start(1)?,
             gpuPhysInstAddr: dev.resource_start(3)?,
-            nvDomainBusDeviceFunc: u64::from(dev.dev_id().into_raw()),
+            nvDomainBusDeviceFunc: u64::from(DomainBusDevice::new(dev)),
 
             // Using TASK_SIZE in r535_gsp_rpc_set_system_info() seems wrong because
             // TASK_SIZE is per-task. That's probably a design issue in GSP-RM though.
@@ -377,6 +377,34 @@ struct GspInitRequest {
     }
 }
 
+bitfield! {
+    /// A GPU's PCI location as GSP-RM reads it: the domain, the bus number and the device number.
+    ///
+    /// The function is omitted on purpose.
+    struct DomainBusDevice(u64) {
+        /// PCI domain number.
+        63:32 domain;
+        /// PCI bus number.
+        15:8 bus;
+        /// PCI device number.
+        ///
+        /// Note: this field is larger than the equivalent one in [`pci::Bdf`]. This follows OpenRM.
+        7:0 device;
+    }
+}
+
+impl DomainBusDevice {
+    /// Returns the PCI location of `dev`.
+    fn new(dev: &pci::Device<device::Bound>) -> Self {
+        let dev_id = dev.dev_id();
+
+        Self::zeroed()
+            .with_domain(dev.domain_nr())
+            .with_bus(u8::from(dev_id.bus()))
+            .with_device(u8::from(dev_id.device()))
+    }
+}
+
 // Decode:
 
 // Should decode with UnknownKeyPolicy::Ignore.

-- 
2.56.1


      parent reply	other threads:[~2026-11-27 11:46 UTC|newest]

Thread overview: 6+ 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 " 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
2026-11-27 14:40   ` Gary Guo
2026-11-27 11:46 ` Alexandre Courbot [this message]

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=20261127-nova-gsp-dbd-v1-3-0fb5f7c2ce63@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --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=dakr@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

all inboxes | Powered by JetHome®