public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>
Cc: "Joel Fernandes" <joelagnelf@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	"Zhi Wang" <zhiw@nvidia.com>, "David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"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>,
	nouveau@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	"John Hubbard" <jhubbard@nvidia.com>
Subject: [PATCH v4 26/33] gpu: nova-core: Blackwell: use correct sysmem flush registers
Date: Mon,  9 Feb 2026 18:45:53 -0800	[thread overview]
Message-ID: <20260210024601.593248-27-jhubbard@nvidia.com> (raw)
In-Reply-To: <20260210024601.593248-1-jhubbard@nvidia.com>

Blackwell GPUs moved the sysmem flush page registers away from the
legacy NV_PFB_NISO_FLUSH_SYSMEM_ADDR used by Ampere/Ada.

GB10x uses HSHUB0 registers, with both a primary and EG (egress) pair
that must be programmed to the same address. GB20x uses FBHUB0
registers.

Add separate GB100 and GB202 fb HALs, and split the Blackwell HAL
dispatch so that each uses its respective registers.

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 drivers/gpu/nova-core/fb/hal.rs       |  6 ++-
 drivers/gpu/nova-core/fb/hal/gb100.rs | 42 ++++++++++++++++--
 drivers/gpu/nova-core/fb/hal/gb202.rs | 62 +++++++++++++++++++++++++++
 drivers/gpu/nova-core/regs.rs         | 36 ++++++++++++++++
 4 files changed, 142 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/nova-core/fb/hal/gb202.rs

diff --git a/drivers/gpu/nova-core/fb/hal.rs b/drivers/gpu/nova-core/fb/hal.rs
index ebd12247f771..01f19a00685c 100644
--- a/drivers/gpu/nova-core/fb/hal.rs
+++ b/drivers/gpu/nova-core/fb/hal.rs
@@ -13,6 +13,7 @@
 mod ga100;
 mod ga102;
 mod gb100;
+mod gb202;
 mod gh100;
 mod tu102;
 
@@ -46,6 +47,9 @@ pub(crate) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal {
         Architecture::Ampere if chipset == Chipset::GA100 => ga100::GA100_HAL,
         Architecture::Ampere | Architecture::Ada => ga102::GA102_HAL,
         Architecture::Hopper => gh100::GH100_HAL,
-        Architecture::Blackwell => gb100::GB100_HAL,
+        Architecture::Blackwell => match chipset {
+            Chipset::GB100 | Chipset::GB102 => gb100::GB100_HAL,
+            _ => gb202::GB202_HAL,
+        },
     }
 }
diff --git a/drivers/gpu/nova-core/fb/hal/gb100.rs b/drivers/gpu/nova-core/fb/hal/gb100.rs
index eaab3f934f6e..6039f66b12cc 100644
--- a/drivers/gpu/nova-core/fb/hal/gb100.rs
+++ b/drivers/gpu/nova-core/fb/hal/gb100.rs
@@ -1,21 +1,57 @@
 // SPDX-License-Identifier: GPL-2.0
 
+//! Blackwell GB10x framebuffer HAL.
+//!
+//! GB10x GPUs use HSHUB0 registers for the sysmem flush page. Both the primary and EG (egress)
+//! register pairs must be programmed to the same address, as required by hardware.
+
 use kernel::prelude::*;
 
 use crate::{
     driver::Bar0,
-    fb::hal::FbHal, //
+    fb::hal::FbHal,
+    regs, //
 };
 
 struct Gb100;
 
+fn read_sysmem_flush_page_gb100(bar: &Bar0) -> u64 {
+    let lo = u64::from(regs::NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO::read(bar).adr());
+    let hi = u64::from(regs::NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI::read(bar).adr());
+
+    lo | (hi << 32)
+}
+
+fn write_sysmem_flush_page_gb100(bar: &Bar0, addr: u64) {
+    let addr_lo = addr as u32;
+    let addr_hi = (addr >> 32) as u32;
+
+    // Write HI first: the hardware may trigger the flush on the LO write.
+
+    // Primary HSHUB pair.
+    regs::NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI::default()
+        .set_adr(addr_hi)
+        .write(bar);
+    regs::NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO::default()
+        .set_adr(addr_lo)
+        .write(bar);
+
+    // EG (egress) pair -- must match the primary pair.
+    regs::NV_PFB_HSHUB0_EG_PCIE_FLUSH_SYSMEM_ADDR_HI::default()
+        .set_adr(addr_hi)
+        .write(bar);
+    regs::NV_PFB_HSHUB0_EG_PCIE_FLUSH_SYSMEM_ADDR_LO::default()
+        .set_adr(addr_lo)
+        .write(bar);
+}
+
 impl FbHal for Gb100 {
     fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
-        super::ga100::read_sysmem_flush_page_ga100(bar)
+        read_sysmem_flush_page_gb100(bar)
     }
 
     fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
-        super::ga100::write_sysmem_flush_page_ga100(bar, addr);
+        write_sysmem_flush_page_gb100(bar, addr);
 
         Ok(())
     }
diff --git a/drivers/gpu/nova-core/fb/hal/gb202.rs b/drivers/gpu/nova-core/fb/hal/gb202.rs
new file mode 100644
index 000000000000..7fa9a49d2cca
--- /dev/null
+++ b/drivers/gpu/nova-core/fb/hal/gb202.rs
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! Blackwell GB20x framebuffer HAL.
+//!
+//! GB20x GPUs moved the sysmem flush registers from `NV_PFB_NISO_FLUSH_SYSMEM_ADDR` to
+//! `NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_{LO,HI}`.
+
+use kernel::prelude::*;
+
+use crate::{
+    driver::Bar0,
+    fb::hal::FbHal,
+    regs, //
+};
+
+struct Gb202;
+
+fn read_sysmem_flush_page_gb202(bar: &Bar0) -> u64 {
+    let lo = u64::from(regs::NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO::read(bar).adr());
+    let hi = u64::from(regs::NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI::read(bar).adr());
+
+    lo | (hi << 32)
+}
+
+fn write_sysmem_flush_page_gb202(bar: &Bar0, addr: u64) {
+    // Write HI first. The hardware will trigger the flush on the LO write.
+    regs::NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI::default()
+        // CAST: upper 32 bits, then masked to 20 bits by the register field.
+        .set_adr((addr >> 32) as u32)
+        .write(bar);
+    regs::NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO::default()
+        // CAST: lower 32 bits. Hardware ignores bits 7:0.
+        .set_adr(addr as u32)
+        .write(bar);
+}
+
+impl FbHal for Gb202 {
+    fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
+        read_sysmem_flush_page_gb202(bar)
+    }
+
+    fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
+        write_sysmem_flush_page_gb202(bar, addr);
+
+        Ok(())
+    }
+
+    fn supports_display(&self, bar: &Bar0) -> bool {
+        super::ga100::display_enabled_ga100(bar)
+    }
+
+    fn vidmem_size(&self, bar: &Bar0) -> u64 {
+        super::ga102::vidmem_size_ga102(bar)
+    }
+
+    fn non_wpr_heap_size(&self) -> Option<u32> {
+        Some(0x220000)
+    }
+}
+
+const GB202: Gb202 = Gb202;
+pub(super) const GB202_HAL: &dyn FbHal = &GB202;
diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs
index 0d3ad4755a81..dfc30247bca6 100644
--- a/drivers/gpu/nova-core/regs.rs
+++ b/drivers/gpu/nova-core/regs.rs
@@ -116,6 +116,42 @@ fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result {
     23:0    adr_63_40 as u32;
 });
 
+// Blackwell GB10x sysmem flush registers (HSHUB0).
+//
+// GB10x GPUs use two pairs of HSHUB registers for sysmembar: a primary pair and an EG
+// (egress) pair. Both must be programmed to the same address. Hardware ignores bits 7:0
+// of each LO register. HSHUB0 base is 0x00891000.
+
+register!(NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO @ 0x00891e50 {
+    31:0    adr as u32;
+});
+
+register!(NV_PFB_HSHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI @ 0x00891e54 {
+    19:0    adr as u32;
+});
+
+register!(NV_PFB_HSHUB0_EG_PCIE_FLUSH_SYSMEM_ADDR_LO @ 0x008916c0 {
+    31:0    adr as u32;
+});
+
+register!(NV_PFB_HSHUB0_EG_PCIE_FLUSH_SYSMEM_ADDR_HI @ 0x008916c4 {
+    19:0    adr as u32;
+});
+
+// Blackwell GB20x sysmem flush registers (FBHUB0).
+//
+// Unlike the older NV_PFB_NISO_FLUSH_SYSMEM_ADDR registers which encode the address with an
+// 8-bit right-shift, these registers take the raw address split into lower/upper 32-bit halves.
+// The hardware ignores bits 7:0 of the LO register.
+
+register!(NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_LO @ 0x008a1d58 {
+    31:0    adr as u32;
+});
+
+register!(NV_PFB_FBHUB0_PCIE_FLUSH_SYSMEM_ADDR_HI @ 0x008a1d5c {
+    19:0    adr as u32;
+});
+
 register!(NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE @ 0x00100ce0 {
     3:0     lower_scale as u8;
     9:4     lower_mag as u8;
-- 
2.53.0


  parent reply	other threads:[~2026-02-10  2:47 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10  2:45 [PATCH v4 00/33] gpu: nova-core: firmware: Hopper/Blackwell support John Hubbard
2026-02-10  2:45 ` [PATCH v4 01/33] gpu: nova-core: pass pdev directly to dev_* logging macros John Hubbard
2026-02-11 10:06   ` Danilo Krummrich
2026-02-11 18:48     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 02/33] gpu: nova-core: print FB sizes, along with ranges John Hubbard
2026-02-10  2:45 ` [PATCH v4 03/33] gpu: nova-core: add FbRange.len() and use it in boot.rs John Hubbard
2026-02-10  2:45 ` [PATCH v4 04/33] gpu: nova-core: Hopper/Blackwell: basic GPU identification John Hubbard
2026-02-10  2:45 ` [PATCH v4 05/33] gpu: nova-core: factor .fwsignature* selection into a new get_gsp_sigs_section() John Hubbard
2026-02-11 10:16   ` Danilo Krummrich
2026-02-12  0:39     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 06/33] gpu: nova-core: use GPU Architecture to simplify HAL selections John Hubbard
2026-02-10  2:45 ` [PATCH v4 07/33] gpu: nova-core: apply the one "use" item per line policy to commands.rs John Hubbard
2026-02-10  2:45 ` [PATCH v4 08/33] gpu: nova-core: set DMA mask width based on GPU architecture John Hubbard
2026-02-11 10:28   ` Danilo Krummrich
2026-02-12  2:06     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 09/33] gpu: nova-core: Hopper/Blackwell: skip GFW boot waiting John Hubbard
2026-02-11 10:09   ` Danilo Krummrich
2026-02-12  1:49     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 10/33] gpu: nova-core: move firmware image parsing code to firmware.rs John Hubbard
2026-02-10  2:45 ` [PATCH v4 11/33] gpu: nova-core: factor out a section_name_eq() function John Hubbard
2026-02-10  2:45 ` [PATCH v4 12/33] gpu: nova-core: don't assume 64-bit firmware images John Hubbard
2026-02-10  2:45 ` [PATCH v4 13/33] gpu: nova-core: add support for 32-bit " John Hubbard
2026-02-10  2:45 ` [PATCH v4 14/33] gpu: nova-core: add auto-detection of 32-bit, 64-bit " John Hubbard
2026-02-10  2:45 ` [PATCH v4 15/33] gpu: nova-core: Hopper/Blackwell: add FMC firmware image, in support of FSP John Hubbard
2026-02-10  2:45 ` [PATCH v4 16/33] gpu: nova-core: Hopper/Blackwell: add FSP falcon engine stub John Hubbard
2026-02-10  2:45 ` [PATCH v4 17/33] gpu: nova-core: Hopper/Blackwell: add FSP falcon EMEM operations John Hubbard
2026-02-11 10:57   ` Danilo Krummrich
2026-02-12  2:09     ` John Hubbard
2026-02-17 15:43       ` Danilo Krummrich
2026-02-19  2:54         ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 18/33] gpu: nova-core: Hopper/Blackwell: add FSP message infrastructure John Hubbard
2026-02-17 16:28   ` Danilo Krummrich
2026-02-20 22:05     ` Tegra notes for Nova: " John Hubbard
2026-02-23  3:36       ` Alexandre Courbot
2026-02-10  2:45 ` [PATCH v4 19/33] gpu: nova-core: Hopper/Blackwell: calculate reserved FB heap size John Hubbard
2026-02-17 16:39   ` Danilo Krummrich
2026-02-19  3:01     ` John Hubbard
2026-02-19  9:01       ` Miguel Ojeda
2026-02-20 22:08         ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 20/33] gpu: nova-core: Hopper/Blackwell: add FSP secure boot completion waiting John Hubbard
2026-02-17 17:13   ` Danilo Krummrich
2026-02-20 23:26     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 21/33] gpu: nova-core: Hopper/Blackwell: add FSP message structures John Hubbard
2026-02-10  2:45 ` [PATCH v4 22/33] gpu: nova-core: Hopper/Blackwell: add FMC signature extraction John Hubbard
2026-02-10  2:45 ` [PATCH v4 23/33] gpu: nova-core: Hopper/Blackwell: add FSP send/receive messaging John Hubbard
2026-02-10  2:45 ` [PATCH v4 24/33] gpu: nova-core: Hopper/Blackwell: add FSP Chain of Trust boot John Hubbard
2026-02-17 18:16   ` Danilo Krummrich
2026-02-20 23:35     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 25/33] gpu: nova-core: Hopper/Blackwell: larger non-WPR heap John Hubbard
2026-02-17 20:04   ` Danilo Krummrich
2026-02-20 23:57     ` John Hubbard
2026-02-10  2:45 ` John Hubbard [this message]
2026-02-10  2:45 ` [PATCH v4 27/33] gpu: nova-core: Hopper/Blackwell: larger WPR2 (GSP) heap John Hubbard
2026-02-17 20:10   ` Danilo Krummrich
2026-02-21  1:01     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 28/33] gpu: nova-core: refactor SEC2 booter loading into run_booter() helper John Hubbard
2026-02-17 20:12   ` Danilo Krummrich
2026-02-21  1:03     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 29/33] gpu: nova-core: Hopper/Blackwell: add GSP lockdown release polling John Hubbard
2026-02-17 20:20   ` Danilo Krummrich
2026-02-21  1:06     ` John Hubbard
2026-02-10  2:45 ` [PATCH v4 30/33] gpu: nova-core: Hopper/Blackwell: add FSP Chain of Trust boot path John Hubbard
2026-02-10  2:45 ` [PATCH v4 31/33] gpu: nova-core: Hopper/Blackwell: new location for PCI config mirror John Hubbard
2026-02-10  2:45 ` [PATCH v4 32/33] gpu: nova-core: clarify the GPU firmware boot steps John Hubbard
2026-02-10  2:46 ` [PATCH v4 33/33] gpu: nova-core: fix aux device registration for multi-GPU systems John Hubbard
2026-02-10 22:27 ` [PATCH v4 00/33] gpu: nova-core: firmware: Hopper/Blackwell support John Hubbard

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=20260210024601.593248-27-jhubbard@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.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