@@ -874,15 +874,21 @@ int ivpu_cmdq_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *
874
874
int ivpu_cmdq_create_ioctl (struct drm_device * dev , void * data , struct drm_file * file )
875
875
{
876
876
struct ivpu_file_priv * file_priv = file -> driver_priv ;
877
+ struct ivpu_device * vdev = file_priv -> vdev ;
877
878
struct drm_ivpu_cmdq_create * args = data ;
878
879
struct ivpu_cmdq * cmdq ;
880
+ int ret ;
879
881
880
- if (!ivpu_is_capable (file_priv -> vdev , DRM_IVPU_CAP_MANAGE_CMDQ ))
882
+ if (!ivpu_is_capable (vdev , DRM_IVPU_CAP_MANAGE_CMDQ ))
881
883
return - ENODEV ;
882
884
883
885
if (args -> priority > DRM_IVPU_JOB_PRIORITY_REALTIME )
884
886
return - EINVAL ;
885
887
888
+ ret = ivpu_rpm_get (vdev );
889
+ if (ret < 0 )
890
+ return ret ;
891
+
886
892
mutex_lock (& file_priv -> lock );
887
893
888
894
cmdq = ivpu_cmdq_create (file_priv , ivpu_job_to_jsm_priority (args -> priority ), false);
@@ -891,6 +897,8 @@ int ivpu_cmdq_create_ioctl(struct drm_device *dev, void *data, struct drm_file *
891
897
892
898
mutex_unlock (& file_priv -> lock );
893
899
900
+ ivpu_rpm_put (vdev );
901
+
894
902
return cmdq ? 0 : - ENOMEM ;
895
903
}
896
904
@@ -900,28 +908,35 @@ int ivpu_cmdq_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file
900
908
struct ivpu_device * vdev = file_priv -> vdev ;
901
909
struct drm_ivpu_cmdq_destroy * args = data ;
902
910
struct ivpu_cmdq * cmdq ;
903
- u32 cmdq_id ;
911
+ u32 cmdq_id = 0 ;
904
912
int ret ;
905
913
906
914
if (!ivpu_is_capable (vdev , DRM_IVPU_CAP_MANAGE_CMDQ ))
907
915
return - ENODEV ;
908
916
917
+ ret = ivpu_rpm_get (vdev );
918
+ if (ret < 0 )
919
+ return ret ;
920
+
909
921
mutex_lock (& file_priv -> lock );
910
922
911
923
cmdq = xa_load (& file_priv -> cmdq_xa , args -> cmdq_id );
912
924
if (!cmdq || cmdq -> is_legacy ) {
913
925
ret = - ENOENT ;
914
- goto err_unlock ;
926
+ } else {
927
+ cmdq_id = cmdq -> id ;
928
+ ivpu_cmdq_destroy (file_priv , cmdq );
929
+ ret = 0 ;
915
930
}
916
931
917
- cmdq_id = cmdq -> id ;
918
- ivpu_cmdq_destroy (file_priv , cmdq );
919
932
mutex_unlock (& file_priv -> lock );
920
- ivpu_cmdq_abort_all_jobs (vdev , file_priv -> ctx .id , cmdq_id );
921
- return 0 ;
922
933
923
- err_unlock :
924
- mutex_unlock (& file_priv -> lock );
934
+ /* Abort any pending jobs only if cmdq was destroyed */
935
+ if (!ret )
936
+ ivpu_cmdq_abort_all_jobs (vdev , file_priv -> ctx .id , cmdq_id );
937
+
938
+ ivpu_rpm_put (vdev );
939
+
925
940
return ret ;
926
941
}
927
942
0 commit comments