Skip to content

Commit c669504

Browse files
committed
drm/asahi: New Mutex style
Signed-off-by: Asahi Lina <[email protected]>
1 parent e24176f commit c669504

6 files changed

Lines changed: 30 additions & 31 deletions

File tree

drivers/gpu/drm/asahi/buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use crate::{alloc, fw, gpu, hw, mmu, slotalloc};
4040
use core::sync::atomic::Ordering;
4141
use kernel::prelude::*;
4242
use kernel::sync::{Arc, Mutex};
43-
use kernel::{c_str, new_mutex, static_lock_class};
43+
use kernel::{c_str, static_lock_class};
4444

4545
const DEBUG_CLASS: DebugFlags = DebugFlags::Buffer;
4646

@@ -394,7 +394,7 @@ impl Buffer::ver {
394394
})?;
395395

396396
Ok(Buffer::ver {
397-
inner: Arc::pin_init(new_mutex!(BufferInner::ver {
397+
inner: Arc::pin_init(Mutex::new(BufferInner::ver {
398398
info,
399399
ualloc,
400400
ualloc_priv,

drivers/gpu/drm/asahi/file.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use kernel::io_buffer::{IoBufferReader, IoBufferWriter};
1717
use kernel::prelude::*;
1818
use kernel::sync::{Arc, Mutex};
1919
use kernel::user_ptr::UserSlicePtr;
20-
use kernel::{dma_fence, drm, new_mutex, uapi, xarray};
20+
use kernel::{dma_fence, drm, uapi, xarray};
2121

2222
const DEBUG_CLASS: DebugFlags = DebugFlags::File;
2323

@@ -287,7 +287,7 @@ impl File {
287287
file_id,
288288
id
289289
);
290-
let ualloc = Arc::pin_init(new_mutex!(alloc::DefaultAllocator::new(
290+
let ualloc = Arc::pin_init(Mutex::new(alloc::DefaultAllocator::new(
291291
device,
292292
&vm,
293293
VM_DRV_GPU_START,
@@ -299,7 +299,7 @@ impl File {
299299
fmt!("File {} VM {} GPU Shared", file_id, id),
300300
false,
301301
)?))?;
302-
let ualloc_priv = Arc::pin_init(new_mutex!(alloc::DefaultAllocator::new(
302+
let ualloc_priv = Arc::pin_init(Mutex::new(alloc::DefaultAllocator::new(
303303
device,
304304
&vm,
305305
VM_DRV_GPUFW_START,
@@ -605,7 +605,7 @@ impl File {
605605
.new_queue(vm, ualloc, ualloc_priv, data.priority, data.queue_caps)?;
606606

607607
data.queue_id = resv.index().try_into()?;
608-
resv.store(Arc::pin_init(new_mutex!(queue))?)?;
608+
resv.store(Arc::pin_init(Mutex::new(queue))?)?;
609609

610610
Ok(0)
611611
}

drivers/gpu/drm/asahi/gem.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use kernel::{
1111
drm::{gem, gem::shmem},
1212
error::Result,
13-
new_mutex,
1413
prelude::*,
1514
soc::apple::rtkit,
1615
sync::Mutex,
@@ -271,7 +270,7 @@ impl gem::BaseDriverObject<Object> for DriverObject {
271270
kernel: false,
272271
flags: 0,
273272
vm_id: None,
274-
mappings <- new_mutex!(Vec::new()),
273+
mappings <- Mutex::new(Vec::new()),
275274
id,
276275
})
277276
}

drivers/gpu/drm/asahi/gpu.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ use core::sync::atomic::{AtomicBool, AtomicU64, Ordering};
1616
use core::time::Duration;
1717

1818
use kernel::{
19+
c_str,
1920
delay::coarse_sleep,
2021
error::code::*,
2122
macros::versions,
22-
new_mutex,
2323
prelude::*,
2424
soc::apple::rtkit,
2525
sync::{
@@ -589,17 +589,17 @@ impl GpuManager::ver {
589589
};
590590

591591
for _i in 0..=NUM_PIPES - 1 {
592-
pipes.vtx.try_push(Box::pin_init(new_mutex!(
592+
pipes.vtx.try_push(Box::pin_init(Mutex::new_named(
593593
channel::PipeChannel::ver::new(dev, &mut alloc)?,
594-
"pipe_vtx",
594+
c_str!("pipe_vtx"),
595595
))?)?;
596-
pipes.frag.try_push(Box::pin_init(new_mutex!(
596+
pipes.frag.try_push(Box::pin_init(Mutex::new_named(
597597
channel::PipeChannel::ver::new(dev, &mut alloc)?,
598-
"pipe_frag",
598+
c_str!("pipe_frag"),
599599
))?)?;
600-
pipes.comp.try_push(Box::pin_init(new_mutex!(
600+
pipes.comp.try_push(Box::pin_init(Mutex::new_named(
601601
channel::PipeChannel::ver::new(dev, &mut alloc)?,
602-
"pipe_comp",
602+
c_str!("pipe_comp"),
603603
))?)?;
604604
}
605605

@@ -626,18 +626,18 @@ impl GpuManager::ver {
626626
initdata: *initdata,
627627
uat: *uat,
628628
io_mappings: Vec::new(),
629-
rtkit <- new_mutex!(None, "rtkit"),
629+
rtkit <- Mutex::new_named(None, c_str!("rtkit")),
630630
crashed: AtomicBool::new(false),
631631
event_manager,
632-
alloc <- new_mutex!(alloc, "alloc"),
633-
fwctl_channel <- new_mutex!(fwctl_channel, "fwctl_channel"),
634-
rx_channels <- new_mutex!(*rx_channels, "rx_channels"),
635-
tx_channels <- new_mutex!(*tx_channels, "tx_channels"),
632+
alloc <- Mutex::new_named(alloc, c_str!("alloc")),
633+
fwctl_channel <- Mutex::new_named(fwctl_channel, c_str!("fwctl_channel")),
634+
rx_channels <- Mutex::new_named(*rx_channels, c_str!("rx_channels")),
635+
tx_channels <- Mutex::new_named(*tx_channels, c_str!("tx_channels")),
636636
pipes,
637637
buffer_mgr: buffer::BufferManager::new()?,
638638
ids: Default::default(),
639-
garbage_work <- new_mutex!(Vec::new(), "garbage_work"),
640-
garbage_contexts <- new_mutex!(Vec::new(), "garbage_contexts"),
639+
garbage_work <- Mutex::new_named(Vec::new(), c_str!("garbage_work")),
640+
garbage_contexts <- Mutex::new_named(Vec::new(), c_str!("garbage_contexts")),
641641
}))?;
642642

643643
Ok(x)

drivers/gpu/drm/asahi/mmu.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use kernel::{
2222
error::{to_result, Result},
2323
io_pgtable,
2424
io_pgtable::{prot, AppleUAT, IoPageTable},
25-
new_mutex,
2625
prelude::*,
2726
static_lock_class,
2827
sync::{
@@ -799,7 +798,7 @@ impl Vm {
799798
Ok(Vm {
800799
id,
801800
file_id,
802-
inner: Arc::pin_init(new_mutex!(
801+
inner: Arc::pin_init(Mutex::new_named(
803802
VmInner {
804803
dev: dev.into(),
805804
min_va,
@@ -813,7 +812,7 @@ impl Vm {
813812
active_users: 0,
814813
id,
815814
},
816-
"VmInner"
815+
c_str!("VmInner"),
817816
))?,
818817
})
819818
}
@@ -1177,16 +1176,16 @@ impl Uat {
11771176

11781177
Arc::pin_init(try_pin_init!(UatInner {
11791178
handoff_flush <- init::pin_init_array_from_fn(|i| {
1180-
new_mutex!(HandoffFlush(&handoff.flush[i]), "handoff_flush")
1179+
Mutex::new_named(HandoffFlush(&handoff.flush[i]), c_str!("handoff_flush"))
11811180
}),
1182-
shared <- new_mutex!(
1181+
shared <- Mutex::new_named(
11831182
UatShared {
11841183
kernel_ttb1: 0,
11851184
map_kernel_to_user: false,
11861185
handoff_rgn,
11871186
ttbs_rgn,
11881187
},
1189-
"uat_shared"
1188+
c_str!("uat_shared")
11901189
),
11911190
}))
11921191
}

drivers/gpu/drm/asahi/workqueue.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::{channel, driver, event, fw, gpu, object, regs};
2424
use core::num::NonZeroU64;
2525
use core::sync::atomic::Ordering;
2626
use kernel::{
27+
c_str,
2728
error::code::*,
2829
prelude::*,
2930
sync::{
@@ -632,9 +633,9 @@ impl WorkQueue::ver {
632633
let info_pointer = inner.info.weak_pointer();
633634

634635
let mutex_init = match pipe_type {
635-
PipeType::Vertex => kernel::new_mutex!(inner, "WorkQueue::inner (Vertex)"),
636-
PipeType::Fragment => kernel::new_mutex!(inner, "WorkQueue::inner (Fragment)"),
637-
PipeType::Compute => kernel::new_mutex!(inner, "WorkQueue::inner (Compute)"),
636+
PipeType::Vertex => Mutex::new_named(inner, c_str!("WorkQueue::inner (Vertex)")),
637+
PipeType::Fragment => Mutex::new_named(inner, c_str!("WorkQueue::inner (Fragment)")),
638+
PipeType::Compute => Mutex::new_named(inner, c_str!("WorkQueue::inner (Compute)")),
638639
};
639640

640641
Arc::pin_init(pin_init!(Self {

0 commit comments

Comments
 (0)