@@ -3660,6 +3660,171 @@ dxgkio_get_allocation_priority(struct dxgprocess *process, void *__user inargs)
36603660 return ret ;
36613661}
36623662
3663+ static int
3664+ set_context_scheduling_priority (struct dxgprocess * process ,
3665+ struct d3dkmthandle hcontext ,
3666+ int priority , bool in_process )
3667+ {
3668+ int ret = 0 ;
3669+ struct dxgdevice * device = NULL ;
3670+ struct dxgadapter * adapter = NULL ;
3671+
3672+ device = dxgprocess_device_by_object_handle (process ,
3673+ HMGRENTRY_TYPE_DXGCONTEXT ,
3674+ hcontext );
3675+ if (device == NULL ) {
3676+ ret = - EINVAL ;
3677+ goto cleanup ;
3678+ }
3679+ adapter = device -> adapter ;
3680+ ret = dxgadapter_acquire_lock_shared (adapter );
3681+ if (ret < 0 ) {
3682+ adapter = NULL ;
3683+ goto cleanup ;
3684+ }
3685+ ret = dxgvmb_send_set_context_sch_priority (process , adapter ,
3686+ hcontext , priority ,
3687+ in_process );
3688+ if (ret < 0 )
3689+ DXG_ERR ("send_set_context_scheduling_priority failed" );
3690+ cleanup :
3691+ if (adapter )
3692+ dxgadapter_release_lock_shared (adapter );
3693+ if (device )
3694+ kref_put (& device -> device_kref , dxgdevice_release );
3695+
3696+ return ret ;
3697+ }
3698+
3699+ static int
3700+ dxgkio_set_context_scheduling_priority (struct dxgprocess * process ,
3701+ void * __user inargs )
3702+ {
3703+ struct d3dkmt_setcontextschedulingpriority args ;
3704+ int ret ;
3705+
3706+ ret = copy_from_user (& args , inargs , sizeof (args ));
3707+ if (ret ) {
3708+ DXG_ERR ("failed to copy input args" );
3709+ ret = - EINVAL ;
3710+ goto cleanup ;
3711+ }
3712+
3713+ ret = set_context_scheduling_priority (process , args .context ,
3714+ args .priority , false);
3715+ cleanup :
3716+ DXG_TRACE ("ioctl:%s %d" , errorstr (ret ), ret );
3717+ return ret ;
3718+ }
3719+
3720+ static int
3721+ get_context_scheduling_priority (struct dxgprocess * process ,
3722+ struct d3dkmthandle hcontext ,
3723+ int __user * priority ,
3724+ bool in_process )
3725+ {
3726+ int ret ;
3727+ struct dxgdevice * device = NULL ;
3728+ struct dxgadapter * adapter = NULL ;
3729+ int pri = 0 ;
3730+
3731+ device = dxgprocess_device_by_object_handle (process ,
3732+ HMGRENTRY_TYPE_DXGCONTEXT ,
3733+ hcontext );
3734+ if (device == NULL ) {
3735+ ret = - EINVAL ;
3736+ goto cleanup ;
3737+ }
3738+ adapter = device -> adapter ;
3739+ ret = dxgadapter_acquire_lock_shared (adapter );
3740+ if (ret < 0 ) {
3741+ adapter = NULL ;
3742+ goto cleanup ;
3743+ }
3744+ ret = dxgvmb_send_get_context_sch_priority (process , adapter ,
3745+ hcontext , & pri , in_process );
3746+ if (ret < 0 )
3747+ goto cleanup ;
3748+ ret = copy_to_user (priority , & pri , sizeof (pri ));
3749+ if (ret ) {
3750+ DXG_ERR ("failed to copy priority to user" );
3751+ ret = - EINVAL ;
3752+ }
3753+
3754+ cleanup :
3755+ if (adapter )
3756+ dxgadapter_release_lock_shared (adapter );
3757+ if (device )
3758+ kref_put (& device -> device_kref , dxgdevice_release );
3759+
3760+ return ret ;
3761+ }
3762+
3763+ static int
3764+ dxgkio_get_context_scheduling_priority (struct dxgprocess * process ,
3765+ void * __user inargs )
3766+ {
3767+ struct d3dkmt_getcontextschedulingpriority args ;
3768+ struct d3dkmt_getcontextschedulingpriority __user * input = inargs ;
3769+ int ret ;
3770+
3771+ ret = copy_from_user (& args , inargs , sizeof (args ));
3772+ if (ret ) {
3773+ DXG_ERR ("failed to copy input args" );
3774+ ret = - EINVAL ;
3775+ goto cleanup ;
3776+ }
3777+
3778+ ret = get_context_scheduling_priority (process , args .context ,
3779+ & input -> priority , false);
3780+ cleanup :
3781+ DXG_TRACE ("ioctl:%s %d" , errorstr (ret ), ret );
3782+ return ret ;
3783+ }
3784+
3785+ static int
3786+ dxgkio_set_context_process_scheduling_priority (struct dxgprocess * process ,
3787+ void * __user inargs )
3788+ {
3789+ struct d3dkmt_setcontextinprocessschedulingpriority args ;
3790+ int ret ;
3791+
3792+ ret = copy_from_user (& args , inargs , sizeof (args ));
3793+ if (ret ) {
3794+ DXG_ERR ("failed to copy input args" );
3795+ ret = - EINVAL ;
3796+ goto cleanup ;
3797+ }
3798+
3799+ ret = set_context_scheduling_priority (process , args .context ,
3800+ args .priority , true);
3801+ cleanup :
3802+ DXG_TRACE ("ioctl:%s %d" , errorstr (ret ), ret );
3803+ return ret ;
3804+ }
3805+
3806+ static int
3807+ dxgkio_get_context_process_scheduling_priority (struct dxgprocess * process ,
3808+ void __user * inargs )
3809+ {
3810+ struct d3dkmt_getcontextinprocessschedulingpriority args ;
3811+ int ret ;
3812+
3813+ ret = copy_from_user (& args , inargs , sizeof (args ));
3814+ if (ret ) {
3815+ DXG_ERR ("failed to copy input args" );
3816+ ret = - EINVAL ;
3817+ goto cleanup ;
3818+ }
3819+
3820+ ret = get_context_scheduling_priority (process , args .context ,
3821+ & ((struct d3dkmt_getcontextinprocessschedulingpriority * )
3822+ inargs )-> priority , true);
3823+ cleanup :
3824+ DXG_TRACE ("ioctl:%s %d" , errorstr (ret ), ret );
3825+ return ret ;
3826+ }
3827+
36633828static int
36643829dxgkio_change_vidmem_reservation (struct dxgprocess * process , void * __user inargs )
36653830{
@@ -4655,8 +4820,10 @@ static struct ioctl_desc ioctls[] = {
46554820/* 0x1e */ {},
46564821/* 0x1f */ {dxgkio_flush_heap_transitions , LX_DXFLUSHHEAPTRANSITIONS },
46574822/* 0x20 */ {},
4658- /* 0x21 */ {},
4659- /* 0x22 */ {},
4823+ /* 0x21 */ {dxgkio_get_context_process_scheduling_priority ,
4824+ LX_DXGETCONTEXTINPROCESSSCHEDULINGPRIORITY },
4825+ /* 0x22 */ {dxgkio_get_context_scheduling_priority ,
4826+ LX_DXGETCONTEXTSCHEDULINGPRIORITY },
46604827/* 0x23 */ {},
46614828/* 0x24 */ {},
46624829/* 0x25 */ {dxgkio_lock2 , LX_DXLOCK2 },
@@ -4669,8 +4836,10 @@ static struct ioctl_desc ioctls[] = {
46694836/* 0x2c */ {dxgkio_reclaim_allocations , LX_DXRECLAIMALLOCATIONS2 },
46704837/* 0x2d */ {},
46714838/* 0x2e */ {dxgkio_set_allocation_priority , LX_DXSETALLOCATIONPRIORITY },
4672- /* 0x2f */ {},
4673- /* 0x30 */ {},
4839+ /* 0x2f */ {dxgkio_set_context_process_scheduling_priority ,
4840+ LX_DXSETCONTEXTINPROCESSSCHEDULINGPRIORITY },
4841+ /* 0x30 */ {dxgkio_set_context_scheduling_priority ,
4842+ LX_DXSETCONTEXTSCHEDULINGPRIORITY },
46744843/* 0x31 */ {dxgkio_signal_sync_object_cpu ,
46754844 LX_DXSIGNALSYNCHRONIZATIONOBJECTFROMCPU },
46764845/* 0x32 */ {dxgkio_signal_sync_object_gpu ,
0 commit comments