drm/amdgpu: add flag to indicate nps mode switch
Subsystems (2)
PATCH 1/23 drm/amdgpu: add flag to indicate nps mode switch
There are two types of gpu reset, nps mode switch and normal gpu reset, add a flag to distigush them.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 13 ++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1681,6 +1681,7 @@ static inline bool amdgpu_is_tmz(struct amdgpu_device *adev) }int amdgpu_in_reset (struct amdgpu_device *adev); +int amdgpu_in_nps_switch (struct amdgpu_device *adev);extern const struct attribute_group amdgpu_vram_mgr_attr_group;extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -2
@@ -5862,7 +5862,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,/* We need to lock reset domain only once both for XGMI and single device */ tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, reset_list); -amdgpu_device_lock_reset_domain (tmp_adev->reset_domain); +amdgpu_device_lock_reset_domain (tmp_adev);/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) {
@@ -6343,7 +6343,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ -amdgpu_device_lock_reset_domain (adev->reset_domain); +amdgpu_device_lock_reset_domain (adev);amdgpu_device_set_mp1_state (adev);/*
@@ -6579,6 +6579,11 @@ int amdgpu_in_reset(struct amdgpu_device *adev)return atomic_read (&adev->reset_domain->in_gpu_reset); } +int amdgpu_in_nps_switch (struct amdgpu_device *adev) +{ +return atomic_read (&adev->reset_domain->in_nps_switch); +} +/** * amdgpu_device_halt() - bring hardware to some kind of halt state *
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +12 -1
@@ -301,15 +301,25 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_dINIT_WORK (&reset_domain->clear, amdgpu_reset_domain_cancel_all_work);atomic_set (&reset_domain->in_gpu_reset,0 ); +atomic_set (&reset_domain->in_nps_switch,0 );atomic_set (&reset_domain->reset_res,0 );init_rwsem (&reset_domain->sem);return reset_domain; } -void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain) +void amdgpu_device_lock_reset_domain (struct amdgpu_device *adev) { +struct amdgpu_reset_domain *reset_domain = adev->reset_domain; +atomic_set (&reset_domain->in_gpu_reset,1 ); +/* The life time of in_nps_switch is longer than +* amdgpu_device_nps_switch_needed +*/ +if (adev->nbio.funcs && adev->nbio.funcs->is_nps_switch_requested && + adev->nbio.funcs->is_nps_switch_requested (adev)) +atomic_set (&reset_domain->in_nps_switch,1 ); +down_write (&reset_domain->sem); }
@@ -317,6 +327,7 @@ void amdgpu_device_lock_reset_domain(struct amdgpu_reset_domain *reset_domain)void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain) {atomic_set (&reset_domain->in_gpu_reset,0 ); +atomic_set (&reset_domain->in_nps_switch,0 );up_write (&reset_domain->sem); }
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +2 -1
@@ -97,6 +97,7 @@ struct amdgpu_reset_domain {enum amdgpu_reset_domain_type type;struct rw_semaphore sem;atomic_t in_gpu_reset; +atomic_t in_nps_switch;atomic_t reset_res;struct work_struct clear;bool drain;
@@ -158,7 +159,7 @@ static inline bool amdgpu_reset_pending(struct amdgpu_reset_domain *domain)return rwsem_is_contended (&domain->sem); } -void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain); +void amdgpu_device_lock_reset_domain (struct amdgpu_device *adev);void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain);
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +1 -1
@@ -1540,7 +1540,7 @@ static void amdgpu_xgmi_reset_on_init_work(struct work_struct *work) tmp_adev = list_first_entry(&device_list, struct amdgpu_device, reset_list); -amdgpu_device_lock_reset_domain (tmp_adev->reset_domain); +amdgpu_device_lock_reset_domain (tmp_adev); reset_context.method =AMD_RESET_METHOD_ON_INIT ; reset_context.reset_req_dev = tmp_adev;
Signature · 1 line
2.34.1
PATCH 2/23 drm/amdgpu: do RAS init in NPS mode switch
NPS mode switch will call gpu reset, but this is different from normal reset.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3293,7 +3293,7 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)return r; } -if (!amdgpu_in_reset (adev)) +if (!amdgpu_in_reset (adev) ||amdgpu_in_nps_switch (adev))amdgpu_ras_set_error_query_ready (adev, true);amdgpu_device_set_cg_state (adev,AMD_CG_STATE_GATE );
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +7 -4
@@ -1253,7 +1253,8 @@ int amdgpu_ras_bind_aca(struct amdgpu_device *adev, enum amdgpu_ras_block blk,struct ras_manager *obj;/* in resume phase, no need to create aca fs node */ -if (adev->in_suspend ||amdgpu_in_reset (adev)) +if (adev->in_suspend || + (amdgpu_in_reset (adev) && !amdgpu_in_nps_switch (adev)))return 0 ; obj =get_ras_manager (adev, blk);
@@ -3780,7 +3781,8 @@ int amdgpu_ras_block_late_init(struct amdgpu_device *adev, r =amdgpu_ras_feature_enable_on_boot (adev, ras_block,1 );if (r) { -if (adev->in_suspend ||amdgpu_in_reset (adev)) { +if (adev->in_suspend || + (amdgpu_in_reset (adev) && !amdgpu_in_nps_switch (adev))) {/* in resume phase, if fail to enable ras, * clean up all ras fs nodes, and disable ras */ goto cleanup;
@@ -3792,7 +3794,8 @@ int amdgpu_ras_block_late_init(struct amdgpu_device *adev,amdgpu_persistent_edc_harvesting (adev, ras_block);/* in resume phase, no need to create ras fs node */ -if (adev->in_suspend ||amdgpu_in_reset (adev)) +if (adev->in_suspend || + (amdgpu_in_reset (adev) && !amdgpu_in_nps_switch (adev)))return 0 ; ras_obj = container_of(ras_block, struct amdgpu_ras_block_object, ras_comm);
@@ -3922,7 +3925,7 @@ int amdgpu_ras_late_init(struct amdgpu_device *adev)amdgpu_ras_event_mgr_init (adev);if (amdgpu_ras_aca_is_supported (adev)) { -if (amdgpu_in_reset (adev)) { +if (amdgpu_in_reset (adev) && !amdgpu_in_nps_switch (adev)) {if (amdgpu_aca_is_enabled (adev)) r =amdgpu_aca_reset (adev);else
Signature · 1 line
2.34.1
RE: [PATCH 02/23] drm/amdgpu: do RAS init in NPS mode switch
[AMD Official Use Only - AMD Internal Distribution Only]
In nps mode is somehow confusing. We'd like to differentiate recovery (*after* reset) from regular initialization.
Is it possible to replace in nps mode check with more general approach? In regular initialization, set ras interface available in ip late init, while in recovery, let the flag set when recovery is completed.
Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Friday, November 8, 2024 7:14 PM
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 02/23] drm/amdgpu: do RAS init in NPS mode switch
NPS mode switch will call gpu reset, but this is different from normal reset.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -3293,7 +3293,7 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)return r; } -if (!amdgpu_in_reset (adev)) +if (!amdgpu_in_reset (adev) ||amdgpu_in_nps_switch (adev))amdgpu_ras_set_error_query_ready (adev, true); amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index de1a55ae1d78..cbecf2380b51 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +6 -3
@@ -1253,7 +1253,8 @@ int amdgpu_ras_bind_aca(struct amdgpu_device *adev, enum amdgpu_ras_block blk,struct ras_manager *obj;/* in resume phase, no need to create aca fs node */ -if (adev->in_suspend ||amdgpu_in_reset (adev)) +if (adev->in_suspend || + (amdgpu_in_reset (adev) && !amdgpu_in_nps_switch (adev)))return 0 ; obj =get_ras_manager (adev, blk);
@@ -3780,7 +3781,8 @@ int amdgpu_ras_block_late_init(struct amdgpu_device *adev, r =amdgpu_ras_feature_enable_on_boot (adev, ras_block,1 );if (r) { -if (adev->in_suspend ||amdgpu_in_reset (adev)) { +if (adev->in_suspend || + (amdgpu_in_reset (adev) && !amdgpu_in_nps_switch (adev))) {/* in resume phase, if fail to enable ras, * clean up all ras fs nodes, and disable ras */ goto cleanup;
@@ -3792,7 +3794,8 @@ int amdgpu_ras_block_late_init(struct amdgpu_device *adev,amdgpu_persistent_edc_harvesting (adev, ras_block);/* in resume phase, no need to create ras fs node */ -if (adev->in_suspend ||amdgpu_in_reset (adev)) +if (adev->in_suspend || + (amdgpu_in_reset (adev) && !amdgpu_in_nps_switch (adev)))return 0 ; ras_obj = container_of(ras_block, struct amdgpu_ras_block_object, ras_comm); @@ -3922,7 +3925,7 @@ int amdgpu_ras_late_init(struct amdgpu_device *adev)
amdgpu_ras_event_mgr_init(adev);
if (amdgpu_ras_aca_is_supported(adev)) {
- if (amdgpu_in_reset(adev)) {
+ if (amdgpu_in_reset(adev) && !amdgpu_in_nps_switch(adev)) {
if (amdgpu_aca_is_enabled(adev))
r = amdgpu_aca_reset(adev);
else--
2.34.1
PATCH 3/23 drm/amdgpu: simplify RAS page retirement in one memory row
In reply to Tao ZhouTake R13 and column bits as a whole for UMC v12.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 57 +++++++++++--------------- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 1 + 2 files changed, 24 insertions(+), 34 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +23 -34
@@ -177,7 +177,7 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev,struct ras_err_data *err_data, struct ta_ras_query_address_input *addr_in) { - uint32_t col, row, row_xor, bank, channel_index; + uint32_t col, row, bank, channel_index;uint64_t soc_pa, retired_page, column, err_addr;struct ta_ras_query_address_output addr_out;
@@ -195,31 +195,27 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev, channel_index = addr_out.pa.channel_idx; col = (err_addr >>1 ) &0x1fULL ; - row = (err_addr >>10 ) &0x3fffULL ; - row_xor = row ^ (0x1ULL <<13 );/* 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 ); +/* clear [R13] in soc physical address */ + soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_R13_BIT ); -/* loop for all possibilities of [C4 C3 C2] */ -for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { +/* loop for all possibilities of [R13 C4 C3 C2] */ +for (column =0 ; column <UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ; column++) { retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); + retired_page |= (((column &0x8 ) >>3 ) <<UMC_V12_0_PA_R13_BIT ); +/* include column bit 0 and 1 */ col &=0x3 ; col |= (column <<2 ); -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, col, bank, channel_index); -amdgpu_umc_fill_error_record (err_data, err_addr, - retired_page, channel_index, addr_in->ma.umc_inst); + row = (retired_page >>UMC_V12_0_PA_R0_BIT ) &0x3fffULL ; -/* 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); + retired_page, row, col, bank, channel_index);amdgpu_umc_fill_error_record (err_data, err_addr, retired_page, channel_index, addr_in->ma.umc_inst); }
@@ -229,7 +225,7 @@ 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; + uint32_t col, row, bank, channel_index;uint64_t soc_pa, retired_page, column; soc_pa = addr_out->pa.pa;
@@ -237,29 +233,27 @@ static void umc_v12_0_dump_addr_info(struct amdgpu_device *adev, channel_index = addr_out->pa.channel_idx; col = (err_addr >>1 ) &0x1fULL ; - row = (err_addr >>10 ) &0x3fffULL ; - row_xor = row ^ (0x1ULL <<13 );/* 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 ); +/* clear [R13] in soc physical address */ + soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_R13_BIT ); -/* loop for all possibilities of [C4 C3 C2] */ -for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { +/* loop for all possibilities of [R13 C4 C3 C2] */ +for (column =0 ; column <UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ; column++) { retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); + retired_page |= (((column &0x8 ) >>3 ) <<UMC_V12_0_PA_R13_BIT ); +/* include column bit 0 and 1 */ col &=0x3 ; - col |= (column <<2 ); -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, col, bank, channel_index); + col |= ((column &0x7 ) <<2 ); + row = (retired_page >>UMC_V12_0_PA_R0_BIT ) &0x3fffULL ; -/* 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); + retired_page, row, col, bank, channel_index); } }
@@ -274,23 +268,18 @@ static int umc_v12_0_lookup_bad_pages_in_a_row(struct amdgpu_device *adev, soc_pa &= ~(0x3ULL <<UMC_V12_0_PA_C2_BIT );/* clear [C4] in soc physical address */ soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_C4_BIT ); +/* clear [R13] in soc physical address */ + soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_R13_BIT );/* loop for all possibilities of [C4 C3 C2] */ -for (column =0 ; column <UMC_V12_0_NA_MAP_PA_NUM ; column++) { +for (column =0 ; column <UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ; column++) { retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); + retired_page |= (((column &0x8 ) >>3 ) <<UMC_V12_0_PA_R13_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 ); - -if (pos >= len) -return 0 ; - pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; - }return pos;
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +1 -0
@@ -60,6 +60,7 @@#define UMC_V12_0_PA_C2_BIT 15#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_R13_BIT 35#define MCA_UMC_HWID_V12_0 0x96
Signature · 1 line
2.34.1
PATCH 4/23 drm/amdgpu: remove redundant RAS error address coversion code
In reply to Tao ZhouOnly one interface is responsible for the conversion.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 136 +++++++++++-------------- 1 file changed, 59 insertions(+), 77 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +59 -77
@@ -175,62 +175,41 @@ static void umc_v12_0_query_ras_error_count(struct amdgpu_device *adev,static void umc_v12_0_convert_error_address (struct amdgpu_device *adev,struct ras_err_data *err_data, -struct ta_ras_query_address_input *addr_in) +struct ta_ras_query_address_input *addr_in, +struct ta_ras_query_address_output *addr_out, +bool dump_addr) { -uint32_t col, row, bank, channel_index; +uint32_t col, row, bank, channel_index, umc_inst =0 ;uint64_t soc_pa, retired_page, column, err_addr; -struct ta_ras_query_address_output addr_out; - - 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 ; - } - - soc_pa = addr_out.pa.pa; - bank = addr_out.pa.bank; - channel_index = addr_out.pa.channel_idx; +struct ta_ras_query_address_output addr_out_tmp; +struct ta_ras_query_address_output *paddr_out; - col = (err_addr >>1 ) &0x1fULL ; -/* 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 ); -/* clear [R13] in soc physical address */ - soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_R13_BIT ); +if (!addr_out) + paddr_out = &addr_out_tmp; +else + paddr_out = addr_out; -/* loop for all possibilities of [R13 C4 C3 C2] */ -for (column =0 ; column <UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ; column++) { - retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); - retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); - retired_page |= (((column &0x8 ) >>3 ) <<UMC_V12_0_PA_R13_BIT ); + err_addr = bank = channel_index =0 ; +if (addr_in) { + 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, paddr_out)) { +dev_warn (adev->dev,"Failed to query RAS physical address for 0x%llx" , + err_addr); -/* include column bit 0 and 1 */ - col &=0x3 ; - col |= (column <<2 ); - row = (retired_page >>UMC_V12_0_PA_R0_BIT ) &0x3fffULL ; +return ; + } -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, col, bank, channel_index); -amdgpu_umc_fill_error_record (err_data, err_addr, - retired_page, channel_index, addr_in->ma.umc_inst); + bank = paddr_out->pa.bank; + channel_index = paddr_out->pa.channel_idx; +/* no need to care about umc inst if addr_in is NULL */ + umc_inst = addr_in->ma.umc_inst; } -} -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, bank, channel_index; -uint64_t soc_pa, retired_page, column; + soc_pa = paddr_out->pa.pa; - soc_pa = addr_out->pa.pa; - bank = addr_out->pa.bank; - channel_index = addr_out->pa.channel_idx; +if (!err_data && !dump_addr) +return ; col = (err_addr >>1 ) &0x1fULL ;/* clear [C3 C2] in soc physical address */
@@ -248,41 +227,50 @@ static void umc_v12_0_dump_addr_info(struct amdgpu_device *adev,/* include column bit 0 and 1 */ col &=0x3 ; - col |= ((column &0x7 ) <<2 ); + col |= (column <<2 ); row = (retired_page >>UMC_V12_0_PA_R0_BIT ) &0x3fffULL ; -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, col, bank, channel_index); +if (dump_addr) +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, col, bank, channel_index); + +if (err_data) +amdgpu_umc_fill_error_record (err_data, err_addr, + retired_page, channel_index, umc_inst); } }static int umc_v12_0_lookup_bad_pages_in_a_row (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 ); -/* clear [R13] in soc physical address */ - soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_R13_BIT ); +uint32_t i, ret =0 , pos =0 ; +struct ta_ras_query_address_output addr_out; +struct ras_err_data err_data; + + err_data.err_addr = +kcalloc (adev->umc.max_ras_err_cnt_per_query, +sizeof (struct eeprom_table_record ),GFP_KERNEL ); +if (!err_data.err_addr) { +dev_warn (adev->dev,"Failed to alloc memory in " +"bad page lookup!\n" ); +return 0 ; + } -/* loop for all possibilities of [C4 C3 C2] */ -for (column =0 ; column <UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ; column++) { - retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); - retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); - retired_page |= (((column &0x8 ) >>3 ) <<UMC_V12_0_PA_R13_BIT ); + addr_out.pa.pa = pa_addr; +umc_v12_0_convert_error_address (adev, &err_data,NULL , &addr_out, false); +for (i =0 ; i < adev->umc.max_ras_err_cnt_per_query; i++) {if (pos >= len) -return 0 ; - pfns[pos++] = retired_page >>AMDGPU_GPU_PAGE_SHIFT ; + goto out; + + pfns[pos++] = err_data.err_addr[pos].retired_page; } + ret = pos; -return pos; +out: +kfree (err_data.err_addr); +return ret; } static int umc_v12_0_convert_mca_to_addr(struct amdgpu_device *adev,
@@ -300,14 +288,8 @@ static int umc_v12_0_convert_mca_to_addr(struct amdgpu_device *adev, 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); +umc_v12_0_convert_error_address (adev,NULL , &addr_in, &addr_out, dump_addr); *addr = addr_out.pa.pa;
@@ -363,7 +345,7 @@ static int umc_v12_0_query_error_address(struct amdgpu_device *adev, addr_in.ma.umc_inst = umc_inst; addr_in.ma.node_inst = node_inst; -umc_v12_0_convert_error_address (adev, err_data, &addr_in); +umc_v12_0_convert_error_address (adev, err_data, &addr_in,NULL , true); }/* clear umc status */
Signature · 1 line
2.34.1
PATCH 5/23 drm/amdgpu: store PA with column bits cleared for RAS bad page
In reply to Tao ZhouSo the code can be simplified, and no need to expose the detail of PA format outside address conversion.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 4 +++- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +3 -1
@@ -219,6 +219,8 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev,/* clear [R13] in soc physical address */ soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_R13_BIT ); + paddr_out->pa.pa = soc_pa; +/* loop for all possibilities of [R13 C4 C3 C2] */ for (column =0 ; column <UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ; column++) { retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT );
@@ -537,7 +539,7 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, 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 ; + ecc_err->pa_pfn = pa_addr >>AMDGPU_GPU_PAGE_SHIFT ;/* If converted pa_pfn is 0, use pa C4 pfn. */ if (!ecc_err->pa_pfn)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +0 -5
@@ -82,11 +82,6 @@ (((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
PATCH 6/23 drm/amdgpu: make convert_ras_err_addr visible outside UMC block
In reply to Tao ZhouAnd change some UMC v12 specific functions to common version, so the code can be shared.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 63 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 11 +++++ drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 62 ++---------------------- 3 files changed, 78 insertions(+), 58 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +63 -0
@@ -445,3 +445,66 @@ int amdgpu_umc_logs_ecc_err(struct amdgpu_device *adev,return ret; } + +int amdgpu_umc_lookup_bad_pages_in_a_row (struct amdgpu_device *adev, +uint64_t pa_addr,uint64_t *pfns,int len) +{ +uint32_t i, ret =0 , pos =0 ; +struct ta_ras_query_address_output addr_out; +struct ras_err_data err_data; + + err_data.err_addr = +kcalloc (adev->umc.max_ras_err_cnt_per_query, +sizeof (struct eeprom_table_record ),GFP_KERNEL ); +if (!err_data.err_addr) { +dev_warn (adev->dev,"Failed to alloc memory in " +"bad page lookup!\n" ); +return 0 ; + } + + addr_out.pa.pa = pa_addr; + +if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) + adev->umc.ras->convert_ras_err_addr (adev, &err_data,NULL , + &addr_out, false); +else + goto out; + +for (i =0 ; i < adev->umc.max_ras_err_cnt_per_query; i++) { +if (pos >= len) + goto out; + + pfns[pos++] = err_data.err_addr[pos].retired_page; + } + ret = pos; + +out: +kfree (err_data.err_addr); +return ret; +} + +int amdgpu_umc_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; + +if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) + adev->umc.ras->convert_ras_err_addr (adev,NULL , &addr_in, + &addr_out, dump_addr); +else +return 0 ; + + *addr = addr_out.pa.pa; + +return 0 ; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +11 -0
@@ -70,6 +70,11 @@ struct amdgpu_umc_ras { enum amdgpu_mca_error_type type, void *ras_error_status);int (*update_ecc_status)(struct amdgpu_device *adev,uint64_t status,uint64_t ipid,uint64_t addr); +void (*convert_ras_err_addr)(struct amdgpu_device *adev, +struct ras_err_data *err_data, +struct ta_ras_query_address_input *addr_in, +struct ta_ras_query_address_output *addr_out, +bool dump_addr); };struct amdgpu_umc_funcs {
@@ -134,4 +139,10 @@ int amdgpu_umc_logs_ecc_err(struct amdgpu_device *adev,void amdgpu_umc_handle_bad_pages (struct amdgpu_device *adev,void *ras_error_status); +int amdgpu_umc_lookup_bad_pages_in_a_row (struct amdgpu_device *adev, +uint64_t pa_addr,uint64_t *pfns,int len); +int amdgpu_umc_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);#endif
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +4 -58
91 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 7/23 drm/amdgpu: reduce memory usage for umc_lookup_bad_pages_in_a_row
In reply to Tao ZhouThe function handles one page in one time, allocating umc.retire_unit bad page records is enough.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -2
@@ -454,7 +454,7 @@ int amdgpu_umc_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,struct ras_err_data err_data; err_data.err_addr = -kcalloc (adev->umc.max_ras_err_cnt_per_query, +kcalloc (adev->umc.retire_unit,sizeof (struct eeprom_table_record ),GFP_KERNEL );if (!err_data.err_addr) { dev_warn(adev->dev, "Failed to alloc memory in "
@@ -470,7 +470,7 @@ int amdgpu_umc_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,else goto out; -for (i =0 ; i < adev->umc.max_ras_err_cnt_per_query; i++) { +for (i =0 ; i < adev->umc.retire_unit; i++) {if (pos >= len) goto out;
Signature · 1 line
2.34.1
PATCH 8/23 drm/amdgpu: add return value for convert_ras_err_addr
In reply to Tao ZhouSo upper layer can return failure directly if address conversion fails.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 19 +++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 +- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 12 ++++++++---- 3 files changed, 22 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +13 -6
@@ -464,11 +464,14 @@ int amdgpu_umc_lookup_bad_pages_in_a_row(struct amdgpu_device *adev, addr_out.pa.pa = pa_addr; -if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) - adev->umc.ras->convert_ras_err_addr (adev, &err_data,NULL , +if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) { + ret = adev->umc.ras->convert_ras_err_addr (adev, &err_data,NULL , &addr_out, false); -else +if (ret) + goto out; + }else { goto out; + }for (i =0 ; i < adev->umc.retire_unit; i++) {if (pos >= len)
@@ -490,6 +493,7 @@ int amdgpu_umc_mca_to_addr(struct amdgpu_device *adev, {struct ta_ras_query_address_input addr_in;struct ta_ras_query_address_output addr_out; +int ret;memset (&addr_in,0 ,sizeof (addr_in)); addr_in.ma.err_addr = err_addr;
@@ -498,11 +502,14 @@ int amdgpu_umc_mca_to_addr(struct amdgpu_device *adev, addr_in.ma.node_inst = node; addr_in.ma.socket_id = socket; -if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) - adev->umc.ras->convert_ras_err_addr (adev,NULL , &addr_in, +if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) { + ret = adev->umc.ras->convert_ras_err_addr (adev,NULL , &addr_in, &addr_out, dump_addr); -else +if (ret) +return ret; + }else {return 0 ; + } *addr = addr_out.pa.pa;
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +1 -1
@@ -70,7 +70,7 @@ struct amdgpu_umc_ras { enum amdgpu_mca_error_type type, void *ras_error_status);int (*update_ecc_status)(struct amdgpu_device *adev,uint64_t status,uint64_t ipid,uint64_t addr); - void (*convert_ras_err_addr)(struct amdgpu_device *adev, + int (*convert_ras_err_addr)(struct amdgpu_device *adev, struct ras_err_data *err_data, struct ta_ras_query_address_input *addr_in, struct ta_ras_query_address_output *addr_out,
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +8 -4
@@ -173,7 +173,7 @@ static void umc_v12_0_query_ras_error_count(struct amdgpu_device *adev,umc_v12_0_reset_error_count (adev); } -static void umc_v12_0_convert_error_address(struct amdgpu_device *adev, +static int umc_v12_0_convert_error_address(struct amdgpu_device *adev, struct ras_err_data *err_data, struct ta_ras_query_address_input *addr_in, struct ta_ras_query_address_output *addr_out,
@@ -183,6 +183,7 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev,uint64_t soc_pa, retired_page, column, err_addr;struct ta_ras_query_address_output addr_out_tmp;struct ta_ras_query_address_output *paddr_out; +int ret =0 ;if (!addr_out) paddr_out = &addr_out_tmp;
@@ -193,11 +194,12 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev,if (addr_in) { 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, paddr_out)) { + ret =psp_ras_query_address (&adev->psp, addr_in, paddr_out); +if (ret) {dev_warn (adev->dev,"Failed to query RAS physical address for 0x%llx" , err_addr); -return ; +return ret; } bank = paddr_out->pa.bank;
@@ -209,7 +211,7 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev, soc_pa = paddr_out->pa.pa;if (!err_data && !dump_addr) -return ; +return ret; col = (err_addr >>1 ) &0x1fULL ;/* clear [C3 C2] in soc physical address */
@@ -241,6 +243,8 @@ static void umc_v12_0_convert_error_address(struct amdgpu_device *adev,amdgpu_umc_fill_error_record (err_data, err_addr, retired_page, channel_index, umc_inst); } + +return ret; } static int umc_v12_0_query_error_address(struct amdgpu_device *adev,
Signature · 1 line
2.34.1
PATCH 9/23 drm/amdgpu: add TA_RAS_INV_NODE value
In reply to Tao ZhouWe can set UMC node instance to invalid state if we use global channel index, and RAS TA can choose UMC address conversion approach by checking node_inst value.
--- drivers/gpu/drm/amd/amdgpu/ta_ras_if.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/ta_ras_if.h +3 -0
@@ -30,6 +30,9 @@#define RSP_ID_MASK (1U << 31)#define RSP_ID (cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK) +/* invalid node instance value */ +#define TA_RAS_INV_NODE 0xffff +/* RAS related enumerations */ /**********************************************************/ enum ras_command {
Signature · 1 line
2.34.1
PATCH 10/23 drm/amdgpu: add flag to indicate the type of RAS eeprom record
In reply to Tao ZhouOne UMC MCA address could map to multiply physical address (PA):
AMDGPU_RAS_EEPROM_REC_PA: one record store one PAAMDGPU_RAS_EEPROM_REC_MCA: one record store one MCA address, PA is not cared about
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 33 +++++++++++++++---- .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 14 ++++++++ 2 files changed, 40 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +26 -7
@@ -2769,10 +2769,20 @@ static int amdgpu_ras_load_bad_pages(struct amdgpu_device *adev)return -ENOMEM ; ret =amdgpu_ras_eeprom_read (control, bps, control->ras_num_recs); -if (ret) +if (ret) {dev_err (adev->dev,"Failed to load EEPROM table records!" ); -else + }else { +if (control->ras_num_recs >1 && + adev->umc.ras && adev->umc.ras->convert_ras_err_addr) { +if ((bps[0 ].address == bps[1 ].address) && + (bps[0 ].mem_channel == bps[1 ].mem_channel)) + control->rec_type =AMDGPU_RAS_EEPROM_REC_PA ; +else + control->rec_type =AMDGPU_RAS_EEPROM_REC_MCA ; + } + ret =amdgpu_ras_add_bad_pages (adev, bps, control->ras_num_recs); + }kfree (bps);return ret;
@@ -3161,13 +3171,14 @@ static int amdgpu_ras_page_retirement_thread(void *param)int amdgpu_ras_init_badpage_info (struct amdgpu_device *adev) {struct amdgpu_ras *con =amdgpu_ras_get_context (adev); +struct amdgpu_ras_eeprom_control *control;int ret;if (!con ||amdgpu_sriov_vf (adev))return 0 ; - ret =amdgpu_ras_eeprom_init (&con->eeprom_control); - + control = &con->eeprom_control; + ret =amdgpu_ras_eeprom_init (control);if (ret)return ret;
@@ -3175,17 +3186,25 @@ int amdgpu_ras_init_badpage_info(struct amdgpu_device *adev)if (amdgpu_ras_is_rma (adev))return -EHWPOISON ; -if (con->eeprom_control.ras_num_recs) { +if (!adev->umc.ras || !adev->umc.ras->convert_ras_err_addr) + control->rec_type =AMDGPU_RAS_EEPROM_REC_PA ; + +/* default status is MCA storage */ +if (control->ras_num_recs <=1 && + adev->umc.ras && adev->umc.ras->convert_ras_err_addr) + control->rec_type =AMDGPU_RAS_EEPROM_REC_MCA ; + +if (control->ras_num_recs) { ret =amdgpu_ras_load_bad_pages (adev);if (ret)return ret;amdgpu_dpm_send_hbm_bad_pages_num ( - adev, con->eeprom_control.ras_num_recs); + adev, control->ras_num_recs);if (con->update_channel_flag == true) {amdgpu_dpm_send_hbm_bad_channel_flag ( - adev, con->eeprom_control.bad_channel_bitmap); + adev, control->bad_channel_bitmap); con->update_channel_flag = false; } }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +14 -0
@@ -43,6 +43,19 @@ enum amdgpu_ras_eeprom_err_type { AMDGPU_RAS_EEPROM_ERR_COUNT, }; +/* +* one UMC MCA address could map to multiply physical address (PA), +* such as 1:16, we use eeprom_table_record.address to store MCA +* address and use eeprom_table_record.retired_page to save PA. +* +* AMDGPU_RAS_EEPROM_REC_PA: one record store one PA +* AMDGPU_RAS_EEPROM_REC_MCA: one record store one MCA address +*/ +enum amdgpu_ras_eeprom_rec_type { +AMDGPU_RAS_EEPROM_REC_PA , +AMDGPU_RAS_EEPROM_REC_MCA , +}; +struct amdgpu_ras_eeprom_table_header {uint32_t header;uint32_t version;
@@ -102,6 +115,7 @@ struct amdgpu_ras_eeprom_control {/* Record channel info which occurred bad pages */ u32 bad_channel_bitmap; +enum amdgpu_ras_eeprom_rec_type rec_type; };/*
Signature · 1 line
2.34.1
PATCH 11/23 drm/amdgpu: do RAS MCA2PA conversion in initial phase
In reply to Tao ZhouNPS mode is introduced, the value of memory physical address (PA) related to a MCA address varies per nps mode. We need to rely on MCA address and convert it into PA accroding to nps mode.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 97 ++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +85 -12
@@ -2665,40 +2665,113 @@ static int amdgpu_ras_realloc_eh_data_space(struct amdgpu_device *adev,return 0 ; } +static int amdgpu_ras_mca2pa (struct amdgpu_device *adev, +struct eeprom_table_record *bps, +struct ras_err_data *err_data) +{ +struct ta_ras_query_address_input addr_in; +uint32_t socket =0 ; +int ret =0 ; + +if (adev->smuio.funcs && adev->smuio.funcs->get_socket_id) + socket = adev->smuio.funcs->get_socket_id (adev); + +/* reinit err_data */ + err_data->err_addr_cnt =0 ; + err_data->err_addr_len = adev->umc.retire_unit; + +memset (&addr_in,0 ,sizeof (addr_in)); + addr_in.ma.err_addr = bps->address; + addr_in.ma.socket_id = socket; + addr_in.ma.ch_inst = bps->mem_channel; +/* tell RAS TA the node instance is not used */ + addr_in.ma.node_inst =TA_RAS_INV_NODE ; + +if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) + ret = adev->umc.ras->convert_ras_err_addr (adev, err_data, + &addr_in,NULL , false); + +return ret; +} +/* it deal with vram only. */ int amdgpu_ras_add_bad_pages (struct amdgpu_device *adev,struct eeprom_table_record *bps,int pages) {struct amdgpu_ras *con =amdgpu_ras_get_context (adev);struct ras_err_handler_data *data; +struct ras_err_data err_data; +struct eeprom_table_record *err_rec; +struct amdgpu_ras_eeprom_control *control = + &adev->psp.ras_context.ras->eeprom_control;int ret =0 ; -uint32_t i; +uint32_t i, j, loop_cnt =1 ; +bool is_mca_add = true;if (!con || !con->eh_data || !bps || pages <=0 )return 0 ; +if (!adev->umc.ras || !adev->umc.ras->convert_ras_err_addr) { + is_mca_add = false; + }else { +if ((pages >1 ) && + (bps[0 ].address == bps[1 ].address) && + (bps[0 ].mem_channel == bps[1 ].mem_channel)) + is_mca_add = false; + } +mutex_lock (&con->recovery_lock); data = con->eh_data;if (!data) goto out; -for (i =0 ; i < pages; i++) { -if (amdgpu_ras_check_bad_page_unlock (con, - bps[i].retired_page <<AMDGPU_GPU_PAGE_SHIFT )) -continue ; - -if (!data->space_left && -amdgpu_ras_realloc_eh_data_space (adev, data,256 )) { +if (is_mca_add) { + err_data.err_addr = +kcalloc (adev->umc.retire_unit, +sizeof (struct eeprom_table_record ),GFP_KERNEL ); +if (!err_data.err_addr) { +dev_warn (adev->dev,"Failed to alloc UMC error address record in " +"mca2pa conversion!\n" ); ret = -ENOMEM ; goto out; } -amdgpu_ras_reserve_page (adev, bps[i].retired_page); + loop_cnt = adev->umc.retire_unit; + } + +for (i =0 ; i < pages; i++) { +if (is_mca_add) { +if (amdgpu_ras_mca2pa (adev, &bps[i], &err_data)) + goto free; + + err_rec = err_data.err_addr; + }else { + err_rec = &bps[i]; + } + +for (j =0 ; j < loop_cnt; j++) { +if (amdgpu_ras_check_bad_page_unlock (con, + err_rec[j].retired_page <<AMDGPU_GPU_PAGE_SHIFT )) +continue ; + +if (!data->space_left && +amdgpu_ras_realloc_eh_data_space (adev, data,256 )) { + ret = -ENOMEM ; + goto free; + } + +amdgpu_ras_reserve_page (adev, err_rec[j].retired_page); -memcpy (&data->bps[data->count], &bps[i],sizeof (*data->bps)); - data->count++; - data->space_left--; +memcpy (&data->bps[data->count], &(err_rec[j]), +sizeof (struct eeprom_table_record )); + data->count++; + data->space_left--; + } } + +free: +if (is_mca_add) +kfree (err_data.err_addr); out:mutex_unlock (&con->recovery_lock);
Signature · 1 line
2.34.1
PATCH 12/23 drm/amdgpu: store only one RAS bad page record for all pages in one row
In reply to Tao ZhouSo eeprom space can be saved, compatible with legacy way.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 35 +++++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +27 -8
@@ -2789,7 +2789,7 @@ int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev,struct amdgpu_ras *con =amdgpu_ras_get_context (adev);struct ras_err_handler_data *data;struct amdgpu_ras_eeprom_control *control; -int save_count; +int save_count, unit_num, bad_page_num, i;if (!con || !con->eh_data) {if (new_cnt)
@@ -2801,19 +2801,38 @@ int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev,mutex_lock (&con->recovery_lock); control = &con->eeprom_control; data = con->eh_data; - save_count = data->count - control->ras_num_recs; + bad_page_num = control->ras_num_recs; +/* one record on eeprom stands for all pages in one memory row +* in this mode +*/ +if (control->rec_type ==AMDGPU_RAS_EEPROM_REC_MCA ) + bad_page_num = control->ras_num_recs * adev->umc.retire_unit; + + save_count = data->count - bad_page_num;mutex_unlock (&con->recovery_lock); + unit_num = save_count / adev->umc.retire_unit;if (new_cnt) - *new_cnt = save_count / adev->umc.retire_unit; + *new_cnt = unit_num;/* only new entries are saved */ if (save_count >0 ) { -if (amdgpu_ras_eeprom_append (control, - &data->bps[control->ras_num_recs], - save_count)) { -dev_err (adev->dev,"Failed to save EEPROM table data!" ); -return -EIO ; +if (control->rec_type ==AMDGPU_RAS_EEPROM_REC_PA ) { +if (amdgpu_ras_eeprom_append (control, + &data->bps[control->ras_num_recs], + save_count)) { +dev_err (adev->dev,"Failed to save EEPROM table data!" ); +return -EIO ; + } + }else { +for (i =0 ; i < unit_num; i++) { +if (amdgpu_ras_eeprom_append (control, + &data->bps[bad_page_num + i * adev->umc.retire_unit], +1 )) { +dev_err (adev->dev,"Failed to save EEPROM table data!" ); +return -EIO ; + } + } }dev_info (adev->dev,"Saved %d pages to EEPROM table.\n" , save_count);
Signature · 1 line
2.34.1
PATCH 13/23 drm/amdgpu: retire RAS bad pages in different NPS modes
In reply to Tao ZhouThere are some changes in format of memory normalized address per NPS mode, need to adjust bit mapping according to NPS mode.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 64 +++++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 11 +++++ 2 files changed, 52 insertions(+), 23 deletions(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +41 -23
@@ -179,10 +179,13 @@ 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, row, bank, channel_index, umc_inst = 0; -uint64_t soc_pa, retired_page, column, err_addr; + uint32_t col, col_lower, row, row_lower, bank; +uint32_t channel_index, umc_inst =0 ; +uint32_t i, loop_bits[UMC_V12_0_RETIRE_LOOP_BITS ]; +uint64_t soc_pa, column, err_addr;struct ta_ras_query_address_output addr_out_tmp;struct ta_ras_query_address_output *paddr_out; +enum amdgpu_memory_partition nps =AMDGPU_NPS1_PARTITION_MODE ;int ret =0 ;if (!addr_out)
@@ -199,7 +202,7 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev,dev_warn (adev->dev,"Failed to query RAS physical address for 0x%llx" , err_addr); -return ret; + goto out; } bank = paddr_out->pa.bank;
@@ -208,42 +211,57 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev, umc_inst = addr_in->ma.umc_inst; } - soc_pa = paddr_out->pa.pa; + loop_bits[0 ] =UMC_V12_0_PA_C2_BIT ; + loop_bits[1 ] =UMC_V12_0_PA_C3_BIT ; + loop_bits[2 ] =UMC_V12_0_PA_C4_BIT ; + loop_bits[3 ] =UMC_V12_0_PA_R13_BIT ; -if (!err_data && !dump_addr) -return ret; +if (adev->gmc.gmc_funcs->query_mem_partition_mode) + nps = adev->gmc.gmc_funcs->query_mem_partition_mode (adev); + +/* other nps modes are taken as nps1 */ +if (nps ==AMDGPU_NPS4_PARTITION_MODE ) { + loop_bits[0 ] =UMC_V12_0_PA_CH4_BIT ; + loop_bits[1 ] =UMC_V12_0_PA_CH5_BIT ; + loop_bits[2 ] =UMC_V12_0_PA_B0_BIT ; + loop_bits[3 ] =UMC_V12_0_PA_R11_BIT ; + } - col = (err_addr >>1 ) &0x1fULL ; -/* 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 ); -/* clear [R13] in soc physical address */ - soc_pa &= ~(0x1ULL <<UMC_V12_0_PA_R13_BIT ); + soc_pa = paddr_out->pa.pa; +/* clear loop bits in soc physical address */ +for (i =0 ; i <UMC_V12_0_RETIRE_LOOP_BITS ; i++) + soc_pa &= ~BIT_ULL (loop_bits[i]); 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 */ + row_lower = (err_addr >>UMC_V12_0_MA_R0_BIT ) &0x1fffULL ; + +if (!err_data && !dump_addr) + goto out; -/* loop for all possibilities of [R13 C4 C3 C2] */ +/* loop for all possibilities of retired bits */ for (column =0 ; column <UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ; column++) { - retired_page = soc_pa | ((column &0x3 ) <<UMC_V12_0_PA_C2_BIT ); - retired_page |= (((column &0x4 ) >>2 ) <<UMC_V12_0_PA_C4_BIT ); - retired_page |= (((column &0x8 ) >>3 ) <<UMC_V12_0_PA_R13_BIT ); + soc_pa = paddr_out->pa.pa; +for (i =0 ; i <UMC_V12_0_RETIRE_LOOP_BITS ; i++) + soc_pa |= (((column >> i) &0x1ULL ) << loop_bits[i]); -/* include column bit 0 and 1 */ - col &=0x3 ; - col |= (column <<2 ); - row = (retired_page >>UMC_V12_0_PA_R0_BIT ) &0x3fffULL ; + col = ((column &0x7 ) <<2 ) | col_lower; +/* add row bit 13 */ + row = ((column >>3 ) <<13 ) | row_lower;if (dump_addr)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, col, bank, channel_index); + soc_pa, row, col, bank, channel_index);if (err_data)amdgpu_umc_fill_error_record (err_data, err_addr, - retired_page, channel_index, umc_inst); + soc_pa, channel_index, umc_inst); } +out:return ret; }
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +11 -0
@@ -55,13 +55,24 @@#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 +#define UMC_V12_0_PA_C3_BIT 16#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_R11_BIT 33#define UMC_V12_0_PA_R13_BIT 35 +/* channel bit in SOC physical address */ +#define UMC_V12_0_PA_CH4_BIT 12 +#define UMC_V12_0_PA_CH5_BIT 13 +/* bank bit in SOC physical address */ +#define UMC_V12_0_PA_B0_BIT 19 +/* row bits in MCA address */ +#define UMC_V12_0_MA_R0_BIT 10#define MCA_UMC_HWID_V12_0 0x96#define MCA_UMC_MCATYPE_V12_0 0x0
Signature · 1 line
2.34.1
PATCH 14/23 drm/amdgpu: add function to find all memory pages in one physical row
In reply to Tao ZhouAnd the function can be reused across amdgpu driver.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 37 +++++++++++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 ++ 2 files changed, 25 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +23 -14
@@ -446,11 +446,27 @@ int amdgpu_umc_logs_ecc_err(struct amdgpu_device *adev,return ret; } +int amdgpu_umc_pages_in_a_row (struct amdgpu_device *adev, +struct ras_err_data *err_data,uint64_t pa_addr) +{ +struct ta_ras_query_address_output addr_out; + +/* reinit err_data */ + err_data->err_addr_cnt =0 ; + err_data->err_addr_len = adev->umc.retire_unit; + + addr_out.pa.pa = pa_addr; +if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) +return adev->umc.ras->convert_ras_err_addr (adev, err_data,NULL , + &addr_out, false); +else +return -EINVAL ; +} +int amdgpu_umc_lookup_bad_pages_in_a_row (struct amdgpu_device *adev,uint64_t pa_addr,uint64_t *pfns,int len) { -uint32_t i, ret =0 , pos =0 ; -struct ta_ras_query_address_output addr_out; +int i, ret;struct ras_err_data err_data; err_data.err_addr =
@@ -462,24 +478,17 @@ int amdgpu_umc_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,return 0 ; } - addr_out.pa.pa = pa_addr; - -if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) { - ret = adev->umc.ras->convert_ras_err_addr (adev, &err_data,NULL , - &addr_out, false); -if (ret) - goto out; - }else { + ret =amdgpu_umc_pages_in_a_row (adev, &err_data, pa_addr); +if (ret) goto out; - }for (i =0 ; i < adev->umc.retire_unit; i++) { -if (pos >= len) +if (i >= len) goto out; - pfns[pos++] = err_data.err_addr[pos].retired_page; + pfns[i] = err_data.err_addr[i].retired_page; } - ret = pos; + ret = i; out:kfree (err_data.err_addr);
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2 -0
@@ -139,6 +139,8 @@ int amdgpu_umc_logs_ecc_err(struct amdgpu_device *adev,void amdgpu_umc_handle_bad_pages (struct amdgpu_device *adev,void *ras_error_status); +int amdgpu_umc_pages_in_a_row (struct amdgpu_device *adev, +struct ras_err_data *err_data,uint64_t pa_addr);int amdgpu_umc_lookup_bad_pages_in_a_row (struct amdgpu_device *adev,uint64_t pa_addr,uint64_t *pfns,int len); int amdgpu_umc_mca_to_addr(struct amdgpu_device *adev,
Signature · 1 line
2.34.1
PATCH 15/23 drm/amdgpu: support to find RAS bad pages via old TA
In reply to Tao ZhouOld version of RAS TA doesn't support to convert MCA address to physical address (PA), support to find all bad pages in one memory row by PA with old RAS TA. This approach is only suitable for nps1 mode.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 26 ++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +23 -3
@@ -2704,9 +2704,10 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev,struct eeprom_table_record *err_rec;struct amdgpu_ras_eeprom_control *control = &adev->psp.ras_context.ras->eeprom_control; +enum amdgpu_memory_partition nps =AMDGPU_NPS1_PARTITION_MODE ;int ret =0 ;uint32_t i, j, loop_cnt =1 ; -bool is_mca_add = true; +bool is_mca_add = true, find_pages_per_pa = false;if (!con || !con->eh_data || !bps || pages <=0 )return 0 ;
@@ -2737,12 +2738,31 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev, } loop_cnt = adev->umc.retire_unit; +if (adev->gmc.gmc_funcs->query_mem_partition_mode) + nps = adev->gmc.gmc_funcs->query_mem_partition_mode (adev); }for (i =0 ; i < pages; i++) {if (is_mca_add) { -if (amdgpu_ras_mca2pa (adev, &bps[i], &err_data)) - goto free; +if (!find_pages_per_pa) { +if (amdgpu_ras_mca2pa (adev, &bps[i], &err_data)) { +if (!i && nps ==AMDGPU_NPS1_PARTITION_MODE ) { +/* may use old RAS TA, use PA to find pages in one row */ +if (amdgpu_umc_pages_in_a_row (adev, &err_data, + bps[i].retired_page <<AMDGPU_GPU_PAGE_SHIFT )) + goto free; +else + find_pages_per_pa = true; + }else { +/* unsupported cases */ + goto free; + } + } + }else { +if (amdgpu_umc_pages_in_a_row (adev, &err_data, + bps[i].retired_page <<AMDGPU_GPU_PAGE_SHIFT )) + goto free; + } err_rec = err_data.err_addr; }else {
Signature · 1 line
2.34.1
PATCH 16/23 drm/amdgpu: save UMC global channel index to eeprom
In reply to Tao ZhouSave the global channel index returned by RAS TA to eeprom. We can get memory physical address by MCA address and channel index.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 7 ++----- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 +- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 13 ++++++++----- 4 files changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
@@ -481,6 +481,8 @@ struct ras_ecc_err {uint64_t ipid;uint64_t addr;uint64_t pa_pfn; +/* save global channel index across all UMC instances */ +uint32_t channel_idx;struct ras_err_pages err_pages; };
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -5
@@ -498,10 +498,9 @@ int amdgpu_umc_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,int amdgpu_umc_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_output *addr_out,bool dump_addr) {struct ta_ras_query_address_input addr_in; -struct ta_ras_query_address_output addr_out;int ret;memset (&addr_in,0 ,sizeof (addr_in));
@@ -513,14 +512,12 @@ int amdgpu_umc_mca_to_addr(struct amdgpu_device *adev,if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) { ret = adev->umc.ras->convert_ras_err_addr (adev,NULL , &addr_in, - &addr_out, dump_addr); + addr_out, dump_addr);if (ret)return ret; }else {return 0 ; } - *addr = addr_out.pa.pa; -return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +1 -1
@@ -146,5 +146,5 @@ int amdgpu_umc_lookup_bad_pages_in_a_row(struct amdgpu_device *adev,int amdgpu_umc_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_output *addr_out,bool dump_addr);#endif
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +8 -5
@@ -180,7 +180,7 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev, bool dump_addr) {uint32_t col, col_lower, row, row_lower, bank; -uint32_t channel_index, umc_inst =0 ; +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;struct ta_ras_query_address_output addr_out_tmp;
@@ -193,7 +193,7 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev,else paddr_out = addr_out; - err_addr = bank = channel_index =0 ; + err_addr = bank =0 ;if (addr_in) { err_addr = addr_in->ma.err_addr; addr_in->addr_type =TA_RAS_MCA_TO_PA ;
@@ -206,7 +206,6 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev, } bank = paddr_out->pa.bank; - channel_index = paddr_out->pa.channel_idx;/* no need to care about umc inst if addr_in is NULL */ umc_inst = addr_in->ma.umc_inst; }
@@ -228,6 +227,7 @@ static int umc_v12_0_convert_error_address(struct amdgpu_device *adev, } soc_pa = paddr_out->pa.pa; + channel_index = paddr_out->pa.channel_idx;/* clear loop bits in soc physical address */ for (i =0 ; i <UMC_V12_0_RETIRE_LOOP_BITS ; i++) soc_pa &= ~BIT_ULL (loop_bits[i]);
@@ -466,6 +466,7 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,uint64_t page_pfn[UMC_V12_0_BAD_PAGE_NUM_PER_CHANNEL ];uint64_t err_addr, pa_addr =0 ;struct ras_ecc_err *ecc_err; +struct ta_ras_query_address_output addr_out;int count, ret, i; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID);
@@ -495,7 +496,7 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, ret =amdgpu_umc_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); +MCA_IPID_2_SOCKET_ID (ipid), &addr_out, true);if (ret)return ret;
@@ -503,10 +504,12 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,if (!ecc_err)return -ENOMEM ; + pa_addr = addr_out.pa.pa; ecc_err->status = status; ecc_err->ipid = ipid; ecc_err->addr = addr; ecc_err->pa_pfn = pa_addr >>AMDGPU_GPU_PAGE_SHIFT ; + ecc_err->channel_idx = addr_out.pa.channel_idx;/* If converted pa_pfn is 0, use pa C4 pfn. */ if (!ecc_err->pa_pfn)
@@ -577,7 +580,7 @@ static int umc_v12_0_fill_error_record(struct amdgpu_device *adev, ret =amdgpu_umc_fill_error_record (err_data, ecc_err->addr, page_pfn[i] <<AMDGPU_GPU_PAGE_SHIFT , -MCA_IPID_2_UMC_CH (ecc_err->ipid), + ecc_err->channel_idx,MCA_IPID_2_UMC_INST (ecc_err->ipid));if (ret)break ;
Signature · 1 line
2.34.1
PATCH 17/23 drm/amdgpu: add a flag to indicate UMC channel index version
In reply to Tao Zhouv1 (legacy way): store channel index within a UMC instance in eeprom
v2: store global channel index in eeprom
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 16 ++++++++++++++++ 2 files changed, 25 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +9 -0
@@ -2838,6 +2838,11 @@ int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev,/* only new entries are saved */ if (save_count >0 ) {if (control->rec_type ==AMDGPU_RAS_EEPROM_REC_PA ) { +/* set the new channel index flag */ +for (i =0 ; i < save_count; i++) + data->bps[control->ras_num_recs + i].retired_page |= +UMC_CHANNEL_IDX_V2 ; +if (amdgpu_ras_eeprom_append (control, &data->bps[control->ras_num_recs], save_count)) {
@@ -2846,6 +2851,10 @@ int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev, } }else {for (i =0 ; i < unit_num; i++) { +/* set the new channel index flag */ + data->bps[bad_page_num + i * adev->umc.retire_unit].retired_page |= +UMC_CHANNEL_IDX_V2 ; +if (amdgpu_ras_eeprom_append (control, &data->bps[bad_page_num + i * adev->umc.retire_unit],1 )) {
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +16 -0
@@ -54,6 +54,22 @@/* Page retirement tag */ #define UMC_ECC_NEW_DETECTED_TAG 0x1 +/* +* a flag to indicate v2 of channel index stored in eeprom +* +* v1 (legacy way): store channel index within a umc instance in eeprom +* range in UMC v12: 0 ~ 7 +* v2: store global channel index in eeprom +* range in UMC v12: 0 ~ 127 +* +* NOTE: it's better to store it in eeprom_table_record.mem_channel, +* but there is only 8 bits in mem_channel, and the channel number may +* increase in the future, we decide to save it in +* eeprom_table_record.retired_page. retired_page is useless in v2, +* we depend on eeprom_table_record.address instead of retired_page in v2. +* Only 48 bits are saved on eeprom, use bit 47 here. +*/ +#define UMC_CHANNEL_IDX_V2 BIT_ULL(47)typedef int (*umc_func )(struct amdgpu_device *adev,uint32_t node_inst,uint32_t umc_inst,uint32_t ch_inst,void *data);
Signature · 1 line
2.34.1
PATCH 18/23 drm/amdgpu: add interface to get die id from memory address
In reply to Tao ZhouAnd implement it for UMC v12_0. The die id calculated from IPID register in bad page retirement, but we don't store it on eeprom and it can be also gotten from physical address.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 2 ++ drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/umc_v12_0.h | 7 +++++++ 3 files changed, 31 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h +2 -0
@@ -91,6 +91,8 @@ struct amdgpu_umc_ras {struct ta_ras_query_address_input *addr_in, struct ta_ras_query_address_output *addr_out, bool dump_addr); +uint32_t (*get_die_id_from_pa)(struct amdgpu_device *adev, +uint64_t retired_page); };struct amdgpu_umc_funcs {
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +22 -0
@@ -619,6 +619,27 @@ static void umc_v12_0_query_ras_ecc_err_addr(struct amdgpu_device *adev,mutex_unlock (&con->umc_ecc_log.lock); } +static uint32_t umc_v12_0_get_die_id (struct amdgpu_device *adev, +uint64_t retired_page) +{ +uint32_t die =0 ; + +/* we only calculate die id for nps1 mode right now */ + die += ((((retired_page >>12 ) &0x1ULL )^ + (((retired_page >>20 ) &0x1ULL ) & HashIntlvCtl64K) ^ + (((retired_page >>27 ) &0x1ULL ) & HashIntlvCtl2M) ^ + (((retired_page >>34 ) &0x1ULL ) & HashIntlvCtl1G) ^ + (((retired_page >>41 ) &0x1ULL ) & HashIntlvCtl1T)) <<0 ); + die += ((((retired_page >>13 ) &0x1ULL ) ^ + (((retired_page >>21 ) &0x1ULL ) & HashIntlvCtl64K) ^ + (((retired_page >>28 ) &0x1ULL ) & HashIntlvCtl2M) ^ + (((retired_page >>35 ) &0x1ULL ) & HashIntlvCtl1G) ^ + (((retired_page >>42 ) &0x1ULL ) & HashIntlvCtl1T)) <<1 ); + die &=3 ; + +return die; +} +struct amdgpu_umc_ras umc_v12_0_ras = { .ras_block = { .hw_ops = &umc_v12_0_ras_hw_ops,
@@ -630,5 +651,6 @@ struct amdgpu_umc_ras umc_v12_0_ras = { .check_ecc_err_status = umc_v12_0_check_ecc_err_status, .update_ecc_status = umc_v12_0_update_ecc_status, .convert_ras_err_addr = umc_v12_0_convert_error_address, + .get_die_id_from_pa = umc_v12_0_get_die_id, };
drivers/gpu/drm/amd/amdgpu/umc_v12_0.h +7 -0
@@ -77,6 +77,13 @@#define MCA_UMC_HWID_V12_0 0x96#define MCA_UMC_MCATYPE_V12_0 0x0 +/* interleave setting */ +#define HashIntlvCtl4K 0 +#define HashIntlvCtl64K 1 +#define HashIntlvCtl2M 1 +#define HashIntlvCtl1G 1 +#define HashIntlvCtl1T 1 +#define MCA_IPID_LO_2_UMC_CH (_ipid_lo) (((((_ipid_lo) >> 20) & 0x1) * 4) + \ (((_ipid_lo) >> 12) & 0xF))#define MCA_IPID_LO_2_UMC_INST (_ipid_lo) (((_ipid_lo) >> 21) & 0x7)
Signature · 1 line
2.34.1
PATCH 19/23 drm/amdgpu: add ras_mca2pa to convert UMC address in legacy way
In reply to Tao ZhouConvert UMC address via node instance, UMC instance and channel instance. IPID is not sotred on eeprom, so we have to get related values in new way, can work in any nps mode.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 41 +++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +39 -2
@@ -2665,7 +2665,7 @@ static int amdgpu_ras_realloc_eh_data_space(struct amdgpu_device *adev,return 0 ; } -static int amdgpu_ras_mca2pa (struct amdgpu_device *adev, +static int amdgpu_ras_mca2pa_by_idx (struct amdgpu_device *adev,struct eeprom_table_record *bps,struct ras_err_data *err_data) {
@@ -2694,6 +2694,43 @@ static int amdgpu_ras_mca2pa(struct amdgpu_device *adev,return ret; } +static int amdgpu_ras_mca2pa (struct amdgpu_device *adev, +struct eeprom_table_record *bps, +struct ras_err_data *err_data) +{ +struct ta_ras_query_address_input addr_in; +uint32_t die_id, socket =0 ; + +if (adev->smuio.funcs && adev->smuio.funcs->get_socket_id) + socket = adev->smuio.funcs->get_socket_id (adev); + +/* although die id is gotten from PA in nps1 mode, the id is +* fitable for any nps mode +*/ +if (adev->umc.ras && adev->umc.ras->get_die_id_from_pa) + die_id = adev->umc.ras->get_die_id_from_pa (adev, + bps->retired_page <<AMDGPU_GPU_PAGE_SHIFT ); +else +return -EINVAL ; + +/* reinit err_data */ + err_data->err_addr_cnt =0 ; + err_data->err_addr_len = adev->umc.retire_unit; + +memset (&addr_in,0 ,sizeof (addr_in)); + addr_in.ma.err_addr = bps->address; + addr_in.ma.ch_inst = bps->mem_channel; + addr_in.ma.umc_inst = bps->mcumc_id; + addr_in.ma.node_inst = die_id; + addr_in.ma.socket_id = socket; + +if (adev->umc.ras && adev->umc.ras->convert_ras_err_addr) +return adev->umc.ras->convert_ras_err_addr (adev, err_data, + &addr_in,NULL , false); +else +return -EINVAL ; +} +/* it deal with vram only. */ int amdgpu_ras_add_bad_pages (struct amdgpu_device *adev,struct eeprom_table_record *bps,int pages)
@@ -2745,7 +2782,7 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev,for (i =0 ; i < pages; i++) {if (is_mca_add) {if (!find_pages_per_pa) { -if (amdgpu_ras_mca2pa (adev, &bps[i], &err_data)) { +if (amdgpu_ras_mca2pa_by_idx (adev, &bps[i], &err_data)) {if (!i && nps ==AMDGPU_NPS1_PARTITION_MODE ) {/* may use old RAS TA, use PA to find pages in one row */ if (amdgpu_umc_pages_in_a_row(adev, &err_data,
Signature · 1 line
2.34.1
PATCH 20/23 drm/amdgpu: add from_rom parameter for ras_add_bad_pages
In reply to Tao ZhouTell the function if the error records come from eeprom.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -3
@@ -192,7 +192,7 @@ static int amdgpu_reserve_page_direct(struct amdgpu_device *adev, uint64_t addreif (amdgpu_bad_page_threshold !=0 ) {amdgpu_ras_add_bad_pages (adev, err_data.err_addr, - err_data.err_addr_cnt); + err_data.err_addr_cnt, false);amdgpu_ras_save_bad_pages (adev,NULL ); }
@@ -2733,7 +2733,7 @@ static int amdgpu_ras_mca2pa(struct amdgpu_device *adev,/* it deal with vram only. */ int amdgpu_ras_add_bad_pages (struct amdgpu_device *adev, -struct eeprom_table_record *bps,int pages) +struct eeprom_table_record *bps,int pages,bool from_rom) {struct amdgpu_ras *con =amdgpu_ras_get_context (adev);struct ras_err_handler_data *data;
@@ -2939,7 +2939,7 @@ static int amdgpu_ras_load_bad_pages(struct amdgpu_device *adev) control->rec_type =AMDGPU_RAS_EEPROM_REC_MCA ; } - ret =amdgpu_ras_add_bad_pages (adev, bps, control->ras_num_recs); + ret =amdgpu_ras_add_bad_pages (adev, bps, control->ras_num_recs, true); }kfree (bps);
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -1
@@ -751,7 +751,7 @@ int amdgpu_ras_query_error_count(struct amdgpu_device *adev,/* error handling functions */ int amdgpu_ras_add_bad_pages (struct amdgpu_device *adev, -struct eeprom_table_record *bps,int pages); +struct eeprom_table_record *bps,int pages,bool from_rom);int amdgpu_ras_save_bad_pages (struct amdgpu_device *adev,unsigned long *new_cnt);
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +2 -2
@@ -78,7 +78,7 @@ int amdgpu_umc_page_retirement_mca(struct amdgpu_device *adev,if (amdgpu_bad_page_threshold !=0 ) {amdgpu_ras_add_bad_pages (adev, err_data.err_addr, - err_data.err_addr_cnt); + err_data.err_addr_cnt, false);amdgpu_ras_save_bad_pages (adev,NULL ); }
@@ -166,7 +166,7 @@ void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev,if ((amdgpu_bad_page_threshold !=0 ) && err_data->err_addr_cnt) {amdgpu_ras_add_bad_pages (adev, err_data->err_addr, - err_data->err_addr_cnt); + err_data->err_addr_cnt, false);amdgpu_ras_save_bad_pages (adev, &err_count);amdgpu_dpm_send_hbm_bad_pages_num (adev, con->eeprom_control.ras_num_recs);
Signature · 1 line
2.34.1
PATCH 21/23 drm/amdgpu: parse legacy RAS bad page mixed with new data in various NPS modes
In reply to Tao ZhouAll legacy RAS bad pages are generated in NPS1 mode, but new bad page can be generated in any NPS mode, so we can't use retired_page sotred on eeprom directly in non-nps1 mode even for legacy data. We need to take different actions for different data, new data can be identified from old data by UMC_CHANNEL_IDX_V2 flag.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 45 +++++++++++++++++++------ 1 file changed, 35 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +35 -10
@@ -2758,12 +2758,7 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev, is_mca_add = false; } -mutex_lock (&con->recovery_lock); - data = con->eh_data; -if (!data) - goto out; - -if (is_mca_add) { +if (from_rom) { err_data.err_addr =kcalloc (adev->umc.retire_unit,sizeof (struct eeprom_table_record ),GFP_KERNEL );
@@ -2774,11 +2769,17 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev, goto out; } + err_rec = err_data.err_addr; loop_cnt = adev->umc.retire_unit;if (adev->gmc.gmc_funcs->query_mem_partition_mode) nps = adev->gmc.gmc_funcs->query_mem_partition_mode (adev); } +mutex_lock (&con->recovery_lock); + data = con->eh_data; +if (!data) + goto free; +for (i =0 ; i < pages; i++) {if (is_mca_add) {if (!find_pages_per_pa) {
@@ -2800,10 +2801,34 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev, bps[i].retired_page << AMDGPU_GPU_PAGE_SHIFT)) goto free; } - - err_rec = err_data.err_addr; }else { - err_rec = &bps[i]; +if (from_rom && !find_pages_per_pa) { +if (bps[i].retired_page &UMC_CHANNEL_IDX_V2 ) { +/* bad page in any NPS mode in eeprom */ +if (amdgpu_ras_mca2pa_by_idx (adev, &bps[i], &err_data)) + goto free; + }else { +/* legacy bad page in eeprom, generated only in NPS1 mode */ +if (amdgpu_ras_mca2pa (adev, &bps[i], &err_data)) { +/* old RAS TA or ASICs which don't support to convert addrss +* via mca address +*/ +if (!i && nps ==AMDGPU_NPS1_PARTITION_MODE ) { + find_pages_per_pa = true; + err_rec = &bps[i]; + loop_cnt =1 ; + }else { +/* non-nps1 mode, old RAS TA can't support it */ + goto free; + } + } + } + +if (!find_pages_per_pa) + i += (adev->umc.retire_unit -1 ); + }else { + err_rec = &bps[i]; + } }for (j =0 ; j < loop_cnt; j++) {
@@ -2827,7 +2852,7 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev, } free: -if (is_mca_add) +if (from_rom)kfree (err_data.err_addr); out:mutex_unlock (&con->recovery_lock);
Signature · 1 line
2.34.1
PATCH 22/23 drm/amdgpu: remove is_mca_add for ras_add_bad_pages
In reply to Tao ZhouRemove unnecessary variable and simplify the logic.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -11
@@ -2744,20 +2744,11 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev,enum amdgpu_memory_partition nps =AMDGPU_NPS1_PARTITION_MODE ;int ret =0 ;uint32_t i, j, loop_cnt =1 ; -bool is_mca_add = true, find_pages_per_pa = false; +bool find_pages_per_pa = false;if (!con || !con->eh_data || !bps || pages <=0 )return 0 ; -if (!adev->umc.ras || !adev->umc.ras->convert_ras_err_addr) { - is_mca_add = false; - }else { -if ((pages >1 ) && - (bps[0 ].address == bps[1 ].address) && - (bps[0 ].mem_channel == bps[1 ].mem_channel)) - is_mca_add = false; - } -if (from_rom) { err_data.err_addr = kcalloc(adev->umc.retire_unit,
@@ -2781,7 +2772,8 @@ int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev, goto free;for (i =0 ; i < pages; i++) { -if (is_mca_add) { +if (from_rom && + control->rec_type ==AMDGPU_RAS_EEPROM_REC_MCA ) {if (!find_pages_per_pa) {if (amdgpu_ras_mca2pa_by_idx (adev, &bps[i], &err_data)) {if (!i && nps ==AMDGPU_NPS1_PARTITION_MODE ) {
Signature · 1 line
2.34.1
PATCH 23/23 drm/amdgpu: set UMC PA per NPS mode when PA is 0
In reply to Tao ZhouThe shift bit of PA varys according to NPS mode due to different address format.
--- drivers/gpu/drm/amd/amdgpu/umc_v12_0.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c +8 -1
@@ -467,6 +467,8 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,uint64_t err_addr, pa_addr =0 ;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 ;int count, ret, i; hwid =REG_GET_FIELD (ipid,MCMP1_IPIDT0 , HardwareID);
@@ -511,9 +513,14 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev, ecc_err->pa_pfn = pa_addr >>AMDGPU_GPU_PAGE_SHIFT ; ecc_err->channel_idx = addr_out.pa.channel_idx; +if (adev->gmc.gmc_funcs->query_mem_partition_mode) + nps = adev->gmc.gmc_funcs->query_mem_partition_mode (adev); +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 (UMC_V12_0_PA_C4_BIT ) >>AMDGPU_GPU_PAGE_SHIFT ; + ecc_err->pa_pfn =BIT_ULL (shift_bit) >>AMDGPU_GPU_PAGE_SHIFT ; ret =amdgpu_umc_logs_ecc_err (adev, &con->umc_ecc_log.de_page_tree, ecc_err);if (ret) {
Signature · 1 line
2.34.1
Quoted 3 lines · Tao Zhou
There are two types of gpu reset, nps mode switch and normal gpu reset, add a flag to distigush them.
Reset for NPS switch is a subcase of Reset on Initialization scenario (reset the device before use). If RAS routines need to be taken care for that in general, this needs to be more generic.
Thanks,
Lijo
Quoted 128 lines
Signed-off-by Tao Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 13 ++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1681,6 +1681,7 @@ static inline bool amdgpu_is_tmz(struct amdgpu_device *adev) }int amdgpu_in_reset (struct amdgpu_device *adev); +int amdgpu_in_nps_switch (struct amdgpu_device *adev);extern const struct attribute_group amdgpu_vram_mgr_attr_group;extern const struct attribute_group amdgpu_gtt_mgr_attr_group;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-2@@ -5862,7 +5862,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,/* We need to lock reset domain only once both for XGMI and single device */ tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, reset_list); -amdgpu_device_lock_reset_domain (tmp_adev->reset_domain); +amdgpu_device_lock_reset_domain (tmp_adev);/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) {@@ -6343,7 +6343,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ -amdgpu_device_lock_reset_domain (adev->reset_domain); +amdgpu_device_lock_reset_domain (adev);amdgpu_device_set_mp1_state (adev);/* @@ -6579,6 +6579,11 @@ int amdgpu_in_reset(struct amdgpu_device *adev)return atomic_read (&adev->reset_domain->in_gpu_reset); } +int amdgpu_in_nps_switch (struct amdgpu_device *adev) +{ +return atomic_read (&adev->reset_domain->in_nps_switch); +} +/** * amdgpu_device_halt() - bring hardware to some kind of halt state * drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +12
-1@@ -301,15 +301,25 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_dINIT_WORK (&reset_domain->clear, amdgpu_reset_domain_cancel_all_work);atomic_set (&reset_domain->in_gpu_reset,0 ); +atomic_set (&reset_domain->in_nps_switch,0 );atomic_set (&reset_domain->reset_res,0 );init_rwsem (&reset_domain->sem);return reset_domain; } -void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain) +void amdgpu_device_lock_reset_domain (struct amdgpu_device *adev) { +struct amdgpu_reset_domain *reset_domain = adev->reset_domain; +atomic_set (&reset_domain->in_gpu_reset,1 ); +/* The life time of in_nps_switch is longer than +* amdgpu_device_nps_switch_needed +*/ +if (adev->nbio.funcs && adev->nbio.funcs->is_nps_switch_requested && + adev->nbio.funcs->is_nps_switch_requested (adev)) +atomic_set (&reset_domain->in_nps_switch,1 ); +down_write (&reset_domain->sem); }@@ -317,6 +327,7 @@ void amdgpu_device_lock_reset_domain(struct amdgpu_reset_domain *reset_domain)void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain) {atomic_set (&reset_domain->in_gpu_reset,0 ); +atomic_set (&reset_domain->in_nps_switch,0 );up_write (&reset_domain->sem); }drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +2
-1@@ -97,6 +97,7 @@ struct amdgpu_reset_domain {enum amdgpu_reset_domain_type type;struct rw_semaphore sem;atomic_t in_gpu_reset; +atomic_t in_nps_switch;atomic_t reset_res;struct work_struct clear;bool drain;@@ -158,7 +159,7 @@ static inline bool amdgpu_reset_pending(struct amdgpu_reset_domain *domain)return rwsem_is_contended (&domain->sem); } -void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain); +void amdgpu_device_lock_reset_domain (struct amdgpu_device *adev);void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain);drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +1
-1@@ -1540,7 +1540,7 @@ static void amdgpu_xgmi_reset_on_init_work(struct work_struct *work) tmp_adev = list_first_entry(&device_list, struct amdgpu_device, reset_list); -amdgpu_device_lock_reset_domain (tmp_adev->reset_domain); +amdgpu_device_lock_reset_domain (tmp_adev); reset_context.method =AMD_RESET_METHOD_ON_INIT ; reset_context.reset_req_dev = tmp_adev;