diff options
Diffstat (limited to 'common/recipes-kernel/linux/linux-yocto-4.19.8/2840-drm-amdgpu-psp-add-a-mutex-to-protect-access-to-the-.patch')
-rw-r--r-- | common/recipes-kernel/linux/linux-yocto-4.19.8/2840-drm-amdgpu-psp-add-a-mutex-to-protect-access-to-the-.patch | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.19.8/2840-drm-amdgpu-psp-add-a-mutex-to-protect-access-to-the-.patch b/common/recipes-kernel/linux/linux-yocto-4.19.8/2840-drm-amdgpu-psp-add-a-mutex-to-protect-access-to-the-.patch new file mode 100644 index 00000000..66fd0c2d --- /dev/null +++ b/common/recipes-kernel/linux/linux-yocto-4.19.8/2840-drm-amdgpu-psp-add-a-mutex-to-protect-access-to-the-.patch @@ -0,0 +1,103 @@ +From 89c7d089ef2d82058ff703c60b27b173c81f7cac Mon Sep 17 00:00:00 2001 +From: Alex Deucher <alexander.deucher@amd.com> +Date: Mon, 8 Jul 2019 13:33:22 -0500 +Subject: [PATCH 2840/2940] drm/amdgpu/psp: add a mutex to protect access to + the psp ring + +We need to serialize access to the psp ring if there are multiple +callers at runtime. + +Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> +Signed-off-by: Alex Deucher <alexander.deucher@amd.com> +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + + drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 16 ++++++++++++++-- + drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 1 + + 3 files changed, 16 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +index bf20223cc263..93fe40989f80 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +@@ -2537,6 +2537,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, + hash_init(adev->mn_hash); + mutex_init(&adev->lock_reset); + mutex_init(&adev->virt.dpm_mutex); ++ mutex_init(&adev->psp.mutex); + + r = amdgpu_device_check_arguments(adev); + if (r) +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +index 8108808267fe..8a4f8c3b5b5d 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +@@ -132,6 +132,8 @@ psp_cmd_submit_buf(struct psp_context *psp, + int index; + int timeout = 2000; + ++ mutex_lock(&psp->mutex); ++ + memset(psp->cmd_buf_mem, 0, PSP_CMD_BUFFER_SIZE); + + memcpy(psp->cmd_buf_mem, cmd, sizeof(struct psp_gfx_cmd_resp)); +@@ -141,6 +143,7 @@ psp_cmd_submit_buf(struct psp_context *psp, + fence_mc_addr, index); + if (ret) { + atomic_dec(&psp->fence_value); ++ mutex_unlock(&psp->mutex); + return ret; + } + +@@ -165,8 +168,10 @@ psp_cmd_submit_buf(struct psp_context *psp, + ucode->ucode_id); + DRM_WARN("psp command failed and response status is (%d)\n", + psp->cmd_buf_mem->resp.status); +- if (!timeout) ++ if (!timeout) { ++ mutex_unlock(&psp->mutex); + return -EINVAL; ++ } + } + + /* get xGMI session id from response buffer */ +@@ -176,6 +181,7 @@ psp_cmd_submit_buf(struct psp_context *psp, + ucode->tmr_mc_addr_lo = psp->cmd_buf_mem->resp.fw_addr_lo; + ucode->tmr_mc_addr_hi = psp->cmd_buf_mem->resp.fw_addr_hi; + } ++ mutex_unlock(&psp->mutex); + + return ret; + } +@@ -1192,10 +1198,16 @@ static int psp_resume(void *handle) + + int psp_gpu_reset(struct amdgpu_device *adev) + { ++ int ret; ++ + if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) + return 0; + +- return psp_mode1_reset(&adev->psp); ++ mutex_lock(&adev->psp.mutex); ++ ret = psp_mode1_reset(&adev->psp); ++ mutex_unlock(&adev->psp.mutex); ++ ++ return ret; + } + + int psp_rlc_autoload_start(struct psp_context *psp) +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +index 6039acc84346..e28cf5e4016e 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +@@ -201,6 +201,7 @@ struct psp_context + uint8_t *ta_ras_start_addr; + struct psp_xgmi_context xgmi_context; + struct psp_ras_context ras; ++ struct mutex mutex; + }; + + struct amdgpu_psp_funcs { +-- +2.17.1 + |