From: Alistair Popple <apopple@nvidia.com>
To: nova-gpu@lists.linux.dev
Cc: Alistair Popple <apopple@nvidia.com>,
Danilo Krummrich <dakr@kernel.org>,
Alice Ryhl <aliceryhl@google.com>,
David Airlie <airlied@gmail.com>,
Alexandre Courbot <acourbot@nvidia.com>,
Benno Lossin <lossin@kernel.org>, Gary Guo <gary@garyguo.net>,
Eliot Courtney <ecourtney@nvidia.com>,
John Hubbard <jhubbard@nvidia.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org
Subject: [PATCH v3 6/7] drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter
Date: Thu, 23 Jul 2026 16:30:44 +1000 [thread overview]
Message-ID: <20260723063046.1265791-7-apopple@nvidia.com> (raw)
In-Reply-To: <20260723063046.1265791-1-apopple@nvidia.com>
Currently nova-drm reads the VRAM BAR size directly from the PCIe device
which requires trying to cast the parent device into a PCIe device. This
obviously requires the parent device to actually be a PCIe bus device.
Whilst that is true today it may not always be the case, and there
is no reason to make this assumption now that NovaCoreApi can hold a
reference to the bound PCIe device.
So convert nova-drm to using nova-core to obtain the VRAM_BAR_SIZE
parameter.
Signed-off-by: Alistair Popple <apopple@nvidia.com>
---
Changes from v2:
- Update nova-core API to use bar1_size() instead of vram_bar_size() as
this is used internally throughout our chip HW.
---
drivers/gpu/drm/nova/file.rs | 10 ++--------
drivers/gpu/nova-core/api.rs | 8 ++++++++
drivers/gpu/nova-core/driver.rs | 2 +-
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/nova/file.rs b/drivers/gpu/drm/nova/file.rs
index 8c02be4f15bf..d65630079237 100644
--- a/drivers/gpu/drm/nova/file.rs
+++ b/drivers/gpu/drm/nova/file.rs
@@ -8,14 +8,11 @@
use crate::gem::NovaObject;
use kernel::{
alloc::flags::*,
- auxiliary,
- device::Bound,
drm::{
self,
gem::BaseObject,
Registered, //
},
- pci,
prelude::*,
uapi,
};
@@ -33,16 +30,13 @@ fn open(_dev: &NovaDevice) -> Result<Pin<KBox<Self>>> {
impl File {
/// IOCTL: get_param: Query GPU / driver metadata.
pub(crate) fn get_param(
- dev: &NovaDevice<Registered>,
+ _dev: &NovaDevice<Registered>,
reg_data: &DrmRegData<'_>,
getparam: &mut uapi::drm_nova_getparam,
_file: &drm::File<File>,
) -> Result<u32> {
- let adev: &auxiliary::Device<Bound> = dev.as_ref();
- let pdev: &pci::Device<Bound> = adev.parent().try_into()?;
-
let value = match getparam.param as u32 {
- uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => pdev.resource_len(1)?,
+ uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => reg_data.api.bar1_size()?,
uapi::NOVA_GETPARAM_GPU_CHIPID => reg_data.api.chipset() as u64,
uapi::NOVA_GETPARAM_VRAM_SIZE => reg_data.api.vram_size(),
_ => return Err(EINVAL),
diff --git a/drivers/gpu/nova-core/api.rs b/drivers/gpu/nova-core/api.rs
index f025df90dc5d..9e2a5ba7c269 100644
--- a/drivers/gpu/nova-core/api.rs
+++ b/drivers/gpu/nova-core/api.rs
@@ -8,6 +8,7 @@
use kernel::{
auxiliary,
device::Bound,
+ pci,
prelude::*,
types::CovariantForLt, //
};
@@ -20,6 +21,7 @@
/// API handle for the auxiliary bus child drivers to interact with nova-core.
pub struct NovaCoreApi<'bound> {
pub(crate) gpu: Pin<&'bound Gpu<'bound>>,
+ pub(crate) pdev: &'bound pci::Device<Bound>,
}
impl NovaCoreApi<'_> {
@@ -34,6 +36,12 @@ pub fn chipset(&self) -> Chipset {
self.gpu.spec.chipset
}
+ /// Returns the size of the PCIe BAR used for accessing VRAM, typically
+ /// BAR1.
+ pub fn bar1_size(&self) -> Result<u64> {
+ self.pdev.resource_len(1)
+ }
+
/// Returns the total usable VRAM size of this GPU in bytes.
pub fn vram_size(&self) -> u64 {
self.gpu.gsp_static_info.vram_size()
diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
index 435aa917d3e7..175275fd7961 100644
--- a/drivers/gpu/nova-core/driver.rs
+++ b/drivers/gpu/nova-core/driver.rs
@@ -113,7 +113,7 @@ fn probe<'bound>(
// never recycles IDs.
AUXILIARY_ID_COUNTER.fetch_add(1, Relaxed),
crate::MODULE_NAME,
- NovaCoreApi { gpu },
+ NovaCoreApi { gpu, pdev },
)?
}
},
--
2.54.0
next prev parent reply other threads:[~2026-07-23 6:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 6:30 [PATCH v3 0/7] gpu: nova: Export parameters from nova-core to nova-drm Alistair Popple
2026-07-23 6:30 ` [PATCH v3 1/7] gpu: nova-core: Add public driver API to nova-core Alistair Popple
2026-07-23 6:30 ` [PATCH v3 2/7] drm: nova: Add DRM registration data Alistair Popple
2026-07-23 6:30 ` [PATCH v3 3/7] drm: nova: Add chipid enum to nova-drm UAPI Alistair Popple
2026-07-23 6:30 ` [PATCH v3 4/7] drm: nova: Add GETPARAM parameter to read the GPU chipid Alistair Popple
2026-07-23 6:30 ` [PATCH v3 5/7] drm: nova: Add GETPARAM parameter to read usable VRAM size Alistair Popple
2026-07-23 6:30 ` Alistair Popple [this message]
2026-07-23 6:30 ` [PATCH v3 7/7] drm: nova: Expose a render node Alistair Popple
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=20260723063046.1265791-7-apopple@nvidia.com \
--to=apopple@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
/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