Add a user queue vm identifier for each userqueue
kms opt accessing.

Signed-off-by: Prike Liang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 5 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h    | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index 8888be4e758c..a8bb3f1b8649 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -1249,10 +1249,13 @@ amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr,
 int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file 
*file_priv,
                          struct amdgpu_device *adev)
 {
+       struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(userq_mgr);
+
        mutex_init(&userq_mgr->userq_mutex);
        xa_init_flags(&userq_mgr->userq_mgr_xa, XA_FLAGS_ALLOC);
        userq_mgr->adev = adev;
        userq_mgr->file = file_priv;
+       fpriv->vm.is_userq_context = true;
 
        INIT_DELAYED_WORK(&userq_mgr->resume_work, amdgpu_userq_restore_worker);
        return 0;
@@ -1262,6 +1265,7 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr 
*userq_mgr)
 {
        struct amdgpu_usermode_queue *queue;
        unsigned long queue_id;
+       struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(userq_mgr);
 
        cancel_delayed_work_sync(&userq_mgr->resume_work);
 
@@ -1276,6 +1280,7 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr 
*userq_mgr)
        xa_destroy(&userq_mgr->userq_mgr_xa);
        mutex_unlock(&userq_mgr->userq_mutex);
        mutex_destroy(&userq_mgr->userq_mutex);
+       fpriv->vm.is_userq_context = false;
 }
 
 int amdgpu_userq_suspend(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index db66b4232de0..48a64d828eb8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2591,7 +2591,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
        ttm_lru_bulk_move_init(&vm->lru_bulk_move);
 
        vm->is_compute_context = false;
-
+       vm->is_userq_context = false;
        vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
                                    AMDGPU_VM_USE_CPU_FOR_GFX);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 77207f4e448e..cbe7dfa4ffcb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -439,7 +439,7 @@ struct amdgpu_vm {
        struct ttm_lru_bulk_move lru_bulk_move;
        /* Flag to indicate if VM is used for compute */
        bool                    is_compute_context;
-
+       bool                    is_userq_context;
        /* Memory partition number, -1 means any partition */
        int8_t                  mem_id;
 
-- 
2.34.1

Reply via email to