drm/amdgpu: implement per-process MES context
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: implement per-process MES context
MES process context is a process-level page where process specific context is saved for MES scheduler.
However, current user-queue code path assigns fw_obj of a queue to MES process_context_addr when adding the queue to MES.
This means every new queue from the same process would replace the previous process context address with that queue's fw_obj address.
What's worse is, when user space frees a queue, its fw_obj will be freed as well, causing MES working on a NULL page pointer.
This issue leads to inconsistency and crash in the scheduler.
This commit allocates a process-level page for MES process contexts for a process other than queue-level
Signed-off-by Zhu Lingshan <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 2 + drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 52 +++++++++++++++++----- 3 files changed, 48 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +6 -0
@@ -1172,6 +1172,7 @@ int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *fxa_init_flags (&userq_mgr->userq_xa,XA_FLAGS_ALLOC ); userq_mgr->adev = adev; userq_mgr->file = file_priv; +mutex_init (&userq_mgr->proc_ctx_lock);INIT_DELAYED_WORK (&userq_mgr->resume_work, amdgpu_userq_restore_worker);INIT_WORK (&userq_mgr->reset_work, amdgpu_userq_mgr_reset_work);
@@ -1225,6 +1226,11 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr)*/ cancel_work_sync (&userq_mgr->reset_work); +amdgpu_bo_free_kernel (&userq_mgr->proc_ctx_obj.obj, + &userq_mgr->proc_ctx_obj.gpu_addr, + &userq_mgr->proc_ctx_obj.cpu_ptr); + +mutex_destroy (&userq_mgr->proc_ctx_lock);mutex_destroy (&userq_mgr->userq_mutex); }
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +2 -0
@@ -127,6 +127,8 @@ struct amdgpu_userq_mgr {struct amdgpu_device *adev;struct delayed_work resume_work;struct drm_file *file; +struct mutex proc_ctx_lock; +struct amdgpu_userq_obj proc_ctx_obj;/** * @reset_work:
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +40 -12
94 lines not on this page · raw message
Signature · 1 line
2.54.0