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 <[email protected]>
---
 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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to