mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter
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. Suggested-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Alistair Popple <apopple@nvidia.com> Link: https://patch.msgid.link/20260909064506.910162-10-apopple@nvidia.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
d9886a1a06
commit
7edc491f6f
|
|
@ -8,8 +8,6 @@
|
|||
use crate::gem::NovaObject;
|
||||
use kernel::{
|
||||
alloc::flags::*,
|
||||
auxiliary,
|
||||
device::Bound,
|
||||
drm::{
|
||||
self,
|
||||
gem::BaseObject,
|
||||
|
|
@ -19,7 +17,6 @@
|
|||
arch::IntoSafeCastArch,
|
||||
IntoSafeCast, //
|
||||
},
|
||||
pci,
|
||||
prelude::*,
|
||||
transmute::AsBytes,
|
||||
uaccess::UserSlice,
|
||||
|
|
@ -85,16 +82,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.try_into()? {
|
||||
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),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ fn probe<'bound>(
|
|||
// never recycles IDs.
|
||||
AUXILIARY_ID_COUNTER.fetch_add(1, Relaxed),
|
||||
crate::MODULE_NAME,
|
||||
NovaCoreApi { gpu },
|
||||
NovaCoreApi { gpu, pdev },
|
||||
)?
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user