Skip to content

Commit 450dfde

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 6414e0d commit 450dfde

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
@@ -20,7 +20,7 @@ use crate::fw::workqueue::*;
2020
use crate::no_debug;
2121
use crate::object::OpaqueGpuObject;
2222
use crate::regs::FaultReason;
23-
use crate::{channel, driver, event, fw, gpu, object, regs};
23+
use crate::{channel, driver, event, fw, gpu, regs};
2424
use core::any::Any;
2525
use core::num::NonZeroU64;
2626
use core::sync::atomic::Ordering;
@@ -36,6 +36,10 @@ use kernel::{
3636
workqueue::{self, impl_has_work, new_work, Work, WorkItem},
3737
};
3838

39+
pub(crate) trait OpaqueCommandObject: OpaqueGpuObject {}
40+
41+
impl<T: GpuStruct + Sync + Send> OpaqueCommandObject for GpuObject<T> where T: Command {}
42+
3943
const DEBUG_CLASS: DebugFlags = DebugFlags::WorkQueue;
4044

4145
const MAX_JOB_SLOTS: u32 = 127;
@@ -151,7 +155,7 @@ impl Drop for GpuContext {
151155

152156
struct SubmittedWork<O, C>
153157
where
154-
O: OpaqueGpuObject,
158+
O: OpaqueCommandObject,
155159
C: FnOnce(&mut O, Option<WorkError>) + Send + Sync + 'static,
156160
{
157161
object: O,
@@ -199,7 +203,7 @@ impl SubmittedWorkContainer {
199203
}
200204
}
201205

202-
impl<O: OpaqueGpuObject, C: FnOnce(&mut O, Option<WorkError>) + Send + Sync> GenSubmittedWork
206+
impl<O: OpaqueCommandObject, C: FnOnce(&mut O, Option<WorkError>) + Send + Sync> GenSubmittedWork
203207
for SubmittedWork<O, C>
204208
{
205209
fn gpu_va(&self) -> NonZeroU64 {
@@ -326,15 +330,15 @@ impl Job::ver {
326330
self.event_info.value.increment();
327331
}
328332

329-
pub(crate) fn add<O: object::OpaqueGpuObject + 'static>(
333+
pub(crate) fn add<O: OpaqueCommandObject + 'static>(
330334
&mut self,
331335
command: O,
332336
vm_slot: u32,
333337
) -> Result {
334338
self.add_cb(command, vm_slot, |_, _| {})
335339
}
336340

337-
pub(crate) fn add_cb<O: object::OpaqueGpuObject + 'static>(
341+
pub(crate) fn add_cb<O: OpaqueCommandObject + 'static>(
338342
&mut self,
339343
command: O,
340344
vm_slot: u32,

0 commit comments

Comments
 (0)