1. 27 Mar, 2024 21 commits
  2. 22 Mar, 2024 19 commits
    • Mario Limonciello's avatar
      drm/amd: Flush GFXOFF requests in prepare stage · 0355b24b
      Mario Limonciello authored
      If the system hasn't entered GFXOFF when suspend starts it can cause
      hangs accessing GC and RLC during the suspend stage.
      
      Cc: <stable@vger.kernel.org> # 6.1.y: 5095d541 ("drm/amd: Evict resources during PM ops prepare() callback")
      Cc: <stable@vger.kernel.org> # 6.1.y: cb11ca32 ("drm/amd: Add concept of running prepare_suspend() sequence for IP blocks")
      Cc: <stable@vger.kernel.org> # 6.1.y: 2ceec37b ("drm/amd: Add missing kernel doc for prepare_suspend()")
      Cc: <stable@vger.kernel.org> # 6.1.y: 3a9626c8 ("drm/amd: Stop evicting resources on APUs in suspend")
      Cc: <stable@vger.kernel.org> # 6.6.y: 5095d541 ("drm/amd: Evict resources during PM ops prepare() callback")
      Cc: <stable@vger.kernel.org> # 6.6.y: cb11ca32 ("drm/amd: Add concept of running prepare_suspend() sequence for IP blocks")
      Cc: <stable@vger.kernel.org> # 6.6.y: 2ceec37b ("drm/amd: Add missing kernel doc for prepare_suspend()")
      Cc: <stable@vger.kernel.org> # 6.6.y: 3a9626c8 ("drm/amd: Stop evicting resources on APUs in suspend")
      Cc: <stable@vger.kernel.org> # 6.1+
      Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3132
      Fixes: ab475033 ("drm/amdgpu/sdma5.2: add begin/end_use ring callbacks")
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      0355b24b
    • Srinivasan Shanmugam's avatar
      drm/amdgpu: Fix truncations in gfx_v11_0_init_microcode() · eb4f6eca
      Srinivasan Shanmugam authored
      Reducing the size of ucode_prefix to 25 in the gfx_v11_0_init_microcode
      function. This would ensure that the total number of characters being
      written into fw_name does not exceed its size of 40.
      
      Fixes the below with gcc W=1:
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c: In function ‘gfx_v11_0_early_init’:
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:523:54: warning: ‘_pfp.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
        523 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", ucode_prefix);
            |                                                      ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:523:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
        523 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", ucode_prefix);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:540:54: warning: ‘_me.bin’ directive output may be truncated writing 7 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
        540 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", ucode_prefix);
            |                                                      ^~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:540:9: note: ‘snprintf’ output between 15 and 44 bytes into a destination of size 40
        540 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", ucode_prefix);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:557:70: warning: ‘_rlc.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
        557 |                         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);
            |                                                                      ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:557:25: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
        557 |                         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:569:54: warning: ‘_mec.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
        569 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", ucode_prefix);
            |                                                      ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:569:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
        569 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", ucode_prefix);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        CC [M]  drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/smu7_clockpowergating.o
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Suggested-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      eb4f6eca
    • Srinivasan Shanmugam's avatar
      drm/amdgpu: Fix truncation in smu_v11_0_init_microcode · 730dd50f
      Srinivasan Shanmugam authored
      Reducing the size of ucode_prefix to 25 in the smu_v11_0_init_microcode
      function. we ensure that fw_name can accommodate the maximum possible
      string size
      
      Fixes the below with gcc W=1:
      drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/smu_v11_0.c: In function ‘smu_v11_0_init_microcode’:
      drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/smu_v11_0.c:110:54: warning: ‘.bin’ directive output may be truncated writing 4 bytes into a region of size between 0 and 29 [-Wformat-truncation=]
        110 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
            |                                                      ^~~~
      drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/smu_v11_0.c:110:9: note: ‘snprintf’ output between 12 and 41 bytes into a destination of size 36
        110 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Suggested-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      730dd50f
    • Tao Zhou's avatar
      drm/amdgpu: simplify convert_error_address interface for UMC v12 · 8e4617c2
      Tao Zhou authored
      Replace separate parameters with struct ta_ras_query_address_input.
      Signed-off-by: default avatarTao Zhou <tao.zhou1@amd.com>
      Reviewed-by: default avatarStanley.Yang <Stanley.Yang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      8e4617c2
    • Srinivasan Shanmugam's avatar
      drm/amdgpu: Fix truncation issues in gfx_v9_0.c · 539ff12e
      Srinivasan Shanmugam authored
      The size of fw_name is increased to ensure that it can accommodate
      the maximum possible size of the string being written into it.
      
      Fixes the below with gcc W=1:
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c: In function ‘gfx_v9_0_early_init’:
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1255:52: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1255 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", chip_name);
            |                                                    ^~
      ......
       1393 |                 r = gfx_v9_0_init_cp_gfx_microcode(adev, ucode_prefix);
            |                                                          ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1255:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 30
       1255 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", chip_name);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1261:52: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1261 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", chip_name);
            |                                                    ^~
      ......
       1393 |                 r = gfx_v9_0_init_cp_gfx_microcode(adev, ucode_prefix);
            |                                                          ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1261:9: note: ‘snprintf’ output between 15 and 44 bytes into a destination of size 30
       1261 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", chip_name);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1267:52: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1267 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name);
            |                                                    ^~
      ......
       1393 |                 r = gfx_v9_0_init_cp_gfx_microcode(adev, ucode_prefix);
            |                                                          ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1267:9: note: ‘snprintf’ output between 15 and 44 bytes into a destination of size 30
       1267 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1303:60: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1303 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc_am4.bin", chip_name);
            |                                                            ^~
      ......
       1398 |         r = gfx_v9_0_init_rlc_microcode(adev, ucode_prefix);
            |                                               ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1303:17: note: ‘snprintf’ output between 20 and 49 bytes into a destination of size 30
       1303 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc_am4.bin", chip_name);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1309:60: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1309 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_kicker_rlc.bin", chip_name);
            |                                                            ^~
      ......
       1398 |         r = gfx_v9_0_init_rlc_microcode(adev, ucode_prefix);
            |                                               ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1309:17: note: ‘snprintf’ output between 23 and 52 bytes into a destination of size 30
       1309 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_kicker_rlc.bin", chip_name);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1311:60: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1311 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name);
            |                                                            ^~
      ......
       1398 |         r = gfx_v9_0_init_rlc_microcode(adev, ucode_prefix);
            |                                               ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1311:17: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 30
       1311 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1344:60: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1344 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sjt_mec.bin", chip_name);
            |                                                            ^~
      ......
       1402 |         r = gfx_v9_0_init_cp_compute_microcode(adev, ucode_prefix);
            |                                                      ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1344:17: note: ‘snprintf’ output between 20 and 49 bytes into a destination of size 30
       1344 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sjt_mec.bin", chip_name);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1346:60: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1346 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
            |                                                            ^~
      ......
       1402 |         r = gfx_v9_0_init_cp_compute_microcode(adev, ucode_prefix);
            |                                                      ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1346:17: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 30
       1346 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1356:68: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1356 |                         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sjt_mec2.bin", chip_name);
            |                                                                    ^~
      ......
       1402 |         r = gfx_v9_0_init_cp_compute_microcode(adev, ucode_prefix);
            |                                                      ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1356:25: note: ‘snprintf’ output between 21 and 50 bytes into a destination of size 30
       1356 |                         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sjt_mec2.bin", chip_name);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1358:68: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=]
       1358 |                         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2.bin", chip_name);
            |                                                                    ^~
      ......
       1402 |         r = gfx_v9_0_init_cp_compute_microcode(adev, ucode_prefix);
            |                                                      ~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:1358:25: note: ‘snprintf’ output between 17 and 46 bytes into a destination of size 30
       1358 |                         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2.bin", chip_name);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Suggested-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      539ff12e
    • Srinivasan Shanmugam's avatar
      drm/amdgpu: Fix truncation in gfx_v10_0_init_microcode · 927a8a80
      Srinivasan Shanmugam authored
      The total size of the fw_name buffer is 8 (for "amdgpu/") + 30 (for
      ucode_prefix) + 5 (for "_pfp") + 5 (for "_wks") + 5 (for ".bin") = 53
      characters.
      
      Fixes the below with gcc W=1:
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c: In function ‘gfx_v10_0_early_init’:
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:3982:58: warning: ‘%s’ directive output may be truncated writing up to 4 bytes into a region of size between 0 and 29 [-Wformat-truncation=]
       3982 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp%s.bin", ucode_prefix, wks);
            |                                                          ^~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:3982:9: note: ‘snprintf’ output between 16 and 49 bytes into a destination of size 40
       3982 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp%s.bin", ucode_prefix, wks);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:3988:57: warning: ‘%s’ directive output may be truncated writing up to 4 bytes into a region of size between 1 and 30 [-Wformat-truncation=]
       3988 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me%s.bin", ucode_prefix, wks);
            |                                                         ^~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:3988:9: note: ‘snprintf’ output between 15 and 48 bytes into a destination of size 40
       3988 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me%s.bin", ucode_prefix, wks);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:3994:57: warning: ‘%s’ directive output may be truncated writing up to 4 bytes into a region of size between 1 and 30 [-Wformat-truncation=]
       3994 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce%s.bin", ucode_prefix, wks);
            |                                                         ^~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:3994:9: note: ‘snprintf’ output between 15 and 48 bytes into a destination of size 40
       3994 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce%s.bin", ucode_prefix, wks);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:4001:62: warning: ‘_rlc.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
       4001 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);
            |                                                              ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:4001:17: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
       4001 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:4017:58: warning: ‘%s’ directive output may be truncated writing up to 4 bytes into a region of size between 0 and 29 [-Wformat-truncation=]
       4017 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec%s.bin", ucode_prefix, wks);
            |                                                          ^~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:4017:9: note: ‘snprintf’ output between 16 and 49 bytes into a destination of size 40
       4017 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec%s.bin", ucode_prefix, wks);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:4024:54: warning: ‘_mec2’ directive output may be truncated writing 5 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
       4024 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2%s.bin", ucode_prefix, wks);
            |                                                      ^~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c:4024:9: note: ‘snprintf’ output between 17 and 50 bytes into a destination of size 40
       4024 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2%s.bin", ucode_prefix, wks);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Suggested-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      927a8a80
    • Srinivasan Shanmugam's avatar
      drm/amdgpu: Fix 'fw_name' buffer size to prevent truncations in amdgpu_mes_init_microcode · 20fd1446
      Srinivasan Shanmugam authored
      The snprintf function is used to write a formatted string into fw_name.
      The format of the string is "amdgpu/%s_mes%s.bin", where %s is replaced
      by the string in ucode_prefix and the second %s is replaced by either
      "_2" or "1" depending on the condition pipe == AMDGPU_MES_SCHED_PIPE.
      
      The length of the string "amdgpu/%s_mes%s.bin" is 16 characters plus the
      length of ucode_prefix and the length of the string "_2" or "1". The
      size of ucode_prefix is 30, so the maximum length of ucode_prefix is 29
      characters (since one character is needed for the null terminator).
      Therefore, the maximum possible length of the string written into
      fw_name is 16 + 29 + 2 = 47 characters.
      
      The size of fw_name is 40, so if the length of the string written into
      fw_name is more than 39 characters (since one character is needed for
      the null terminator), it will be truncated by the snprintf function, and
      thus warnings will be seen.
      
      By increasing the size of fw_name to 50, we ensure that fw_name is
      large enough to hold the maximum possible length of the string, so the
      snprintf function will not truncate the output.
      
      Fixes the below with gcc W=1:
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c: In function ‘amdgpu_mes_init_microcode’:
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1482:66: warning: ‘%s’ directive output may be truncated writing up to 1 bytes into a region of size between 0 and 29 [-Wformat-truncation=]
       1482 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
            |                                                                  ^~
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1482:17: note: ‘snprintf’ output between 16 and 46 bytes into a destination of size 40
       1482 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       1483 |                          ucode_prefix,
            |                          ~~~~~~~~~~~~~
       1484 |                          pipe == AMDGPU_MES_SCHED_PIPE ? "" : "1");
            |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1477:66: warning: ‘%s’ directive output may be truncated writing 1 byte into a region of size between 0 and 29 [-Wformat-truncation=]
       1477 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
            |                                                                  ^~
       1478 |                          ucode_prefix,
       1479 |                          pipe == AMDGPU_MES_SCHED_PIPE ? "_2" : "1");
            |                                                                 ~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1477:17: note: ‘snprintf’ output between 17 and 46 bytes into a destination of size 40
       1477 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       1478 |                          ucode_prefix,
            |                          ~~~~~~~~~~~~~
       1479 |                          pipe == AMDGPU_MES_SCHED_PIPE ? "_2" : "1");
            |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1477:66: warning: ‘%s’ directive output may be truncated writing 2 bytes into a region of size between 0 and 29 [-Wformat-truncation=]
       1477 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
            |                                                                  ^~
       1478 |                          ucode_prefix,
       1479 |                          pipe == AMDGPU_MES_SCHED_PIPE ? "_2" : "1");
            |                                                          ~~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1477:17: note: ‘snprintf’ output between 18 and 47 bytes into a destination of size 40
       1477 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes%s.bin",
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       1478 |                          ucode_prefix,
            |                          ~~~~~~~~~~~~~
       1479 |                          pipe == AMDGPU_MES_SCHED_PIPE ? "_2" : "1");
            |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1489:62: warning: ‘_mes.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
       1489 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes.bin",
            |                                                              ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1489:17: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
       1489 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mes.bin",
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       1490 |                          ucode_prefix);
            |                          ~~~~~~~~~~~~~
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Suggested-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      20fd1446
    • Srinivasan Shanmugam's avatar
      drm/amdgpu: Fix format character cut-off issues in amdgpu_vcn_early_init() · 7c2bc34a
      Srinivasan Shanmugam authored
      Reducing the size of ucode_prefix to 25 in the amdgpu_vcn_early_init
      function. This would ensure that the total number of characters being
      written into fw_name does not exceed its size of 40.
      
      Fixes the below with gcc W=1:
      drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c: In function ‘amdgpu_vcn_early_init’:
      drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:102:66: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
        102 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
            |                                                                  ^
      drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:102:17: note: ‘snprintf’ output between 12 and 41 bytes into a destination of size 40
        102 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:102:66: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
        102 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
            |                                                                  ^
      drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:102:17: note: ‘snprintf’ output between 12 and 41 bytes into a destination of size 40
        102 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:105:73: warning: ‘.bin’ directive output may be truncated writing 4 bytes into a region of size between 2 and 31 [-Wformat-truncation=]
        105 |                         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_%d.bin", ucode_prefix, i);
            |                                                                         ^~~~
      drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:105:25: note: ‘snprintf’ output between 14 and 43 bytes into a destination of size 40
        105 |                         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_%d.bin", ucode_prefix, i);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Suggested-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      7c2bc34a
    • Tao Zhou's avatar
      drm/amdgpu: add socket id parameter for psp query address cmd · 8b3495ea
      Tao Zhou authored
      And set the socket id.
      Signed-off-by: default avatarTao Zhou <tao.zhou1@amd.com>
      Reviewed-by: default avatarStanley.Yang <Stanley.Yang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      8b3495ea
    • Mukul Joshi's avatar
      drm/amdkfd: Cleanup workqueue during module unload · 417f78a2
      Mukul Joshi authored
      Destroy the high priority workqueue that handles interrupts
      during KFD node cleanup.
      Signed-off-by: default avatarMukul Joshi <mukul.joshi@amd.com>
      Reviewed-by: default avatarFelix Kuehling <felix.kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      417f78a2
    • Jonathan Kim's avatar
      drm/amdkfd: range check cp bad op exception interrupts · fb880635
      Jonathan Kim authored
      Due to a CP interrupt bug, bad packet garbage exception codes are raised.
      Do a range check so that the debugger and runtime do not receive garbage
      codes.
      Update the user api to guard exception code type checking as well.
      Signed-off-by: default avatarJonathan Kim <jonathan.kim@amd.com>
      Tested-by: default avatarJesse Zhang <jesse.zhang@amd.com>
      Reviewed-by: default avatarFelix Kuehling <felix.kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      fb880635
    • Harry Wentland's avatar
      Revert "drm/amd/display: Fix sending VSC (+ colorimetry) packets for DP/eDP displays without PSR" · 5daa2947
      Harry Wentland authored
      This causes flicker on a bunch of eDP panels. The info_packet code
      also caused regressions on other OSes that we haven't' seen on Linux
      yet, but that is likely due to the fact that we haven't had a chance
      to test those environments on Linux.
      
      We'll need to revisit this.
      
      This reverts commit 202260f6.
      
      Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3207
      Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3151Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      5daa2947
    • Shashank Sharma's avatar
      drm/amdgpu: Add a NULL check for freeing root PT · f88a7dd0
      Shashank Sharma authored
      This patch adds a NULL check to fix this crash reported during the
      freeing of root PT entry:
      
       BUG: unable to handle page fault for address: ffffc9002d637aa0
       #PF: supervisor write access in kernel mode
       #PF: error_code(0x0002) - not-present page
       RIP: 0010:amdgpu_vm_pt_free+0x66/0xe0 [amdgpu]
       PKRU: 55555554
       Call Trace:
       <TASK>
        amdgpu_vm_pt_free_root+0x60/0xa0 [amdgpu]
        amdgpu_vm_fini+0x2cb/0x5d0 [amdgpu]
        ? amdgpu_ctx_mgr_entity_fini+0x53/0x1c0 [amdgpu]
        amdgpu_driver_postclose_kms+0x191/0x2d0 [amdgpu]
        drm_file_free.part.0+0x1e5/0x260 [drm]
      
      Cc: Christian König <Christian.Koenig@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Felix Kuehling <felix.kuehling@amd.com>
      Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
      Acked-by: default avatarChristian König <Christian.Koenig@amd.com>
      Signed-off-by: default avatarShashank Sharma <shashank.sharma@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      f88a7dd0
    • Eric Huang's avatar
      drm/amdkfd: fix TLB flush after unmap for GFX9.4.2 · acf760c8
      Eric Huang authored
      TLB flush after unmap accidentially was removed on
      gfx9.4.2. It is to add it back.
      Signed-off-by: default avatarEric Huang <jinhuieric.huang@amd.com>
      Reviewed-by: default avatarHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      acf760c8
    • Sunil Khatri's avatar
      drm/amdgpu: refactor code to split devcoredump code · 9022f01b
      Sunil Khatri authored
      Refractor devcoredump code into new files since its
      functionality is expanded further and better to slit
      and devcoredump to have its own file.
      
      v2: Fix the build failure caught by arm compiler
      of implicit function declaration with #ifdef
      
      v3: squash in fix for implicit declaration error
      
      Cc: Ivan Lipski <ivan.lipski@amd.com>
      Acked-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarSunil Khatri <sunil.khatri@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      9022f01b
    • Aric Cyr's avatar
      drm/amd/display: 3.2.277 · b1edfb91
      Aric Cyr authored
      This version brings along following fixes:
      - Fix few problems for DCN35
      - Fix a bug which dereferences freed memory
      - Enable new interface design for alternate scrambling
      - Enhance IPS handshake
      - Increase Z8 watermark times
      - Fix DML2 problem
      - Revert patch which cause regression
      - Fix problems for dmub idle power optimization
      Acked-by: default avatarWayne Lin <wayne.lin@amd.com>
      Signed-off-by: default avatarAric Cyr <aric.cyr@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      b1edfb91
    • Chaitanya Dhere's avatar
      drm/amd/display: Add TB_BORROWED_MAX definition · aae9734b
      Chaitanya Dhere authored
      [Why & How]
      For DML2 to decouple it from other DML versions.
      Reviewed-by: default avatarDillon Varone <dillon.varone@amd.com>
      Acked-by: default avatarWayne Lin <wayne.lin@amd.com>
      Signed-off-by: default avatarChaitanya Dhere <chaitanya.dhere@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      aae9734b
    • Wenjing Liu's avatar
      drm/amd/display: fix a bug to dereference already freed old current state memory · 621cf07a
      Wenjing Liu authored
      [why]
      During minimal transition commit, the base state could be freed if it is current state.
      This is because after committing minimal transition state, the current state will be
      swapped to the minimal transition state and the old current state will be released.
      the release could cause the old current state's memory to be freed. However dc
      will derefernce this memory when release minimal transition state. Therefore, we
      need to retain the old current state until we release minimal transition state.
      
      Cc: Mario Limonciello <mario.limonciello@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJosip Pavic <josip.pavic@amd.com>
      Acked-by: default avatarWayne Lin <wayne.lin@amd.com>
      Signed-off-by: default avatarWenjing Liu <wenjing.liu@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      621cf07a
    • Peyton Lee's avatar
      drm/amdgpu/vpe: power on vpe when hw_init · 9ddafd1d
      Peyton Lee authored
      To fix mode2 reset failure.
      Should power on VPE when hw_init.
      Signed-off-by: default avatarPeyton Lee <peytolee@amd.com>
      Reviewed-by: default avatarLang Yu <lang.yu@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      9ddafd1d