File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ impl drv::Driver for AsahiDriver {
8484 ioctl:: AUTH | ioctl:: RENDER_ALLOW , crate :: file:: File :: queue_destroy) ,
8585 ( ASAHI_SUBMIT , drm_asahi_submit,
8686 ioctl:: AUTH | ioctl:: RENDER_ALLOW , crate :: file:: File :: submit) ,
87+ ( ASAHI_GET_TIME , drm_asahi_get_time,
88+ ioctl:: AUTH | ioctl:: RENDER_ALLOW , crate :: file:: File :: get_time) ,
8789 }
8890}
8991
Original file line number Diff line number Diff line change @@ -241,7 +241,7 @@ impl File {
241241 unstable_uabi_version : uapi:: DRM_ASAHI_UNSTABLE_UABI_VERSION ,
242242 pad0 : 0 ,
243243
244- feat_compat : gpu. get_cfg ( ) . gpu_feat_compat ,
244+ feat_compat : gpu. get_cfg ( ) . gpu_feat_compat | hw :: feat :: compat :: GETTIME ,
245245 feat_incompat : gpu. get_cfg ( ) . gpu_feat_incompat ,
246246
247247 gpu_generation : gpu. get_dyncfg ( ) . id . gpu_gen as u32 ,
@@ -959,6 +959,33 @@ impl File {
959959 Ok ( ( ) ) => Ok ( 0 ) ,
960960 }
961961 }
962+
963+ /// IOCTL: get_time: Get the current GPU timer value.
964+ pub ( crate ) fn get_time (
965+ _device : & AsahiDevice ,
966+ _dev_data : <Self as drm:: file:: DriverFile >:: BorrowedData < ' _ > ,
967+ data : & mut uapi:: drm_asahi_get_time ,
968+ _file : & DrmFile ,
969+ ) -> Result < u32 > {
970+ if data. extensions != 0 || data. flags != 0 {
971+ cls_pr_debug ! ( Errors , "get_time: Unexpected extensions or flags\n " ) ;
972+ return Err ( EINVAL ) ;
973+ }
974+
975+ let gputime: u64 ;
976+
977+ // SAFETY: Assembly only loads the timer
978+ unsafe {
979+ core:: arch:: asm!(
980+ "mrs {x}, CNTPCT_EL0" ,
981+ x = out( reg) gputime
982+ ) ;
983+ }
984+
985+ data. gpu_timestamp = gputime;
986+
987+ Ok ( 0 )
988+ }
962989}
963990
964991impl Drop for File {
Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ pub(crate) mod feat {
9494 /// Soft MMU faults enabled.
9595 pub ( crate ) const SOFT_FAULTS : u64 =
9696 uapi:: drm_asahi_feat_compat_DRM_ASAHI_FEAT_SOFT_FAULTS as u64 ;
97+ /// GETTIME API supported
98+ pub ( crate ) const GETTIME : u64 = uapi:: drm_asahi_feat_compat_DRM_ASAHI_FEAT_GETTIME as u64 ;
9799 }
98100
99101 /// Backwards-incompatible features.
You can’t perform that action at this time.
0 commit comments