[PATCH] drm/amdgpu: fix baco handling for soc15

Alex Deucher alexdeucher at gmail.com
Fri Jan 25 20:31:22 UTC 2019


Need to check if the operation is one that involves
registers before getting the register offset.  Fixes a
crash in when handling commands without a register offset,
e.g., wait.

Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.c b/drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.c
index 002693c421d2..9c57c1f67749 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.c
@@ -84,11 +84,14 @@ bool soc15_baco_program_registers(struct pp_hwmgr *hwmgr,
 				 const u32 array_size)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
-	u32 i, reg;
+	u32 i, reg = 0;
 
 	for (i = 0; i < array_size; i++) {
-		reg = adev->reg_offset[entry[i].hwip][entry[i].inst][entry[i].seg]
-			+ entry[i].reg_offset;
+		if ((entry[i].cmd == CMD_WRITE) ||
+		    (entry[i].cmd == CMD_READMODIFYWRITE) ||
+		    (entry[i].cmd == CMD_WAITFOR))
+			reg = adev->reg_offset[entry[i].hwip][entry[i].inst][entry[i].seg]
+				+ entry[i].reg_offset;
 		if (!baco_cmd_handler(hwmgr, entry[i].cmd, reg, entry[i].mask,
 				     entry[i].shift, entry[i].val, entry[i].timeout))
 			return false;
-- 
2.20.1



More information about the amd-gfx mailing list