Skip to content

Commit 3a2c375

Browse files
hoshinolinajannau
authored andcommitted
drm/asahi: workqueue: Restrict command objects to only job commands
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent a2c5332 commit 3a2c375

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/gpu/drm/asahi/workqueue.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::fw::workqueue::*;
2121
use crate::no_debug;
2222
use crate::object::OpaqueGpuObject;
2323
use crate::regs::FaultReason;
24-
use crate::{channel, driver, event, fw, gpu, object, regs};
24+
use crate::{channel, driver, event, fw, gpu, regs};
2525
use core::any::Any;
2626
use core::num::NonZeroU64;
2727
use core::sync::atomic::Ordering;
@@ -38,6 +38,10 @@ use kernel::{
3838
workqueue::{self, impl_has_work, new_work, Work, WorkItem},
3939
};
4040

41+
pub(crate) trait OpaqueCommandObject: OpaqueGpuObject {}
42+
43+
impl<T: GpuStruct + Sync + Send> OpaqueCommandObject for GpuObject<T> where T: Command {}
44+
4145
const DEBUG_CLASS: DebugFlags = DebugFlags::WorkQueue;
4246

4347
const MAX_JOB_SLOTS: u32 = 127;
@@ -154,7 +158,7 @@ impl Drop for GpuContext {
154158

155159
struct SubmittedWork<O, C>
156160
where
157-
O: OpaqueGpuObject,
161+
O: OpaqueCommandObject,
158162
C: FnOnce(&mut O, Option<WorkError>) + Send + Sync + 'static,
159163
{
160164
object: O,
@@ -202,7 +206,7 @@ impl SubmittedWorkContainer {
202206
}
203207
}
204208

205-
impl<O: OpaqueGpuObject, C: FnOnce(&mut O, Option<WorkError>) + Send + Sync> GenSubmittedWork
209+
impl<O: OpaqueCommandObject, C: FnOnce(&mut O, Option<WorkError>) + Send + Sync> GenSubmittedWork
206210
for SubmittedWork<O, C>
207211
{
208212
fn gpu_va(&self) -> NonZeroU64 {
@@ -329,15 +333,15 @@ impl Job::ver {
329333
self.event_info.value.increment();
330334
}
331335

332-
pub(crate) fn add<O: object::OpaqueGpuObject + 'static>(
336+
pub(crate) fn add<O: OpaqueCommandObject + 'static>(
333337
&mut self,
334338
command: O,
335339
vm_slot: u32,
336340
) -> Result {
337341
self.add_cb(command, vm_slot, |_, _| {})
338342
}
339343

340-
pub(crate) fn add_cb<O: object::OpaqueGpuObject + 'static>(
344+
pub(crate) fn add_cb<O: OpaqueCommandObject + 'static>(
341345
&mut self,
342346
command: O,
343347
vm_slot: u32,

0 commit comments

Comments
 (0)