mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
drm: nova: Add DRM registration data
Currently the nova-drm stub driver doesn't really interact with a real device, so it doesn't have any registration data and has no way to call into nova-core. To allow for this add a DrmRegData type which will hold a NovaCoreApiHandle for the NovaCoreApi associated with the auxbus device. Signed-off-by: Alistair Popple <apopple@nvidia.com> Suggested-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260909064506.910162-4-apopple@nvidia.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
6e70b17199
commit
ecedc604e0
|
|
@ -18,6 +18,11 @@
|
|||
use crate::file::File;
|
||||
use crate::gem::NovaObject;
|
||||
|
||||
use nova_core::api::{
|
||||
NovaCoreApi,
|
||||
NovaCoreApiHandle, //
|
||||
};
|
||||
|
||||
pub(crate) struct NovaDriver;
|
||||
|
||||
pub(crate) struct Nova<'bound> {
|
||||
|
|
@ -26,6 +31,12 @@ pub(crate) struct Nova<'bound> {
|
|||
_reg: drm::Registration<'bound, NovaDriver>,
|
||||
}
|
||||
|
||||
/// DRM registration data, accessible from ioctl handlers via the registration guard.
|
||||
pub(crate) struct DrmRegData<'bound> {
|
||||
#[expect(unused)]
|
||||
pub(crate) api: NovaCoreApiHandle<'bound>,
|
||||
}
|
||||
|
||||
/// Convienence type alias for the DRM device type for this driver
|
||||
pub(crate) type NovaDevice<Ctx = drm::Normal> = drm::Device<NovaDriver, Ctx>;
|
||||
|
||||
|
|
@ -59,9 +70,12 @@ fn probe<'bound>(
|
|||
_info: &'bound Self::IdInfo,
|
||||
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
|
||||
let drm = drm::UnregisteredDevice::<Self>::new(adev, Ok(()))?;
|
||||
let reg_data = DrmRegData {
|
||||
api: NovaCoreApi::of(adev)?,
|
||||
};
|
||||
// SAFETY: `reg` is stored in `Nova` and dropped when the driver is unbound; it is
|
||||
// never forgotten.
|
||||
let reg = unsafe { drm::Registration::new(adev.as_ref(), drm, (), 0)? };
|
||||
let reg = unsafe { drm::Registration::new(adev.as_ref(), drm, reg_data, 0)? };
|
||||
|
||||
Ok(Nova {
|
||||
drm: reg.device().into(),
|
||||
|
|
@ -73,7 +87,7 @@ fn probe<'bound>(
|
|||
#[vtable]
|
||||
impl drm::Driver for NovaDriver {
|
||||
type Data = ();
|
||||
type RegistrationData<'a> = ();
|
||||
type RegistrationData<'a> = DrmRegData<'a>;
|
||||
type File = File;
|
||||
type Object = gem::Object<NovaObject>;
|
||||
type ParentDevice<Ctx: DeviceContext> = auxiliary::Device<Ctx>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
use crate::driver::{NovaDevice, NovaDriver};
|
||||
use crate::driver::{
|
||||
DrmRegData,
|
||||
NovaDevice,
|
||||
NovaDriver, //
|
||||
};
|
||||
use crate::gem::NovaObject;
|
||||
use kernel::{
|
||||
alloc::flags::*,
|
||||
|
|
@ -30,7 +34,7 @@ impl File {
|
|||
/// IOCTL: get_param: Query GPU / driver metadata.
|
||||
pub(crate) fn get_param(
|
||||
dev: &NovaDevice<Registered>,
|
||||
_reg_data: &(),
|
||||
_reg_data: &DrmRegData<'_>,
|
||||
getparam: &mut uapi::drm_nova_getparam,
|
||||
_file: &drm::File<File>,
|
||||
) -> Result<u32> {
|
||||
|
|
@ -50,7 +54,7 @@ pub(crate) fn get_param(
|
|||
/// IOCTL: gem_create: Create a new DRM GEM object.
|
||||
pub(crate) fn gem_create(
|
||||
dev: &NovaDevice<Registered>,
|
||||
_reg_data: &(),
|
||||
_reg_data: &DrmRegData<'_>,
|
||||
req: &mut uapi::drm_nova_gem_create,
|
||||
file: &drm::File<File>,
|
||||
) -> Result<u32> {
|
||||
|
|
@ -64,7 +68,7 @@ pub(crate) fn gem_create(
|
|||
/// IOCTL: gem_info: Query GEM metadata.
|
||||
pub(crate) fn gem_info(
|
||||
_dev: &NovaDevice<Registered>,
|
||||
_reg_data: &(),
|
||||
_reg_data: &DrmRegData<'_>,
|
||||
req: &mut uapi::drm_nova_gem_info,
|
||||
file: &drm::File<File>,
|
||||
) -> Result<u32> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user