From: Alistair Popple <apopple@nvidia.com>
To: rust-for-linux@vger.kernel.org, nova-gpu <nova-gpu@lists.linux.dev>
Cc: Alistair Popple <apopple@nvidia.com>,
M Henning <mhenning@darkrefraction.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>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH v6 09/13] drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter
Date: Wed, 9 Sep 2026 16:45:02 +1000 [thread overview]
Message-ID: <20260909064506.910162-10-apopple@nvidia.com> (raw)
In-Reply-To: <20260909064506.910162-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 since v5:
- Call bar1_size() through the NovaCoreApiHandle closure
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 | 12 +++---------
drivers/gpu/nova-core/api.rs | 8 ++++++++
drivers/gpu/nova-core/driver.rs | 2 +-
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/nova/file.rs b/drivers/gpu/drm/nova/file.rs
index d0ab3df6bcd2..dad3c83c920b 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::*,
transmute::AsBytes,
uaccess::UserSlice,
@@ -80,16 +77,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>,
- _reg_data: &DrmRegData<'_>,
+ _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.with(|api| api.bar1_size())?,
_ => return Err(EINVAL),
};
diff --git a/drivers/gpu/nova-core/api.rs b/drivers/gpu/nova-core/api.rs
index 64f9ea442278..f02c6c7c7e51 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::ForLt, //
};
@@ -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<'_> {
@@ -38,6 +40,12 @@ pub fn gsp_static_info(&self) -> &GetGspStaticInfoReply {
pub fn spec(&self) -> &Spec {
&self.gpu.spec
}
+
+ /// 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)
+ }
}
/// Expose a handle to nova-core API
diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
index 922068df7707..025ba2869d6c 100644
--- a/drivers/gpu/nova-core/driver.rs
+++ b/drivers/gpu/nova-core/driver.rs
@@ -110,7 +110,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-09-09 6:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 6:44 [PATCH v6 00/13] gpu: nova: Export parameters from nova-core to nova-drm Alistair Popple
2026-09-09 6:44 ` [PATCH v6 01/13] rust: auxiliary: let registration_data_with() closures return covariant sub-fields Alistair Popple
2026-09-09 6:44 ` [PATCH v6 02/13] gpu: nova-core: Add public driver API to nova-core Alistair Popple
2026-09-09 6:44 ` [PATCH v6 03/13] drm: nova: Add DRM registration data Alistair Popple
2026-09-09 6:44 ` [PATCH v6 04/13] drm: nova: Add GPU architecture enum to nova-drm UAPI Alistair Popple
2026-09-09 6:44 ` [PATCH v6 05/13] drm: nova: Add chipid " Alistair Popple
2026-09-09 6:44 ` [PATCH v6 06/13] rust: uaccess: add UserSliceWriter::write_truncated() Alistair Popple
2026-09-09 6:45 ` [PATCH v6 07/13] drm: nova: Add an info ioctl Alistair Popple
2026-09-09 6:45 ` [PATCH v6 08/13] drm: nova: Add usable VRAM size to GPU info Alistair Popple
2026-09-09 6:45 ` Alistair Popple [this message]
2026-09-09 6:45 ` [PATCH v6 10/13] drm: nova: Expose a render node Alistair Popple
2026-09-09 6:45 ` [PATCH v6 11/13] drm: nova: Report GPU name in GPU info Alistair Popple
2026-09-09 6:45 ` [PATCH v6 12/13] drm: nova: Report GPU short " Alistair Popple
2026-09-09 6:45 ` [PATCH v6 13/13] drm: nova: Report GPU GID " 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=20260909064506.910162-10-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=gregkh@linuxfoundation.org \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mhenning@darkrefraction.com \
--cc=nova-gpu@lists.linux.dev \
--cc=rafael@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).