Skip to contentSkip to conversation

drm/amdgpu/psp: always call psp_load_toc()

PATCH In review Alex Deucher 3 participants 3 messages Nov 23, 2022 – Nov 24, 2022

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu/psp: always call psp_load_toc()

We need to always call psp_load_toc() regardless of whether we re-allocate the TMR buffer or not. Fixes S4.

Fixes 36238df85ade ("drm/amdgpu/psp: don't free PSP buffers on suspend")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 42 ++++++++++++-------------
 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +21 -21
index 621723f510a9..7978307e1d6d 100644
@@ -750,29 +750,29 @@ static int psp_tmr_init(struct psp_context *psp)
 	void *tmr_buf;
 	void **pptr;
 
-	if (!psp->tmr_bo) {
-		/*
-		 * According to HW engineer, they prefer the TMR address be "naturally
-		 * aligned" , e.g. the start address be an integer divide of TMR size.
-		 *
-		 * Note: this memory need be reserved till the driver
-		 * uninitializes.
-		 */
-		tmr_size = PSP_TMR_SIZE(psp->adev);
-
-		/* For ASICs support RLC autoload, psp will parse the toc
-		 * and calculate the total size of TMR needed */
-		if (!amdgpu_sriov_vf(psp->adev) &&
-		    psp->toc.start_addr &&
-		    psp->toc.size_bytes &&
-		    psp->fw_pri_buf) {
-			ret = psp_load_toc(psp, &tmr_size);
-			if (ret) {
-				DRM_ERROR("Failed to load toc\n");
-				return ret;
-			}
+	/*
+	 * According to HW engineer, they prefer the TMR address be "naturally
+	 * aligned" , e.g. the start address be an integer divide of TMR size.
+	 *
+	 * Note: this memory need be reserved till the driver
+	 * uninitializes.
+	 */
+	tmr_size = PSP_TMR_SIZE(psp->adev);
+
+	/* For ASICs support RLC autoload, psp will parse the toc
+	 * and calculate the total size of TMR needed */
+	if (!amdgpu_sriov_vf(psp->adev) &&
+	    psp->toc.start_addr &&
+	    psp->toc.size_bytes &&
+	    psp->fw_pri_buf) {
+		ret = psp_load_toc(psp, &tmr_size);
+		if (ret) {
+			DRM_ERROR("Failed to load toc\n");
+			return ret;
 		}
+	}
 
+	if (!psp->tmr_bo) {
 		pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
 		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_ALIGNMENT,
 					      AMDGPU_GEM_DOMAIN_VRAM,
Signature · 1 line
2.38.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Alex Deucher

We need to always call psp_load_toc() regardless of whether we re-allocate the TMR buffer or not. Fixes S4.

I guess this fixes all cases where psp_suspend is called (regression introduced by the fixes-tag patch) and not just S4. Suggest to refine the commit comment.

Thanks,
Lijo

Quoted 63 lines
Fixes 36238df85ade ("drm/amdgpu/psp: don't free PSP buffers on suspend")
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 42 ++++++++++++-------------
  1 file changed, 21 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +21 -21
index 621723f510a9..7978307e1d6d 100644
@@ -750,29 +750,29 @@ static int psp_tmr_init(struct psp_context *psp)
  	void *tmr_buf;
  	void **pptr;
 
-	if (!psp->tmr_bo) {
-		/*
-		 * According to HW engineer, they prefer the TMR address be "naturally
-		 * aligned" , e.g. the start address be an integer divide of TMR size.
-		 *
-		 * Note: this memory need be reserved till the driver
-		 * uninitializes.
-		 */
-		tmr_size = PSP_TMR_SIZE(psp->adev);
-
-		/* For ASICs support RLC autoload, psp will parse the toc
-		 * and calculate the total size of TMR needed */
-		if (!amdgpu_sriov_vf(psp->adev) &&
-		    psp->toc.start_addr &&
-		    psp->toc.size_bytes &&
-		    psp->fw_pri_buf) {
-			ret = psp_load_toc(psp, &tmr_size);
-			if (ret) {
-				DRM_ERROR("Failed to load toc\n");
-				return ret;
-			}
+	/*
+	 * According to HW engineer, they prefer the TMR address be "naturally
+	 * aligned" , e.g. the start address be an integer divide of TMR size.
+	 *
+	 * Note: this memory need be reserved till the driver
+	 * uninitializes.
+	 */
+	tmr_size = PSP_TMR_SIZE(psp->adev);
+
+	/* For ASICs support RLC autoload, psp will parse the toc
+	 * and calculate the total size of TMR needed */
+	if (!amdgpu_sriov_vf(psp->adev) &&
+	    psp->toc.start_addr &&
+	    psp->toc.size_bytes &&
+	    psp->fw_pri_buf) {
+		ret = psp_load_toc(psp, &tmr_size);
+		if (ret) {
+			DRM_ERROR("Failed to load toc\n");
+			return ret;
  		}
+	}
 
+	if (!psp->tmr_bo) {
  		pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
  		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_ALIGNMENT,
  					      AMDGPU_GEM_DOMAIN_VRAM,
Reviewed-by on v1 1/1
#2 lore raw
In reply to Alex Deucher

[AMD Official Use Only - General]

-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Wednesday, November 23, 2022 10:00 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Guo, Shikai <[email protected]>
Subject: [PATCH] drm/amdgpu/psp: always call psp_load_toc()

We need to always call psp_load_toc() regardless of whether we re-allocate the TMR buffer or not. Fixes S4.

Fixes 36238df85ade ("drm/amdgpu/psp: don't free PSP buffers on suspend")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 42 ++++++++++++-------------
 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +21 -21
index 621723f510a9..7978307e1d6d 100644
@@ -750,29 +750,29 @@ static int psp_tmr_init(struct psp_context *psp)
 	void *tmr_buf;
 	void **pptr;
 
-	if (!psp->tmr_bo) {
-		/*
-		 * According to HW engineer, they prefer the TMR address be "naturally
-		 * aligned" , e.g. the start address be an integer divide of TMR size.
-		 *
-		 * Note: this memory need be reserved till the driver
-		 * uninitializes.
-		 */
-		tmr_size = PSP_TMR_SIZE(psp->adev);
-
-		/* For ASICs support RLC autoload, psp will parse the toc
-		 * and calculate the total size of TMR needed */
-		if (!amdgpu_sriov_vf(psp->adev) &&
-		    psp->toc.start_addr &&
-		    psp->toc.size_bytes &&
-		    psp->fw_pri_buf) {
-			ret = psp_load_toc(psp, &tmr_size);
-			if (ret) {
-				DRM_ERROR("Failed to load toc\n");
-				return ret;
-			}
+	/*
+	 * According to HW engineer, they prefer the TMR address be "naturally
+	 * aligned" , e.g. the start address be an integer divide of TMR size.
+	 *
+	 * Note: this memory need be reserved till the driver
+	 * uninitializes.
+	 */
+	tmr_size = PSP_TMR_SIZE(psp->adev);
+
+	/* For ASICs support RLC autoload, psp will parse the toc
+	 * and calculate the total size of TMR needed */
+	if (!amdgpu_sriov_vf(psp->adev) &&
+	    psp->toc.start_addr &&
+	    psp->toc.size_bytes &&
+	    psp->fw_pri_buf) {
+		ret = psp_load_toc(psp, &tmr_size);
+		if (ret) {
+			DRM_ERROR("Failed to load toc\n");
+			return ret;
 		}
+	}
 
+	if (!psp->tmr_bo) {
 		pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
 		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_ALIGNMENT,
 					      AMDGPU_GEM_DOMAIN_VRAM,

--
2.38.1