not update the same version ras ta. Signed-off-by: YiPeng Chai <YiPeng.Chai@xxxxxxx> --- drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c index 049d34fd5ba0..c27574239fde 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c @@ -120,6 +120,7 @@ static const struct file_operations ta_invoke_debugfs_fops = { * Transmit buffer: * - TA type (4bytes) * - TA bin length (4bytes) + * - TA bin version (4bytes) * - TA bin * Receive buffer: * - TA ID (4bytes) @@ -148,6 +149,7 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t uint8_t *ta_bin = NULL; uint32_t copy_pos = 0; int ret = 0; + uint32_t ta_version = 0; struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(fp)->i_private; struct psp_context *psp = &adev->psp; @@ -168,6 +170,12 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t copy_pos += sizeof(uint32_t); + ret = copy_from_user((void *)&ta_version, &buf[copy_pos], sizeof(uint32_t)); + if (ret) + return -EFAULT; + + copy_pos += sizeof(uint32_t); + ta_bin = kzalloc(ta_bin_len, GFP_KERNEL); if (!ta_bin) return -ENOMEM; @@ -185,6 +193,16 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t goto err_free_bin; } + if (ta_version == context->bin_desc.fw_version) { + dev_info(adev->dev, + "new ta is same as running ta, running ta will not be updated!\n"); + if (copy_to_user((char *)buf, (void *)&context->session_id, sizeof(uint32_t))) + ret = -EFAULT; + else + ret = len; + goto err_free_bin; + } + /* * Allocate TA shared buf in case shared buf was freed * due to loading TA failed before. @@ -209,7 +227,7 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t /* Prepare TA context for TA initialization */ context->ta_type = ta_type; - context->bin_desc.fw_version = get_bin_version(ta_bin); + context->bin_desc.fw_version = ta_version; context->bin_desc.size_bytes = ta_bin_len; context->bin_desc.start_addr = ta_bin; -- 2.34.1