Skip to content

Commit 866183c

Browse files
hoshinolinajannau
authored andcommitted
drm/asahi: queue: Split into Queue and QueueInner
Work around mutability issues when entity.new_job() takes a mutable reference to the entity by moving all the fields used by the submit_render() and submit_compute() functions to an inner struct, eliminating the double-mutable-borrow. Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent e27b2bf commit 866183c

3 files changed

Lines changed: 39 additions & 26 deletions

File tree

drivers/gpu/drm/asahi/queue/compute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use kernel::user_ptr::UserSlicePtr;
2727
const DEBUG_CLASS: DebugFlags = DebugFlags::Compute;
2828

2929
#[versions(AGX)]
30-
impl super::Queue::ver {
30+
impl super::QueueInner::ver {
3131
/// Submit work to a compute queue.
3232
pub(super) fn submit_compute(
3333
&self,

drivers/gpu/drm/asahi/queue/mod.rs

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,22 @@ pub(crate) struct Queue {
9999
_sched: sched::Scheduler<QueueJob::ver>,
100100
entity: sched::Entity<QueueJob::ver>,
101101
vm: mmu::Vm,
102-
ualloc: Arc<Mutex<alloc::DefaultAllocator>>,
103102
q_vtx: Option<SubQueue::ver>,
104103
q_frag: Option<SubQueue::ver>,
105104
q_comp: Option<SubQueue::ver>,
105+
fence_ctx: FenceContexts,
106+
inner: QueueInner::ver,
107+
}
108+
109+
#[versions(AGX)]
110+
pub(crate) struct QueueInner {
111+
dev: AsahiDevRef,
112+
ualloc: Arc<Mutex<alloc::DefaultAllocator>>,
106113
buffer: Option<buffer::Buffer::ver>,
107114
gpu_context: Arc<workqueue::GpuContext>,
108115
notifier_list: Arc<GpuObject<fw::event::NotifierList>>,
109116
notifier: Arc<GpuObject<fw::event::Notifier::ver>>,
110117
id: u64,
111-
fence_ctx: FenceContexts,
112118
#[ver(V >= V13_0B4)]
113119
counter: AtomicU64,
114120
}
@@ -430,22 +436,25 @@ impl Queue::ver {
430436
_sched: sched,
431437
entity,
432438
vm,
433-
ualloc,
434439
q_vtx: None,
435440
q_frag: None,
436441
q_comp: None,
437-
gpu_context: Arc::try_new(workqueue::GpuContext::new(
438-
dev,
439-
alloc,
440-
buffer.as_ref().map(|b| b.any_ref()),
441-
)?)?,
442-
buffer,
443-
notifier_list: Arc::try_new(notifier_list)?,
444-
notifier,
445-
id,
446442
fence_ctx: FenceContexts::new(1, QUEUE_NAME, QUEUE_CLASS_KEY)?,
447-
#[ver(V >= V13_0B4)]
448-
counter: AtomicU64::new(0),
443+
inner: QueueInner::ver {
444+
dev: dev.into(),
445+
ualloc,
446+
gpu_context: Arc::new(
447+
workqueue::GpuContext::new(dev, alloc, buffer.as_ref().map(|b| b.any_ref()))?,
448+
GFP_KERNEL,
449+
)?,
450+
451+
buffer,
452+
notifier_list: Arc::new(notifier_list, GFP_KERNEL)?,
453+
notifier,
454+
id,
455+
#[ver(V >= V13_0B4)]
456+
counter: AtomicU64::new(0),
457+
},
449458
};
450459

451460
// Rendering structures
@@ -455,15 +464,19 @@ impl Queue::ver {
455464
*crate::initial_tvb_size.read(&lock)
456465
};
457466

458-
ret.buffer.as_ref().unwrap().ensure_blocks(tvb_blocks)?;
467+
ret.inner
468+
.buffer
469+
.as_ref()
470+
.unwrap()
471+
.ensure_blocks(tvb_blocks)?;
459472

460473
ret.q_vtx = Some(SubQueue::ver {
461474
wq: workqueue::WorkQueue::ver::new(
462475
dev,
463476
alloc,
464477
event_manager.clone(),
465-
ret.gpu_context.clone(),
466-
ret.notifier_list.clone(),
478+
ret.inner.gpu_context.clone(),
479+
ret.inner.notifier_list.clone(),
467480
channel::PipeType::Vertex,
468481
id,
469482
priority,
@@ -483,8 +496,8 @@ impl Queue::ver {
483496
dev,
484497
alloc,
485498
event_manager.clone(),
486-
ret.gpu_context.clone(),
487-
ret.notifier_list.clone(),
499+
ret.inner.gpu_context.clone(),
500+
ret.inner.notifier_list.clone(),
488501
channel::PipeType::Fragment,
489502
id,
490503
priority,
@@ -500,8 +513,8 @@ impl Queue::ver {
500513
dev,
501514
alloc,
502515
event_manager,
503-
ret.gpu_context.clone(),
504-
ret.notifier_list.clone(),
516+
ret.inner.gpu_context.clone(),
517+
ret.inner.notifier_list.clone(),
505518
channel::PipeType::Compute,
506519
id,
507520
priority,
@@ -736,7 +749,7 @@ impl Queue for Queue::ver {
736749

737750
match cmd.cmd_type {
738751
uapi::drm_asahi_cmd_type_DRM_ASAHI_CMD_RENDER => {
739-
self.submit_render(
752+
self.inner.submit_render(
740753
&mut job,
741754
&cmd,
742755
result_writer,
@@ -757,7 +770,7 @@ impl Queue for Queue::ver {
757770
)?;
758771
}
759772
uapi::drm_asahi_cmd_type_DRM_ASAHI_CMD_COMPUTE => {
760-
self.submit_compute(
773+
self.inner.submit_compute(
761774
&mut job,
762775
&cmd,
763776
result_writer,
@@ -807,6 +820,6 @@ impl Queue for Queue::ver {
807820
#[versions(AGX)]
808821
impl Drop for Queue::ver {
809822
fn drop(&mut self) {
810-
mod_dev_dbg!(self.dev, "[Queue {}] Dropping queue\n", self.id);
823+
mod_dev_dbg!(self.dev, "[Queue {}] Dropping queue\n", self.inner.id);
811824
}
812825
}

drivers/gpu/drm/asahi/queue/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl RenderResult {
6868
}
6969

7070
#[versions(AGX)]
71-
impl super::Queue::ver {
71+
impl super::QueueInner::ver {
7272
/// Get the appropriate tiling parameters for a given userspace command buffer.
7373
fn get_tiling_params(
7474
cmdbuf: &uapi::drm_asahi_cmd_render,

0 commit comments

Comments
 (0)