Skip to content

Commit 3b8d758

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

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
@@ -80,6 +80,8 @@ const IOVA_KERN_SHARED_RO_RANGE: Range<u64> = 0xffffffaa00000000..0xffffffac0000
8080
const IOVA_KERN_GPU_RANGE: Range<u64> = 0xffffffac00000000..0xffffffae00000000;
8181
/// GPU/FW shared structure VA range base.
8282
const IOVA_KERN_RTKIT_RANGE: Range<u64> = 0xffffffae00000000..0xffffffae10000000;
83+
/// Shared (uncached) timestamp region.
84+
pub(crate) const IOVA_KERN_TIMESTAMP_RANGE: Range<u64> = 0xffffffae10000000..0xffffffae14000000;
8385
/// FW MMIO VA range base.
8486
const IOVA_KERN_MMIO_RANGE: Range<u64> = 0xffffffaf00000000..0xffffffb000000000;
8587

drivers/gpu/drm/asahi/initdata.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,7 @@ impl<'a> InitDataBuilder::ver<'a> {
492492
// Unknown page
493493
//unk_30: U64(0x6f_ffff8000),
494494
unk_30: U64(mmu::IOVA_UNK_PAGE),
495-
// unmapped?
496-
unkptr_38: U64(0xffffffa0_11800000),
495+
timestamp_area_base: U64(gpu::IOVA_KERN_TIMESTAMP_RANGE.start),
497496
// TODO: yuv matrices
498497
chip_id: cfg.chip_id,
499498
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
@@ -185,11 +185,11 @@ impl super::QueueInner::ver {
185185
if has_result {
186186
builder.add(microseq::Timestamp::ver {
187187
header: microseq::op::Timestamp::new(true),
188-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
189-
start_ts: inner_weak_ptr!(ptr, start_ts),
190-
update_ts: inner_weak_ptr!(ptr, start_ts),
188+
command_time: inner_weak_ptr!(ptr, command_time),
189+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
190+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.start_addr),
191191
work_queue: ev_comp.info_ptr,
192-
unk_24: U64(0),
192+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
193193
#[ver(V >= V13_0B4)]
194194
unk_ts: inner_weak_ptr!(ptr, context_store_req),
195195
uuid,
@@ -209,11 +209,11 @@ impl super::QueueInner::ver {
209209
if has_result {
210210
builder.add(microseq::Timestamp::ver {
211211
header: microseq::op::Timestamp::new(false),
212-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
213-
start_ts: inner_weak_ptr!(ptr, start_ts),
214-
update_ts: inner_weak_ptr!(ptr, end_ts),
212+
command_time: inner_weak_ptr!(ptr, command_time),
213+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
214+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.end_addr),
215215
work_queue: ev_comp.info_ptr,
216-
unk_24: U64(0),
216+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
217217
#[ver(V >= V13_0B4)]
218218
unk_ts: inner_weak_ptr!(ptr, context_store_req),
219219
uuid,
@@ -366,13 +366,15 @@ impl super::QueueInner::ver {
366366
uuid,
367367
event_seq: ev_comp.event_seq as u32,
368368
}),
369-
cur_ts: U64(0),
370-
start_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), start)),
371-
end_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), end)),
372-
unk_2c0: 0,
373-
unk_2c4: 0,
374-
unk_2c8: 0,
375-
unk_2cc: 0,
369+
command_time: U64(0),
370+
timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
371+
start_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), start)),
372+
end_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), end)),
373+
}),
374+
user_timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
375+
start_addr: None,
376+
end_addr: None,
377+
}),
376378
client_sequence: slot_client_seq,
377379
pad_2d1: Default::default(),
378380
unk_2d4: 0,

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

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,11 @@ impl super::QueueInner::ver {
691691
if has_result {
692692
builder.add(microseq::Timestamp::ver {
693693
header: microseq::op::Timestamp::new(true),
694-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
695-
start_ts: inner_weak_ptr!(ptr, start_ts),
696-
update_ts: inner_weak_ptr!(ptr, start_ts),
694+
command_time: inner_weak_ptr!(ptr, command_time),
695+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
696+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.start_addr),
697697
work_queue: ev_frag.info_ptr,
698-
unk_24: U64(0),
698+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
699699
#[ver(V >= V13_0B4)]
700700
unk_ts: inner_weak_ptr!(ptr, unk_ts),
701701
uuid: uuid_3d,
@@ -715,11 +715,11 @@ impl super::QueueInner::ver {
715715
if has_result {
716716
builder.add(microseq::Timestamp::ver {
717717
header: microseq::op::Timestamp::new(false),
718-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
719-
start_ts: inner_weak_ptr!(ptr, start_ts),
720-
update_ts: inner_weak_ptr!(ptr, end_ts),
718+
command_time: inner_weak_ptr!(ptr, command_time),
719+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
720+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.end_addr),
721721
work_queue: ev_frag.info_ptr,
722-
unk_24: U64(0),
722+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
723723
#[ver(V >= V13_0B4)]
724724
unk_ts: inner_weak_ptr!(ptr, unk_ts),
725725
uuid: uuid_3d,
@@ -1086,12 +1086,15 @@ impl super::QueueInner::ver {
10861086
unk_buf_10: U64(1),
10871087
#[ver(G >= G14X)]
10881088
unk_buf_10: U64(0),
1089-
cur_ts: U64(0),
1090-
start_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), frag.start)),
1091-
end_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), frag.end)),
1092-
unk_914: 0,
1093-
unk_918: U64(0),
1094-
unk_920: 0,
1089+
command_time: U64(0),
1090+
timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
1091+
start_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), frag.start)),
1092+
end_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), frag.end)),
1093+
}),
1094+
user_timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
1095+
start_addr: None,
1096+
end_addr: None,
1097+
}),
10951098
client_sequence: slot_client_seq,
10961099
pad_925: Default::default(),
10971100
unk_928: 0,
@@ -1218,11 +1221,11 @@ impl super::QueueInner::ver {
12181221
if has_result {
12191222
builder.add(microseq::Timestamp::ver {
12201223
header: microseq::op::Timestamp::new(true),
1221-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
1222-
start_ts: inner_weak_ptr!(ptr, start_ts),
1223-
update_ts: inner_weak_ptr!(ptr, start_ts),
1224+
command_time: inner_weak_ptr!(ptr, command_time),
1225+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
1226+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.start_addr),
12241227
work_queue: ev_vtx.info_ptr,
1225-
unk_24: U64(0),
1228+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
12261229
#[ver(V >= V13_0B4)]
12271230
unk_ts: inner_weak_ptr!(ptr, unk_ts),
12281231
uuid: uuid_ta,
@@ -1242,11 +1245,11 @@ impl super::QueueInner::ver {
12421245
if has_result {
12431246
builder.add(microseq::Timestamp::ver {
12441247
header: microseq::op::Timestamp::new(false),
1245-
cur_ts: inner_weak_ptr!(ptr, cur_ts),
1246-
start_ts: inner_weak_ptr!(ptr, start_ts),
1247-
update_ts: inner_weak_ptr!(ptr, end_ts),
1248+
command_time: inner_weak_ptr!(ptr, command_time),
1249+
ts_pointers: inner_weak_ptr!(ptr, timestamp_pointers),
1250+
update_ts: inner_weak_ptr!(ptr, timestamp_pointers.end_addr),
12481251
work_queue: ev_vtx.info_ptr,
1249-
unk_24: U64(0),
1252+
user_ts_pointers: inner_weak_ptr!(ptr, user_timestamp_pointers),
12501253
#[ver(V >= V13_0B4)]
12511254
unk_ts: inner_weak_ptr!(ptr, unk_ts),
12521255
uuid: uuid_ta,
@@ -1540,13 +1543,15 @@ impl super::QueueInner::ver {
15401543
unk_buf_0: U64(0),
15411544
unk_buf_8: U64(0),
15421545
unk_buf_10: U64(0),
1543-
cur_ts: U64(0),
1544-
start_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), vtx.start)),
1545-
end_ts: Some(inner_ptr!(inner.timestamps.gpu_pointer(), vtx.end)),
1546-
unk_5c4: 0,
1547-
unk_5c8: 0,
1548-
unk_5cc: 0,
1549-
unk_5d0: 0,
1546+
command_time: U64(0),
1547+
timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
1548+
start_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), vtx.start)),
1549+
end_addr: Some(inner_ptr!(inner.timestamps.gpu_pointer(), vtx.end)),
1550+
}),
1551+
user_timestamp_pointers <- try_init!(fw::job::raw::TimestampPointers {
1552+
start_addr: None,
1553+
end_addr: None,
1554+
}),
15501555
client_sequence: slot_client_seq,
15511556
pad_5d5: Default::default(),
15521557
unk_5d8: 0,

0 commit comments

Comments
 (0)