1. 20 May, 2021 30 commits
  2. 12 May, 2021 2 commits
  3. 11 May, 2021 4 commits
  4. 10 May, 2021 4 commits
    • Gustavo A. R. Silva's avatar
      drm/amd/pm: Fix out-of-bounds bug · 564ac172
      Gustavo A. R. Silva authored
      Create new structure SISLANDS_SMC_SWSTATE_SINGLE, as initialState.levels
      and ACPIState.levels are never actually used as flexible arrays. Those
      arrays can be used as simple objects of type
      SISLANDS_SMC_HW_PERFORMANCE_LEVEL, instead.
      
      Currently, the code fails because flexible array _levels_ in
      struct SISLANDS_SMC_SWSTATE doesn't allow for code that accesses
      the first element of initialState.levels and ACPIState.levels
      arrays:
      
      drivers/gpu/drm/amd/pm/powerplay/si_dpm.c:
      4820: table->initialState.levels[0].mclk.vDLL_CNTL =
      4821:         cpu_to_be32(si_pi->clock_registers.dll_cntl);
      ...
      5021: table->ACPIState.levels[0].mclk.vDLL_CNTL =
      5022:         cpu_to_be32(dll_cntl);
      
      because such element cannot be accessed without previously allocating
      enough dynamic memory for it to exist (which never actually happens).
      So, there is an out-of-bounds bug in this case.
      
      That's why struct SISLANDS_SMC_SWSTATE should only be used as type
      for object driverState and new struct SISLANDS_SMC_SWSTATE_SINGLE is
      created as type for objects initialState, ACPIState and ULVState.
      
      Also, with the change from one-element array to flexible-array member
      in commit 0e1aa13c ("drm/amd/pm: Replace one-element array with
      flexible-array in struct SISLANDS_SMC_SWSTATE"), the size of
      dpmLevels in struct SISLANDS_SMC_STATETABLE should be fixed to be
      SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE instead of
      SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1.
      
      Fixes: 0e1aa13c ("drm/amd/pm: Replace one-element array with flexible-array in struct SISLANDS_SMC_SWSTATE")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      564ac172
    • Gustavo A. R. Silva's avatar
      drm/radeon/si_dpm: Fix SMU power state load · cc1a54d8
      Gustavo A. R. Silva authored
      Create new structure SISLANDS_SMC_SWSTATE_SINGLE, as initialState.levels
      and ACPIState.levels are never actually used as flexible arrays. Those
      arrays can be used as simple objects of type
      SISLANDS_SMC_HW_PERFORMANCE_LEVEL, instead.
      
      Currently, the code fails because flexible array _levels_ in
      struct SISLANDS_SMC_SWSTATE doesn't allow for code that access
      the first element of initialState.levels and ACPIState.levels
      arrays:
      
      4353         table->initialState.levels[0].mclk.vDLL_CNTL =
      4354                 cpu_to_be32(si_pi->clock_registers.dll_cntl);
      ...
      4555         table->ACPIState.levels[0].mclk.vDLL_CNTL =
      4556                 cpu_to_be32(dll_cntl);
      
      because such element cannot exist without previously allocating
      any dynamic memory for it (which never actually happens).
      
      That's why struct SISLANDS_SMC_SWSTATE should only be used as type
      for object driverState and new struct SISLANDS_SMC_SWSTATE_SINGLE is
      created as type for objects initialState, ACPIState and ULVState.
      
      Also, with the change from one-element array to flexible-array member
      in commit 96e27e8d ("drm/radeon/si_dpm: Replace one-element array
      with flexible-array in struct SISLANDS_SMC_SWSTATE"), the size of
      dpmLevels in struct SISLANDS_SMC_STATETABLE should be fixed to be
      SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE instead of
      SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1.
      
      Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1583
      Fixes: 96e27e8d ("drm/radeon/si_dpm: Replace one-element array with flexible-array in struct SISLANDS_SMC_SWSTATE")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Tested-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      cc1a54d8
    • Gustavo A. R. Silva's avatar
      drm/radeon/ni_dpm: Fix booting bug · 29377441
      Gustavo A. R. Silva authored
      Create new structure NISLANDS_SMC_SWSTATE_SINGLE, as initialState.levels
      and ACPIState.levels are never actually used as flexible arrays. Those
      arrays can be used as simple objects of type
      NISLANDS_SMC_HW_PERFORMANCE_LEVEL, instead.
      
      Currently, the code fails because flexible array _levels_ in
      struct NISLANDS_SMC_SWSTATE doesn't allow for code that access
      the first element of initialState.levels and ACPIState.levels
      arrays:
      
      drivers/gpu/drm/radeon/ni_dpm.c:
      1690         table->initialState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
      1691                 cpu_to_be32(ni_pi->clock_registers.mpll_ad_func_cntl);
      ...
      1903:   table->ACPIState.levels[0].mclk.vMPLL_AD_FUNC_CNTL = cpu_to_be32(mpll_ad_func_cntl);
      1904:   table->ACPIState.levels[0].mclk.vMPLL_AD_FUNC_CNTL_2 = cpu_to_be32(mpll_ad_func_cntl_2);
      
      because such element cannot exist without previously allocating
      any dynamic memory for it (which never actually happens).
      
      That's why struct NISLANDS_SMC_SWSTATE should only be used as type
      for object driverState and new struct SISLANDS_SMC_SWSTATE_SINGLE is
      created as type for objects initialState, ACPIState and ULVState.
      
      Also, with the change from one-element array to flexible-array member
      in commit 434fb1e7 ("drm/radeon/nislands_smc.h: Replace one-element
      array with flexible-array member in struct NISLANDS_SMC_SWSTATE"), the
      size of dpmLevels in struct NISLANDS_SMC_STATETABLE should be fixed to
      be NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE instead of
      NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1.
      
      Bug: https://lore.kernel.org/dri-devel/3eedbe78-1fbd-4763-a7f3-ac5665e76a4a@xenosoft.de/
      Fixes: 434fb1e7 ("drm/radeon/nislands_smc.h: Replace one-element array with flexible-array member in struct NISLANDS_SMC_SWSTATE")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarChristian Zigotzky <chzigotzky@xenosoft.de>
      Tested-by: default avatarChristian Zigotzky <chzigotzky@xenosoft.de>
      Link: https://lore.kernel.org/dri-devel/9bb5fcbd-daf5-1669-b3e7-b8624b3c36f9@xenosoft.de/Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      29377441
    • Dwaipayan Ray's avatar
      drm/amd/amdgpu: Fix errors in function documentation · c666bbf0
      Dwaipayan Ray authored
      Fix a couple of syntax errors and removed one excess
      parameter in the function documentations which lead
      to kernel docs build warning.
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarDwaipayan Ray <dwaipayanray1@gmail.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      c666bbf0