]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdgpu: change if condition for bad channel bitmap update
authorTao Zhou <tao.zhou1@amd.com>
Tue, 19 Sep 2023 08:00:19 +0000 (16:00 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2023 20:54:52 +0000 (16:54 -0400)
The amdgpu_ras_eeprom_control.bad_channel_bitmap is u32 type, but the
channel index could be larger than 32. For the ASICs whose channel
number is more than 32, the amdgpu_dpm_send_hbm_bad_channel_flag
interface is not supported, so we simply bypass channel bitmap update under
this condition.

v2: replace sizeof with BITS_PER_TYPE, we should check bit number
instead of byte number.

Signed-off-by: Tao Zhou <tao.zhou1@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c

index 8ced4be784e004e181d0587e28ab245a142465b8..c60d2f79eeeff88737ff2a41f4502dcfc69b2e04 100644 (file)
@@ -616,7 +616,8 @@ amdgpu_ras_eeprom_append_table(struct amdgpu_ras_eeprom_control *control,
                __encode_table_record_to_buf(control, &record[i], pp);
 
                /* update bad channel bitmap */
-               if (!(control->bad_channel_bitmap & (1 << record[i].mem_channel))) {
+               if ((record[i].mem_channel < BITS_PER_TYPE(control->bad_channel_bitmap)) &&
+                   !(control->bad_channel_bitmap & (1 << record[i].mem_channel))) {
                        control->bad_channel_bitmap |= 1 << record[i].mem_channel;
                        con->update_channel_flag = true;
                }
@@ -969,7 +970,8 @@ int amdgpu_ras_eeprom_read(struct amdgpu_ras_eeprom_control *control,
                __decode_table_record_from_buf(control, &record[i], pp);
 
                /* update bad channel bitmap */
-               if (!(control->bad_channel_bitmap & (1 << record[i].mem_channel))) {
+               if ((record[i].mem_channel < BITS_PER_TYPE(control->bad_channel_bitmap)) &&
+                   !(control->bad_channel_bitmap & (1 << record[i].mem_channel))) {
                        control->bad_channel_bitmap |= 1 << record[i].mem_channel;
                        con->update_channel_flag = true;
                }