Skip to content

Commit 38f6258

Browse files
committed
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 55bb501 commit 38f6258

File tree

3 files changed

+40
-26
lines changed

3 files changed

+40
-26
lines changed

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: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,22 @@ pub(crate) struct Queue {
9898
_sched: sched::Scheduler<QueueJob::ver>,
9999
entity: sched::Entity<QueueJob::ver>,
100100
vm: mmu::Vm,
101-
ualloc: Arc<Mutex<alloc::DefaultAllocator>>,
102101
q_vtx: Option<SubQueue::ver>,
103102
q_frag: Option<SubQueue::ver>,
104103
q_comp: Option<SubQueue::ver>,
104+
fence_ctx: FenceContexts,
105+
inner: QueueInner::ver,
106+
}
107+
108+
#[versions(AGX)]
109+
pub(crate) struct QueueInner {
110+
dev: AsahiDevRef,
111+
ualloc: Arc<Mutex<alloc::DefaultAllocator>>,
105112
buffer: Option<buffer::Buffer::ver>,
106113
gpu_context: Arc<workqueue::GpuContext>,
107114
notifier_list: Arc<GpuObject<fw::event::NotifierList>>,
108115
notifier: Arc<GpuObject<fw::event::Notifier::ver>>,
109116
id: u64,
110-
fence_ctx: FenceContexts,
111117
#[ver(V >= V13_0B4)]
112118
counter: AtomicU64,
113119
}
@@ -427,22 +433,26 @@ impl Queue::ver {
427433
_sched: sched,
428434
entity,
429435
vm,
430-
ualloc,
431436
q_vtx: None,
432437
q_frag: None,
433438
q_comp: None,
434-
gpu_context: Arc::try_new(workqueue::GpuContext::new(
435-
dev,
436-
alloc,
437-
buffer.as_ref().map(|b| b.any_ref()),
438-
)?)?,
439-
buffer,
440-
notifier_list: Arc::try_new(notifier_list)?,
441-
notifier,
442-
id,
443439
fence_ctx: FenceContexts::new(1, QUEUE_NAME, QUEUE_CLASS_KEY)?,
444-
#[ver(V >= V13_0B4)]
445-
counter: AtomicU64::new(0),
440+
inner: QueueInner::ver {
441+
dev: dev.into(),
442+
ualloc,
443+
gpu_context: Arc::try_new(workqueue::GpuContext::new(
444+
dev,
445+
alloc,
446+
buffer.as_ref().map(|b| b.any_ref()),
447+
)?)?,
448+
449+
buffer,
450+
notifier_list: Arc::try_new(notifier_list)?,
451+
notifier,
452+
id,
453+
#[ver(V >= V13_0B4)]
454+
counter: AtomicU64::new(0),
455+
},
446456
};
447457

448458
// Rendering structures
@@ -452,15 +462,19 @@ impl Queue::ver {
452462
*crate::initial_tvb_size.read(&lock)
453463
};
454464

455-
ret.buffer.as_ref().unwrap().ensure_blocks(tvb_blocks)?;
465+
ret.inner
466+
.buffer
467+
.as_ref()
468+
.unwrap()
469+
.ensure_blocks(tvb_blocks)?;
456470

457471
ret.q_vtx = Some(SubQueue::ver {
458472
wq: workqueue::WorkQueue::ver::new(
459473
dev,
460474
alloc,
461475
event_manager.clone(),
462-
ret.gpu_context.clone(),
463-
ret.notifier_list.clone(),
476+
ret.inner.gpu_context.clone(),
477+
ret.inner.notifier_list.clone(),
464478
channel::PipeType::Vertex,
465479
id,
466480
priority,
@@ -480,8 +494,8 @@ impl Queue::ver {
480494
dev,
481495
alloc,
482496
event_manager.clone(),
483-
ret.gpu_context.clone(),
484-
ret.notifier_list.clone(),
497+
ret.inner.gpu_context.clone(),
498+
ret.inner.notifier_list.clone(),
485499
channel::PipeType::Fragment,
486500
id,
487501
priority,
@@ -497,8 +511,8 @@ impl Queue::ver {
497511
dev,
498512
alloc,
499513
event_manager,
500-
ret.gpu_context.clone(),
501-
ret.notifier_list.clone(),
514+
ret.inner.gpu_context.clone(),
515+
ret.inner.notifier_list.clone(),
502516
channel::PipeType::Compute,
503517
id,
504518
priority,
@@ -727,7 +741,7 @@ impl Queue for Queue::ver {
727741

728742
match cmd.cmd_type {
729743
uapi::drm_asahi_cmd_type_DRM_ASAHI_CMD_RENDER => {
730-
self.submit_render(
744+
self.inner.submit_render(
731745
&mut job,
732746
&cmd,
733747
result_writer,
@@ -745,7 +759,7 @@ impl Queue for Queue::ver {
745759
))?;
746760
}
747761
uapi::drm_asahi_cmd_type_DRM_ASAHI_CMD_COMPUTE => {
748-
self.submit_compute(
762+
self.inner.submit_compute(
749763
&mut job,
750764
&cmd,
751765
result_writer,
@@ -792,6 +806,6 @@ impl Queue for Queue::ver {
792806
#[versions(AGX)]
793807
impl Drop for Queue::ver {
794808
fn drop(&mut self) {
795-
mod_dev_dbg!(self.dev, "[Queue {}] Dropping queue\n", self.id);
809+
mod_dev_dbg!(self.dev, "[Queue {}] Dropping queue\n", self.inner.id);
796810
}
797811
}

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)