Re: [PATCH] Revert "drm/[radeon|amdgpu]: Replace one-element array and use struct_size() helper"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 02.06.20 um 21:10 schrieb Alex Deucher:
This reverts commit 4dea25853a6c0c16e373665153bd9eb6edc6319e.

This changes structs used by the hardware and breaks dpm on some cards.

Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>

We should also CC the original author of that patch. It is perfectly possible that sooner or later an automated script will test for this and we need an exception for our code.

Apart from that Acked-by: Christian König <christian.koenig@xxxxxxx>.

Christian.

---
  drivers/gpu/drm/amd/amdgpu/si_dpm.c       | 5 +++--
  drivers/gpu/drm/amd/amdgpu/sislands_smc.h | 2 +-
  drivers/gpu/drm/radeon/si_dpm.c           | 5 +++--
  3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
index 0fc56c5bac08..c00ba4b23c9a 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
@@ -5715,9 +5715,10 @@ static int si_upload_sw_state(struct amdgpu_device *adev,
  	int ret;
  	u32 address = si_pi->state_table_start +
  		offsetof(SISLANDS_SMC_STATETABLE, driverState);
+	u32 state_size = sizeof(SISLANDS_SMC_SWSTATE) +
+		((new_state->performance_level_count - 1) *
+		 sizeof(SISLANDS_SMC_HW_PERFORMANCE_LEVEL));
  	SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.driverState;
-	size_t state_size = struct_size(smc_state, levels,
-					new_state->performance_level_count);
memset(smc_state, 0, state_size); diff --git a/drivers/gpu/drm/amd/amdgpu/sislands_smc.h b/drivers/gpu/drm/amd/amdgpu/sislands_smc.h
index a089dbf8f7a9..d2930eceaf3c 100644
--- a/drivers/gpu/drm/amd/amdgpu/sislands_smc.h
+++ b/drivers/gpu/drm/amd/amdgpu/sislands_smc.h
@@ -186,7 +186,7 @@ struct SISLANDS_SMC_SWSTATE
      uint8_t                             levelCount;
      uint8_t                             padding2;
      uint8_t                             padding3;
-    SISLANDS_SMC_HW_PERFORMANCE_LEVEL   levels[];
+    SISLANDS_SMC_HW_PERFORMANCE_LEVEL   levels[1];
  };
typedef struct SISLANDS_SMC_SWSTATE SISLANDS_SMC_SWSTATE;
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index bab01ca864c6..a167e1c36d24 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -5253,9 +5253,10 @@ static int si_upload_sw_state(struct radeon_device *rdev,
  	int ret;
  	u32 address = si_pi->state_table_start +
  		offsetof(SISLANDS_SMC_STATETABLE, driverState);
+	u32 state_size = sizeof(SISLANDS_SMC_SWSTATE) +
+		((new_state->performance_level_count - 1) *
+		 sizeof(SISLANDS_SMC_HW_PERFORMANCE_LEVEL));
  	SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.driverState;
-	size_t state_size = struct_size(smc_state, levels,
-					new_state->performance_level_count);
memset(smc_state, 0, state_size);

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux