]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdgpu: add a flag to indicate UMC channel index version
authorTao Zhou <tao.zhou1@amd.com>
Wed, 30 Oct 2024 06:17:49 +0000 (14:17 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 10 Dec 2024 15:26:46 +0000 (10:26 -0500)
v1 (legacy way): store channel index within a UMC instance in eeprom
v2: store global channel index in eeprom

V2: only save the flag on eeprom, clear it after saving.

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
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h

index f28f6b4ba765d0022badbb5e2790f62d7b867e44..f4a9e15389ae24a0b5f5852d9eb08fc8dea63548 100644 (file)
@@ -841,7 +841,7 @@ int amdgpu_ras_eeprom_append(struct amdgpu_ras_eeprom_control *control,
                             const u32 num)
 {
        struct amdgpu_device *adev = to_amdgpu_device(control);
-       int res;
+       int res, i;
 
        if (!__is_ras_eeprom_supported(adev))
                return 0;
@@ -855,6 +855,10 @@ int amdgpu_ras_eeprom_append(struct amdgpu_ras_eeprom_control *control,
                return -EINVAL;
        }
 
+       /* set the new channel index flag */
+       for (i = 0; i < num; i++)
+               record[i].retired_page |= UMC_CHANNEL_IDX_V2;
+
        mutex_lock(&control->ras_tbl_mutex);
 
        res = amdgpu_ras_eeprom_append_table(control, record, num);
@@ -864,6 +868,11 @@ int amdgpu_ras_eeprom_append(struct amdgpu_ras_eeprom_control *control,
                amdgpu_ras_debugfs_set_ret_size(control);
 
        mutex_unlock(&control->ras_tbl_mutex);
+
+       /* clear channel index flag, the flag is only saved on eeprom */
+       for (i = 0; i < num; i++)
+               record[i].retired_page &= ~UMC_CHANNEL_IDX_V2;
+
        return res;
 }
 
index 2f71194d5da86cf344104650db642923235b5478..f97c45b4eeb8e2ae0c26219d4e0e5922b59e1d14 100644 (file)
 
 /* Page retirement tag */
 #define UMC_ECC_NEW_DETECTED_TAG       0x1
+/*
+ * a flag to indicate v2 of channel index stored in eeprom
+ *
+ * v1 (legacy way): store channel index within a umc instance in eeprom
+ *    range in UMC v12: 0 ~ 7
+ * v2: store global channel index in eeprom
+ *    range in UMC v12: 0 ~ 127
+ *
+ * NOTE: it's better to store it in eeprom_table_record.mem_channel,
+ * but there is only 8 bits in mem_channel, and the channel number may
+ * increase in the future, we decide to save it in
+ * eeprom_table_record.retired_page. retired_page is useless in v2,
+ * we depend on eeprom_table_record.address instead of retired_page in v2.
+ * Only 48 bits are saved on eeprom, use bit 47 here.
+ */
+#define UMC_CHANNEL_IDX_V2     BIT_ULL(47)
 
 typedef int (*umc_func)(struct amdgpu_device *adev, uint32_t node_inst,
                        uint32_t umc_inst, uint32_t ch_inst, void *data);