* [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
2026-11-11 11:45 ` (subset) [PATCH 0/2] gpu: nova-core: add two prerequisites for the r000 GSP firmware Danilo Krummrich
2 siblings, 1 reply; 7+ 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] 7+ messages in thread* Re: [PATCH 1/2] rust: pci: add domain_nr() accessor
2026-11-10 3:36 ` [PATCH 1/2] rust: pci: add domain_nr() accessor John Hubbard
@ 2026-11-10 12:43 ` Danilo Krummrich
2026-11-11 19:07 ` John Hubbard
0 siblings, 1 reply; 7+ messages in thread
From: Danilo Krummrich @ 2026-11-10 12:43 UTC (permalink / raw)
To: John Hubbard
Cc: Alexandre Courbot, 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
On Tue Nov 10, 2026 at 4:36 AM CET, John Hubbard wrote:
> 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>
Is this tag intentional? (Just asking since my tooling flagged it as it wasn't
present in the first submission of this patch and some other criteria.)
> 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 helpers should generally be transparent wrappers and not provide any
semantics, even if it is just to resolve a pointer.
> +}
> +
> __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
NIT: Please move the comment directly above the actual cast statement.
> + }
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 1/2] rust: pci: add domain_nr() accessor
2026-11-10 12:43 ` Danilo Krummrich
@ 2026-11-11 19:07 ` John Hubbard
0 siblings, 0 replies; 7+ messages in thread
From: John Hubbard @ 2026-11-11 19:07 UTC (permalink / raw)
To: Danilo Krummrich
Cc: Alexandre Courbot, 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
On 11/10/26 4:43 AM, Danilo Krummrich wrote:
> On Tue Nov 10, 2026 at 4:36 AM CET, John Hubbard wrote:
>> 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>
>
> Is this tag intentional? (Just asking since my tooling flagged it as it wasn't
> present in the first submission of this patch and some other criteria.)
Yes, intentional, but perhaps it is too strong. I'll remove it. It
came from Miguel's suggestion to use debug_assert!(), in [1].
[1] https://lore.kernel.org/all/CANiq72=Loa21e-pywymk+KcQ+8p8NuqYQc79XDKduQh6f8TnxQ@mail.gmail.com/
>> 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 helpers should generally be transparent wrappers and not provide any
> semantics, even if it is just to resolve a pointer.
OK.
>
>> +}
>> +
>> __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
>
> NIT: Please move the comment directly above the actual cast statement.
OK.
thanks,
--
John Hubbard
^ permalink raw reply [flat|nested] 7+ 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
2026-11-11 4:20 ` Eliot Courtney
2026-11-11 11:45 ` (subset) [PATCH 0/2] gpu: nova-core: add two prerequisites for the r000 GSP firmware Danilo Krummrich
2 siblings, 1 reply; 7+ 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] 7+ messages in thread* Re: [PATCH 2/2] gpu: nova-core: factor out and expose Falcon::is_processor_suspended()
2026-11-10 3:36 ` [PATCH 2/2] gpu: nova-core: factor out and expose Falcon::is_processor_suspended() John Hubbard
@ 2026-11-11 4:20 ` Eliot Courtney
0 siblings, 0 replies; 7+ messages in thread
From: Eliot Courtney @ 2026-11-11 4:20 UTC (permalink / raw)
To: John Hubbard, 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, dri-devel
On Tue Nov 10, 2026 at 12:36 PM JST, John Hubbard wrote:
> 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>
> ---
Reviewed-by: Eliot Courtney <ecourtney@nvidia.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (subset) [PATCH 0/2] gpu: nova-core: add two prerequisites for the r000 GSP firmware
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 ` [PATCH 2/2] gpu: nova-core: factor out and expose Falcon::is_processor_suspended() John Hubbard
@ 2026-11-11 11:45 ` Danilo Krummrich
2 siblings, 0 replies; 7+ messages in thread
From: Danilo Krummrich @ 2026-11-11 11:45 UTC (permalink / raw)
To: John Hubbard
Cc: Danilo Krummrich, Alexandre Courbot, 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
On Mon, 9 Nov 2026 19:36:52 -0800, John Hubbard wrote:
> [PATCH 0/2] gpu: nova-core: add two prerequisites for the r000 GSP firmware
Applied, thanks!
Branch: drm-rust-next
Tree: https://gitlab.freedesktop.org/drm/rust/kernel.git
[2/2] gpu: nova-core: factor out and expose Falcon::is_processor_suspended()
commit: 6e557330b874
The patch will appear in the next linux-next integration (typically within 24
hours on weekdays).
The patch is queued up for the upcoming merge window for the next major kernel
release.
^ permalink raw reply [flat|nested] 7+ messages in thread