drm/amdgpu: optimize umc v12 address conversion function
Subsystems (2)
PATCH 1/3 drm/amdgpu: optimize umc v12 address conversion function
Split into 3 parts:
1. Convert soc physical address via ras ta.
2. Expand bad pages from soc physical address.
3. Dump bad address info.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 116 ++++++++++++++++--------- 1 file changed, 77 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +77 -39
@@ -225,26 +225,16 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev, } } -static int umc_v12_0_convert_err_addr (struct amdgpu_device *adev, -struct ta_ras_query_address_input *addr_in, -uint64_t *pfns,int len) +static void umc_v12_0_dump_addr_info (struct amdgpu_device *adev, +struct ta_ras_query_address_output *addr_out, +uint64_t err_addr) {uint32_t col, row, row_xor, bank, channel_index; -uint64_t soc_pa, retired_page, column, err_addr; -struct ta_ras_query_address_output addr_out; -uint32_t pos =0 ; - - err_addr = addr_in->ma.err_addr; - addr_in->addr_type =TA_RAS_MCA_TO_PA ; -if (psp_ras_query_address (&adev->psp, addr_in, &addr_out)) { -dev_warn (adev->dev,"Failed to query RAS physical address for 0x%llx" , - err_addr); -return 0 ; - } +uint64_t soc_pa, retired_page, column; - soc_pa = addr_out.pa.pa; - bank = addr_out.pa.bank; - channel_index = addr_out.pa.channel_idx; + soc_pa = addr_out->pa.pa; + bank = addr_out->pa.bank; + channel_index = addr_out->pa.channel_idx; col = (err_addr >>1 ) &0x1fULL ; row = (err_addr >>10 ) &0x3fffULL ;
@@ -258,11 +248,6 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); - -if (pos >= len) -return 0 ; - pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; -/* include column bit 0 and 1 */ col &=0x3 ; col |= (column <<2 );
@@ -270,6 +255,35 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,"Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n" , retired_page, row, col, bank, channel_index); +/* shift R13 bit */ + retired_page ^= (0x1ULL <<UMC_V12_0_PA_R13_BIT ); +dev_info (adev->dev, +"Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n" , + retired_page, row_xor, col, bank, channel_index); + } +} + +static int umc_v12_0_expand_addr_to_bad_pages (struct amdgpu_device *adev, +uint64_t pa_addr,uint64_t *pfns,int len) +{ +uint64_t soc_pa, retired_page, column; +uint32_t pos =0 ; + + soc_pa = pa_addr; +/* clear [C3 C2] in soc physical address */ + soc_pa &= ~(0x3ULL <<UMC_V12_0_PA_C2_BIT ); +/* clear [C4] in soc physical address */ + soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_C4_BIT ); + +/* loop for all possibilities of [C4 C3 C2] */ +for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { + retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); + retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); + +if (pos >= len) +return 0 ; + pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; +/* shift R13 bit */ retired_page ^= (0x1ULL <<UMC_V12_0_PA_R13_BIT );
@@ -277,14 +291,40 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,return 0 ; pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; -dev_info (adev->dev, -"Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n" , - retired_page, row_xor, col, bank, channel_index); }return pos; } +static int umc_v12_0_convert_mca_to_addr (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch,uint32_t umc, +uint32_t node,uint32_t socket, +uint64_t *addr,bool dump_addr) +{ +struct ta_ras_query_address_input addr_in; +struct ta_ras_query_address_output addr_out; + +memset (&addr_in,0 ,sizeof (addr_in)); + addr_in.ma.err_addr = err_addr; + addr_in.ma.ch_inst = ch; + addr_in.ma.umc_inst = umc; + addr_in.ma.node_inst = node; + addr_in.ma.socket_id = socket; + addr_in.addr_type =TA_RAS_MCA_TO_PA ; +if (psp_ras_query_address (&adev->psp, &addr_in, &addr_out)) { +dev_warn (adev->dev,"Failed to query RAS physical address for 0x%llx" , + err_addr); +return -EINVAL ; + } + +if (dump_addr) +umc_v12_0_dump_addr_info (adev, &addr_out, err_addr); + + *addr = addr_out.pa.pa; + +return 0 ; +} +static int umc_v12_0_query_error_address (struct amdgpu_device *adev,uint32_t node_inst,uint32_t umc_inst,uint32_t ch_inst,void *data)
@@ -483,12 +523,10 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, {struct amdgpu_ras *con =amdgpu_ras_get_context (adev);uint16_t hwid, mcatype; -struct ta_ras_query_address_input addr_in;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 ; +uint64_t err_addr, hash_val =0 , pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count; -int ret; +int count, ret; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID); mcatype =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , McaType);
@@ -514,17 +552,17 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,MCA_IPID_2_UMC_CH (ipid), err_addr); -memset (page_pfn,0 ,sizeof (page_pfn)); - -memset (&addr_in,0 ,sizeof (addr_in)); - addr_in.ma.err_addr = err_addr; - addr_in.ma.ch_inst =MCA_IPID_2_UMC_CH (ipid); - addr_in.ma.umc_inst =MCA_IPID_2_UMC_INST (ipid); - addr_in.ma.node_inst =MCA_IPID_2_DIE_ID (ipid); - addr_in.ma.socket_id =MCA_IPID_2_SOCKET_ID (ipid); + ret =umc_v12_0_convert_mca_to_addr (adev, + err_addr,MCA_IPID_2_UMC_CH (ipid), +MCA_IPID_2_UMC_INST (ipid),MCA_IPID_2_DIE_ID (ipid), +MCA_IPID_2_SOCKET_ID (ipid), &pa_addr, true); +if (ret) +return ret; - count =umc_v12_0_convert_err_addr (adev, - &addr_in, page_pfn,ARRAY_SIZE (page_pfn)); +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + pa_addr, + page_pfn,ARRAY_SIZE (page_pfn));if (count <=0 ) {dev_warn (adev->dev,"Fail to convert error address! count:%d\n" , count);return 0 ;
Signature · 1 line
2.34.1
PATCH 2/3 drm/amdgpu: optimize logging deferred error info
1. Use pa_pfn as the radix-tree key index to log
deferred error info.
2. Use local array to store expanded bad pages.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 14 ++---- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 65 ++++++++++++------------- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 5 ++ 4 files changed, 40 insertions(+), 46 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -1
@@ -476,10 +476,10 @@ struct ras_err_pages { };struct ras_ecc_err { -u64 hash_index;uint64_t status;uint64_t ipid;uint64_t addr; +uint64_t pa_pfn;struct ras_err_pages err_pages; };
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -11
@@ -523,18 +523,10 @@ int amdgpu_umc_logs_ecc_err(struct amdgpu_device *adev, ecc_log = &con->umc_ecc_log;mutex_lock (&ecc_log->lock); - ret =radix_tree_insert (ecc_tree, ecc_err->hash_index, ecc_err); -if (!ret) { -struct ras_err_pages *err_pages = &ecc_err->err_pages; -int i; - -/* Reserve memory */ -for (i =0 ; i < err_pages->count; i++) -amdgpu_ras_reserve_page (adev, err_pages->pfn[i]); - + ret =radix_tree_insert (ecc_tree, ecc_err->pa_pfn, ecc_err); +if (!ret)radix_tree_tag_set (ecc_tree, - ecc_err->hash_index,UMC_ECC_NEW_DETECTED_TAG ); - } + ecc_err->pa_pfn,UMC_ECC_NEW_DETECTED_TAG );mutex_unlock (&ecc_log->lock);return ret;
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +31 -34
115 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +5 -0
@@ -81,6 +81,11 @@ (((REG_GET_FIELD (ipid,MCMP1_IPIDT0 , InstanceIdLo) &0x1 ) <<2 ) | \ (REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdHi) & 0x03)) +#define UMC_V12_ADDR_MASK_BAD_COLS (addr) \ + ((addr) & ~((0x3ULL << UMC_V12_0_PA_C2_BIT) | \ + (0x1ULL << UMC_V12_0_PA_C4_BIT) | \ + (0x1ULL << UMC_V12_0_PA_R13_BIT))) +bool umc_v12_0_is_deferred_error (struct amdgpu_device *adev,uint64_t mc_umc_status);bool umc_v12_0_is_uncorrectable_error (struct amdgpu_device *adev,uint64_t mc_umc_status);bool umc_v12_0_is_correctable_error (struct amdgpu_device *adev,uint64_t mc_umc_status);
Signature · 1 line
2.34.1
RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 123 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 4:16 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info1. Use
pa_pfnas the radix-tree key index to log
deferred error info.
2. Use local array to store expanded bad pages.Signed-off-by YiPeng Chai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 14 ++---- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 65 ++++++++++++------------- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 5 ++ 4 files changed, 40 insertions(+), 46 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1
-1@@ -476,10 +476,10 @@ struct ras_err_pages { };struct ras_ecc_err { -u64 hash_index;uint64_t status;uint64_t ipid;uint64_t addr; +uint64_t pa_pfn;struct ras_err_pages err_pages; };drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3
-11@@ -523,18 +523,10 @@ int amdgpu_umc_logs_ecc_err(struct amdgpu_device *adev, ecc_log = &con->umc_ecc_log;mutex_lock (&ecc_log->lock); - ret =radix_tree_insert (ecc_tree, ecc_err->hash_index, ecc_err); -if (!ret) { -struct ras_err_pages *err_pages = &ecc_err->err_pages; -int i; - -/* Reserve memory */ -for (i =0 ; i < err_pages->count; i++) -amdgpu_ras_reserve_page (adev, err_pages->pfn[i]); - + ret =radix_tree_insert (ecc_tree, ecc_err->pa_pfn, ecc_err); +if (!ret)radix_tree_tag_set (ecc_tree, - ecc_err->hash_index,UMC_ECC_NEW_DETECTED_TAG ); - } + ecc_err->pa_pfn, UMC_ECC_NEW_DETECTED_TAG);mutex_unlock (&ecc_log->lock);return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-2@@ -524,9 +524,9 @@ static int umc_v12_0_update_ecc_status(structamdgpu_device *adev, struct amdgpu_ras *con = amdgpu_ras_get_context(adev);uint16_t hwid, mcatype;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 , pa_addr =0 ; +uint64_t err_addr, pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count, ret; +int count, ret, i; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID);mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@ -559,39 +559,18 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, if (ret) return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-memset (page_pfn,0 ,sizeof (page_pfn)); - count =umc_v12_0_expand_addr_to_bad_pages (adev, - pa_addr, - page_pfn,ARRAY_SIZE (page_pfn)); -if (count <=0 ) { - dev_warn(adev->dev, "Fail to convert error address!count:%d\n", count);
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-11-return 0 ; - } - - ret =amdgpu_umc_build_pages_hash (adev, - page_pfn, count, &hash_val); -if (ret) { -dev_err (adev->dev,"Fail to build error pages hash\n" ); -return ret; - } - ecc_err =kzalloc (sizeof (*ecc_err),GFP_KERNEL );if (!ecc_err)return -ENOMEM ; - ecc_err->err_pages.pfn = kcalloc(count, sizeof(*ecc_err->err_pages.pfn),
GFP_KERNEL);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-if (!ecc_err->err_pages.pfn) { -kfree (ecc_err); -return -ENOMEM ; - } - - memcpy(ecc_err->err_pages.pfn, page_pfn, count * sizeof(*ecc_err-Quoted 1 line
err_pages.pfn));
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-3- ecc_err->err_pages.count = count; - - ecc_err->hash_index = hash_val;
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +7
-0ecc_err->status = status; ecc_err->ipid = ipid; ecc_err->addr = addr; + ecc_err->pa_pfn =UMC_V12_ADDR_MASK_BAD_COLS (pa_addr) >> +AMDGPU_GPU_PAGE_SHIFT ; + +/* If converted pa_pfn is 0, use pa xor pfn. */ +if (!ecc_err->pa_pfn) + ecc_err->pa_pfn =BIT_ULL (UMC_V12_0_PA_R13_BIT ) >> +AMDGPU_GPU_PAGE_SHIFT ;
[Tao] why address 0 should be avoided?
Quoted 98 lines
ret = amdgpu_umc_logs_ecc_err(adev, &con-
Quoted 1 line
umc_ecc_log.de_page_tree,
ecc_err);if (ret) {drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +13
-1@@ -600,13 +579,25 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, else dev_err(adev->dev, "Fail to log ecc error! ret:%d\n", ret); -kfree (ecc_err->err_pages.pfn);kfree (ecc_err);return ret; } con->umc_ecc_log.de_queried_count++; +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + pa_addr, + page_pfn,ARRAY_SIZE (page_pfn)); +if (count <=0 ) { +dev_warn (adev->dev,"Fail to convert error address! count:%d\n", count); +return 0 ; + } + +/* Reserve memory */ +for (i =0 ; i < count; i++) +amdgpu_ras_reserve_page (adev, page_pfn[i]); +/* The problem case is as follows:
* 1. GPU A triggers a gpu ras reset, and GPU A drives
* GPU B to also perform a gpu ras reset.drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +9
-4@@ -631,16 +622,21 @@ static int umc_v12_0_fill_error_record(structamdgpu_device *adev, struct ras_ecc_err *ecc_err, void *ras_error_status) { struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status; -uint32_t i =0 ; -int ret =0 ; +uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; +int ret, i, count;if (!err_data || !ecc_err)return -EINVAL ; - for (i = 0; i < ecc_err->err_pages.count; i++) { +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + ecc_err->pa_pfn <<AMDGPU_GPU_PAGE_SHIFT , + page_pfn,ARRAY_SIZE (page_pfn)); + + for (i = 0; i < count; i++) { ret = amdgpu_umc_fill_error_record(err_data, ecc_err->addr, - ecc_err->err_pages.pfn[i] << AMDGPU_GPU_PAGE_SHIFT, + page_pfn[i] << AMDGPU_GPU_PAGE_SHIFT,MCA_IPID_2_UMC_CH(ecc_err->ipid), MCA_IPID_2_UMC_INST(ecc_err->ipid)); if (ret)drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-1@@ -674,7 +670,8 @@ static void umc_v12_0_query_ras_ecc_err_addr(struct amdgpu_device *adev,dev_err (adev->dev,"Fail to fill umc error record, ret:%d\n", ret);break ; } -radix_tree_tag_clear (ecc_tree, entries[i]->hash_index, UMC_ECC_NEW_DETECTED_TAG); + radix_tree_tag_clear(ecc_tree, + entries[i]->pa_pfn,UMC_ECC_NEW_DETECTED_TAG); } mutex_unlock(&con->umc_ecc_log.lock);}
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +5
-0@@ -81,6 +81,11 @@ (((REG_GET_FIELD (ipid,MCMP1_IPIDT0 , InstanceIdLo) &0x1 ) <<2 ) | \ (REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdHi) & 0x03)) +#define UMC_V12_ADDR_MASK_BAD_COLS (addr) \ + ((addr) & ~((0x3ULL << UMC_V12_0_PA_C2_BIT) | \ + (0x1ULL << UMC_V12_0_PA_C4_BIT) | \ + (0x1ULL << UMC_V12_0_PA_R13_BIT))) + bool umc_v12_0_is_deferred_error(struct amdgpu_device *adev, uint64_t
mc_umc_status); boolumc_v12_0_is_uncorrectable_error(struct amdgpu_device *adev, uint64_t mc_umc_status); boolumc_v12_0_is_correctable_error(struct amdgpu_device *adev, uint64_t mc_umc_status);
--
2.34.1
RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Thursday, July 18, 2024 10:57 AM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 134 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 4:16 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info1. Use
pa_pfnas the radix-tree key index to log
deferred error info.
2. Use local array to store expanded bad pages.Signed-off-by YiPeng Chai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 14 ++---- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 65 ++++++++++++------------- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 5 ++ 4 files changed, 40 insertions(+), 46 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1
-1@@ -476,10 +476,10 @@ struct ras_err_pages { };struct ras_ecc_err { -u64 hash_index;uint64_t status;uint64_t ipid;uint64_t addr; +uint64_t pa_pfn;struct ras_err_pages err_pages; };drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3
-11@@ -523,18 +523,10 @@ int amdgpu_umc_logs_ecc_err(struct amdgpu_device *adev, ecc_log = &con->umc_ecc_log;mutex_lock (&ecc_log->lock); - ret =radix_tree_insert (ecc_tree, ecc_err->hash_index, ecc_err); -if (!ret) { -struct ras_err_pages *err_pages = &ecc_err->err_pages; -int i; - -/* Reserve memory */ -for (i =0 ; i < err_pages->count; i++) -amdgpu_ras_reserve_page (adev, err_pages->pfn[i]); - + ret =radix_tree_insert (ecc_tree, ecc_err->pa_pfn, ecc_err); +if (!ret)radix_tree_tag_set (ecc_tree, - ecc_err->hash_index,UMC_ECC_NEW_DETECTED_TAG ); - } + ecc_err->pa_pfn, UMC_ECC_NEW_DETECTED_TAG);mutex_unlock (&ecc_log->lock);return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-2@@ -524,9 +524,9 @@ static int umc_v12_0_update_ecc_status(structamdgpu_device *adev, struct amdgpu_ras *con = amdgpu_ras_get_context(adev);uint16_t hwid, mcatype;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 , pa_addr =0 ; +uint64_t err_addr, pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count, ret; +int count, ret, i; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID);mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@ -559,39 +559,18 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, if (ret) return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-memset (page_pfn,0 ,sizeof (page_pfn)); - count =umc_v12_0_expand_addr_to_bad_pages (adev, - pa_addr, - page_pfn,ARRAY_SIZE (page_pfn)); -if (count <=0 ) { - dev_warn(adev->dev, "Fail to convert error address!count:%d\n", count);
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-11-return 0 ; - } - - ret =amdgpu_umc_build_pages_hash (adev, - page_pfn, count, &hash_val); -if (ret) { -dev_err (adev->dev,"Fail to build error pages hash\n" ); -return ret; - } - ecc_err =kzalloc (sizeof (*ecc_err),GFP_KERNEL );if (!ecc_err)return -ENOMEM ; - ecc_err->err_pages.pfn = kcalloc(count, sizeof(*ecc_err->err_pages.pfn),
GFP_KERNEL);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-if (!ecc_err->err_pages.pfn) { -kfree (ecc_err); -return -ENOMEM ; - } - - memcpy(ecc_err->err_pages.pfn, page_pfn, count * sizeof(*ecc_err-Quoted 1 line
err_pages.pfn));
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +7
-3- ecc_err->err_pages.count = count; - - ecc_err->hash_index = hash_val; ecc_err->status = status; ecc_err->ipid = ipid; ecc_err->addr = addr; + ecc_err->pa_pfn =UMC_V12_ADDR_MASK_BAD_COLS (pa_addr) >> +AMDGPU_GPU_PAGE_SHIFT ; + +/* If converted pa_pfn is 0, use pa xor pfn. */ +if (!ecc_err->pa_pfn) + ecc_err->pa_pfn =BIT_ULL (UMC_V12_0_PA_R13_BIT ) >> +AMDGPU_GPU_PAGE_SHIFT ;
Quoted 1 line
[Tao] why address 0 should be avoided?
[Thomas] When address is 0, it means the data has just been loaded from EEPROM, it should calculate pa_pfn.
Quoted 99 lines
ret = amdgpu_umc_logs_ecc_err(adev, &con-
Quoted 1 line
umc_ecc_log.de_page_tree,
ecc_err);if (ret) {drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +13
-1@@ -600,13 +579,25 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, else dev_err(adev->dev, "Fail to log ecc error! ret:%d\n", ret); - kfree(ecc_err->err_pages.pfn); kfree(ecc_err);return ret; } con->umc_ecc_log.de_queried_count++; +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + pa_addr, + page_pfn,ARRAY_SIZE (page_pfn)); +if (count <=0 ) { +dev_warn (adev->dev,"Fail to convert error address! count:%d\n", count); +return 0 ; + } + +/* Reserve memory */ +for (i =0 ; i < count; i++) +amdgpu_ras_reserve_page (adev, page_pfn[i]); +/* The problem case is as follows:
* 1. GPU A triggers a gpu ras reset, and GPU A drives
* GPU B to also perform a gpu ras reset.drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +9
-4@@ -631,16 +622,21 @@ static int umc_v12_0_fill_error_record(structamdgpu_device *adev, struct ras_ecc_err *ecc_err, void *ras_error_status) { struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status; -uint32_t i =0 ; -int ret =0 ; +uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; +int ret, i, count;if (!err_data || !ecc_err)return -EINVAL ; - for (i = 0; i < ecc_err->err_pages.count; i++) { +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + ecc_err->pa_pfn <<AMDGPU_GPU_PAGE_SHIFT , + page_pfn,ARRAY_SIZE (page_pfn)); + + for (i = 0; i < count; i++) { ret = amdgpu_umc_fill_error_record(err_data, ecc_err->addr, - ecc_err->err_pages.pfn[i] << AMDGPU_GPU_PAGE_SHIFT, + page_pfn[i] << AMDGPU_GPU_PAGE_SHIFT,MCA_IPID_2_UMC_CH(ecc_err->ipid), MCA_IPID_2_UMC_INST(ecc_err->ipid)); if (ret)drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-0@@ -674,7 +670,8 @@ static voidumc_v12_0_query_ras_ecc_err_addr(struct
amdgpu_device*adev,dev_err(adev->dev, "Fail to fill umc error record, ret:%d\n", ret); break; }- radix_tree_tag_clear(ecc_tree, entries[i]->hash_index,
UMC_ECC_NEW_DETECTED_TAG);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-0+ radix_tree_tag_clear(ecc_tree, + entries[i]->pa_pfn,UMC_ECC_NEW_DETECTED_TAG); } mutex_unlock(&con->umc_ecc_log.lock);}
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +5
-0@@ -81,6 +81,11 @@ (((REG_GET_FIELD (ipid,MCMP1_IPIDT0 , InstanceIdLo) &0x1 ) <<2 ) | \ (REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdHi) & 0x03)) +#define UMC_V12_ADDR_MASK_BAD_COLS (addr) \ + ((addr) & ~((0x3ULL << UMC_V12_0_PA_C2_BIT) | \ + (0x1ULL << UMC_V12_0_PA_C4_BIT) | \ + (0x1ULL << UMC_V12_0_PA_R13_BIT))) + bool umc_v12_0_is_deferred_error(struct amdgpu_device *adev, uint64_t
mc_umc_status); boolumc_v12_0_is_uncorrectable_error(struct amdgpu_device *adev, uint64_t mc_umc_status); boolumc_v12_0_is_correctable_error(struct amdgpu_device *adev, uint64_t mc_umc_status);
--
2.34.1
RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chai, Thomas
Sent: Thursday, July 18, 2024 11:35 AM
To: Zhou1, Tao <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Thursday, July 18, 2024 10:57 AM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 134 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 4:16 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info1. Use
pa_pfnas the radix-tree key index to log
deferred error info.
2. Use local array to store expanded bad pages.Signed-off-by YiPeng Chai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 14 ++---- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 65 ++++++++++++------------- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 5 ++ 4 files changed, 40 insertions(+), 46 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1
-1@@ -476,10 +476,10 @@ struct ras_err_pages { };struct ras_ecc_err { -u64 hash_index;uint64_t status;uint64_t ipid;uint64_t addr; +uint64_t pa_pfn;struct ras_err_pages err_pages; };drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3
-11@@ -523,18 +523,10 @@ int amdgpu_umc_logs_ecc_err(struct amdgpu_device *adev, ecc_log = &con->umc_ecc_log;mutex_lock (&ecc_log->lock); - ret =radix_tree_insert (ecc_tree, ecc_err->hash_index, ecc_err); -if (!ret) { -struct ras_err_pages *err_pages = &ecc_err->err_pages; -int i; - -/* Reserve memory */ -for (i =0 ; i < err_pages->count; i++) -amdgpu_ras_reserve_page (adev, err_pages->pfn[i]); - + ret =radix_tree_insert (ecc_tree, ecc_err->pa_pfn, ecc_err); +if (!ret)radix_tree_tag_set (ecc_tree, - ecc_err->hash_index,UMC_ECC_NEW_DETECTED_TAG ); - } + ecc_err->pa_pfn, UMC_ECC_NEW_DETECTED_TAG);mutex_unlock (&ecc_log->lock);return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-2@@ -524,9 +524,9 @@ static int umc_v12_0_update_ecc_status(structamdgpu_device *adev, struct amdgpu_ras *con = amdgpu_ras_get_context(adev);uint16_t hwid, mcatype;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 , pa_addr =0 ; +uint64_t err_addr, pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count, ret; +int count, ret, i; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID);mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@ -559,39 +559,18 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, if (ret) return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-memset (page_pfn,0 ,sizeof (page_pfn)); - count =umc_v12_0_expand_addr_to_bad_pages (adev, - pa_addr, - page_pfn,ARRAY_SIZE (page_pfn)); -if (count <=0 ) { - dev_warn(adev->dev, "Fail to convert error address!count:%d\n", count);
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-11-return 0 ; - } - - ret =amdgpu_umc_build_pages_hash (adev, - page_pfn, count, &hash_val); -if (ret) { -dev_err (adev->dev,"Fail to build error pages hash\n" ); -return ret; - } - ecc_err =kzalloc (sizeof (*ecc_err),GFP_KERNEL );if (!ecc_err)return -ENOMEM ; - ecc_err->err_pages.pfn = kcalloc(count, sizeof(*ecc_err->err_pages.pfn),
GFP_KERNEL);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-if (!ecc_err->err_pages.pfn) { -kfree (ecc_err); -return -ENOMEM ; - } - - memcpy(ecc_err->err_pages.pfn, page_pfn, count * sizeof(*ecc_err-Quoted 1 line
err_pages.pfn));
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +7
-3- ecc_err->err_pages.count = count; - - ecc_err->hash_index = hash_val; ecc_err->status = status; ecc_err->ipid = ipid; ecc_err->addr = addr; + ecc_err->pa_pfn =UMC_V12_ADDR_MASK_BAD_COLS (pa_addr) >> +AMDGPU_GPU_PAGE_SHIFT ; + +/* If converted pa_pfn is 0, use pa xor pfn. */ +if (!ecc_err->pa_pfn) + ecc_err->pa_pfn =BIT_ULL (UMC_V12_0_PA_R13_BIT ) >> +AMDGPU_GPU_PAGE_SHIFT ;
Quoted 1 line
[Tao] why address 0 should be avoided?
[Thomas] When address is 0, it means the data has just been loaded from EEPROM, it should calculate pa_pfn. This will be useful for the eeprom new data formats in the future.
Quoted 99 lines
ret = amdgpu_umc_logs_ecc_err(adev, &con-
Quoted 1 line
umc_ecc_log.de_page_tree,
ecc_err);if (ret) {drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +13
-1@@ -600,13 +579,25 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, else dev_err(adev->dev, "Fail to log ecc error! ret:%d\n", ret); - kfree(ecc_err->err_pages.pfn); kfree(ecc_err);return ret; } con->umc_ecc_log.de_queried_count++; +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + pa_addr, + page_pfn,ARRAY_SIZE (page_pfn)); +if (count <=0 ) { +dev_warn (adev->dev,"Fail to convert error address! count:%d\n", count); +return 0 ; + } + +/* Reserve memory */ +for (i =0 ; i < count; i++) +amdgpu_ras_reserve_page (adev, page_pfn[i]); +/* The problem case is as follows:
* 1. GPU A triggers a gpu ras reset, and GPU A drives
* GPU B to also perform a gpu ras reset.drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +9
-4@@ -631,16 +622,21 @@ static int umc_v12_0_fill_error_record(structamdgpu_device *adev, struct ras_ecc_err *ecc_err, void *ras_error_status) { struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status; -uint32_t i =0 ; -int ret =0 ; +uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; +int ret, i, count;if (!err_data || !ecc_err)return -EINVAL ; - for (i = 0; i < ecc_err->err_pages.count; i++) { +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + ecc_err->pa_pfn <<AMDGPU_GPU_PAGE_SHIFT , + page_pfn,ARRAY_SIZE (page_pfn)); + + for (i = 0; i < count; i++) { ret = amdgpu_umc_fill_error_record(err_data, ecc_err->addr, - ecc_err->err_pages.pfn[i] << AMDGPU_GPU_PAGE_SHIFT, + page_pfn[i] << AMDGPU_GPU_PAGE_SHIFT,MCA_IPID_2_UMC_CH(ecc_err->ipid), MCA_IPID_2_UMC_INST(ecc_err->ipid)); if (ret)drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-0@@ -674,7 +670,8 @@ static voidumc_v12_0_query_ras_ecc_err_addr(struct
amdgpu_device*adev,dev_err(adev->dev, "Fail to fill umc error record, ret:%d\n", ret); break; }- radix_tree_tag_clear(ecc_tree, entries[i]->hash_index,
UMC_ECC_NEW_DETECTED_TAG);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-0+ radix_tree_tag_clear(ecc_tree, + entries[i]->pa_pfn,UMC_ECC_NEW_DETECTED_TAG); } mutex_unlock(&con->umc_ecc_log.lock);}
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +5
-0@@ -81,6 +81,11 @@ (((REG_GET_FIELD (ipid,MCMP1_IPIDT0 , InstanceIdLo) &0x1 ) <<2 ) | \ (REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdHi) & 0x03)) +#define UMC_V12_ADDR_MASK_BAD_COLS (addr) \ + ((addr) & ~((0x3ULL << UMC_V12_0_PA_C2_BIT) | \ + (0x1ULL << UMC_V12_0_PA_C4_BIT) | \ + (0x1ULL << UMC_V12_0_PA_R13_BIT))) + bool umc_v12_0_is_deferred_error(struct amdgpu_device *adev, uint64_t
mc_umc_status); boolumc_v12_0_is_uncorrectable_error(struct amdgpu_device *adev, uint64_t mc_umc_status); boolumc_v12_0_is_correctable_error(struct amdgpu_device *adev, uint64_t mc_umc_status);
--
2.34.1
RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 180 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Thursday, July 18, 2024 12:34 PM
To: Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chai, Thomas
Sent: Thursday, July 18, 2024 11:35 AM
To: Zhou1, Tao <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Thursday, July 18, 2024 10:57 AM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info[AMD Official Use Only - AMD Internal Distribution Only]
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_logs_ecc_err(struct
Quoted 44 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 4:16 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info1. Use
pa_pfnas the radix-tree key index to log
deferred error info.
2. Use local array to store expanded bad pages.Signed-off-by YiPeng Chai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 14 ++---- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 65 ++++++++++++------------- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 5 ++ 4 files changed, 40 insertions(+), 46 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1
-1@@ -476,10 +476,10 @@ struct ras_err_pages { };struct ras_ecc_err { -u64 hash_index;uint64_t status;uint64_t ipid;uint64_t addr; +uint64_t pa_pfn;struct ras_err_pages err_pages; };drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-0@@ -523,18 +523,10 @@ int amdgpu_umc_logs_ecc_err(struct
amdgpu_deviceQuoted 89 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3
-11*adev, ecc_log = &con->umc_ecc_log;mutex_lock (&ecc_log->lock); - ret =radix_tree_insert (ecc_tree, ecc_err->hash_index, ecc_err); -if (!ret) { -struct ras_err_pages *err_pages = &ecc_err->err_pages; -int i; - -/* Reserve memory */ -for (i =0 ; i < err_pages->count; i++) -amdgpu_ras_reserve_page (adev, err_pages->pfn[i]); - + ret =radix_tree_insert (ecc_tree, ecc_err->pa_pfn, ecc_err); +if (!ret)radix_tree_tag_set (ecc_tree, - ecc_err->hash_index,UMC_ECC_NEW_DETECTED_TAG ); - } + ecc_err->pa_pfn, UMC_ECC_NEW_DETECTED_TAG);mutex_unlock (&ecc_log->lock);return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-2@@ -524,9 +524,9 @@ static int umc_v12_0_update_ecc_status(structamdgpu_device *adev, struct amdgpu_ras *con = amdgpu_ras_get_context(adev);uint16_t hwid, mcatype;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 , pa_addr =0 ; +uint64_t err_addr, pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count, ret; +int count, ret, i; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID);mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@ -559,39 +559,18 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, if (ret) return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-memset (page_pfn,0 ,sizeof (page_pfn)); - count =umc_v12_0_expand_addr_to_bad_pages (adev, - pa_addr, - page_pfn,ARRAY_SIZE (page_pfn)); -if (count <=0 ) { - dev_warn(adev->dev, "Fail to convert error address!count:%d\n", count);
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-11-return 0 ; - } - - ret =amdgpu_umc_build_pages_hash (adev, - page_pfn, count, &hash_val); -if (ret) { -dev_err (adev->dev,"Fail to build error pages hash\n" ); -return ret; - } - ecc_err =kzalloc (sizeof (*ecc_err),GFP_KERNEL );if (!ecc_err)return -ENOMEM ; - ecc_err->err_pages.pfn = kcalloc(count, sizeof(*ecc_err->err_pages.pfn),
GFP_KERNEL);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-if (!ecc_err->err_pages.pfn) { -kfree (ecc_err); -return -ENOMEM ; - } - - memcpy(ecc_err->err_pages.pfn, page_pfn, count * sizeof(*ecc_err-Quoted 1 line
err_pages.pfn));
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +7
-3- ecc_err->err_pages.count = count; - - ecc_err->hash_index = hash_val; ecc_err->status = status; ecc_err->ipid = ipid; ecc_err->addr = addr; + ecc_err->pa_pfn =UMC_V12_ADDR_MASK_BAD_COLS (pa_addr) >> +AMDGPU_GPU_PAGE_SHIFT ; + +/* If converted pa_pfn is 0, use pa xor pfn. */ +if (!ecc_err->pa_pfn) + ecc_err->pa_pfn =BIT_ULL (UMC_V12_0_PA_R13_BIT ) >> +AMDGPU_GPU_PAGE_SHIFT ;
Quoted 5 lines
Quoted 1 line
[Tao] why address 0 should be avoided?
[Thomas] When address is 0, it means the data has just been loaded from
EEPROM, it should calculatepa_pfn. This will be useful for the eeprom new data
formats in the future.
[Tao] better not to rely on this rule, R13 shift requirement comes from HBM provider.
Quoted 102 lines
Quoted 100 lines
ret = amdgpu_umc_logs_ecc_err(adev, &con-
Quoted 1 line
umc_ecc_log.de_page_tree,
ecc_err);if (ret) {drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +13
-1@@ -600,13 +579,25 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, else dev_err(adev->dev, "Fail to log ecc error! ret:%d\n", ret); - kfree(ecc_err->err_pages.pfn); kfree(ecc_err);return ret; } con->umc_ecc_log.de_queried_count++; +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + pa_addr, + page_pfn,ARRAY_SIZE (page_pfn)); +if (count <=0 ) { +dev_warn (adev->dev,"Fail to convert error address! count:%d\n", count); +return 0 ; + } + +/* Reserve memory */ +for (i =0 ; i < count; i++) +amdgpu_ras_reserve_page (adev, page_pfn[i]); +/* The problem case is as follows:
* 1. GPU A triggers a gpu ras reset, and GPU A drives
* GPU B to also perform a gpu ras reset.drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +9
-4@@ -631,16 +622,21 @@ static int umc_v12_0_fill_error_record(structamdgpu_device *adev, struct ras_ecc_err *ecc_err, void *ras_error_status) { struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status; -uint32_t i =0 ; -int ret =0 ; +uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; +int ret, i, count;if (!err_data || !ecc_err)return -EINVAL ; - for (i = 0; i < ecc_err->err_pages.count; i++) { +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + ecc_err->pa_pfn <<AMDGPU_GPU_PAGE_SHIFT , + page_pfn,ARRAY_SIZE (page_pfn)); + + for (i = 0; i < count; i++) { ret = amdgpu_umc_fill_error_record(err_data, ecc_err->addr, - ecc_err->err_pages.pfn[i] << AMDGPU_GPU_PAGE_SHIFT, + page_pfn[i] << AMDGPU_GPU_PAGE_SHIFT,MCA_IPID_2_UMC_CH(ecc_err->ipid), MCA_IPID_2_UMC_INST(ecc_err->ipid)); if (ret)drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-0@@ -674,7 +670,8 @@ static voidumc_v12_0_query_ras_ecc_err_addr(struct
amdgpu_device*adev,dev_err(adev->dev, "Fail to fill umc error record, ret:%d\n", ret); break; }- radix_tree_tag_clear(ecc_tree, entries[i]->hash_index,
UMC_ECC_NEW_DETECTED_TAG);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-0+ radix_tree_tag_clear(ecc_tree, + entries[i]->pa_pfn,UMC_ECC_NEW_DETECTED_TAG); } mutex_unlock(&con->umc_ecc_log.lock);}
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +5
-0@@ -81,6 +81,11 @@ (((REG_GET_FIELD (ipid,MCMP1_IPIDT0 , InstanceIdLo) &0x1 ) <<2 ) | \ (REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdHi) & 0x03)) +#define UMC_V12_ADDR_MASK_BAD_COLS (addr) \ + ((addr) & ~((0x3ULL << UMC_V12_0_PA_C2_BIT) | \ + (0x1ULL << UMC_V12_0_PA_C4_BIT) | \ + (0x1ULL << UMC_V12_0_PA_R13_BIT))) + bool umc_v12_0_is_deferred_error(struct amdgpu_device *adev, uint64_t
mc_umc_status); boolumc_v12_0_is_uncorrectable_error(struct amdgpu_device *adev, uint64_t mc_umc_status); boolumc_v12_0_is_correctable_error(struct amdgpu_device *adev, uint64_t mc_umc_status);
--
2.34.1
RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Thursday, July 18, 2024 1:39 PM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 186 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Thursday, July 18, 2024 12:34 PM
To: Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chai, Thomas
Sent: Thursday, July 18, 2024 11:35 AM
To: Zhou1, Tao <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Thursday, July 18, 2024 10:57 AM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info[AMD Official Use Only - AMD Internal Distribution Only]
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c int amdgpu_umc_logs_ecc_err(struct
Quoted 45 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 4:16 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: optimize logging deferred error info1. Use
pa_pfnas the radix-tree key index to log
deferred error info.
2. Use local array to store expanded bad pages.Signed-off-by YiPeng Chai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c| 14 ++----drivers/gpu/drm/amd/amdgpu/umc_v12_0.c| 65 ++++++++++++-------------drivers/gpu/drm/amd/amdgpu/umc_v12_0.h| 5 ++4 files changed, 40 insertions(+), 46 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1
-1@@ -476,10 +476,10 @@ struct ras_err_pages { };struct ras_ecc_err { -u64 hash_index;uint64_t status;uint64_t ipid;uint64_t addr; +uint64_t pa_pfn;struct ras_err_pages err_pages; };drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0
-0@@ -523,18 +523,10 @@ int amdgpu_umc_logs_ecc_err(struct
amdgpu_deviceQuoted 91 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3
-11*adev, ecc_log = &con->umc_ecc_log;mutex_lock (&ecc_log->lock); - ret =radix_tree_insert (ecc_tree, ecc_err->hash_index, ecc_err); -if (!ret) { -struct ras_err_pages *err_pages = &ecc_err->err_pages; -int i; - -/* Reserve memory */ -for (i =0 ; i < err_pages->count; i++) -amdgpu_ras_reserve_page (adev, err_pages->pfn[i]); - + ret =radix_tree_insert (ecc_tree, ecc_err->pa_pfn, ecc_err); +if (!ret)radix_tree_tag_set (ecc_tree, - ecc_err->hash_index,UMC_ECC_NEW_DETECTED_TAG ); - } + ecc_err->pa_pfn, UMC_ECC_NEW_DETECTED_TAG);mutex_unlock (&ecc_log->lock);return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-2@@ -524,9 +524,9 @@ static int umc_v12_0_update_ecc_status(structamdgpu_device *adev, struct amdgpu_ras *con = amdgpu_ras_get_context(adev);uint16_t hwid, mcatype;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 , pa_addr =0 ; +uint64_t err_addr, pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count, ret; +int count, ret, i; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID);mcatype =
REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@
-559,39
+559,18 @@ static int umc_v12_0_update_ecc_status(struct +amdgpu_device
*adev,if (ret) return ret;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-memset (page_pfn,0 ,sizeof (page_pfn)); - count =umc_v12_0_expand_addr_to_bad_pages (adev, - pa_addr, - page_pfn,ARRAY_SIZE (page_pfn)); -if (count <=0 ) { - dev_warn(adev->dev, "Fail to convert error address!count:%d\n", count);
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-11-return 0 ; - } - - ret =amdgpu_umc_build_pages_hash (adev, - page_pfn, count, &hash_val); -if (ret) { -dev_err (adev->dev,"Fail to build error pages hash\n" ); -return ret; - } - ecc_err =kzalloc (sizeof (*ecc_err),GFP_KERNEL );if (!ecc_err)return -ENOMEM ; - ecc_err->err_pages.pfn = kcalloc(count, sizeof(*ecc_err->err_pages.pfn),
GFP_KERNEL);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-6-if (!ecc_err->err_pages.pfn) { -kfree (ecc_err); -return -ENOMEM ; - } - - memcpy(ecc_err->err_pages.pfn, page_pfn, count * sizeof(*ecc_err-Quoted 1 line
err_pages.pfn));
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +7
-3- ecc_err->err_pages.count = count; - - ecc_err->hash_index = hash_val; ecc_err->status = status; ecc_err->ipid = ipid; ecc_err->addr = addr; + ecc_err->pa_pfn =UMC_V12_ADDR_MASK_BAD_COLS (pa_addr) >> +AMDGPU_GPU_PAGE_SHIFT ; + +/* If converted pa_pfn is 0, use pa xor pfn. */ +if (!ecc_err->pa_pfn) + ecc_err->pa_pfn =BIT_ULL (UMC_V12_0_PA_R13_BIT ) >> +AMDGPU_GPU_PAGE_SHIFT ;
Quoted 7 lines
Quoted 1 line
[Tao] why address 0 should be avoided?
[Thomas] When address is 0, it means the data has just been loaded from
EEPROM, it should calculatepa_pfn. This will be useful for the eeprom new data
formats in the future.[Tao] better not to rely on this rule, R13 shift requirement comes from HBM provider.
[Thomas] Currently, pa_pfn is only used as a radix-tree key index. non-zero value for pa_pfn can help distinguish incorrect values.
If xor pa_pfn does not work for all HBMs, we can discuss solutions during the "eeprom New Data Format" patch review.
Quoted 103 lines
Quoted 101 lines
ret = amdgpu_umc_logs_ecc_err(adev, &con-
Quoted 1 line
umc_ecc_log.de_page_tree,
ecc_err);if (ret) {drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +13
-1@@ -600,13 +579,25 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, else dev_err(adev->dev, "Fail to log ecc error! ret:%d\n", ret); - kfree(ecc_err->err_pages.pfn); kfree(ecc_err);return ret; } con->umc_ecc_log.de_queried_count++; +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + pa_addr, + page_pfn,ARRAY_SIZE (page_pfn)); +if (count <=0 ) { +dev_warn (adev->dev,"Fail to convert error address! count:%d\n", count); +return 0 ; + } + +/* Reserve memory */ +for (i =0 ; i < count; i++) +amdgpu_ras_reserve_page (adev, page_pfn[i]); +/* The problem case is as follows:
* 1. GPU A triggers a gpu ras reset, and GPU A drives
* GPU B to also perform a gpu ras reset.drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +9
-4@@ -631,16 +622,21 @@ static int umc_v12_0_fill_error_record(structamdgpu_device *adev, struct ras_ecc_err *ecc_err, void *ras_error_status) { struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status; -uint32_t i =0 ; -int ret =0 ; +uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; +int ret, i, count;if (!err_data || !ecc_err)return -EINVAL ; - for (i = 0; i < ecc_err->err_pages.count; i++) { +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + ecc_err->pa_pfn <<AMDGPU_GPU_PAGE_SHIFT , + page_pfn,ARRAY_SIZE (page_pfn)); + + for (i = 0; i < count; i++) { ret = amdgpu_umc_fill_error_record(err_data, ecc_err->addr, - ecc_err->err_pages.pfn[i] << AMDGPU_GPU_PAGE_SHIFT, + page_pfn[i] << AMDGPU_GPU_PAGE_SHIFT,MCA_IPID_2_UMC_CH(ecc_err->ipid), MCA_IPID_2_UMC_INST(ecc_err->ipid)); if (ret)drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-0@@ -674,7 +670,8 @@ static voidumc_v12_0_query_ras_ecc_err_addr(struct
amdgpu_device*adev,dev_err(adev->dev, "Fail to fill umc error record, ret:%d\n", ret); break; }- radix_tree_tag_clear(ecc_tree, entries[i]->hash_index,
UMC_ECC_NEW_DETECTED_TAG);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +2
-0+ radix_tree_tag_clear(ecc_tree, + entries[i]->pa_pfn,UMC_ECC_NEW_DETECTED_TAG); } mutex_unlock(&con->umc_ecc_log.lock);}
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +5
-0@@ -81,6 +81,11 @@ (((REG_GET_FIELD (ipid,MCMP1_IPIDT0 , InstanceIdLo) &0x1 ) <<2 ) | \ (REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdHi) & 0x03)) +#define UMC_V12_ADDR_MASK_BAD_COLS (addr) \ + ((addr) & ~((0x3ULL << UMC_V12_0_PA_C2_BIT) | \ + (0x1ULL << UMC_V12_0_PA_C4_BIT) | \ + (0x1ULL << UMC_V12_0_PA_R13_BIT))) + bool umc_v12_0_is_deferred_error(struct amdgpu_device *adev,
uint64_tmc_umc_status); bool umc_v12_0_is_uncorrectable_error(structamdgpu_device*adev,uint64_tmc_umc_status); boolumc_v12_0_is_correctable_error(struct amdgpu_device *adev, uint64_t mc_umc_status);
--
2.34.1
PATCH 3/3 drm/amdgpu: Remove unused code
In reply to YiPeng ChaiRemove unused code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 29 --------- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 10 --- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 86 ------------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 5 -- 4 files changed, 130 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -29
@@ -2886,9 +2886,6 @@ static void amdgpu_ras_ecc_log_init(struct ras_ecc_log_info *ecc_log) {mutex_init (&ecc_log->lock); -/* Set any value as siphash key */ -memset (&ecc_log->ecc_key,0xad ,sizeof (ecc_log->ecc_key)); -INIT_RADIX_TREE (&ecc_log->de_page_tree,GFP_KERNEL ); ecc_log->de_queried_count =0 ; ecc_log->prev_de_queried_count =0 ;
@@ -3153,12 +3150,6 @@ static int amdgpu_ras_page_retirement_thread(void *param)/* Wake up work to save bad pages to eeprom */ schedule_delayed_work(&con->page_retirement_dwork, 0); } -#else -dev_info (adev->dev,"Start processing page retirement. request:%d\n" , -atomic_read (&con->page_retirement_req_cnt)); - -amdgpu_umc_bad_page_polling_timeout (adev, -0 ,MAX_UMC_POISON_POLLING_TIME_ASYNC );#endif }
@@ -4638,8 +4629,6 @@ static struct ras_err_info *amdgpu_ras_error_get_info(struct ras_err_data *err_dif (!err_node)return NULL ; -INIT_LIST_HEAD (&err_node->err_info.err_addr_list); -memcpy (&err_node->err_info.mcm_info, mcm_info,sizeof (*mcm_info)); err_data->err_list_count++;
@@ -4649,18 +4638,6 @@ static struct ras_err_info *amdgpu_ras_error_get_info(struct ras_err_data *err_dreturn &err_node->err_info; } -void amdgpu_ras_add_mca_err_addr (struct ras_err_info *err_info,struct ras_err_addr *err_addr) -{ -/* This function will be retired. */ -return ; -} - -void amdgpu_ras_del_mca_err_addr (struct ras_err_info *err_info,struct ras_err_addr *mca_err_addr) -{ -list_del (&mca_err_addr->node); -kfree (mca_err_addr); -} -int amdgpu_ras_error_statistic_ue_count (struct ras_err_data *err_data,struct amdgpu_smuio_mcm_config_info *mcm_info,struct ras_err_addr *err_addr,u64 count)
@@ -4677,9 +4654,6 @@ int amdgpu_ras_error_statistic_ue_count(struct ras_err_data *err_data,if (!err_info)return -EINVAL ; -if (err_addr && err_addr->err_status) -amdgpu_ras_add_mca_err_addr (err_info, err_addr); - err_info->ue_count += count; err_data->ue_count += count;
@@ -4724,9 +4698,6 @@ int amdgpu_ras_error_statistic_de_count(struct ras_err_data *err_data,if (!err_info)return -EINVAL ; -if (err_addr && err_addr->err_status) -amdgpu_ras_add_mca_err_addr (err_info, err_addr); - err_info->de_count += count; err_data->de_count += count;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +0 -10
@@ -28,7 +28,6 @@#include <linux/list.h> #include <linux/kfifo.h> #include <linux/radix-tree.h> -#include <linux/siphash.h> #include "ta_ras_if.h" #include "amdgpu_ras_eeprom.h" #include "amdgpu_smuio.h"
@@ -485,7 +484,6 @@ struct ras_ecc_err {struct ras_ecc_log_info {struct mutex lock; -siphash_key_t ecc_key;struct radix_tree_root de_page_tree;uint64_t de_queried_count;uint64_t prev_de_queried_count;
@@ -573,7 +571,6 @@ struct ras_fs_data { };struct ras_err_addr { -struct list_head node;uint64_t err_status;uint64_t err_ipid;uint64_t err_addr;
@@ -584,7 +581,6 @@ struct ras_err_info {u64 ce_count;u64 ue_count;u64 de_count; -struct list_head err_addr_list; };struct ras_err_node {
@@ -957,12 +953,6 @@ int amdgpu_ras_unbind_aca(struct amdgpu_device *adev, enum amdgpu_ras_block blk)ssize_t amdgpu_ras_aca_sysfs_read (struct device *dev,struct device_attribute *attr,struct aca_handle *handle,char *buf,void *data); -void amdgpu_ras_add_mca_err_addr (struct ras_err_info *err_info, -struct ras_err_addr *err_addr); - -void amdgpu_ras_del_mca_err_addr (struct ras_err_info *err_info, -struct ras_err_addr *mca_err_addr); -void amdgpu_ras_set_fed (struct amdgpu_device *adev,bool status);bool amdgpu_ras_get_fed_status (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +0 -86
98 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +0 -5
@@ -127,13 +127,8 @@ int amdgpu_umc_page_retirement_mca(struct amdgpu_device *adev,int amdgpu_umc_loop_channels (struct amdgpu_device *adev,umc_func func,void *data); -int amdgpu_umc_bad_page_polling_timeout (struct amdgpu_device *adev, -uint32_t reset,uint32_t timeout_ms); -int amdgpu_umc_update_ecc_status (struct amdgpu_device *adev,uint64_t status,uint64_t ipid,uint64_t addr); -int amdgpu_umc_build_pages_hash (struct amdgpu_device *adev, -uint64_t *pfns,int len,uint64_t *val);int amdgpu_umc_logs_ecc_err (struct amdgpu_device *adev,struct radix_tree_root *ecc_tree,struct ras_ecc_err *ecc_err);
Signature · 1 line
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
+static int umc_v12_0_expand_addr_to_bad_pages(struct amdgpu_device *adev,
+ uint64_t pa_addr, uint64_t *pfns, int len)
I would call this function as lookup_bad_pages_in_a_row, or something like that.
Anyway, the series is
Regards,
Hawking
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 16:16
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: optimize umc v12 address conversion function
Split into 3 parts:
1. Convert soc physical address via ras ta.
2. Expand bad pages from soc physical address.
3. Dump bad address info.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 116 ++++++++++++++++--------- 1 file changed, 77 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +66 -29
@@ -225,26 +225,16 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev, } } -static int umc_v12_0_convert_err_addr (struct amdgpu_device *adev, -struct ta_ras_query_address_input *addr_in, -uint64_t *pfns,int len) +static void umc_v12_0_dump_addr_info (struct amdgpu_device *adev, +struct ta_ras_query_address_output *addr_out, +uint64_t err_addr) {uint32_t col, row, row_xor, bank, channel_index; -uint64_t soc_pa, retired_page, column, err_addr; -struct ta_ras_query_address_output addr_out; -uint32_t pos =0 ; - - err_addr = addr_in->ma.err_addr; - addr_in->addr_type =TA_RAS_MCA_TO_PA ; -if (psp_ras_query_address (&adev->psp, addr_in, &addr_out)) { -dev_warn (adev->dev,"Failed to query RAS physical address for 0x%llx" , - err_addr); -return 0 ; - } +uint64_t soc_pa, retired_page, column; - soc_pa = addr_out.pa.pa; - bank = addr_out.pa.bank; - channel_index = addr_out.pa.channel_idx; + soc_pa = addr_out->pa.pa; + bank = addr_out->pa.bank; + channel_index = addr_out->pa.channel_idx; col = (err_addr >>1 ) &0x1fULL ; row = (err_addr >>10 ) &0x3fffULL ;
@@ -258,11 +248,6 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); - -if (pos >= len) -return 0 ; - pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; -/* include column bit 0 and 1 */ col &=0x3 ; col |= (column <<2 );
@@ -270,6 +255,35 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,"Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n" , retired_page, row, col, bank, channel_index); +/* shift R13 bit */ + retired_page ^= (0x1ULL <<UMC_V12_0_PA_R13_BIT ); +dev_info (adev->dev, +"Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n" , + retired_page, row_xor, col, bank, channel_index); + } +} + +static int umc_v12_0_expand_addr_to_bad_pages (struct amdgpu_device *adev, +uint64_t pa_addr,uint64_t *pfns,int len) { +uint64_t soc_pa, retired_page, column; +uint32_t pos =0 ; + + soc_pa = pa_addr; +/* clear [C3 C2] in soc physical address */ + soc_pa &= ~(0x3ULL <<UMC_V12_0_PA_C2_BIT ); +/* clear [C4] in soc physical address */ + soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_C4_BIT ); + +/* loop for all possibilities of [C4 C3 C2] */ +for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { + retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); + retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); + +if (pos >= len) +return 0 ; + pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; +/* shift R13 bit */ retired_page ^= (0x1ULL <<UMC_V12_0_PA_R13_BIT );
@@ -277,14 +291,40 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,return 0 ; pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; -dev_info (adev->dev, -"Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n" , - retired_page, row_xor, col, bank, channel_index); }return pos; } +static int umc_v12_0_convert_mca_to_addr (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch,uint32_t umc, +uint32_t node,uint32_t socket, +uint64_t *addr,bool dump_addr) +{ +struct ta_ras_query_address_input addr_in; +struct ta_ras_query_address_output addr_out; + +memset (&addr_in,0 ,sizeof (addr_in)); + addr_in.ma.err_addr = err_addr; + addr_in.ma.ch_inst = ch; + addr_in.ma.umc_inst = umc; + addr_in.ma.node_inst = node; + addr_in.ma.socket_id = socket; + addr_in.addr_type =TA_RAS_MCA_TO_PA ; +if (psp_ras_query_address (&adev->psp, &addr_in, &addr_out)) { +dev_warn (adev->dev,"Failed to query RAS physical address for 0x%llx" , + err_addr); +return -EINVAL ; + } + +if (dump_addr) +umc_v12_0_dump_addr_info (adev, &addr_out, err_addr); + + *addr = addr_out.pa.pa; + +return 0 ; +} +static int umc_v12_0_query_error_address (struct amdgpu_device *adev,uint32_t node_inst,uint32_t umc_inst,uint32_t ch_inst,void *data)
@@ -483,12 +523,10 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, {struct amdgpu_ras *con =amdgpu_ras_get_context (adev);uint16_t hwid, mcatype; -struct ta_ras_query_address_input addr_in;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 ; +uint64_t err_addr, hash_val =0 , pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count; -int ret; +int count, ret; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID); mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@ -514,17 +552,17 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, MCA_IPID_2_UMC_CH(ipid),
err_addr);
- memset(page_pfn, 0, sizeof(page_pfn));
-
- memset(&addr_in, 0, sizeof(addr_in)); - addr_in.ma.err_addr = err_addr; - addr_in.ma.ch_inst = MCA_IPID_2_UMC_CH(ipid); - addr_in.ma.umc_inst = MCA_IPID_2_UMC_INST(ipid); - addr_in.ma.node_inst = MCA_IPID_2_DIE_ID(ipid); - addr_in.ma.socket_id = MCA_IPID_2_SOCKET_ID(ipid); + ret = umc_v12_0_convert_mca_to_addr(adev, + err_addr, MCA_IPID_2_UMC_CH(ipid), + MCA_IPID_2_UMC_INST(ipid), MCA_IPID_2_DIE_ID(ipid), + MCA_IPID_2_SOCKET_ID(ipid), &pa_addr, true);
+ if (ret)
+ return ret;
- count = umc_v12_0_convert_err_addr(adev,
- &addr_in, page_pfn, ARRAY_SIZE(page_pfn));
+ memset(page_pfn, 0, sizeof(page_pfn));
+ count = umc_v12_0_expand_addr_to_bad_pages(adev,
+ pa_addr,
+ page_pfn, ARRAY_SIZE(page_pfn));
if (count <= 0) {
dev_warn(adev->dev, "Fail to convert error address! count:%d\n", count);
return 0;--
2.34.1
Chai, Thomas
Reviewed-by Hawking Zhang[AMD Official Use Only - AMD Internal Distribution Only]
OK
-----------------
Best Regards,
Thomas
-----Original Message-----
From: Zhang, Hawking <[email protected]>
Sent: Wednesday, July 17, 2024 9:00 PM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: optimize umc v12 address conversion function
[AMD Official Use Only - AMD Internal Distribution Only]
+static int umc_v12_0_expand_addr_to_bad_pages(struct amdgpu_device *adev,
+ uint64_t pa_addr, uint64_t *pfns, int len)
I would call this function as lookup_bad_pages_in_a_row, or something like that.
Anyway, the series is
Regards,
Hawking
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 16:16
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: optimize umc v12 address conversion function
Split into 3 parts:
1. Convert soc physical address via ras ta.
2. Expand bad pages from soc physical address.
3. Dump bad address info.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 116 ++++++++++++++++--------- 1 file changed, 77 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +7 -17
@@ -225,26 +225,16 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev, } } -static int umc_v12_0_convert_err_addr (struct amdgpu_device *adev, -struct ta_ras_query_address_input *addr_in, -uint64_t *pfns,int len) +static void umc_v12_0_dump_addr_info (struct amdgpu_device *adev, +struct ta_ras_query_address_output *addr_out, +uint64_t err_addr) {uint32_t col, row, row_xor, bank, channel_index; -uint64_t soc_pa, retired_page, column, err_addr; -struct ta_ras_query_address_output addr_out; -uint32_t pos =0 ; - - err_addr = addr_in->ma.err_addr; - addr_in->addr_type =TA_RAS_MCA_TO_PA ; -if (psp_ras_query_address (&adev->psp, addr_in, &addr_out)) { -dev_warn (adev->dev,"Failed to query RAS physical address for 0x%llx" , - err_addr); -return 0 ; - } +uint64_t soc_pa, retired_page, column; - soc_pa = addr_out.pa.pa; - bank = addr_out.pa.bank; - channel_index = addr_out.pa.channel_idx; + soc_pa = addr_out->pa.pa; + bank = addr_out->pa.bank; + channel_index = addr_out->pa.channel_idx; col = (err_addr >>1 ) &0x1fULL ; row = (err_addr >> 10) & 0x3fffULL; @@ -258,11 +248,6 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,
for (column = 0; column < UMC_V12_0_NA_MAP_PA_NUM; column++) {
retired_page = soc_pa | ((column & 0x3) << UMC_V12_0_PA_C2_BIT);
retired_page |= (((column & 0x4) >> 2) << UMC_V12_0_PA_C4_BIT);-
- if (pos >= len)
- return 0;
- pfns[pos++] = retired_page >> AMDGPU_GPU_PAGE_SHIFT;
-
/* include column bit 0 and 1 */
col &= 0x3;
col |= (column << 2);
@@ -270,6 +255,35 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,
"Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n",
retired_page, row, col, bank, channel_index);+ /* shift R13 bit */ + retired_page ^= (0x1ULL << UMC_V12_0_PA_R13_BIT); + dev_info(adev->dev,
+ "Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n",
+ retired_page, row_xor, col, bank, channel_index);
+ }
+}
+
+static int umc_v12_0_expand_addr_to_bad_pages(struct amdgpu_device *adev,
+ uint64_t pa_addr, uint64_t *pfns, int len) {
+ uint64_t soc_pa, retired_page, column;
+ uint32_t pos = 0;
+
+ soc_pa = pa_addr; + /* clear [C3 C2] in soc physical address */ + soc_pa &= ~(0x3ULL << UMC_V12_0_PA_C2_BIT); + /* clear [C4] in soc physical address */ + soc_pa &= ~(0x1ULL << UMC_V12_0_PA_C4_BIT);
+
+ /* loop for all possibilities of [C4 C3 C2] */
+ for (column = 0; column < UMC_V12_0_NA_MAP_PA_NUM; column++) {
+ retired_page = soc_pa | ((column & 0x3) << UMC_V12_0_PA_C2_BIT);
+ retired_page |= (((column & 0x4) >> 2) <<
+ UMC_V12_0_PA_C4_BIT);
+
+ if (pos >= len)
+ return 0;
+ pfns[pos++] = retired_page >> AMDGPU_GPU_PAGE_SHIFT;
+
/* shift R13 bit */
retired_page ^= (0x1ULL << UMC_V12_0_PA_R13_BIT);@@ -277,14 +291,40 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev,
return 0;
pfns[pos++] = retired_page >> AMDGPU_GPU_PAGE_SHIFT;- dev_info(adev->dev,
- "Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n",
- retired_page, row_xor, col, bank, channel_index);
}
return pos;}
+static int umc_v12_0_convert_mca_to_addr(struct amdgpu_device *adev,
+ uint64_t err_addr, uint32_t ch, uint32_t umc,
+ uint32_t node, uint32_t socket,
+ uint64_t *addr, bool dump_addr) {
+ struct ta_ras_query_address_input addr_in;
+ struct ta_ras_query_address_output addr_out;
+
+ memset(&addr_in, 0, sizeof(addr_in));
+ addr_in.ma.err_addr = err_addr;
+ addr_in.ma.ch_inst = ch;
+ addr_in.ma.umc_inst = umc;
+ addr_in.ma.node_inst = node;
+ addr_in.ma.socket_id = socket;
+ addr_in.addr_type = TA_RAS_MCA_TO_PA;
+ if (psp_ras_query_address(&adev->psp, &addr_in, &addr_out)) {+ dev_warn(adev->dev, "Failed to query RAS physical address for 0x%llx",
+ err_addr);
+ return -EINVAL;
+ }
+
+ if (dump_addr)
+ umc_v12_0_dump_addr_info(adev, &addr_out, err_addr);
+
+ *addr = addr_out.pa.pa;
+
+ return 0;
+}
+
static int umc_v12_0_query_error_address(struct amdgpu_device *adev,
uint32_t node_inst, uint32_t umc_inst,
uint32_t ch_inst, void *data) @@ -483,12 +523,10 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, {
struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
uint16_t hwid, mcatype;
- struct ta_ras_query_address_input addr_in;
uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL];
- uint64_t err_addr, hash_val = 0;
+ uint64_t err_addr, hash_val = 0, pa_addr = 0;
struct ras_ecc_err *ecc_err;
- int count;
- int ret;
+ int count, ret; hwid = REG_GET_FIELD(ipid, MCMP1_IPIDT0, HardwareID);
mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@ -514,17 +552,17 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,
MCA_IPID_2_UMC_CH(ipid),
err_addr);- memset(page_pfn, 0, sizeof(page_pfn));
-
- memset(&addr_in, 0, sizeof(addr_in)); - addr_in.ma.err_addr = err_addr; - addr_in.ma.ch_inst = MCA_IPID_2_UMC_CH(ipid); - addr_in.ma.umc_inst = MCA_IPID_2_UMC_INST(ipid); - addr_in.ma.node_inst = MCA_IPID_2_DIE_ID(ipid); - addr_in.ma.socket_id = MCA_IPID_2_SOCKET_ID(ipid); + ret = umc_v12_0_convert_mca_to_addr(adev, + err_addr, MCA_IPID_2_UMC_CH(ipid), + MCA_IPID_2_UMC_INST(ipid), MCA_IPID_2_DIE_ID(ipid), + MCA_IPID_2_SOCKET_ID(ipid), &pa_addr, true);
+ if (ret)
+ return ret;
- count = umc_v12_0_convert_err_addr(adev,
- &addr_in, page_pfn, ARRAY_SIZE(page_pfn));
+ memset(page_pfn, 0, sizeof(page_pfn));
+ count = umc_v12_0_expand_addr_to_bad_pages(adev,
+ pa_addr,
+ page_pfn, ARRAY_SIZE(page_pfn));
if (count <= 0) {
dev_warn(adev->dev, "Fail to convert error address! count:%d\n", count);
return 0;--
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 93 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 4:16 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: optimize umc v12 address conversion functionSplit into 3 parts:
1. Convert soc physical address via ras ta.
2. Expand bad pages from soc physical address.
3. Dump bad address info.Signed-off-by YiPeng Chai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 116 ++++++++++++++++--------- 1 file changed, 77 insertions(+), 39 deletions(-)drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +7
-17@@ -225,26 +225,16 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev, } } -static int umc_v12_0_convert_err_addr (struct amdgpu_device *adev, -struct ta_ras_query_address_input *addr_in, -uint64_t *pfns,int len) +static void umc_v12_0_dump_addr_info (struct amdgpu_device *adev, +struct ta_ras_query_address_output *addr_out, +uint64_t err_addr) {uint32_t col, row, row_xor, bank, channel_index; -uint64_t soc_pa, retired_page, column, err_addr; -struct ta_ras_query_address_output addr_out; -uint32_t pos =0 ; - - err_addr = addr_in->ma.err_addr; - addr_in->addr_type =TA_RAS_MCA_TO_PA ; -if (psp_ras_query_address (&adev->psp, addr_in, &addr_out)) { - dev_warn(adev->dev, "Failed to query RAS physical address for 0x%llx", - err_addr); -return 0 ; - } + uint64_t soc_pa, retired_page, column; - soc_pa = addr_out.pa.pa; - bank = addr_out.pa.bank; - channel_index = addr_out.pa.channel_idx; + soc_pa = addr_out->pa.pa; + bank = addr_out->pa.bank; + channel_index = addr_out->pa.channel_idx;col = (err_addr >> 1) & 0x1fULL; row = (err_addr >> 10) & 0x3fffULL;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-5@@ -258,11 +248,6 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev, for (column = 0; column < UMC_V12_0_NA_MAP_PA_NUM; column++) { retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); - -if (pos >= len) -return 0 ; - pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; -/* include column bit 0 and 1 */ col &= 0x3; col |= (column << 2);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +9
-0@@ -270,6 +255,35 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev, "Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n", retired_page, row, col, bank, channel_index); +/* shift R13 bit */ + retired_page ^= (0x1ULL <<UMC_V12_0_PA_R13_BIT ); +dev_info (adev->dev, + "Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n", + retired_page, row_xor, col, bank, channel_index); + } +} + +static int umc_v12_0_expand_addr_to_bad_pages(struct amdgpu_device*adev,
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev, · line 276
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +9
-0+ uint64_t pa_addr, uint64_t *pfns, int len) { + uint64_t soc_pa, retired_page, column; +uint32_t pos =0 ; + + soc_pa = pa_addr; +/* clear [C3 C2] in soc physical address */ + soc_pa &= ~(0x3ULL <<UMC_V12_0_PA_C2_BIT ); +/* clear [C4] in soc physical address */ + soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_C4_BIT );
[Tao] these bits are already cleared via UMC_V12_ADDR_MASK_BAD_COLS in patch #2, is the clear here redundant?
Quoted 93 lines
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +4
-0+ +/* loop for all possibilities of [C4 C3 C2] */ +for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { + retired_page = soc_pa | ((column & 0x3) <<
UMC_V12_0_PA_C2_BIT);
+retired_page|= (((column &0x4) >> 2) <<UMC_V12_0_PA_C4_BIT);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +34
-3+ +if (pos >= len) +return 0 ; + pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; +/* shift R13 bit */ retired_page ^= (0x1ULL <<UMC_V12_0_PA_R13_BIT );@@ -277,14 +291,40 @@ static int umc_v12_0_convert_err_addr(structamdgpu_device *adev, return 0; pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; -dev_info (adev->dev, - "Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n", - retired_page, row_xor, col, bank, channel_index); }return pos; } +static int umc_v12_0_convert_mca_to_addr (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch,uint32_t umc, +uint32_t node,uint32_t socket, +uint64_t *addr,bool dump_addr) +{ +struct ta_ras_query_address_input addr_in; +struct ta_ras_query_address_output addr_out; + +memset (&addr_in,0 ,sizeof (addr_in)); + addr_in.ma.err_addr = err_addr; + addr_in.ma.ch_inst = ch; + addr_in.ma.umc_inst = umc; + addr_in.ma.node_inst = node; + addr_in.ma.socket_id = socket; + addr_in.addr_type =TA_RAS_MCA_TO_PA ; +if (psp_ras_query_address (&adev->psp, &addr_in, &addr_out)) { + dev_warn(adev->dev, "Failed to query RAS physical address for 0x%llx", + err_addr); +return -EINVAL ; + } + +if (dump_addr) +umc_v12_0_dump_addr_info (adev, &addr_out, err_addr); + + *addr = addr_out.pa.pa; + +return 0 ; +} +static int umc_v12_0_query_error_address(struct
amdgpu_device*adev,
uint32_tnode_inst,uint32_tumc_inst,uint32_tch_inst, void *data)drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +3
-4@@ -483,12 +523,10 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, {struct amdgpu_ras *con =amdgpu_ras_get_context (adev);uint16_t hwid, mcatype; -struct ta_ras_query_address_input addr_in;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 ; +uint64_t err_addr, hash_val =0 , pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count; -int ret; +int count, ret; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID); mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@ -514,17 +552,17 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device*adev,
MCA_IPID_2_UMC_CH(ipid), err_addr);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +3
-8-memset (page_pfn,0 ,sizeof (page_pfn)); - -memset (&addr_in,0 ,sizeof (addr_in)); - addr_in.ma.err_addr = err_addr; - addr_in.ma.ch_inst =MCA_IPID_2_UMC_CH (ipid); - addr_in.ma.umc_inst =MCA_IPID_2_UMC_INST (ipid); - addr_in.ma.node_inst =MCA_IPID_2_DIE_ID (ipid); - addr_in.ma.socket_id =MCA_IPID_2_SOCKET_ID (ipid); + ret = umc_v12_0_convert_mca_to_addr(adev, + err_addr, MCA_IPID_2_UMC_CH(ipid), + MCA_IPID_2_UMC_INST(ipid),
Quoted 2 lines
MCA_IPID_2_DIE_ID(ipid),
+MCA_IPID_2_SOCKET_ID(ipid),&pa_addr, true);
[Tao] I prefer to using addr_in as input parameter for convert_mca_to_addr to simplify the function, and it's also convenient to make the function as a common interface for all ASICs in the future.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +6
-2+if (ret) +return ret; - count =umc_v12_0_convert_err_addr (adev, - &addr_in, page_pfn,ARRAY_SIZE (page_pfn)); +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + pa_addr, + page_pfn,ARRAY_SIZE (page_pfn));if (count <=0 ) { dev_warn(adev->dev, "Fail to convert error address!count:%d\n", count); return 0;--
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
-----------------
Best Regards,
Thomas
-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Thursday, July 18, 2024 10:51 AM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>
Subject: RE: [PATCH 1/3] drm/amdgpu: optimize umc v12 address conversion function
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 106 lines
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, July 17, 2024 4:16 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Yang, Stanley <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: optimize umc v12 address conversion functionSplit into 3 parts:
1. Convert soc physical address via ras ta.
2. Expand bad pages from soc physical address.
3. Dump bad address info.Signed-off-by YiPeng Chai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 116 ++++++++++++++++--------- 1 file changed, 77 insertions(+), 39 deletions(-)drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +0
-0@@ -225,26 +225,16 @@ static voidumc_v12_0_convert_error_address(struct
amdgpu_device*adev,}}
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +3
-11-static int umc_v12_0_convert_err_addr (struct amdgpu_device *adev, -struct ta_ras_query_address_input *addr_in, -uint64_t *pfns,int len) +static void umc_v12_0_dump_addr_info (struct amdgpu_device *adev, +struct ta_ras_query_address_output *addr_out, +uint64_t err_addr) {uint32_t col, row, row_xor, bank, channel_index; -uint64_t soc_pa, retired_page, column, err_addr; -struct ta_ras_query_address_output addr_out; -uint32_t pos =0 ; - - err_addr = addr_in->ma.err_addr; - addr_in->addr_type =TA_RAS_MCA_TO_PA ; -if (psp_ras_query_address (&adev->psp, addr_in, &addr_out)) { - dev_warn(adev->dev, "Failed to query RAS physical address for0x%llx",
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +4
-6- err_addr); -return 0 ; - } +uint64_t soc_pa, retired_page, column; - soc_pa = addr_out.pa.pa; - bank = addr_out.pa.bank; - channel_index = addr_out.pa.channel_idx; + soc_pa = addr_out->pa.pa; + bank = addr_out->pa.bank; + channel_index = addr_out->pa.channel_idx; col = (err_addr >>1 ) &0x1fULL ; row = (err_addr >> 10) & 0x3fffULL; @@ -258,11 +248,6 @@ staticint umc_v12_0_convert_err_addr(struct
amdgpu_device*adev,for (column = 0; column < UMC_V12_0_NA_MAP_PA_NUM; column++) { retired_page = soc_pa | ((column & 0x3) << UMC_V12_0_PA_C2_BIT); retired_page |= (((column & 0x4) >> 2) <<
UMC_V12_0_PA_C4_BIT);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +10
-5- -if (pos >= len) -return 0 ; - pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; -/* include column bit 0 and 1 */ col &=0x3 ; col |= (column <<2 );@@ -270,6 +255,35 @@ static int umc_v12_0_convert_err_addr(struct amdgpu_device *adev, "Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n", retired_page, row, col, bank, channel_index); +/* shift R13 bit */ + retired_page ^= (0x1ULL <<UMC_V12_0_PA_R13_BIT ); +dev_info (adev->dev, + "Error Address(PA):0x%-10llx Row:0x%-4x + Col:0x%-2x Bank:0x%x Channel:0x%x\n", + retired_page, row_xor, col, bank, channel_index); + } +} + +static int umc_v12_0_expand_addr_to_bad_pages(struct amdgpu_device*adev,
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +9
-0+ uint64_t pa_addr, uint64_t *pfns, int len) { + uint64_t soc_pa, retired_page, column; +uint32_t pos =0 ; + + soc_pa = pa_addr; +/* clear [C3 C2] in soc physical address */ + soc_pa &= ~(0x3ULL <<UMC_V12_0_PA_C2_BIT ); +/* clear [C4] in soc physical address */ + soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_C4_BIT );
Quoted 1 line
[Tao] these bits are already cleared via
UMC_V12_ADDR_MASK_BAD_COLSin patch #2, is the clear here redundant?
[Thomas] I think these code are like checking input parameters and cannot rely on external call data.
Quoted 96 lines
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +4
-0+ +/* loop for all possibilities of [C4 C3 C2] */ +for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { + retired_page = soc_pa | ((column & 0x3) <<
UMC_V12_0_PA_C2_BIT);
+retired_page|= (((column &0x4) >> 2) <<UMC_V12_0_PA_C4_BIT);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +34
-3+ +if (pos >= len) +return 0 ; + pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; +/* shift R13 bit */ retired_page ^= (0x1ULL <<UMC_V12_0_PA_R13_BIT );@@ -277,14 +291,40 @@ static int umc_v12_0_convert_err_addr(structamdgpu_device *adev, return 0; pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; -dev_info (adev->dev, - "Error Address(PA):0x%-10llx Row:0x%-4x Col:0x%-2x Bank:0x%x Channel:0x%x\n", - retired_page, row_xor, col, bank, channel_index); }return pos; } +static int umc_v12_0_convert_mca_to_addr (struct amdgpu_device *adev, +uint64_t err_addr,uint32_t ch,uint32_t umc, +uint32_t node,uint32_t socket, +uint64_t *addr,bool dump_addr) { +struct ta_ras_query_address_input addr_in; +struct ta_ras_query_address_output addr_out; + +memset (&addr_in,0 ,sizeof (addr_in)); + addr_in.ma.err_addr = err_addr; + addr_in.ma.ch_inst = ch; + addr_in.ma.umc_inst = umc; + addr_in.ma.node_inst = node; + addr_in.ma.socket_id = socket; + addr_in.addr_type =TA_RAS_MCA_TO_PA ; +if (psp_ras_query_address (&adev->psp, &addr_in, &addr_out)) { + dev_warn(adev->dev, "Failed to query RAS physical + address for 0x%llx", + err_addr); +return -EINVAL ; + } + +if (dump_addr) +umc_v12_0_dump_addr_info (adev, &addr_out, err_addr); + + *addr = addr_out.pa.pa; + +return 0 ; +} +static int umc_v12_0_query_error_address(struct
amdgpu_device*adev,uint32_t node_inst, uint32_t umc_inst, uint32_t ch_inst, void *data) @@ -483,12 +523,10 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, { struct amdgpu_ras *con = amdgpu_ras_get_context(adev); uint16_t hwid, mcatype;drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +3
-4-struct ta_ras_query_address_input addr_in;uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ]; -uint64_t err_addr, hash_val =0 ; +uint64_t err_addr, hash_val =0 , pa_addr =0 ;struct ras_ecc_err *ecc_err; -int count; -int ret; +int count, ret; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID); mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType); @@ -514,17 +552,17 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device*adev,
MCA_IPID_2_UMC_CH(ipid), err_addr);drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +3
-8-memset (page_pfn,0 ,sizeof (page_pfn)); - -memset (&addr_in,0 ,sizeof (addr_in)); - addr_in.ma.err_addr = err_addr; - addr_in.ma.ch_inst =MCA_IPID_2_UMC_CH (ipid); - addr_in.ma.umc_inst =MCA_IPID_2_UMC_INST (ipid); - addr_in.ma.node_inst =MCA_IPID_2_DIE_ID (ipid); - addr_in.ma.socket_id =MCA_IPID_2_SOCKET_ID (ipid); + ret = umc_v12_0_convert_mca_to_addr(adev, + err_addr, MCA_IPID_2_UMC_CH(ipid), + MCA_IPID_2_UMC_INST(ipid),
MCA_IPID_2_DIE_ID(ipid),
+MCA_IPID_2_SOCKET_ID(ipid),&pa_addr, true);
Quoted 1 line
[Tao] I prefer to using
addr_inas input parameter forconvert_mca_to_addrto simplify the function, and it's also convenient to make the function as a common interface for all ASICs in the future.
[Thomas] convert_mca_to_addr will be called in multiple places: 1. Detecting a newly ecc error; 2. Loading ecc data from EEPROM (when using new data format). 3. Switch NPS?
If using addr_in as input parameter, a lot of redundant code must be added to convert IPID to add_in in each place before calling convert_mca_to_addr.
Each ASIC may have different address translation, umc_v12_0_convert_mca_to_addr is only for umc v12, if address translation has a common interface in future, it only need to change umc_v12_0_convert_mca_to_addr.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +6
-2+if (ret) +return ret; - count =umc_v12_0_convert_err_addr (adev, - &addr_in, page_pfn,ARRAY_SIZE (page_pfn)); +memset (page_pfn,0 ,sizeof (page_pfn)); + count =umc_v12_0_expand_addr_to_bad_pages (adev, + pa_addr, + page_pfn,ARRAY_SIZE (page_pfn));if (count <=0 ) { dev_warn(adev->dev, "Fail to convert error address!count:%d\n", count); return 0;--
2.34.1