@@ -149,6 +149,65 @@ static int dxgkio_open_adapter_from_luid(struct dxgprocess *process,
149149 return ret ;
150150}
151151
152+ static int dxgkio_query_statistics (struct dxgprocess * process ,
153+ void __user * inargs )
154+ {
155+ struct d3dkmt_querystatistics * args ;
156+ int ret ;
157+ struct dxgadapter * entry ;
158+ struct dxgadapter * adapter = NULL ;
159+ struct winluid tmp ;
160+ struct dxgglobal * dxgglobal = dxggbl ();
161+
162+ args = vzalloc (sizeof (struct d3dkmt_querystatistics ));
163+ if (args == NULL ) {
164+ ret = - ENOMEM ;
165+ goto cleanup ;
166+ }
167+
168+ ret = copy_from_user (args , inargs , sizeof (* args ));
169+ if (ret ) {
170+ DXG_ERR ("failed to copy input args" );
171+ ret = - EINVAL ;
172+ goto cleanup ;
173+ }
174+
175+ dxgglobal_acquire_adapter_list_lock (DXGLOCK_SHARED );
176+ list_for_each_entry (entry , & dxgglobal -> adapter_list_head ,
177+ adapter_list_entry ) {
178+ if (dxgadapter_acquire_lock_shared (entry ) == 0 ) {
179+ if (* (u64 * ) & entry -> luid ==
180+ * (u64 * ) & args -> adapter_luid ) {
181+ adapter = entry ;
182+ break ;
183+ }
184+ dxgadapter_release_lock_shared (entry );
185+ }
186+ }
187+ dxgglobal_release_adapter_list_lock (DXGLOCK_SHARED );
188+ if (adapter ) {
189+ tmp = args -> adapter_luid ;
190+ args -> adapter_luid = adapter -> host_adapter_luid ;
191+ ret = dxgvmb_send_query_statistics (process , adapter , args );
192+ if (ret >= 0 ) {
193+ args -> adapter_luid = tmp ;
194+ ret = copy_to_user (inargs , args , sizeof (* args ));
195+ if (ret ) {
196+ DXG_ERR ("failed to copy args" );
197+ ret = - EINVAL ;
198+ }
199+ }
200+ dxgadapter_release_lock_shared (adapter );
201+ }
202+
203+ cleanup :
204+ if (args )
205+ vfree (args );
206+
207+ DXG_TRACE ("ioctl:%s %d" , errorstr (ret ), ret );
208+ return ret ;
209+ }
210+
152211static int
153212dxgkp_enum_adapters (struct dxgprocess * process ,
154213 union d3dkmt_enumadapters_filter filter ,
@@ -3536,6 +3595,54 @@ dxgkio_change_vidmem_reservation(struct dxgprocess *process, void *__user inargs
35363595 return ret ;
35373596}
35383597
3598+ static int
3599+ dxgkio_query_clock_calibration (struct dxgprocess * process , void * __user inargs )
3600+ {
3601+ struct d3dkmt_queryclockcalibration args ;
3602+ int ret ;
3603+ struct dxgadapter * adapter = NULL ;
3604+ bool adapter_locked = false;
3605+
3606+ ret = copy_from_user (& args , inargs , sizeof (args ));
3607+ if (ret ) {
3608+ DXG_ERR ("failed to copy input args" );
3609+ ret = - EINVAL ;
3610+ goto cleanup ;
3611+ }
3612+
3613+ adapter = dxgprocess_adapter_by_handle (process , args .adapter );
3614+ if (adapter == NULL ) {
3615+ ret = - EINVAL ;
3616+ goto cleanup ;
3617+ }
3618+
3619+ ret = dxgadapter_acquire_lock_shared (adapter );
3620+ if (ret < 0 ) {
3621+ adapter = NULL ;
3622+ goto cleanup ;
3623+ }
3624+ adapter_locked = true;
3625+
3626+ args .adapter = adapter -> host_handle ;
3627+ ret = dxgvmb_send_query_clock_calibration (process , adapter ,
3628+ & args , inargs );
3629+ if (ret < 0 )
3630+ goto cleanup ;
3631+ ret = copy_to_user (inargs , & args , sizeof (args ));
3632+ if (ret ) {
3633+ DXG_ERR ("failed to copy output args" );
3634+ ret = - EINVAL ;
3635+ }
3636+
3637+ cleanup :
3638+
3639+ if (adapter_locked )
3640+ dxgadapter_release_lock_shared (adapter );
3641+ if (adapter )
3642+ kref_put (& adapter -> adapter_kref , dxgadapter_release );
3643+ return ret ;
3644+ }
3645+
35393646static int
35403647dxgkio_flush_heap_transitions (struct dxgprocess * process , void * __user inargs )
35413648{
@@ -4470,14 +4577,14 @@ static struct ioctl_desc ioctls[] = {
44704577/* 0x3b */ {dxgkio_wait_sync_object_gpu ,
44714578 LX_DXWAITFORSYNCHRONIZATIONOBJECTFROMGPU },
44724579/* 0x3c */ {dxgkio_get_allocation_priority , LX_DXGETALLOCATIONPRIORITY },
4473- /* 0x3d */ {},
4580+ /* 0x3d */ {dxgkio_query_clock_calibration , LX_DXQUERYCLOCKCALIBRATION },
44744581/* 0x3e */ {dxgkio_enum_adapters3 , LX_DXENUMADAPTERS3 },
44754582/* 0x3f */ {dxgkio_share_objects , LX_DXSHAREOBJECTS },
44764583/* 0x40 */ {dxgkio_open_sync_object_nt , LX_DXOPENSYNCOBJECTFROMNTHANDLE2 },
44774584/* 0x41 */ {dxgkio_query_resource_info_nt ,
44784585 LX_DXQUERYRESOURCEINFOFROMNTHANDLE },
44794586/* 0x42 */ {dxgkio_open_resource_nt , LX_DXOPENRESOURCEFROMNTHANDLE },
4480- /* 0x43 */ {},
4587+ /* 0x43 */ {dxgkio_query_statistics , LX_DXQUERYSTATISTICS },
44814588/* 0x44 */ {dxgkio_share_object_with_host , LX_DXSHAREOBJECTWITHHOST },
44824589/* 0x45 */ {},
44834590};
0 commit comments