Skip to contentSkip to conversation

drm/amdgpu: add ta initialization failure check condition

PATCH In review YiPeng Chai 2 participants 4 messages Jul 19, 2023 – Jul 20, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: add ta initialization failure check condition

Add ta initialization failure check condition.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1 -1
index 468a67b302d4..049d34fd5ba0 100644
@@ -220,7 +220,7 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t
 	}
 
 	ret = psp_fn_ta_initialize(psp);
-	if (ret || context->resp_status) {
+	if (ret || context->resp_status || !context->initialized) {
 		dev_err(adev->dev, "Failed to load TA via debugfs (%d) and status (0x%X)\n",
 			ret, context->resp_status);
 		if (!ret)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 drm/amdgpu: not update the same version ras ta

not update the same version ras ta.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +19 -1
index 049d34fd5ba0..c27574239fde 100644
@@ -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;
 
Signature · 1 line
2.34.1
#2 lore raw

RE: [PATCH 2/2] drm/amdgpu: not update the same version ras ta

[AMD Official Use Only - General]

Quoted 11 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 19, 2023 8:40 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: not update the same version ras ta

not update the same version ras ta.

[Tao] don't update ras ta with same version

Quoted 12 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +0 -0
index 049d34fd5ba0..c27574239fde 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c static const struct file_operations · line 124

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1 -0
@@ -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)

[Tao] the patch is fine for me, but since the bin structure is updated, do we need to consider backward compatibility?

Quoted 60 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +0 -0
  *    - TA bin
  *   Receive buffer:

* - TA ID (4bytes)

drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +0 -0
@@ -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)-

Quoted 1 line

i_private;

      struct psp_context   *psp     = &adev->psp;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +0 -0
@@ -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));

drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +5 -0
+     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;
      }
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +3 -0
+     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)))

drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +6 -0
+                     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;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1 -2
-     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

#3 lore raw
In reply to YiPeng Chai

[AMD Official Use Only - General]

Quoted 11 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 19, 2023 8:40 PM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: add ta initialization failure check condition

Add ta initialization failure check condition.

[Tao] better to say "Add condition check for ta initialization failure"

Quoted 24 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +0 -0
index 468a67b302d4..049d34fd5ba0 100644
@@ -220,7 +220,7 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp,

const char *buf, size_t

      }

      ret = psp_fn_ta_initialize(psp);
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +1 -1
-     if (ret || context->resp_status) {
+     if (ret || context->resp_status || !context->initialized) {
              dev_err(adev->dev, "Failed to load TA via debugfs (%d) and status

(0x%X)\n",

                      ret, context->resp_status);
              if (!ret)

--
2.34.1