drm/amd: add definitions for new memory type
Subsystems (3)
PATCH 1/6 drm/amd: add definitions for new memory type
Support new versions of HBM and GDDR.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 12 ++++++++++++ drivers/gpu/drm/amd/include/atomfirmware.h | 4 ++++ include/uapi/drm/amdgpu_drm.h | 4 ++++ 3 files changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +12 -0
@@ -281,6 +281,18 @@ static int convert_atom_mem_type_to_vram_type(struct amdgpu_device *adev,case ATOM_DGPU_VRAM_TYPE_GDDR6 : vram_type =AMDGPU_VRAM_TYPE_GDDR6 ;break ; +case ATOM_DGPU_VRAM_TYPE_HBM3E : + vram_type =AMDGPU_VRAM_TYPE_HBM3E ; +break ; +case ATOM_DGPU_VRAM_TYPE_HBM4 : + vram_type =AMDGPU_VRAM_TYPE_HBM4 ; +break ; +case ATOM_DGPU_VRAM_TYPE_HBM4E : + vram_type =AMDGPU_VRAM_TYPE_HBM4E ; +break ; +case ATOM_DGPU_VRAM_TYPE_GDDR7 : + vram_type =AMDGPU_VRAM_TYPE_GDDR7 ; +break ;default : vram_type =AMDGPU_VRAM_TYPE_UNKNOWN ;break ;
drivers/gpu/drm/amd/include/atomfirmware.h +4 -0
@@ -183,6 +183,10 @@ enum atom_dgpu_vram_type {ATOM_DGPU_VRAM_TYPE_HBM2E =0x61 ,ATOM_DGPU_VRAM_TYPE_GDDR6 =0x70 ,ATOM_DGPU_VRAM_TYPE_HBM3 =0x80 , +ATOM_DGPU_VRAM_TYPE_HBM3E =0x81 , +ATOM_DGPU_VRAM_TYPE_HBM4 =0x82 , +ATOM_DGPU_VRAM_TYPE_HBM4E =0x83 , + ATOM_DGPU_VRAM_TYPE_GDDR7 = 0x90, }; enum atom_dp_vs_preemph_def{
include/uapi/drm/amdgpu_drm.h +4 -0
@@ -1423,6 +1423,10 @@ struct drm_amdgpu_info_vbios {#define AMDGPU_VRAM_TYPE_DDR5 10#define AMDGPU_VRAM_TYPE_LPDDR4 11#define AMDGPU_VRAM_TYPE_LPDDR5 12 +#define AMDGPU_VRAM_TYPE_HBM3E 13 +#define AMDGPU_VRAM_TYPE_HBM4 14 +#define AMDGPU_VRAM_TYPE_HBM4E 15 +#define AMDGPU_VRAM_TYPE_GDDR7 16#define AMDGPU_VRAM_TYPE_HBM_WIDTH 4096
Signature · 1 line
2.34.1
PATCH 2/6 drm/amdgpu: adjust high bits for RAS retired page
Per UMC address conversion algorithm, the high row bits of UMC MCA address are changed when they're converted into normalized address on specific ASICs.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +11 -2
@@ -180,7 +180,7 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev,struct ta_ras_query_address_output *addr_out, bool dump_addr) { - uint32_t col, col_lower, row, row_lower, bank; + uint32_t col, col_lower, row, row_lower, row_high, bank;uint32_t channel_index =0 , umc_inst =0 ;uint32_t i, loop_bits[UMC_V12_0_RETIRE_LOOP_BITS ];uint64_t soc_pa, column, err_addr;
@@ -243,9 +243,18 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev, paddr_out->pa.pa = soc_pa;/* get column bit 0 and 1 in mca address */ col_lower = (err_addr >>1 ) &0x3ULL ; -/* MA_R13_BIT will be handled later */ +/* extra row bit will be handled later */ row_lower = (err_addr >>UMC_V12_0_MA_R0_BIT ) &0x1fffULL ; +if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) { + row_high = (soc_pa >>UMC_V12_0_PA_R13_BIT ) &0x3ULL ; +/* it's 2.25GB in each channel, from MCA address to PA +* [R14 R13] is converted if the two bits value are 0x3, +* get them from PA instead of MCA address. +*/ + row_lower |= (row_high <<13 ); + } +if (!err_data && !dump_addr) goto out;
Signature · 1 line
2.34.1
PATCH 3/6 drm/amdgpu: add get_retire_flip_bits for UMC
In reply to Tao ZhouAdd the general interface to get flip bits for RAS bad page retirement.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
@@ -3474,6 +3474,10 @@ int amdgpu_ras_init_badpage_info(struct amdgpu_device *adev)if (!adev->umc.ras || !adev->umc.ras->convert_ras_err_addr) control->ras_num_pa_recs = control->ras_num_recs; +if (adev->umc.ras && + adev->umc.ras->get_retire_flip_bits) + adev->umc.ras->get_retire_flip_bits (adev); +if (control->ras_num_recs) { ret =amdgpu_ras_load_bad_pages (adev);if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +15 -0
@@ -78,6 +78,18 @@#define UMC_NPS_SHIFT 40#define UMC_NPS_MASK 0xffULL +/* three column bits and one row bit in MCA address flip +* in bad page retirement +*/ +#define RETIRE_FLIP_BITS_NUM 4 + +struct amdgpu_umc_flip_bits { +uint32_t flip_bits_in_pa[RETIRE_FLIP_BITS_NUM ]; +uint32_t flip_row_bit; +uint32_t r13_in_pa; +uint32_t bit_num; +}; +typedef int (*umc_func )(struct amdgpu_device *adev,uint32_t node_inst,uint32_t umc_inst,uint32_t ch_inst,void *data);
@@ -100,6 +112,7 @@ struct amdgpu_umc_ras { bool dump_addr);uint32_t (*get_die_id_from_pa)(struct amdgpu_device *adev,uint64_t mca_addr,uint64_t retired_page); +void (*get_retire_flip_bits)(struct amdgpu_device *adev); };struct amdgpu_umc_funcs {
@@ -130,6 +143,8 @@ struct amdgpu_umc {/* active mask for umc node instance */ unsigned long active_mask; + +struct amdgpu_umc_flip_bits flip_bits; };int amdgpu_umc_ras_sw_init (struct amdgpu_device *adev);
Signature · 1 line
2.34.1
PATCH 4/6 drm/amdgpu: implement get_retire_flip_bits for UMC v12
In reply to Tao ZhouThe RAS bad page retire flip bits can be set per vram type, vram vendor and nps mode.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 1 - drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 82 +++++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 2 - 3 files changed, 53 insertions(+), 32 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -1
@@ -1504,7 +1504,6 @@ static void gmc_v9_0_set_umc_funcs(struct amdgpu_device *adev) adev->umc.umc_inst_num =UMC_V12_0_UMC_INSTANCE_NUM ; adev->umc.node_inst_num /=UMC_V12_0_UMC_INSTANCE_NUM ; adev->umc.channel_offs =UMC_V12_0_PER_CHANNEL_OFFSET ; - adev->umc.retire_unit =UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ;if (!adev->gmc.xgmi.connected_to_cpu && !adev->gmc.is_app_apu) adev->umc.ras = &umc_v12_0_ras;break ;
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +53 -29
119 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +0 -2
@@ -55,8 +55,6 @@#define UMC_V12_0_NA_MAP_PA_NUM 8/* R13 bit shift should be considered, double the number */ #define UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL (UMC_V12_0_NA_MAP_PA_NUM * 2) -/* C2, C3, C4, R13, four bits in MCA address are looped in retirement */ -#define UMC_V12_0_RETIRE_LOOP_BITS 4/* column bits in SOC physical address */ #define UMC_V12_0_PA_C2_BIT 15
Signature · 1 line
2.34.1
PATCH 5/6 drm/amdgu: get RAS retire flip bits for HBM3E/HBM4
In reply to Tao ZhouGet RAS retire flip bits for HBM with different types and vendors in various NPS modes.
Also set flip row bit and MCA R13 bit in PA in different NPS modes.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 59 ++++++++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 1 + 2 files changed, 51 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +50 -9
@@ -24,6 +24,7 @@#include "amdgpu_ras.h" #include "amdgpu_umc.h" #include "amdgpu.h" +#include "atom.h" #include "umc/umc_12_0_0_offset.h" #include "umc/umc_12_0_0_sh_mask.h" #include "mp/mp_13_0_6_sh_mask.h"
@@ -178,6 +179,7 @@ static void umc_v12_0_get_retire_flip_bits(struct amdgpu_device *adev) {enum amdgpu_memory_partition nps =AMDGPU_NPS1_PARTITION_MODE ;uint32_t vram_type = adev->gmc.vram_type; +uint8_t hbm_vendor = adev->gmc.vram_vendor;struct amdgpu_umc_flip_bits *flip_bits = &(adev->umc.flip_bits);if (adev->gmc.gmc_funcs->query_mem_partition_mode)
@@ -188,23 +190,62 @@ static void umc_v12_0_get_retire_flip_bits(struct amdgpu_device *adev) flip_bits->flip_bits_in_pa[1 ] =UMC_V12_0_PA_C3_BIT ; flip_bits->flip_bits_in_pa[2 ] =UMC_V12_0_PA_C4_BIT ; flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R13_BIT ; + flip_bits->flip_row_bit =13 ; flip_bits->bit_num =4 ; + flip_bits->r13_in_pa =UMC_V12_0_PA_R13_BIT ; + +if (nps ==AMDGPU_NPS2_PARTITION_MODE ) { + flip_bits->flip_bits_in_pa[0 ] =UMC_V12_0_PA_CH5_BIT ; + flip_bits->flip_bits_in_pa[1 ] =UMC_V12_0_PA_C2_BIT ; + flip_bits->flip_bits_in_pa[2 ] =UMC_V12_0_PA_B1_BIT ; + flip_bits->r13_in_pa =UMC_V12_0_PA_R12_BIT ; + }else if (nps ==AMDGPU_NPS4_PARTITION_MODE ) { + flip_bits->flip_bits_in_pa[0 ] =UMC_V12_0_PA_CH4_BIT ; + flip_bits->flip_bits_in_pa[1 ] =UMC_V12_0_PA_CH5_BIT ; + flip_bits->flip_bits_in_pa[2 ] =UMC_V12_0_PA_B0_BIT ; + flip_bits->r13_in_pa =UMC_V12_0_PA_R11_BIT ; + }switch (vram_type) {case AMDGPU_VRAM_TYPE_HBM :/* other nps modes are taken as nps1 */ -if (nps ==AMDGPU_NPS2_PARTITION_MODE ) { - flip_bits->flip_bits_in_pa[0 ] =UMC_V12_0_PA_CH5_BIT ; - flip_bits->flip_bits_in_pa[1 ] =UMC_V12_0_PA_C2_BIT ; - flip_bits->flip_bits_in_pa[2 ] =UMC_V12_0_PA_B1_BIT ; +if (nps ==AMDGPU_NPS2_PARTITION_MODE ) flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R12_BIT ; +else if (nps ==AMDGPU_NPS4_PARTITION_MODE ) + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R11_BIT ; + +break ; +case AMDGPU_VRAM_TYPE_HBM3E : +if (hbm_vendor ==SAMSUNG ) { + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R12_BIT ; + flip_bits->flip_row_bit =12 ; + +if (nps ==AMDGPU_NPS2_PARTITION_MODE ) + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R11_BIT ; +else if (nps ==AMDGPU_NPS4_PARTITION_MODE ) + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R10_BIT ; + }else if (hbm_vendor ==HYNIX ) { + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R0_BIT ; + flip_bits->flip_row_bit =0 ; + +if (nps ==AMDGPU_NPS2_PARTITION_MODE ) + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_C4_BIT ; +else if (nps ==AMDGPU_NPS4_PARTITION_MODE ) + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_B1_BIT ; } -if (nps ==AMDGPU_NPS4_PARTITION_MODE ) { - flip_bits->flip_bits_in_pa[0 ] =UMC_V12_0_PA_CH4_BIT ; - flip_bits->flip_bits_in_pa[1 ] =UMC_V12_0_PA_CH5_BIT ; - flip_bits->flip_bits_in_pa[2 ] =UMC_V12_0_PA_B0_BIT ; - flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R11_BIT ; +break ; +case AMDGPU_VRAM_TYPE_HBM4 : +if (hbm_vendor ==HYNIX ) { + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_R0_BIT ; + flip_bits->flip_row_bit =0 ; + +if (nps ==AMDGPU_NPS2_PARTITION_MODE ) + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_C4_BIT ; +else if (nps ==AMDGPU_NPS4_PARTITION_MODE ) + flip_bits->flip_bits_in_pa[3 ] =UMC_V12_0_PA_B1_BIT ; + }else { + flip_bits->bit_num =3 ; }break ;
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +1 -0
@@ -62,6 +62,7 @@#define UMC_V12_0_PA_C4_BIT 21/* row bits in SOC physical address */ #define UMC_V12_0_PA_R0_BIT 22 +#define UMC_V12_0_PA_R10_BIT 32#define UMC_V12_0_PA_R11_BIT 33#define UMC_V12_0_PA_R12_BIT 34#define UMC_V12_0_PA_R13_BIT 35
Signature · 1 line
2.34.1
PATCH 6/6 drm/amdgpu: set flip bits for RAS bad pages
In reply to Tao ZhouMake the code more general, user doesn't need to pay attention to the detail of flip bits setting.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +8 -9
@@ -309,9 +309,10 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev, col_lower = (err_addr >>1 ) &0x3ULL ;/* extra row bit will be handled later */ row_lower = (err_addr >>UMC_V12_0_MA_R0_BIT ) &0x1fffULL ; + row_lower &= ~BIT_ULL (adev->umc.flip_bits.flip_row_bit);if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,5 ,0 )) { - row_high = (soc_pa >>UMC_V12_0_PA_R13_BIT ) &0x3ULL ; + row_high = (soc_pa >> adev->umc.flip_bits.r13_in_pa) &0x3ULL ;/* it's 2.25GB in each channel, from MCA address to PA * [R14 R13] is converted if the two bits value are 0x3, * get them from PA instead of MCA address.
@@ -329,8 +330,11 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev, soc_pa |= (((column >> i) &0x1ULL ) << flip_bits[i]); col = ((column &0x7 ) <<2 ) | col_lower; -/* add row bit 13 */ - row = ((column >>3 ) <<13 ) | row_lower; +/* handle extra row bit */ +if (bit_num ==RETIRE_FLIP_BITS_NUM ) { + row = ((column >>3 ) << adev->umc.flip_bits.flip_row_bit) | + row_lower; + }if (dump_addr) dev_info(adev->dev,
@@ -550,7 +554,7 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,struct ras_ecc_err *ecc_err;struct ta_ras_query_address_output addr_out;enum amdgpu_memory_partition nps =AMDGPU_NPS1_PARTITION_MODE ; -uint32_t shift_bit =UMC_V12_0_PA_C4_BIT ; +uint32_t shift_bit = adev->umc.flip_bits.flip_bits_in_pa[2 ];int count, ret, i; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID);
@@ -598,11 +602,6 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,if (adev->gmc.gmc_funcs->query_mem_partition_mode) nps = adev->gmc.gmc_funcs->query_mem_partition_mode (adev); -if (nps ==AMDGPU_NPS2_PARTITION_MODE ) - shift_bit =UMC_V12_0_PA_B1_BIT ; -if (nps ==AMDGPU_NPS4_PARTITION_MODE ) - shift_bit =UMC_V12_0_PA_B0_BIT ; -/* If converted pa_pfn is 0, use pa C4 pfn. */ if (!ecc_err->pa_pfn) ecc_err->pa_pfn =BIT_ULL (shift_bit) >>AMDGPU_GPU_PAGE_SHIFT ;
Signature · 1 line
2.34.1