Add API which queues a work to reset domain and waits for it to finish. Signed-off-by: Lijo Lazar <lijo.lazar@xxxxxxx> --- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 18 ++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c index 713362a60c9f..0c29acb65b88 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c @@ -263,3 +263,21 @@ int amdgpu_reset_schedule_work(struct amdgpu_device *adev, return ret; } +int amdgpu_reset_exec_work(struct amdgpu_device *adev, + struct amdgpu_reset_context *reset_context, + amdgpu_reset_work_func_t reset_work_handler) +{ + struct amdgpu_reset_work reset_work; + + if (!reset_context || !reset_context->reset_req_dev || + !reset_work_handler) + return -EINVAL; + + INIT_WORK_ONSTACK(&reset_work.work, amdgpu_reset_work_handler); + amdgpu_reset_init_work(&reset_work, reset_context, reset_work_handler); + queue_work(adev->reset_domain->wq, &reset_work.work); + flush_work(&reset_work.work); + destroy_work_on_stack(&reset_work.work); + + return 0; +} diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h index 73d1f78d2b0e..dba719012516 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h @@ -145,9 +145,13 @@ void amdgpu_device_unlock_reset_domain(struct amdgpu_reset_domain *reset_domain) int amdgpu_reset_schedule_work(struct amdgpu_device *adev, struct amdgpu_reset_context *reset_context, amdgpu_reset_work_func_t handler); +int amdgpu_reset_exec_work(struct amdgpu_device *adev, + struct amdgpu_reset_context *reset_context, + amdgpu_reset_work_func_t reset_work_handler); #define for_each_handler(i, handler, reset_ctl) \ for (i = 0; (i < AMDGPU_RESET_MAX_HANDLERS) && \ (handler = (*reset_ctl->reset_handlers)[i]); \ ++i) + #endif -- 2.25.1