* [PATCH 1/2] rust: pci: add domain_nr() accessor
2026-11-10 3:36 [PATCH 0/2] gpu: nova-core: add two prerequisites for the r000 GSP firmware John Hubbard
@ 2026-11-10 3:36 ` John Hubbard
2026-11-10 12:43 ` Danilo Krummrich
2026-11-10 3:36 ` [PATCH 2/2] gpu: nova-core: factor out and expose Falcon::is_processor_suspended() John Hubbard
1 sibling, 1 reply; 4+ messages in thread
From: John Hubbard @ 2026-11-10 3:36 UTC (permalink / raw)
To: Danilo Krummrich, Alexandre Courbot
Cc: Timur Tabi, Alistair Popple, Eliot Courtney, Zhi Wang,
David Airlie, Simona Vetter, Bjorn Helgaas, Miguel Ojeda,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, nova-gpu, dri-devel,
LKML, linux-pci, rust-for-linux, John Hubbard
The nova-core driver has to send the GPU's PCI location to the GPU's
firmware as one word that holds the domain, the bus and the device
number.
The PCI abstraction has dev_id(), which packs the bus, the device and
the function into one value. It has no accessor that reports the domain.
Add an accessor for the domain number.
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
rust/helpers/pci.c | 5 +++++
rust/kernel/pci.rs | 14 ++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/rust/helpers/pci.c b/rust/helpers/pci.c
index a8540f90b13c..49f2c089d236 100644
--- a/rust/helpers/pci.c
+++ b/rust/helpers/pci.c
@@ -7,6 +7,11 @@ __rust_helper u16 rust_helper_pci_dev_id(struct pci_dev *dev)
return PCI_DEVID(dev->bus->number, dev->devfn);
}
+__rust_helper int rust_helper_pci_domain_nr(struct pci_dev *dev)
+{
+ return pci_domain_nr(dev->bus);
+}
+
__rust_helper resource_size_t
rust_helper_pci_resource_start(struct pci_dev *pdev, int bar)
{
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 769d01d23429..57718e48208d 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -408,6 +408,20 @@ pub fn dev_id(&self) -> u16 {
unsafe { bindings::pci_dev_id(self.as_raw()) }
}
+ /// Returns the PCI domain number of the bus that this device is on.
+ #[inline]
+ pub fn domain_nr(&self) -> u32 {
+ // SAFETY: By its type invariant `self.as_raw` is always a valid pointer to a
+ // `struct pci_dev`.
+ let domain_nr = unsafe { bindings::pci_domain_nr(self.as_raw()) };
+
+ // CAST: `pci_domain_nr()` returns an `int`, but a registered bus never has a negative
+ // domain, because `pci_register_host_bridge()` fails when the domain allocation fails.
+ // A negative value here is a kernel bug rather than a condition for a caller to handle.
+ debug_assert!(domain_nr >= 0);
+ domain_nr as u32
+ }
+
/// Returns the PCI subsystem vendor ID.
#[inline]
pub fn subsystem_vendor_id(&self) -> u16 {
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] gpu: nova-core: factor out and expose Falcon::is_processor_suspended()
2026-11-10 3:36 [PATCH 0/2] gpu: nova-core: add two prerequisites for the r000 GSP firmware John Hubbard
2026-11-10 3:36 ` [PATCH 1/2] rust: pci: add domain_nr() accessor John Hubbard
@ 2026-11-10 3:36 ` John Hubbard
1 sibling, 0 replies; 4+ messages in thread
From: John Hubbard @ 2026-11-10 3:36 UTC (permalink / raw)
To: Danilo Krummrich, Alexandre Courbot
Cc: Timur Tabi, Alistair Popple, Eliot Courtney, Zhi Wang,
David Airlie, Simona Vetter, Bjorn Helgaas, Miguel Ojeda,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, nova-gpu, dri-devel,
LKML, linux-pci, rust-for-linux, John Hubbard
The r000 boot protocol requires the driver to wait for the GSP suspend
bit after each load-and-execute event. The shutdown path already does
this.
The boot sequence will soon need this same functionality, so factor it
out into a method, and put it in it's logical location as well, as a new
method of Falcon<Gsp>.
Also, use register!() for this, instead of manually masking off bit 31.
As usual, that results in much more readable code.
No functional changes.
Co-developed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/gpu/nova-core/falcon/gsp.rs | 7 +++++++
drivers/gpu/nova-core/gsp/boot.rs | 6 ++----
drivers/gpu/nova-core/regs.rs | 5 +++++
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/nova-core/falcon/gsp.rs b/drivers/gpu/nova-core/falcon/gsp.rs
index 1faefaede9fe..54247691b53c 100644
--- a/drivers/gpu/nova-core/falcon/gsp.rs
+++ b/drivers/gpu/nova-core/falcon/gsp.rs
@@ -47,6 +47,13 @@ fn pfalcon2(io: Bar0<'_>) -> Mmio<'_, super::PFalcon2Registers> {
}
impl<'a> Falcon<'a, Gsp> {
+ /// Returns `true` if GSP-RM has suspended the RISC-V core.
+ pub(crate) fn is_processor_suspended(&self) -> bool {
+ self.pfalcon
+ .read(regs::NV_PFALCON_FALCON_MAILBOX0_LIBOS)
+ .processor_suspended()
+ }
+
/// Clears the SWGEN0 latch in the GSP falcon.
///
/// While the latch is set, no later message signals the tree, so a caller that consumed a
diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs
index 1887806dc330..9d5da5b165ac 100644
--- a/drivers/gpu/nova-core/gsp/boot.rs
+++ b/drivers/gpu/nova-core/gsp/boot.rs
@@ -2,7 +2,6 @@
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
use kernel::{
- bits,
io::poll::read_poll_timeout,
prelude::*,
time::Delta,
@@ -98,10 +97,9 @@ fn shutdown_gsp(
cmdq.send_rpc_command(commands::rpc::UnloadingGuestDriver::new(mode))?;
// Wait until GSP signals it is suspended.
- const LIBOS_INTERRUPT_PROCESSOR_SUSPENDED: u32 = bits::bit_u32(31);
read_poll_timeout(
- || Ok(gsp_falcon.read_mailbox0()),
- |&mb0| mb0 & LIBOS_INTERRUPT_PROCESSOR_SUSPENDED != 0,
+ || Ok(gsp_falcon.is_processor_suspended()),
+ |suspended| *suspended,
Delta::from_millis(10),
Delta::from_secs(5),
)
diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs
index df2eddc58efb..3a0c7159fa7e 100644
--- a/drivers/gpu/nova-core/regs.rs
+++ b/drivers/gpu/nova-core/regs.rs
@@ -147,6 +147,11 @@ pub(crate) fn usable_fb_size(self) -> u64 {
31:0 value => u32;
}
+ /// `MAILBOX0` as LibOS, the kernel that GSP-RM runs on, writes it.
+ pub(crate) NV_PFALCON_FALCON_MAILBOX0_LIBOS(u32) => NV_PFALCON_FALCON_MAILBOX0 {
+ 31:31 processor_suspended => bool;
+ }
+
pub(crate) NV_PFALCON_FALCON_MAILBOX1(u32) @ 0x00000044 {
31:0 value => u32;
}
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread