Skip to contentSkip to conversation

drm/amdgpu/vpe: fix vpe dpm setup failed

PATCH In review Peyton Lee 3 participants 3 messages Apr 18, 2024 – Apr 19, 2024

Subsystems (2)
lore
Share & tools
lore

Peyton Lee

author
#0 lore raw

PATCH 1/1 drm/amdgpu/vpe: fix vpe dpm setup failed

The vpe dpm settings should be done before firmware is loaded. Otherwise, the frequency cannot be successfully raised.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c   | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +1 -1
index 6695481f870f..c23d97d34b7e 100644
@@ -205,7 +205,7 @@ int amdgpu_vpe_configure_dpm(struct amdgpu_vpe *vpe)
 	dpm_ctl &= 0xfffffffe; /* Disable DPM */
 	WREG32(vpe_get_reg_offset(vpe, 0, vpe->regs.dpm_enable), dpm_ctl);
 	dev_dbg(adev->dev, "%s: disable vpe dpm\n", __func__);
-	return 0;
+	return -EINVAL;
 }
 
 int amdgpu_vpe_psp_update_sram(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c +7 -7
index 769eb8f7bb3c..09315dd5a1ec 100644
@@ -144,6 +144,12 @@ static int vpe_v6_1_load_microcode(struct amdgpu_vpe *vpe)
 			WREG32(vpe_get_reg_offset(vpe, j, regVPEC_CNTL), ret);
 	}
 
+	/* setup collaborate mode */
+	vpe_v6_1_set_collaborate_mode(vpe, true);
+	/* setup DPM */
+	if (amdgpu_vpe_configure_dpm(vpe))
+		dev_warn(adev->dev, "VPE failed to enable DPM\n");
+
 	/*
 	 * For VPE 6.1.1, still only need to add master's offset, and psp will apply it to slave as well.
 	 * Here use instance 0 as master.
@@ -159,11 +165,7 @@ static int vpe_v6_1_load_microcode(struct amdgpu_vpe *vpe)
 		adev->vpe.cmdbuf_cpu_addr[0] = f32_offset;
 		adev->vpe.cmdbuf_cpu_addr[1] = f32_cntl;
 
-		amdgpu_vpe_psp_update_sram(adev);
-		vpe_v6_1_set_collaborate_mode(vpe, true);
-		amdgpu_vpe_configure_dpm(vpe);
-
-		return 0;
+		return amdgpu_vpe_psp_update_sram(adev);
 	}
 
 	vpe_hdr = (const struct vpe_firmware_header_v1_0 *)adev->vpe.fw->data;
@@ -196,8 +198,6 @@ static int vpe_v6_1_load_microcode(struct amdgpu_vpe *vpe)
 	}
 
 	vpe_v6_1_halt(vpe, false);
-	vpe_v6_1_set_collaborate_mode(vpe, true);
-	amdgpu_vpe_configure_dpm(vpe);
 
 	return 0;
 }
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

________________________________
From: Lee, Peyton <[email protected]>
Sent: Thursday, April 18, 2024 1:12 AM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Liu, HaoPing (Alan) <[email protected]>; Yu, Lang <[email protected]>; Lee, Peyton <[email protected]>
Subject: [PATCH] drm/amdgpu/vpe: fix vpe dpm setup failed

The vpe dpm settings should be done before firmware is loaded. Otherwise, the frequency cannot be successfully raised.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c   | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +1 -1
index 6695481f870f..c23d97d34b7e 100644
@@ -205,7 +205,7 @@ int amdgpu_vpe_configure_dpm(struct amdgpu_vpe *vpe)
         dpm_ctl &= 0xfffffffe; /* Disable DPM */
         WREG32(vpe_get_reg_offset(vpe, 0, vpe->regs.dpm_enable), dpm_ctl);
         dev_dbg(adev->dev, "%s: disable vpe dpm\n", __func__);
-       return 0;
+       return -EINVAL;
 }
 
 int amdgpu_vpe_psp_update_sram(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c +7 -7
index 769eb8f7bb3c..09315dd5a1ec 100644
@@ -144,6 +144,12 @@ static int vpe_v6_1_load_microcode(struct amdgpu_vpe *vpe)
                         WREG32(vpe_get_reg_offset(vpe, j, regVPEC_CNTL), ret);
         }
 
+       /* setup collaborate mode */
+       vpe_v6_1_set_collaborate_mode(vpe, true);
+       /* setup DPM */
+       if (amdgpu_vpe_configure_dpm(vpe))
+               dev_warn(adev->dev, "VPE failed to enable DPM\n");
+
         /*
          * For VPE 6.1.1, still only need to add master's offset, and psp will apply it to slave as well.
          * Here use instance 0 as master.
@@ -159,11 +165,7 @@ static int vpe_v6_1_load_microcode(struct amdgpu_vpe *vpe)
                 adev->vpe.cmdbuf_cpu_addr[0] = f32_offset;
                 adev->vpe.cmdbuf_cpu_addr[1] = f32_cntl;
 
-               amdgpu_vpe_psp_update_sram(adev);
-               vpe_v6_1_set_collaborate_mode(vpe, true);
-               amdgpu_vpe_configure_dpm(vpe);
-
-               return 0;
+               return amdgpu_vpe_psp_update_sram(adev);
         }
 
         vpe_hdr = (const struct vpe_firmware_header_v1_0 *)adev->vpe.fw->data;
@@ -196,8 +198,6 @@ static int vpe_v6_1_load_microcode(struct amdgpu_vpe *vpe)
         }
 
         vpe_v6_1_halt(vpe, false);
-       vpe_v6_1_set_collaborate_mode(vpe, true);
-       amdgpu_vpe_configure_dpm(vpe);
 
         return 0;
 }

--
2.34.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Peyton Lee

[Public]

Quoted 81 lines

-----Original Message-----
From: Lee, Peyton <[email protected]>
Sent: Thursday, April 18, 2024 1:13 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liu, HaoPing (Alan) <[email protected]>; Yu, Lang <[email protected]>; Lee, Peyton <[email protected]>
Subject: [PATCH] drm/amdgpu/vpe: fix vpe dpm setup failed

The vpe dpm settings should be done before firmware is loaded. Otherwise, the frequency cannot be successfully raised.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c | 2 +-
drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c | 14 +++++++-------

2 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +1 -1
index 6695481f870f..c23d97d34b7e 100644
@@ -205,7 +205,7 @@ int amdgpu_vpe_configure_dpm(struct amdgpu_vpe
 *vpe)
      dpm_ctl &= 0xfffffffe; /* Disable DPM */
      WREG32(vpe_get_reg_offset(vpe, 0, vpe->regs.dpm_enable),
 dpm_ctl);
      dev_dbg(adev->dev, "%s: disable vpe dpm\n", __func__);
-      return 0;
+      return -EINVAL;
 }

int amdgpu_vpe_psp_update_sram(struct amdgpu_device *adev) diff --git a/drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c b/drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c
index 769eb8f7bb3c..09315dd5a1ec 100644

drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c +6 -0
@@ -144,6 +144,12 @@ static int vpe_v6_1_load_microcode(struct
 amdgpu_vpe *vpe)
                      WREG32(vpe_get_reg_offset(vpe, j, regVPEC_CNTL),
 ret);
      }
 
+      /* setup collaborate mode */
+      vpe_v6_1_set_collaborate_mode(vpe, true);
+      /* setup DPM */
+      if (amdgpu_vpe_configure_dpm(vpe))
+              dev_warn(adev->dev, "VPE failed to enable DPM\n");
+
      /*

* For VPE 6.1.1, still only need to add master's offset, and psp will
apply it to slave as well.
* Here use instance 0 as master.

drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c +1 -5
@@ -159,11 +165,7 @@ static int vpe_v6_1_load_microcode(struct
 amdgpu_vpe *vpe)
              adev->vpe.cmdbuf_cpu_addr[0] = f32_offset;
              adev->vpe.cmdbuf_cpu_addr[1] = f32_cntl;
 
-              amdgpu_vpe_psp_update_sram(adev);
-              vpe_v6_1_set_collaborate_mode(vpe, true);
-              amdgpu_vpe_configure_dpm(vpe);
-
-              return 0;
+              return amdgpu_vpe_psp_update_sram(adev);
      }
 
      vpe_hdr = (const struct vpe_firmware_header_v1_0 *)adev->vpe.fw-
Quoted 1 line

data; @@ -196,8 +198,6 @@ static int vpe_v6_1_load_microcode(struct

amdgpu_vpe *vpe)

      }

      vpe_v6_1_halt(vpe, false);
drivers/gpu/drm/amd/amdgpu/vpe_v6_1.c +0 -2
-      vpe_v6_1_set_collaborate_mode(vpe, true);
-      amdgpu_vpe_configure_dpm(vpe);
 
      return 0;

}
--
2.34.1