diff options
author | Jay Cornwall <jay@jcornwall.me> | 2016-02-24 16:48:34 -0600 |
---|---|---|
committer | Gerrit Code Review <gerritcr@atlswgit01.amd.com> | 2016-05-02 13:17:32 -0400 |
commit | b3c5e1bc113e7b97029b42e2410f0192cda3db5e (patch) | |
tree | 0aa3a550e4c840ac0a1e308080baf2f1a3a6c4d6 | |
parent | 3c396d2126fd6262fd660d40d1a3165dcb3e56c0 (diff) |
drm/amdgpu: Fix CP_HQD_PQ_WPTR initialization on KFD HQD loadroc-1.1.0
The return value from copy_from_user() was interpreted as the opposite
of its intended meaning. This caused PQ_WPTR to be populated with the
uninitialized value from shadow_wptr, causing intermittent HIQ hangs.
Always initialize PQ_WPTR to zero if a shadow write pointer is not
available. Also check for NULL as this may be mapped in userspace
but has a specific meaning when passed to hqd_load().
Change-Id: I3ced7765659a043a53b8123bace0e6288a23b59d
Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
Reviewed-by: David Ogbeide <davidboyowa.ogbeide@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 13 |
2 files changed, 10 insertions, 11 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c index 5b937015b3d8..d868ba3e9d3b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c @@ -416,12 +416,13 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, uint32_t page_table_base) { struct amdgpu_device *adev = get_amdgpu_device(kgd); - uint32_t wptr_shadow, is_wptr_shadow_valid; struct cik_mqd *m; + uint32_t wptr_shadow = 0, is_wptr_shadow_valid = 0; m = get_mqd(mqd); - is_wptr_shadow_valid = !get_user(wptr_shadow, wptr); + if (wptr != NULL) + is_wptr_shadow_valid = !get_user(wptr_shadow, wptr); acquire_queue(kgd, pipe_id, queue_id); @@ -475,8 +476,7 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, WREG32(mmCP_HQD_IQ_RPTR, m->cp_hqd_iq_rptr); - if (is_wptr_shadow_valid) - WREG32(mmCP_HQD_PQ_WPTR, wptr_shadow); + WREG32(mmCP_HQD_PQ_WPTR, (is_wptr_shadow_valid ? wptr_shadow : 0)); WREG32(mmCP_HQD_ACTIVE, m->cp_hqd_active); release_queue(kgd); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c index a2f9c322af0c..a9447a49aa53 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c @@ -322,13 +322,15 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, uint32_t queue_id, uint32_t __user *wptr, uint32_t page_table_base) { - struct vi_mqd *m; - uint32_t shadow_wptr, valid_wptr; struct amdgpu_device *adev = get_amdgpu_device(kgd); + struct vi_mqd *m; + uint32_t wptr_shadow = 0, is_wptr_shadow_valid = 0; m = get_mqd(mqd); - valid_wptr = copy_from_user(&shadow_wptr, wptr, sizeof(shadow_wptr)); + if (wptr != NULL) + is_wptr_shadow_valid = !get_user(wptr_shadow, wptr); + acquire_queue(kgd, pipe_id, queue_id); WREG32(mmCOMPUTE_STATIC_THREAD_MGMT_SE0, @@ -354,10 +356,7 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, WREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR, m->cp_hqd_pq_rptr_report_addr_lo); WREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI, m->cp_hqd_pq_rptr_report_addr_hi); - - if (valid_wptr > 0) - WREG32(mmCP_HQD_PQ_WPTR, shadow_wptr); - + WREG32(mmCP_HQD_PQ_WPTR, (is_wptr_shadow_valid ? wptr_shadow : 0)); WREG32(mmCP_HQD_PQ_CONTROL, m->cp_hqd_pq_control); WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, m->cp_hqd_pq_doorbell_control); |