Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/tyr: Clarify driver/device type names

Currently the `TyrDriver` struct implements both `platform::Driver` and
`drm::Driver`. For clarity, split up these two roles:
- Introduce `TyrPlatformDriverData` to implement `platform::Driver`, and
- Introduce `TyrDrmDriver` to implement `drm::Driver`.

Also rename other variables to reflect their roles in the DRM context:
- Rename `TyrDevice` to `TyrDrmDevice`
- Rename `TyrData` to `TyrDrmDeviceData`
- Rename `File` to `TyrDrmFileData`
- Rename `DrmFile` to `TyrDrmFile`

No functional changes are intended.

Co-developed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Link: https://patch.msgid.link/20260224002314.344675-1-deborah.brouwer@collabora.com
Signed-off-by: Alice Ryhl <aliceryhl@google.com>

authored by

Deborah Brouwer and committed by
Alice Ryhl
15da5bc9 6ca4bcc2

+36 -40
+21 -19
drivers/gpu/drm/tyr/driver.rs
··· 30 30 }; 31 31 32 32 use crate::{ 33 - file::File, 33 + file::TyrDrmFileData, 34 34 gem::TyrObject, 35 35 gpu, 36 36 gpu::GpuInfo, ··· 39 39 40 40 pub(crate) type IoMem = kernel::io::mem::IoMem<SZ_2M>; 41 41 42 + pub(crate) struct TyrDrmDriver; 43 + 42 44 /// Convenience type alias for the DRM device type for this driver. 43 - pub(crate) type TyrDevice = drm::Device<TyrDriver>; 45 + pub(crate) type TyrDrmDevice = drm::Device<TyrDrmDriver>; 44 46 45 47 #[pin_data(PinnedDrop)] 46 - pub(crate) struct TyrDriver { 47 - _device: ARef<TyrDevice>, 48 + pub(crate) struct TyrPlatformDriverData { 49 + _device: ARef<TyrDrmDevice>, 48 50 } 49 51 50 52 #[pin_data(PinnedDrop)] 51 - pub(crate) struct TyrData { 53 + pub(crate) struct TyrDrmDeviceData { 52 54 pub(crate) pdev: ARef<platform::Device>, 53 55 54 56 #[pin] ··· 73 71 // that it will be removed in a future patch. 74 72 // 75 73 // SAFETY: This will be removed in a future patch. 76 - unsafe impl Send for TyrData {} 74 + unsafe impl Send for TyrDrmDeviceData {} 77 75 // SAFETY: This will be removed in a future patch. 78 - unsafe impl Sync for TyrData {} 76 + unsafe impl Sync for TyrDrmDeviceData {} 79 77 80 78 fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result { 81 79 regs::GPU_CMD.write(dev, iomem, regs::GPU_CMD_SOFT_RESET)?; ··· 94 92 kernel::of_device_table!( 95 93 OF_TABLE, 96 94 MODULE_OF_TABLE, 97 - <TyrDriver as platform::Driver>::IdInfo, 95 + <TyrPlatformDriverData as platform::Driver>::IdInfo, 98 96 [ 99 97 (of::DeviceId::new(c"rockchip,rk3588-mali"), ()), 100 98 (of::DeviceId::new(c"arm,mali-valhall-csf"), ()) 101 99 ] 102 100 ); 103 101 104 - impl platform::Driver for TyrDriver { 102 + impl platform::Driver for TyrPlatformDriverData { 105 103 type IdInfo = (); 106 104 const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE); 107 105 ··· 131 129 132 130 let platform: ARef<platform::Device> = pdev.into(); 133 131 134 - let data = try_pin_init!(TyrData { 132 + let data = try_pin_init!(TyrDrmDeviceData { 135 133 pdev: platform.clone(), 136 134 clks <- new_mutex!(Clocks { 137 135 core: core_clk, ··· 145 143 gpu_info, 146 144 }); 147 145 148 - let tdev: ARef<TyrDevice> = drm::Device::new(pdev.as_ref(), data)?; 149 - drm::driver::Registration::new_foreign_owned(&tdev, pdev.as_ref(), 0)?; 146 + let ddev: ARef<TyrDrmDevice> = drm::Device::new(pdev.as_ref(), data)?; 147 + drm::driver::Registration::new_foreign_owned(&ddev, pdev.as_ref(), 0)?; 150 148 151 - let driver = TyrDriver { _device: tdev }; 149 + let driver = TyrPlatformDriverData { _device: ddev }; 152 150 153 151 // We need this to be dev_info!() because dev_dbg!() does not work at 154 152 // all in Rust for now, and we need to see whether probe succeeded. ··· 158 156 } 159 157 160 158 #[pinned_drop] 161 - impl PinnedDrop for TyrDriver { 159 + impl PinnedDrop for TyrPlatformDriverData { 162 160 fn drop(self: Pin<&mut Self>) {} 163 161 } 164 162 165 163 #[pinned_drop] 166 - impl PinnedDrop for TyrData { 164 + impl PinnedDrop for TyrDrmDeviceData { 167 165 fn drop(self: Pin<&mut Self>) { 168 166 // TODO: the type-state pattern for Clks will fix this. 169 167 let clks = self.clks.lock(); ··· 184 182 }; 185 183 186 184 #[vtable] 187 - impl drm::Driver for TyrDriver { 188 - type Data = TyrData; 189 - type File = File; 185 + impl drm::Driver for TyrDrmDriver { 186 + type Data = TyrDrmDeviceData; 187 + type File = TyrDrmFileData; 190 188 type Object = drm::gem::Object<TyrObject>; 191 189 192 190 const INFO: drm::DriverInfo = INFO; 193 191 194 192 kernel::declare_drm_ioctls! { 195 - (PANTHOR_DEV_QUERY, drm_panthor_dev_query, ioctl::RENDER_ALLOW, File::dev_query), 193 + (PANTHOR_DEV_QUERY, drm_panthor_dev_query, ioctl::RENDER_ALLOW, TyrDrmFileData::dev_query), 196 194 } 197 195 } 198 196
+10 -13
drivers/gpu/drm/tyr/file.rs
··· 7 7 uapi, // 8 8 }; 9 9 10 - use crate::{ 11 - driver::TyrDevice, 12 - TyrDriver, // 13 - }; 10 + use crate::driver::TyrDrmDriver; 14 11 15 12 #[pin_data] 16 - pub(crate) struct File {} 13 + pub(crate) struct TyrDrmFileData {} 17 14 18 15 /// Convenience type alias for our DRM `File` type 19 - pub(crate) type DrmFile = drm::file::File<File>; 16 + pub(crate) type TyrDrmFile = drm::file::File<TyrDrmFileData>; 20 17 21 - impl drm::file::DriverFile for File { 22 - type Driver = TyrDriver; 18 + impl drm::file::DriverFile for TyrDrmFileData { 19 + type Driver = TyrDrmDriver; 23 20 24 21 fn open(_dev: &drm::Device<Self::Driver>) -> Result<Pin<KBox<Self>>> { 25 22 KBox::try_pin_init(try_pin_init!(Self {}), GFP_KERNEL) 26 23 } 27 24 } 28 25 29 - impl File { 26 + impl TyrDrmFileData { 30 27 pub(crate) fn dev_query( 31 - tdev: &TyrDevice, 28 + ddev: &drm::Device<TyrDrmDriver>, 32 29 devquery: &mut uapi::drm_panthor_dev_query, 33 - _file: &DrmFile, 30 + _file: &TyrDrmFile, 34 31 ) -> Result<u32> { 35 32 if devquery.pointer == 0 { 36 33 match devquery.type_ { 37 34 uapi::drm_panthor_dev_query_type_DRM_PANTHOR_DEV_QUERY_GPU_INFO => { 38 - devquery.size = core::mem::size_of_val(&tdev.gpu_info) as u32; 35 + devquery.size = core::mem::size_of_val(&ddev.gpu_info) as u32; 39 36 Ok(0) 40 37 } 41 38 _ => Err(EINVAL), ··· 46 49 ) 47 50 .writer(); 48 51 49 - writer.write(&tdev.gpu_info)?; 52 + writer.write(&ddev.gpu_info)?; 50 53 51 54 Ok(0) 52 55 }
+3 -6
drivers/gpu/drm/tyr/gem.rs
··· 5 5 prelude::*, // 6 6 }; 7 7 8 - use crate::driver::{ 9 - TyrDevice, 10 - TyrDriver, // 11 - }; 8 + use crate::driver::TyrDrmDriver; 12 9 13 10 /// GEM Object inner driver data 14 11 #[pin_data] 15 12 pub(crate) struct TyrObject {} 16 13 17 14 impl gem::DriverObject for TyrObject { 18 - type Driver = TyrDriver; 15 + type Driver = TyrDrmDriver; 19 16 20 - fn new(_dev: &TyrDevice, _size: usize) -> impl PinInit<Self, Error> { 17 + fn new(_dev: &kernel::drm::Device<TyrDrmDriver>, _size: usize) -> impl PinInit<Self, Error> { 21 18 try_pin_init!(TyrObject {}) 22 19 } 23 20 }
+2 -2
drivers/gpu/drm/tyr/tyr.rs
··· 5 5 //! The name "Tyr" is inspired by Norse mythology, reflecting Arm's tradition of 6 6 //! naming their GPUs after Nordic mythological figures and places. 7 7 8 - use crate::driver::TyrDriver; 8 + use crate::driver::TyrPlatformDriverData; 9 9 10 10 mod driver; 11 11 mod file; ··· 14 14 mod regs; 15 15 16 16 kernel::module_platform_driver! { 17 - type: TyrDriver, 17 + type: TyrPlatformDriverData, 18 18 name: "tyr", 19 19 authors: ["The Tyr driver authors"], 20 20 description: "Arm Mali Tyr DRM driver",