From b69b3051d6b044b4a1558d9e2ca82d318897e54c Mon Sep 17 00:00:00 2001 From: Hawking Zhang Date: Fri, 12 Jun 2026 12:03:44 +0800 Subject: [PATCH] drm/amdgpu: Use max SA WGP count for GC info v1.5 CU config For GC info table v1.5, calculate the WGP totals for SA and SA1 independently, then initialize max_cu_per_sh with the greater value. If both totals are equal, keep the SA value. Signed-off-by: Hawking Zhang Reviewed-by: Shiwu Zhang Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c index b567860aa555..5488715938b0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c @@ -1997,6 +1997,7 @@ static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev) uint8_t *discovery_bin = adev->discovery.bin; struct table_info *info; union gc_info *gc_info; + uint32_t num_wgps_per_sa, num_wgps_per_sa1; u16 offset; if (!discovery_bin) { @@ -2070,11 +2071,13 @@ static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev) adev->gfx.config.gc_max_num_residency_ways = le32_to_cpu(gc_info->v1_5.gc_max_num_residency_ways); adev->gfx.config.gc_cache_ways_size_in_bytes = le32_to_cpu(gc_info->v1_5.gc_cache_ways_size_in_bytes); adev->gfx.config.gc_reserved = le32_to_cpu(gc_info->v1_5.gc_reserved); - /* GC info v1.5 derives max_cu_per_sh from the combined SA/SA1 WGP counts. */ - adev->gfx.config.max_cu_per_sh = le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) + - le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa) + - le32_to_cpu(gc_info->v1_5.gc_num_wgp0_per_sa1) + - le32_to_cpu(gc_info->v1_5.gc_num_wgp1_per_sa1); + + num_wgps_per_sa = le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) + + le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa); + num_wgps_per_sa1 = le32_to_cpu(gc_info->v1_5.gc_num_wgp0_per_sa1) + + le32_to_cpu(gc_info->v1_5.gc_num_wgp1_per_sa1); + adev->gfx.config.max_cu_per_sh = num_wgps_per_sa >= num_wgps_per_sa1 ? + num_wgps_per_sa : num_wgps_per_sa1; } break; case 2: