drm/amdgpu/psp: add a mutex to protect access to the psp ring
Subsystems (2)
PATCH 1/1 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.
--- 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
@@ -2544,6 +2544,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)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +14 -2
@@ -131,6 +131,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 ));
@@ -140,6 +142,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; }
@@ -162,8 +165,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 */
@@ -173,6 +178,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; }
@@ -1189,10 +1195,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)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -201,6 +201,7 @@ struct psp_contextuint8_t *ta_ras_start_addr;struct psp_xgmi_context xgmi_context;struct psp_ras_context ras; +struct mutex mutex; };struct amdgpu_psp_funcs {
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190708183622.5705-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Zhang, Hawking
Reviewed-by Hawking ZhangRegards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: 2019年7月9日 2:36
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] 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.
--- 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
@@ -2544,6 +2544,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)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -0
@@ -131,6 +131,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)); @@ -140,6 +142,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;
}
@@ -162,8 +165,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 */ @@ -173,6 +178,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;
}
@@ -1189,10 +1195,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
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -201,6 +201,7 @@ struct psp_contextuint8_t *ta_ras_start_addr;struct psp_xgmi_context xgmi_context;struct psp_ras_context ras; +struct mutex mutex; };struct amdgpu_psp_funcs {
--
2.20.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx