Skip to content

Commit a2c5332

Browse files
hoshinolinajannau
authored andcommitted
drm/asahi: Document timestamp ops better, refactor fields
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent dc78a20 commit a2c5332

10 files changed

Lines changed: 75 additions & 70 deletions

File tree

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,9 @@ pub(crate) mod raw {
7373
pub(crate) job_params2: JobParameters2::ver<'a>,
7474
pub(crate) encoder_params: job::raw::EncoderParams,
7575
pub(crate) meta: job::raw::JobMeta,
76-
pub(crate) cur_ts: U64,
77-
pub(crate) start_ts: Option<GpuPointer<'a, AtomicU64>>,
78-
pub(crate) end_ts: Option<GpuPointer<'a, AtomicU64>>,
79-
pub(crate) unk_2c0: u32,
80-
pub(crate) unk_2c4: u32,
81-
pub(crate) unk_2c8: u32,
82-
pub(crate) unk_2cc: u32,
76+
pub(crate) command_time: U64,
77+
pub(crate) timestamp_pointers: job::raw::TimestampPointers<'a>,
78+
pub(crate) user_timestamp_pointers: job::raw::TimestampPointers<'a>,
8379
pub(crate) client_sequence: u8,
8480
pub(crate) pad_2d1: Array<3, u8>,
8581
pub(crate) unk_2d4: u32,

drivers/gpu/drm/asahi/fw/fragment.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,9 @@ pub(crate) mod raw {
250250
pub(crate) unk_buf_0: U64,
251251
pub(crate) unk_buf_8: U64,
252252
pub(crate) unk_buf_10: U64,
253-
pub(crate) cur_ts: U64,
254-
pub(crate) start_ts: Option<GpuPointer<'a, AtomicU64>>,
255-
pub(crate) end_ts: Option<GpuPointer<'a, AtomicU64>>,
256-
pub(crate) unk_914: u32,
257-
pub(crate) unk_918: U64,
258-
pub(crate) unk_920: u32,
253+
pub(crate) command_time: U64,
254+
pub(crate) timestamp_pointers: job::raw::TimestampPointers<'a>,
255+
pub(crate) user_timestamp_pointers: job::raw::TimestampPointers<'a>,
259256
pub(crate) client_sequence: u8,
260257
pub(crate) pad_925: Array<3, u8>,
261258
pub(crate) unk_928: u32,

drivers/gpu/drm/asahi/fw/initdata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ pub(crate) mod raw {
647647
pub(crate) unk_20: U64,
648648
pub(crate) unk_28: U64,
649649
pub(crate) unk_30: U64,
650-
pub(crate) unkptr_38: U64,
650+
pub(crate) timestamp_area_base: U64,
651651
pub(crate) pad_40: Pad<0x20>,
652652

653653
#[ver(V < V13_0B4)]

drivers/gpu/drm/asahi/fw/job.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ pub(crate) mod raw {
108108
self.length += core::mem::size_of::<Register>() as u16;
109109
}
110110
}
111+
112+
#[derive(Debug)]
113+
#[repr(C)]
114+
pub(crate) struct TimestampPointers<'a> {
115+
pub(crate) start_addr: Option<GpuPointer<'a, AtomicU64>>,
116+
pub(crate) end_addr: Option<GpuPointer<'a, AtomicU64>>,
117+
}
111118
}
112119

113120
trivial_gpustruct!(JobTimestamps);

drivers/gpu/drm/asahi/fw/microseq.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,12 @@ impl Operation for RetireStamp {}
144144
#[repr(C)]
145145
pub(crate) struct Timestamp<'a> {
146146
pub(crate) header: op::Timestamp,
147-
pub(crate) cur_ts: GpuWeakPointer<U64>,
148-
pub(crate) start_ts: GpuWeakPointer<Option<GpuPointer<'a, AtomicU64>>>,
147+
pub(crate) command_time: GpuWeakPointer<U64>,
148+
pub(crate) ts_pointers: GpuWeakPointer<job::raw::TimestampPointers<'a>>,
149+
// Unused?
149150
pub(crate) update_ts: GpuWeakPointer<Option<GpuPointer<'a, AtomicU64>>>,
150151
pub(crate) work_queue: GpuWeakPointer<workqueue::QueueInfo::ver>,
151-
pub(crate) unk_24: U64,
152+
pub(crate) user_ts_pointers: GpuWeakPointer<job::raw::TimestampPointers<'a>>,
152153

153154
#[ver(V >= V13_0B4)]
154155
pub(crate) unk_ts: GpuWeakPointer<U64>,

drivers/gpu/drm/asahi/fw/vertex.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,9 @@ pub(crate) mod raw {
148148
pub(crate) unk_buf_0: U64,
149149
pub(crate) unk_buf_8: U64,
150150
pub(crate) unk_buf_10: U64,
151-
pub(crate) cur_ts: U64,
152-
pub(crate) start_ts: Option<GpuPointer<'a, AtomicU64>>,
153-
pub(crate) end_ts: Option<GpuPointer<'a, AtomicU64>>,
154-
pub(crate) unk_5c4: u32,
155-
pub(crate) unk_5c8: u32,
156-
pub(crate) unk_5cc: u32,
157-
pub(crate) unk_5d0: u32,
151+
pub(crate) command_time: U64,
152+
pub(crate) timestamp_pointers: job::raw::TimestampPointers<'a>,
153+
pub(crate) user_timestamp_pointers: job::raw::TimestampPointers<'a>,
158154
pub(crate) client_sequence: u8,
159155
pub(crate) pad_5d5: Array<3, u8>,
160156
pub(crate) unk_5d8: u32,

drivers/gpu/drm/asahi/gpu.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ const IOVA_KERN_SHARED_RO_RANGE: Range<u64> = 0xffffffaa00000000..0xffffffac0000
7979
const IOVA_KERN_GPU_RANGE: Range<u64> = 0xffffffac00000000..0xffffffae00000000;
8080
/// GPU/FW shared structure VA range base.
8181
const IOVA_KERN_RTKIT_RANGE: Range<u64> = 0xffffffae00000000..0xffffffae10000000;
82+
/// Shared (uncached) timestamp region.
83+
pub(crate) const IOVA_KERN_TIMESTAMP_RANGE: Range<u64> = 0xffffffae10000000..0xffffffae14000000;
8284
/// FW MMIO VA range base.
8385
const IOVA_KERN_MMIO_RANGE: Range<u64> = 0xffffffaf00000000..0xffffffb000000000;
8486

drivers/gpu/drm/asahi/initdata.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,7 @@ impl<'a> InitDataBuilder::ver<'a> {
493493
// Unknown page
494494
//unk_30: U64(0x6f_ffff8000),
495495
unk_30: U64(mmu::IOVA_UNK_PAGE),
496-
// unmapped?
497-
unkptr_38: U64(0xffffffa0_11800000),
496+
timestamp_area_base: U64(gpu::IOVA_KERN_TIMESTAMP_RANGE.start),
498497
// TODO: yuv matrices
499498
chip_id: cfg.chip_id,
500499
unk_454: cfg.db.unk_454,

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ impl super::QueueInner::ver {
176176
if has_result {
177177
builder.add(microseq::Timestamp::ver {
178178
header: microseq::op::Timestamp::new(true),
179-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
180-
start_ts: inner_weak_ptr!(ptr, start_ts),
181-
update_ts: inner_weak_ptr!(ptr, start_ts),
179+
command_time: inner_weak_ptr!(ptr, command_time),
180+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
181+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.start_addr),
182182
work_queue: ev_comp.info_ptr,
183-
unk_24: U64(0),
183+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
184184
#[ver(V >= V13_0B4)]
185185
unk_ts: inner_weak_ptr!(ptr, context_store_req),
186186
uuid,
@@ -200,11 +200,11 @@ impl super::QueueInner::ver {
200200
if has_result {
201201
builder.add(microseq::Timestamp::ver {
202202
header: microseq::op::Timestamp::new(false),
203-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
204-
start_ts: inner_weak_ptr!(ptr, start_ts),
205-
update_ts: inner_weak_ptr!(ptr, end_ts),
203+
command_time: inner_weak_ptr!(ptr, command_time),
204+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
205+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.end_addr),
206206
work_queue: ev_comp.info_ptr,
207-
unk_24: U64(0),
207+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
208208
#[ver(V >= V13_0B4)]
209209
unk_ts: inner_weak_ptr!(ptr, context_store_req),
210210
uuid,
@@ -357,13 +357,15 @@ impl super::QueueInner::ver {
357357
uuid,
358358
event_seq: ev_comp.event_seq as u32,
359359
}),
360-
cur_ts: U64(0),
361-
start_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), start)),
362-
end_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), end)),
363-
unk_2c0: 0,
364-
unk_2c4: 0,
365-
unk_2c8: 0,
366-
unk_2cc: 0,
360+
command_time: U64(0),
361+
timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
362+
start_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), start)),
363+
end_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), end)),
364+
}),
365+
user_timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
366+
start_addr: None,
367+
end_addr: None,
368+
}),
367369
client_sequence: slot_client_seq,
368370
pad_2d1: Default::default(),
369371
unk_2d4: 0,

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

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,11 @@ impl super::QueueInner::ver {
679679
if has_result {
680680
builder.add(microseq::Timestamp::ver {
681681
header: microseq::op::Timestamp::new(true),
682-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
683-
start_ts: inner_weak_ptr!(ptr, start_ts),
684-
update_ts: inner_weak_ptr!(ptr, start_ts),
682+
command_time: inner_weak_ptr!(ptr, command_time),
683+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
684+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.start_addr),
685685
work_queue: ev_frag.info_ptr,
686-
unk_24: U64(0),
686+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
687687
#[ver(V >= V13_0B4)]
688688
unk_ts: inner_weak_ptr!(ptr, unk_ts),
689689
uuid: uuid_3d,
@@ -703,11 +703,11 @@ impl super::QueueInner::ver {
703703
if has_result {
704704
builder.add(microseq::Timestamp::ver {
705705
header: microseq::op::Timestamp::new(false),
706-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
707-
start_ts: inner_weak_ptr!(ptr, start_ts),
708-
update_ts: inner_weak_ptr!(ptr, end_ts),
706+
command_time: inner_weak_ptr!(ptr, command_time),
707+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
708+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.end_addr),
709709
work_queue: ev_frag.info_ptr,
710-
unk_24: U64(0),
710+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
711711
#[ver(V >= V13_0B4)]
712712
unk_ts: inner_weak_ptr!(ptr, unk_ts),
713713
uuid: uuid_3d,
@@ -1074,12 +1074,15 @@ impl super::QueueInner::ver {
10741074
unk_buf_10: U64(1),
10751075
#[ver(G >= G14X)]
10761076
unk_buf_10: U64(0),
1077-
cur_ts: U64(0),
1078-
start_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), frag.start)),
1079-
end_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), frag.end)),
1080-
unk_914: 0,
1081-
unk_918: U64(0),
1082-
unk_920: 0,
1077+
command_time: U64(0),
1078+
timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
1079+
start_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), frag.start)),
1080+
end_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), frag.end)),
1081+
}),
1082+
user_timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
1083+
start_addr: None,
1084+
end_addr: None,
1085+
}),
10831086
client_sequence: slot_client_seq,
10841087
pad_925: Default::default(),
10851088
unk_928: 0,
@@ -1206,11 +1209,11 @@ impl super::QueueInner::ver {
12061209
if has_result {
12071210
builder.add(microseq::Timestamp::ver {
12081211
header: microseq::op::Timestamp::new(true),
1209-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
1210-
start_ts: inner_weak_ptr!(ptr, start_ts),
1211-
update_ts: inner_weak_ptr!(ptr, start_ts),
1212+
command_time: inner_weak_ptr!(ptr, command_time),
1213+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
1214+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.start_addr),
12121215
work_queue: ev_vtx.info_ptr,
1213-
unk_24: U64(0),
1216+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
12141217
#[ver(V >= V13_0B4)]
12151218
unk_ts: inner_weak_ptr!(ptr, unk_ts),
12161219
uuid: uuid_ta,
@@ -1230,11 +1233,11 @@ impl super::QueueInner::ver {
12301233
if has_result {
12311234
builder.add(microseq::Timestamp::ver {
12321235
header: microseq::op::Timestamp::new(false),
1233-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
1234-
start_ts: inner_weak_ptr!(ptr, start_ts),
1235-
update_ts: inner_weak_ptr!(ptr, end_ts),
1236+
command_time: inner_weak_ptr!(ptr, command_time),
1237+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
1238+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.end_addr),
12361239
work_queue: ev_vtx.info_ptr,
1237-
unk_24: U64(0),
1240+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
12381241
#[ver(V >= V13_0B4)]
12391242
unk_ts: inner_weak_ptr!(ptr, unk_ts),
12401243
uuid: uuid_ta,
@@ -1528,13 +1531,15 @@ impl super::QueueInner::ver {
15281531
unk_buf_0: U64(0),
15291532
unk_buf_8: U64(0),
15301533
unk_buf_10: U64(0),
1531-
cur_ts: U64(0),
1532-
start_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), vtx.start)),
1533-
end_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), vtx.end)),
1534-
unk_5c4: 0,
1535-
unk_5c8: 0,
1536-
unk_5cc: 0,
1537-
unk_5d0: 0,
1534+
command_time: U64(0),
1535+
timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
1536+
start_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), vtx.start)),
1537+
end_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), vtx.end)),
1538+
}),
1539+
user_timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
1540+
start_addr: None,
1541+
end_addr: None,
1542+
}),
15381543
client_sequence: slot_client_seq,
15391544
pad_5d5: Default::default(),
15401545
unk_5d8: 0,

0 commit comments

Comments
 (0)