mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-30 21:52:21 +00:00

In 32-bit arm, the build fails with:
error[E0308]: mismatched types
--> drivers/gpu/drm/nova/file.rs:42:28
|
42 | getparam.set_value(value);
| --------- ^^^^^ expected `u64`, found `u32`
| |
| arguments to this method are incorrect
|
note: method defined here
--> drivers/gpu/drm/nova/uapi.rs:29:12
|
29 | pub fn set_value(&self, v: u64) {
| ^^^^^^^^^ ------
help: you can convert a `u32` to a `u64`
|
42 | getparam.set_value(value.into());
| +++++++
The reason is that `Getparam::set_value` takes a `u64` (from the UAPI),
but `pci::Device::resource_len()` returns a `resource_size_t`, which is a
`phys_addr_t`, which may be 32- or 64-bit.
Thus add an `into()` call to support the 32-bit case, while allowing the
Clippy lint that complains in the 64-bit case where the type is the same.
Fixes: cdeaeb9dd7
("drm: nova-drm: add initial driver skeleton")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com>
Link: https://lore.kernel.org/r/20250724165441.2105632-1-ojeda@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
76 lines
1.9 KiB
Rust
76 lines
1.9 KiB
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
use crate::driver::{NovaDevice, NovaDriver};
|
|
use crate::gem::NovaObject;
|
|
use crate::uapi::{GemCreate, GemInfo, Getparam};
|
|
use kernel::{
|
|
alloc::flags::*,
|
|
drm::{self, gem::BaseObject},
|
|
pci,
|
|
prelude::*,
|
|
types::Opaque,
|
|
uapi,
|
|
};
|
|
|
|
pub(crate) struct File;
|
|
|
|
impl drm::file::DriverFile for File {
|
|
type Driver = NovaDriver;
|
|
|
|
fn open(_dev: &NovaDevice) -> Result<Pin<KBox<Self>>> {
|
|
Ok(KBox::new(Self, GFP_KERNEL)?.into())
|
|
}
|
|
}
|
|
|
|
impl File {
|
|
/// IOCTL: get_param: Query GPU / driver metadata.
|
|
pub(crate) fn get_param(
|
|
dev: &NovaDevice,
|
|
getparam: &Opaque<uapi::drm_nova_getparam>,
|
|
_file: &drm::File<File>,
|
|
) -> Result<u32> {
|
|
let adev = &dev.adev;
|
|
let parent = adev.parent().ok_or(ENOENT)?;
|
|
let pdev: &pci::Device = parent.try_into()?;
|
|
let getparam: &Getparam = getparam.into();
|
|
|
|
let value = match getparam.param() as u32 {
|
|
uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => pdev.resource_len(1)?,
|
|
_ => return Err(EINVAL),
|
|
};
|
|
|
|
#[allow(clippy::useless_conversion)]
|
|
getparam.set_value(value.into());
|
|
|
|
Ok(0)
|
|
}
|
|
|
|
/// IOCTL: gem_create: Create a new DRM GEM object.
|
|
pub(crate) fn gem_create(
|
|
dev: &NovaDevice,
|
|
req: &Opaque<uapi::drm_nova_gem_create>,
|
|
file: &drm::File<File>,
|
|
) -> Result<u32> {
|
|
let req: &GemCreate = req.into();
|
|
let obj = NovaObject::new(dev, req.size().try_into()?)?;
|
|
|
|
req.set_handle(obj.create_handle(file)?);
|
|
|
|
Ok(0)
|
|
}
|
|
|
|
/// IOCTL: gem_info: Query GEM metadata.
|
|
pub(crate) fn gem_info(
|
|
_dev: &NovaDevice,
|
|
req: &Opaque<uapi::drm_nova_gem_info>,
|
|
file: &drm::File<File>,
|
|
) -> Result<u32> {
|
|
let req: &GemInfo = req.into();
|
|
let bo = NovaObject::lookup_handle(file, req.handle())?;
|
|
|
|
req.set_size(bo.size().try_into()?);
|
|
|
|
Ok(0)
|
|
}
|
|
}
|