Skip to contentSkip to conversation

drm/amdgpu: add RAS is_rma flag

PATCH In review Tao Zhou 2 participants 10 messages May 31, 2024 – Jun 5, 2024

Subsystems (3)
lore
Share & tools
lore

Tao Zhou

author
#0 lore raw

PATCH 1/5 drm/amdgpu: add RAS is_rma flag

Set the flag to true if bad page number reaches threshold.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c        |  7 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h |  3 +--
 4 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -4
index 2dc47475b8e9..616dc2387f34 100644
@@ -2940,7 +2940,6 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
 	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 	struct ras_err_handler_data **data;
 	u32  max_eeprom_records_count = 0;
-	bool exc_err_limit = false;
 	int ret;
 
 	if (!con || amdgpu_sriov_vf(adev))
@@ -2977,12 +2976,12 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
 	 */
 	if (adev->gmc.xgmi.pending_reset)
 		return 0;
-	ret = amdgpu_ras_eeprom_init(&con->eeprom_control, &exc_err_limit);
+	ret = amdgpu_ras_eeprom_init(&con->eeprom_control);
 	/*
 	 * This calling fails when exc_err_limit is true or
 	 * ret != 0.
 	 */
-	if (exc_err_limit || ret)
+	if (con->is_rma || ret)
 		goto free;
 
 	if (con->eeprom_control.ras_num_recs) {
@@ -3033,7 +3032,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
 	 * Except error threshold exceeding case, other failure cases in this
 	 * function would not fail amdgpu driver init.
 	 */
-	if (!exc_err_limit)
+	if (!con->is_rma)
 		ret = 0;
 	else
 		ret = -EINVAL;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -0
index d06c01b978cd..437c58c85639 100644
@@ -521,6 +521,7 @@ struct amdgpu_ras {
 	bool update_channel_flag;
 	/* Record status of smu mca debug mode */
 	bool is_aca_debug_mode;
+	bool is_rma;
 
 	/* Record special requirements of gpu reset caller */
 	uint32_t  gpu_reset_flags;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +6 -4
index 9b789dcc2bd1..eae0a555df3c 100644
@@ -750,6 +750,9 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control)
 			control->tbl_rai.health_percent = 0;
 		}
 
+		if (amdgpu_bad_page_threshold != -1)
+			ras->is_rma = true;
+
 		/* ignore the -ENOTSUPP return value */
 		amdgpu_dpm_send_rma_reason(adev);
 	}
@@ -1321,8 +1324,7 @@ static int __read_table_ras_info(struct amdgpu_ras_eeprom_control *control)
 	return res == RAS_TABLE_V2_1_INFO_SIZE ? 0 : res;
 }
 
-int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,
-			   bool *exceed_err_limit)
+int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)
 {
 	struct amdgpu_device *adev = to_amdgpu_device(control);
 	unsigned char buf[RAS_TABLE_HEADER_SIZE] = { 0 };
@@ -1330,7 +1332,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,
 	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 	int res;
 
-	*exceed_err_limit = false;
+	ras->is_rma = false;
 
 	if (!__is_ras_eeprom_supported(adev))
 		return 0;
@@ -1422,7 +1424,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,
 				dev_warn(adev->dev, "GPU will be initialized due to bad_page_threshold = -1.");
 				res = 0;
 			} else {
-				*exceed_err_limit = true;
+				ras->is_rma = true;
 				dev_err(adev->dev,
 					"RAS records:%d exceed threshold:%d, "
 					"GPU will not be initialized. Replace this GPU or increase the threshold",
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +1 -2
index 6dfd667f3013..b9ebda577797 100644
@@ -129,8 +129,7 @@ struct eeprom_table_record {
 	unsigned char mcumc_id;
 } __packed;
 
-int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,
-			   bool *exceed_err_limit);
+int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control);
 
 int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control);
 
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/5 drm/amdgpu: trigger mode1 reset for RAS RMA status

Check RMA status in bad page retirement flow.

v2: fix coding bugs in v1.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c  | 28 +++++++++++++++++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c  |  8 +++----
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c |  4 +++-
 3 files changed, 29 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +22 -6
index 616dc2387f34..10cbcc0d1a1a 100644
@@ -2049,8 +2049,9 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager *
 	struct amdgpu_device *adev = obj->adev;
 	struct amdgpu_ras_block_object *block_obj =
 		amdgpu_ras_get_ras_block(adev, obj->head.block, 0);
+	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 
-	if (!block_obj)
+	if (!block_obj || !con)
 		return;
 
 	/* both query_poison_status and handle_poison_consumption are optional,
@@ -2073,14 +2074,17 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager *
 	if (block_obj->hw_ops && block_obj->hw_ops->handle_poison_consumption)
 		poison_stat = block_obj->hw_ops->handle_poison_consumption(adev);
 
-	/* gpu reset is fallback for failed and default cases */
-	if (poison_stat) {
+	/* gpu reset is fallback for failed and default cases.
+	 * For RMA case, amdgpu_umc_poison_handler will handle gpu reset.
+	 */
+	if (poison_stat && !con->is_rma) {
 		dev_info(adev->dev, "GPU reset for %s RAS poison consumption is issued!\n",
 				block_obj->ras_comm.name);
 		amdgpu_ras_reset_gpu(adev);
-	} else {
-		amdgpu_gfx_poison_consumption_handler(adev, entry);
 	}
+
+	if (!poison_stat)
+		amdgpu_gfx_poison_consumption_handler(adev, entry);
 }
 
 static void amdgpu_ras_interrupt_poison_creation_handler(struct ras_manager *obj,
@@ -2801,6 +2805,7 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)
 					      page_retirement_dwork.work);
 	struct amdgpu_device *adev = con->adev;
 	struct ras_err_data err_data;
+	unsigned long err_cnt;
 
 	if (amdgpu_in_reset(adev) || atomic_read(&con->in_recovery))
 		return;
@@ -2808,9 +2813,13 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)
 	amdgpu_ras_error_data_init(&err_data);
 
 	amdgpu_umc_handle_bad_pages(adev, &err_data);
+	err_cnt = err_data.err_addr_cnt;
 
 	amdgpu_ras_error_data_fini(&err_data);
 
+	if (err_cnt && con->is_rma)
+		amdgpu_ras_reset_gpu(adev);
+
 	mutex_lock(&con->umc_ecc_log.lock);
 	if (radix_tree_tagged(&con->umc_ecc_log.de_page_tree,
 				UMC_ECC_NEW_DETECTED_TAG))
@@ -2867,7 +2876,8 @@ static int amdgpu_ras_poison_consumption_handler(struct amdgpu_device *adev,
 	if (poison_msg->pasid_fn)
 		poison_msg->pasid_fn(adev, pasid, poison_msg->data);
 
-	if (reset) {
+	/* for RMA, amdgpu_ras_poison_creation_handler will trigger gpu reset */
+	if (reset && !con->is_rma) {
 		flush_delayed_work(&con->page_retirement_dwork);
 
 		con->gpu_reset_flags |= reset;
@@ -3983,6 +3993,12 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)
 {
 	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
+	/* mode1 is the only selection for RMA status */
+	if (ras->is_rma) {
+		ras->gpu_reset_flags = 0;
+		ras->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE1_RESET;
+	}
+
 	if (atomic_cmpxchg(&ras->in_recovery, 0, 1) == 0)
 		amdgpu_reset_domain_schedule(ras->adev->reset_domain, &ras->recovery_work);
 	return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +4 -4
index 1dbe69eabb9a..4a72ff8d8d80 100644
@@ -195,7 +195,8 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,
 	kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
 	amdgpu_umc_handle_bad_pages(adev, ras_error_status);
 
-	if (err_data->ue_count && reset) {
+	if ((err_data->ue_count || err_data->de_count) &&
+	    (reset || (con && con->is_rma))) {
 		con->gpu_reset_flags |= reset;
 		amdgpu_ras_reset_gpu(adev);
 	}
@@ -211,6 +212,7 @@ int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev,
 		.block = AMDGPU_RAS_BLOCK__UMC,
 	};
 	struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head);
+	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 	uint32_t timeout = timeout_ms;
 
 	memset(&err_data, 0, sizeof(err_data));
@@ -243,9 +245,7 @@ int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev,
 
 	kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
 
-	if (reset) {
-		struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
-
+	if (reset || (err_data.err_addr_cnt && con && con->is_rma)) {
 		con->gpu_reset_flags |= reset;
 		amdgpu_ras_reset_gpu(adev);
 	}
drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c +3 -1
index 9e7ce1e6bc06..9cd221ed240c 100644
@@ -85,6 +85,7 @@ static int gfx_v11_0_3_poison_consumption_handler(struct amdgpu_device *adev,
 	if (entry && (entry->client_id == SOC21_IH_CLIENTID_GFX) &&
 	    (entry->src_id == GFX_11_0_0__SRCID__RLC_GC_FED_INTERRUPT) &&
 	     !entry->vmid && !entry->pasid) {
+		struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 		uint32_t rlc_status0 = 0;
 
 		rlc_status0 = RREG32_SOC15(GC, 0, regRLC_RLCS_FED_STATUS_0);
@@ -96,7 +97,8 @@ static int gfx_v11_0_3_poison_consumption_handler(struct amdgpu_device *adev,
 			ras->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE2_RESET;
 		}
 
-		amdgpu_ras_reset_gpu(adev);
+		if (con && !con->is_rma)
+			amdgpu_ras_reset_gpu(adev);
 	}
 
 	return 0;
Signature · 1 line
2.34.1
Reviewed-by on v1 2/5
#2 lore raw

RE: [PATCH 2/5] drm/amdgpu: trigger mode1 reset for RAS RMA status

[AMD Official Use Only - AMD Internal Distribution Only]

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Friday, May 31, 2024 18:49
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 2/5] drm/amdgpu: trigger mode1 reset for RAS RMA status

Check RMA status in bad page retirement flow.

v2: fix coding bugs in v1.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c  | 28 +++++++++++++++++++-----  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c  |  8 +++----  drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c |  4 +++-
 3 files changed, 29 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -1
index 616dc2387f34..10cbcc0d1a1a 100644
@@ -2049,8 +2049,9 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager *
        struct amdgpu_device *adev = obj->adev;
        struct amdgpu_ras_block_object *block_obj =
                amdgpu_ras_get_ras_block(adev, obj->head.block, 0);
+       struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 
-       if (!block_obj)
+       if (!block_obj || !con)
                return;
 
        /* both query_poison_status and handle_poison_consumption are optional, @@ -2073,14 +2074,17 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager *
        if (block_obj->hw_ops && block_obj->hw_ops->handle_poison_consumption)
                poison_stat = block_obj->hw_ops->handle_poison_consumption(adev);
-       /* gpu reset is fallback for failed and default cases */
-       if (poison_stat) {
+       /* gpu reset is fallback for failed and default cases.
+        * For RMA case, amdgpu_umc_poison_handler will handle gpu reset.
+        */
+       if (poison_stat && !con->is_rma) {
                dev_info(adev->dev, "GPU reset for %s RAS poison consumption is issued!\n",
                                block_obj->ras_comm.name);
                amdgpu_ras_reset_gpu(adev);
-       } else {
-               amdgpu_gfx_poison_consumption_handler(adev, entry);
        }

+
+ if (!poison_stat)
+ amdgpu_gfx_poison_consumption_handler(adev, entry);
}

static void amdgpu_ras_interrupt_poison_creation_handler(struct ras_manager *obj, @@ -2801,6 +2805,7 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)

                                              page_retirement_dwork.work);
        struct amdgpu_device *adev = con->adev;
        struct ras_err_data err_data;

+ unsigned long err_cnt;

        if (amdgpu_in_reset(adev) || atomic_read(&con->in_recovery))
                return;
@@ -2808,9 +2813,13 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)
        amdgpu_ras_error_data_init(&err_data);

        amdgpu_umc_handle_bad_pages(adev, &err_data);

+ err_cnt = err_data.err_addr_cnt;

        amdgpu_ras_error_data_fini(&err_data);

+ if (err_cnt && con->is_rma)
+ amdgpu_ras_reset_gpu(adev);
+

        mutex_lock(&con->umc_ecc_log.lock);
        if (radix_tree_tagged(&con->umc_ecc_log.de_page_tree,
                                UMC_ECC_NEW_DETECTED_TAG))
@@ -2867,7 +2876,8 @@ static int amdgpu_ras_poison_consumption_handler(struct amdgpu_device *adev,
        if (poison_msg->pasid_fn)
                poison_msg->pasid_fn(adev, pasid, poison_msg->data);
-       if (reset) {
+       /* for RMA, amdgpu_ras_poison_creation_handler will trigger gpu reset */
+       if (reset && !con->is_rma) {
                flush_delayed_work(&con->page_retirement_dwork);

                con->gpu_reset_flags |= reset;
@@ -3983,6 +3993,12 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)  {
        struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);

+ /* mode1 is the only selection for RMA status */
+ if (ras->is_rma) {
+ ras->gpu_reset_flags = 0;
+ ras->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE1_RESET;
+ }
+

        if (atomic_cmpxchg(&ras->in_recovery, 0, 1) == 0)
                amdgpu_reset_domain_schedule(ras->adev->reset_domain, &ras->recovery_work);
        return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -1
index 1dbe69eabb9a..4a72ff8d8d80 100644
@@ -195,7 +195,8 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,
        kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
        amdgpu_umc_handle_bad_pages(adev, ras_error_status);
 
-       if (err_data->ue_count && reset) {
+       if ((err_data->ue_count || err_data->de_count) &&
+           (reset || (con && con->is_rma))) {
                con->gpu_reset_flags |= reset;
                amdgpu_ras_reset_gpu(adev);
        }
@@ -211,6 +212,7 @@ int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev,
                .block = AMDGPU_RAS_BLOCK__UMC,
        };
        struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head);
+       struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
        uint32_t timeout = timeout_ms;
 
        memset(&err_data, 0, sizeof(err_data)); @@ -243,9 +245,7 @@ int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev,
        kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);

- if (reset) {
- struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
-

+       if (reset || (err_data.err_addr_cnt && con && con->is_rma)) {
                con->gpu_reset_flags |= reset;
                amdgpu_ras_reset_gpu(adev);
        }
drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c +1 -0
index 9e7ce1e6bc06..9cd221ed240c 100644
@@ -85,6 +85,7 @@ static int gfx_v11_0_3_poison_consumption_handler(struct amdgpu_device *adev,
        if (entry && (entry->client_id == SOC21_IH_CLIENTID_GFX) &&
            (entry->src_id == GFX_11_0_0__SRCID__RLC_GC_FED_INTERRUPT) &&
             !entry->vmid && !entry->pasid) {
+               struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
                uint32_t rlc_status0 = 0;
 
                rlc_status0 = RREG32_SOC15(GC, 0, regRLC_RLCS_FED_STATUS_0); @@ -96,7 +97,8 @@ static int gfx_v11_0_3_poison_consumption_handler(struct amdgpu_device *adev,
                        ras->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE2_RESET;
                }

- amdgpu_ras_reset_gpu(adev);
+ if (con && !con->is_rma)

+                       amdgpu_ras_reset_gpu(adev);
        }

        return 0;

--
2.34.1

author
#3 lore raw

PATCH 3/5 drm/amdgpu: create amdgpu_ras_in_recovery to simplify code

In reply to Tao Zhou

Reduce redundant code and user doesn't need to pay attention to RAS details.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 13 ++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c       | 14 ++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       | 31 ++++++++++++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h       |  2 ++
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    |  5 ++-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  |  3 +-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 12 +------
 7 files changed, 29 insertions(+), 51 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -11
index 2ba8c4d5dc76..1811c7ba9bdc 100644
@@ -6325,20 +6325,11 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)
 	struct amdgpu_reset_context reset_context;
 	u32 memsize;
 	struct list_head device_list;
-	struct amdgpu_hive_info *hive;
-	int hive_ras_recovery = 0;
-	struct amdgpu_ras *ras;
 
 	/* PCI error slot reset should be skipped During RAS recovery */
-	hive = amdgpu_get_xgmi_hive(adev);
-	if (hive) {
-		hive_ras_recovery = atomic_read(&hive->ras_recovery);
-		amdgpu_put_xgmi_hive(hive);
-	}
-	ras = amdgpu_ras_get_context(adev);
 	if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3) ||
-	     amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4)) &&
-	    ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery))
+	    amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4)) &&
+	    amdgpu_ras_in_recovery(adev))
 		return PCI_ERS_RESULT_RECOVERED;
 
 	DRM_INFO("PCI error: slot reset callback!!\n");
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2 -12
index 68505eaa92f9..fb5fc1fe6ad0 100644
@@ -505,9 +505,6 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
 {
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
 	struct amdgpu_ring *kiq_ring = &kiq->ring;
-	struct amdgpu_hive_info *hive;
-	struct amdgpu_ras *ras;
-	int hive_ras_recovery = 0;
 	int i, r = 0;
 	int j;
 
@@ -532,16 +529,9 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
 	 * This is workaround: only skip kiq_ring test
 	 * during ras recovery in suspend stage for gfx9.4.3
 	 */
-	hive = amdgpu_get_xgmi_hive(adev);
-	if (hive) {
-		hive_ras_recovery = atomic_read(&hive->ras_recovery);
-		amdgpu_put_xgmi_hive(hive);
-	}
-
-	ras = amdgpu_ras_get_context(adev);
 	if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3) ||
-	     amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4)) &&
-		ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery)) {
+	    amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4)) &&
+	    amdgpu_ras_in_recovery(adev)) {
 		spin_unlock(&kiq->ring_lock);
 		return 0;
 	}
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +19 -12
index 10cbcc0d1a1a..ff2d34dc9718 100644
@@ -1409,11 +1409,8 @@ int amdgpu_ras_reset_error_count(struct amdgpu_device *adev,
 		enum amdgpu_ras_block block)
 {
 	struct amdgpu_ras_block_object *block_obj = amdgpu_ras_get_ras_block(adev, block, 0);
-	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 	const struct amdgpu_mca_smu_funcs *mca_funcs = adev->mca.mca_funcs;
 	const struct aca_smu_funcs *smu_funcs = adev->aca.smu_funcs;
-	struct amdgpu_hive_info *hive;
-	int hive_ras_recovery = 0;
 
 	if (!block_obj || !block_obj->hw_ops) {
 		dev_dbg_once(adev->dev, "%s doesn't config RAS function\n",
@@ -1425,15 +1422,8 @@ int amdgpu_ras_reset_error_count(struct amdgpu_device *adev,
 	    !amdgpu_ras_get_aca_debug_mode(adev))
 		return -EOPNOTSUPP;
 
-	hive = amdgpu_get_xgmi_hive(adev);
-	if (hive) {
-		hive_ras_recovery = atomic_read(&hive->ras_recovery);
-		amdgpu_put_xgmi_hive(hive);
-	}
-
 	/* skip ras error reset in gpu reset */
-	if ((amdgpu_in_reset(adev) || atomic_read(&ras->in_recovery) ||
-	    hive_ras_recovery) &&
+	if ((amdgpu_in_reset(adev) || amdgpu_ras_in_recovery(adev)) &&
 	    ((smu_funcs && smu_funcs->set_debug_mode) ||
 	     (mca_funcs && mca_funcs->mca_set_debug_mode)))
 		return -EOPNOTSUPP;
@@ -2444,6 +2434,23 @@ static void amdgpu_ras_set_fed_all(struct amdgpu_device *adev,
 	}
 }
 
+bool amdgpu_ras_in_recovery(struct amdgpu_device *adev)
+{
+	struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev);
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+	int hive_ras_recovery = 0;
+
+	if (hive) {
+		hive_ras_recovery = atomic_read(&hive->ras_recovery);
+		amdgpu_put_xgmi_hive(hive);
+	}
+
+	if (ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery))
+		return true;
+
+	return false;
+}
+
 static void amdgpu_ras_do_recovery(struct work_struct *work)
 {
 	struct amdgpu_ras *ras =
@@ -2807,7 +2814,7 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)
 	struct ras_err_data err_data;
 	unsigned long err_cnt;
 
-	if (amdgpu_in_reset(adev) || atomic_read(&con->in_recovery))
+	if (amdgpu_in_reset(adev) || amdgpu_ras_in_recovery(adev))
 		return;
 
 	amdgpu_ras_error_data_init(&err_data);
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
index 437c58c85639..37e1c93c243d 100644
@@ -952,6 +952,8 @@ int amdgpu_ras_put_poison_req(struct amdgpu_device *adev,
 		enum amdgpu_ras_block block, uint16_t pasid,
 		pasid_notify pasid_fn, void *data, uint32_t reset);
 
+bool amdgpu_ras_in_recovery(struct amdgpu_device *adev);
+
 __printf(3, 4)
 void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
 				const char *fmt, ...);
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -3
index 825786fc849e..04533f99f1e3 100644
@@ -1863,7 +1863,6 @@ static int aldebaran_mode1_reset(struct smu_context *smu)
 	u32 fatal_err, param;
 	int ret = 0;
 	struct amdgpu_device *adev = smu->adev;
-	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
 	fatal_err = 0;
 	param = SMU_RESET_MODE_1;
@@ -1876,8 +1875,8 @@ static int aldebaran_mode1_reset(struct smu_context *smu)
 	} else {
 		/* fatal error triggered by ras, PMFW supports the flag
 		   from 68.44.0 */
-		if ((smu->smc_fw_version >= 0x00442c00) && ras &&
-		    atomic_read(&ras->in_recovery))
+		if ((smu->smc_fw_version >= 0x00442c00) &&
+		    amdgpu_ras_in_recovery(adev))
 			fatal_err = 1;
 
 		param |= (fatal_err << 16);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +1 -2
index fa78665458a7..d1766a603bb9 100644
@@ -2786,10 +2786,9 @@ static void smu_v13_0_0_set_mode1_reset_param(struct smu_context *smu,
 						uint32_t *param)
 {
 	struct amdgpu_device *adev = smu->adev;
-	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
 	if ((smu->smc_fw_version >= supported_version) &&
-			ras && atomic_read(&ras->in_recovery))
+	    amdgpu_ras_in_recovery(adev))
 		/* Set RAS fatal error reset flag */
 		*param = 1 << 16;
 	else
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +1 -11
index 15c0aa0ad443..c1d7528a6dc8 100644
@@ -2573,24 +2573,14 @@ static int smu_v13_0_6_get_thermal_temperature_range(struct smu_context *smu,
 static int smu_v13_0_6_mode1_reset(struct smu_context *smu)
 {
 	struct amdgpu_device *adev = smu->adev;
-	struct amdgpu_hive_info *hive = NULL;
-	u32 hive_ras_recovery = 0;
-	struct amdgpu_ras *ras;
 	u32 fatal_err, param;
 	int ret = 0;
 
-	hive = amdgpu_get_xgmi_hive(adev);
-	ras = amdgpu_ras_get_context(adev);
 	fatal_err = 0;
 	param = SMU_RESET_MODE_1;
 
-	if (hive) {
-		hive_ras_recovery = atomic_read(&hive->ras_recovery);
-		amdgpu_put_xgmi_hive(hive);
-	}
-
 	/* fatal error triggered by ras, PMFW supports the flag */
-	if (ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery))
+	if (amdgpu_ras_in_recovery(adev))
 		fatal_err = 1;
 
 	param |= (fatal_err << 16);
Signature · 1 line
2.34.1
Reviewed-by on v1 3/5
#4 lore raw

RE: [PATCH 3/5] drm/amdgpu: create amdgpu_ras_in_recovery to simplify code

[AMD Official Use Only - AMD Internal Distribution Only]

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Friday, May 31, 2024 18:49
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 3/5] drm/amdgpu: create amdgpu_ras_in_recovery to simplify code

Reduce redundant code and user doesn't need to pay attention to RAS details.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 13 ++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c       | 14 ++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       | 31 ++++++++++++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h       |  2 ++
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    |  5 ++-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  |  3 +-  .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 12 +------
 7 files changed, 29 insertions(+), 51 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -11
index 2ba8c4d5dc76..1811c7ba9bdc 100644
@@ -6325,20 +6325,11 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)
        struct amdgpu_reset_context reset_context;
        u32 memsize;
        struct list_head device_list;
-       struct amdgpu_hive_info *hive;
-       int hive_ras_recovery = 0;
-       struct amdgpu_ras *ras;
 
        /* PCI error slot reset should be skipped During RAS recovery */
-       hive = amdgpu_get_xgmi_hive(adev);
-       if (hive) {
-               hive_ras_recovery = atomic_read(&hive->ras_recovery);
-               amdgpu_put_xgmi_hive(hive);
-       }
-       ras = amdgpu_ras_get_context(adev);
        if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3) ||
-            amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4)) &&
-           ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery))
+           amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4)) &&
+           amdgpu_ras_in_recovery(adev))
                return PCI_ERS_RESULT_RECOVERED;
 
        DRM_INFO("PCI error: slot reset callback!!\n"); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c

index 68505eaa92f9..fb5fc1fe6ad0 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2 -12
@@ -505,9 +505,6 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)  {
        struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
        struct amdgpu_ring *kiq_ring = &kiq->ring;
-       struct amdgpu_hive_info *hive;
-       struct amdgpu_ras *ras;
-       int hive_ras_recovery = 0;
        int i, r = 0;
        int j;
 
@@ -532,16 +529,9 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
         * This is workaround: only skip kiq_ring test
         * during ras recovery in suspend stage for gfx9.4.3
         */
-       hive = amdgpu_get_xgmi_hive(adev);
-       if (hive) {
-               hive_ras_recovery = atomic_read(&hive->ras_recovery);
-               amdgpu_put_xgmi_hive(hive);
-       }
-
-       ras = amdgpu_ras_get_context(adev);
        if ((amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3) ||
-            amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4)) &&
-               ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery)) {
+           amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4)) &&
+           amdgpu_ras_in_recovery(adev)) {
                spin_unlock(&kiq->ring_lock);
                return 0;
        }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -3
index 10cbcc0d1a1a..ff2d34dc9718 100644
@@ -1409,11 +1409,8 @@ int amdgpu_ras_reset_error_count(struct amdgpu_device *adev,
                enum amdgpu_ras_block block)
 {
        struct amdgpu_ras_block_object *block_obj = amdgpu_ras_get_ras_block(adev, block, 0);
-       struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
        const struct amdgpu_mca_smu_funcs *mca_funcs = adev->mca.mca_funcs;
        const struct aca_smu_funcs *smu_funcs = adev->aca.smu_funcs;
-       struct amdgpu_hive_info *hive;
-       int hive_ras_recovery = 0;
 
        if (!block_obj || !block_obj->hw_ops) {
                dev_dbg_once(adev->dev, "%s doesn't config RAS function\n", @@ -1425,15 +1422,8 @@ int amdgpu_ras_reset_error_count(struct amdgpu_device *adev,
            !amdgpu_ras_get_aca_debug_mode(adev))
                return -EOPNOTSUPP;

- hive = amdgpu_get_xgmi_hive(adev);
- if (hive) {
- hive_ras_recovery = atomic_read(&hive->ras_recovery);
- amdgpu_put_xgmi_hive(hive);
- }
-

        /* skip ras error reset in gpu reset */
-       if ((amdgpu_in_reset(adev) || atomic_read(&ras->in_recovery) ||
-           hive_ras_recovery) &&
+       if ((amdgpu_in_reset(adev) || amdgpu_ras_in_recovery(adev)) &&
            ((smu_funcs && smu_funcs->set_debug_mode) ||
             (mca_funcs && mca_funcs->mca_set_debug_mode)))
                return -EOPNOTSUPP;
@@ -2444,6 +2434,23 @@ static void amdgpu_ras_set_fed_all(struct amdgpu_device *adev,
        }

}

+bool amdgpu_ras_in_recovery(struct amdgpu_device *adev) {

+       struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev);
+       struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+       int hive_ras_recovery = 0;

+
+ if (hive) {
+ hive_ras_recovery = atomic_read(&hive->ras_recovery);
+ amdgpu_put_xgmi_hive(hive);
+ }
+
+ if (ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery))
+ return true;
+
+ return false;
+}
+
static void amdgpu_ras_do_recovery(struct work_struct *work) {
struct amdgpu_ras *ras =
@@ -2807,7 +2814,7 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)

        struct ras_err_data err_data;
        unsigned long err_cnt;
-       if (amdgpu_in_reset(adev) || atomic_read(&con->in_recovery))
+       if (amdgpu_in_reset(adev) || amdgpu_ras_in_recovery(adev))
                return;

        amdgpu_ras_error_data_init(&err_data);
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
index 437c58c85639..37e1c93c243d 100644
@@ -952,6 +952,8 @@ int amdgpu_ras_put_poison_req(struct amdgpu_device *adev,
                enum amdgpu_ras_block block, uint16_t pasid,
                pasid_notify pasid_fn, void *data, uint32_t reset);
 
+bool amdgpu_ras_in_recovery(struct amdgpu_device *adev);
+
 __printf(3, 4)
 void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
                                const char *fmt, ...);
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -3
index 825786fc849e..04533f99f1e3 100644
@@ -1863,7 +1863,6 @@ static int aldebaran_mode1_reset(struct smu_context *smu)
        u32 fatal_err, param;
        int ret = 0;
        struct amdgpu_device *adev = smu->adev;
-       struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
        fatal_err = 0;
        param = SMU_RESET_MODE_1;
@@ -1876,8 +1875,8 @@ static int aldebaran_mode1_reset(struct smu_context *smu)
        } else {
                /* fatal error triggered by ras, PMFW supports the flag
                   from 68.44.0 */
-               if ((smu->smc_fw_version >= 0x00442c00) && ras &&
-                   atomic_read(&ras->in_recovery))
+               if ((smu->smc_fw_version >= 0x00442c00) &&
+                   amdgpu_ras_in_recovery(adev))
                        fatal_err = 1;
 
                param |= (fatal_err << 16);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +1 -2
index fa78665458a7..d1766a603bb9 100644
@@ -2786,10 +2786,9 @@ static void smu_v13_0_0_set_mode1_reset_param(struct smu_context *smu,
                                                uint32_t *param)
 {
        struct amdgpu_device *adev = smu->adev;
-       struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
        if ((smu->smc_fw_version >= supported_version) &&
-                       ras && atomic_read(&ras->in_recovery))
+           amdgpu_ras_in_recovery(adev))
                /* Set RAS fatal error reset flag */
                *param = 1 << 16;
        else
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +1 -12
index 15c0aa0ad443..c1d7528a6dc8 100644
@@ -2573,24 +2573,14 @@ static int smu_v13_0_6_get_thermal_temperature_range(struct smu_context *smu,  static int smu_v13_0_6_mode1_reset(struct smu_context *smu)  {
        struct amdgpu_device *adev = smu->adev;
-       struct amdgpu_hive_info *hive = NULL;
-       u32 hive_ras_recovery = 0;
-       struct amdgpu_ras *ras;
        u32 fatal_err, param;
        int ret = 0;
 
-       hive = amdgpu_get_xgmi_hive(adev);
-       ras = amdgpu_ras_get_context(adev);
        fatal_err = 0;
        param = SMU_RESET_MODE_1;
 
-       if (hive) {
-               hive_ras_recovery = atomic_read(&hive->ras_recovery);
-               amdgpu_put_xgmi_hive(hive);
-       }
-
        /* fatal error triggered by ras, PMFW supports the flag */
-       if (ras && (atomic_read(&ras->in_recovery) || hive_ras_recovery))
+       if (amdgpu_ras_in_recovery(adev))
                fatal_err = 1;
 
        param |= (fatal_err << 16);
--

2.34.1

author
#5 lore raw

PATCH 4/5 drma/amdgpu: set fatal flag for RAS recovery

In reply to Tao Zhou

PMFW needs the flag to know the reason of mode1.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c  | 10 +++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h  |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c  |  6 +++---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c   |  2 +-
 7 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
index fb5fc1fe6ad0..f55bff59052f 100644
@@ -940,7 +940,7 @@ int amdgpu_gfx_process_ras_data_cb(struct amdgpu_device *adev,
 		if (adev->gfx.ras && adev->gfx.ras->ras_block.hw_ops &&
 		    adev->gfx.ras->ras_block.hw_ops->query_ras_error_count)
 			adev->gfx.ras->ras_block.hw_ops->query_ras_error_count(adev, err_data);
-		amdgpu_ras_reset_gpu(adev);
+		amdgpu_ras_reset_gpu(adev, true);
 	}
 	return AMDGPU_RAS_SUCCESS;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -5
index ff2d34dc9718..2071e30d7e56 100644
@@ -2070,7 +2070,7 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager *
 	if (poison_stat && !con->is_rma) {
 		dev_info(adev->dev, "GPU reset for %s RAS poison consumption is issued!\n",
 				block_obj->ras_comm.name);
-		amdgpu_ras_reset_gpu(adev);
+		amdgpu_ras_reset_gpu(adev, false);
 	}
 
 	if (!poison_stat)
@@ -2825,7 +2825,7 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)
 	amdgpu_ras_error_data_fini(&err_data);
 
 	if (err_cnt && con->is_rma)
-		amdgpu_ras_reset_gpu(adev);
+		amdgpu_ras_reset_gpu(adev, false);
 
 	mutex_lock(&con->umc_ecc_log.lock);
 	if (radix_tree_tagged(&con->umc_ecc_log.de_page_tree,
@@ -2888,7 +2888,7 @@ static int amdgpu_ras_poison_consumption_handler(struct amdgpu_device *adev,
 		flush_delayed_work(&con->page_retirement_dwork);
 
 		con->gpu_reset_flags |= reset;
-		amdgpu_ras_reset_gpu(adev);
+		amdgpu_ras_reset_gpu(adev, false);
 	}
 
 	return 0;
@@ -3815,7 +3815,7 @@ void amdgpu_ras_global_ras_isr(struct amdgpu_device *adev)
 
 		amdgpu_ras_set_fed(adev, true);
 		ras->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE1_RESET;
-		amdgpu_ras_reset_gpu(adev);
+		amdgpu_ras_reset_gpu(adev, true);
 	}
 }
 
@@ -3996,7 +3996,7 @@ int amdgpu_ras_is_supported(struct amdgpu_device *adev,
 	return ret;
 }
 
-int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)
+int amdgpu_ras_reset_gpu(struct amdgpu_device *adev, bool fatal)
 {
 	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -1
index 37e1c93c243d..ed5793458a70 100644
@@ -878,7 +878,7 @@ bool amdgpu_ras_is_poison_mode_supported(struct amdgpu_device *adev);
 
 int amdgpu_ras_is_supported(struct amdgpu_device *adev, unsigned int block);
 
-int amdgpu_ras_reset_gpu(struct amdgpu_device *adev);
+int amdgpu_ras_reset_gpu(struct amdgpu_device *adev, bool fatal);
 
 struct amdgpu_ras* amdgpu_ras_get_context(struct amdgpu_device *adev);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +1 -1
index 151f83ea803b..f976b6deb42d 100644
@@ -129,7 +129,7 @@ int amdgpu_sdma_process_ras_data_cb(struct amdgpu_device *adev,
 	if (amdgpu_sriov_vf(adev))
 		return AMDGPU_RAS_SUCCESS;
 
-	amdgpu_ras_reset_gpu(adev);
+	amdgpu_ras_reset_gpu(adev, true);
 
 	return AMDGPU_RAS_SUCCESS;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -3
index 4a72ff8d8d80..2596a1c2a64e 100644
@@ -198,7 +198,7 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,
 	if ((err_data->ue_count || err_data->de_count) &&
 	    (reset || (con && con->is_rma))) {
 		con->gpu_reset_flags |= reset;
-		amdgpu_ras_reset_gpu(adev);
+		amdgpu_ras_reset_gpu(adev, false);
 	}
 
 	return AMDGPU_RAS_SUCCESS;
@@ -247,7 +247,7 @@ int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev,
 
 	if (reset || (err_data.err_addr_cnt && con && con->is_rma)) {
 		con->gpu_reset_flags |= reset;
-		amdgpu_ras_reset_gpu(adev);
+		amdgpu_ras_reset_gpu(adev, false);
 	}
 
 	return 0;
@@ -266,7 +266,7 @@ int amdgpu_umc_pasid_poison_handler(struct amdgpu_device *adev,
 			 * let MCA notifier do page retirement.
 			 */
 			kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
-			amdgpu_ras_reset_gpu(adev);
+			amdgpu_ras_reset_gpu(adev, false);
 		}
 		return ret;
 	}
drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c +1 -1
index 9cd221ed240c..07c24704c4b8 100644
@@ -98,7 +98,7 @@ static int gfx_v11_0_3_poison_consumption_handler(struct amdgpu_device *adev,
 		}
 
 		if (con && !con->is_rma)
-			amdgpu_ras_reset_gpu(adev);
+			amdgpu_ras_reset_gpu(adev, false);
 	}
 
 	return 0;
drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +1 -1
index b8fc9e126e0d..0935ed57a906 100644
@@ -414,7 +414,7 @@ static void nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device
 		/* ras_controller_int is dedicated for nbif ras error,
 		 * not the global interrupt for sync flood
 		 */
-		amdgpu_ras_reset_gpu(adev);
+		amdgpu_ras_reset_gpu(adev, true);
 	}
 
 	amdgpu_ras_error_data_fini(&err_data);
Signature · 1 line
2.34.1
#6 lore raw

RE: [PATCH 4/5] drma/amdgpu: set fatal flag for RAS recovery

[AMD Official Use Only - AMD Internal Distribution Only]

Please correct the commit subject before pushing the change

drma->drm

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Friday, May 31, 2024 18:49
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 4/5] drma/amdgpu: set fatal flag for RAS recovery

PMFW needs the flag to know the reason of mode1.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c  |  2 +-  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c  | 10 +++++-----  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h  |  2 +-  drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c |  2 +-  drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c  |  6 +++---  drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c   |  2 +-
 7 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
index fb5fc1fe6ad0..f55bff59052f 100644
@@ -940,7 +940,7 @@ int amdgpu_gfx_process_ras_data_cb(struct amdgpu_device *adev,
                if (adev->gfx.ras && adev->gfx.ras->ras_block.hw_ops &&
                    adev->gfx.ras->ras_block.hw_ops->query_ras_error_count)
                        adev->gfx.ras->ras_block.hw_ops->query_ras_error_count(adev, err_data);
-               amdgpu_ras_reset_gpu(adev);
+               amdgpu_ras_reset_gpu(adev, true);
        }
        return AMDGPU_RAS_SUCCESS;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -5
index ff2d34dc9718..2071e30d7e56 100644
@@ -2070,7 +2070,7 @@ static void amdgpu_ras_interrupt_poison_consumption_handler(struct ras_manager *
        if (poison_stat && !con->is_rma) {
                dev_info(adev->dev, "GPU reset for %s RAS poison consumption is issued!\n",
                                block_obj->ras_comm.name);
-               amdgpu_ras_reset_gpu(adev);
+               amdgpu_ras_reset_gpu(adev, false);
        }
 
        if (!poison_stat)
@@ -2825,7 +2825,7 @@ static void amdgpu_ras_do_page_retirement(struct work_struct *work)
        amdgpu_ras_error_data_fini(&err_data);
 
        if (err_cnt && con->is_rma)
-               amdgpu_ras_reset_gpu(adev);
+               amdgpu_ras_reset_gpu(adev, false);
 
        mutex_lock(&con->umc_ecc_log.lock);
        if (radix_tree_tagged(&con->umc_ecc_log.de_page_tree,
@@ -2888,7 +2888,7 @@ static int amdgpu_ras_poison_consumption_handler(struct amdgpu_device *adev,
                flush_delayed_work(&con->page_retirement_dwork);
 
                con->gpu_reset_flags |= reset;
-               amdgpu_ras_reset_gpu(adev);
+               amdgpu_ras_reset_gpu(adev, false);
        }
 
        return 0;
@@ -3815,7 +3815,7 @@ void amdgpu_ras_global_ras_isr(struct amdgpu_device *adev)
 
                amdgpu_ras_set_fed(adev, true);
                ras->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE1_RESET;
-               amdgpu_ras_reset_gpu(adev);
+               amdgpu_ras_reset_gpu(adev, true);
        }
 }
 
@@ -3996,7 +3996,7 @@ int amdgpu_ras_is_supported(struct amdgpu_device *adev,
        return ret;
 }
 
-int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)
+int amdgpu_ras_reset_gpu(struct amdgpu_device *adev, bool fatal)
 {
        struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -1
index 37e1c93c243d..ed5793458a70 100644
@@ -878,7 +878,7 @@ bool amdgpu_ras_is_poison_mode_supported(struct amdgpu_device *adev);
 
 int amdgpu_ras_is_supported(struct amdgpu_device *adev, unsigned int block);
 
-int amdgpu_ras_reset_gpu(struct amdgpu_device *adev);
+int amdgpu_ras_reset_gpu(struct amdgpu_device *adev, bool fatal);
 
 struct amdgpu_ras* amdgpu_ras_get_context(struct amdgpu_device *adev);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +1 -1
index 151f83ea803b..f976b6deb42d 100644
@@ -129,7 +129,7 @@ int amdgpu_sdma_process_ras_data_cb(struct amdgpu_device *adev,
        if (amdgpu_sriov_vf(adev))
                return AMDGPU_RAS_SUCCESS;
 
-       amdgpu_ras_reset_gpu(adev);
+       amdgpu_ras_reset_gpu(adev, true);
 
        return AMDGPU_RAS_SUCCESS;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c +3 -3
index 4a72ff8d8d80..2596a1c2a64e 100644
@@ -198,7 +198,7 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,
        if ((err_data->ue_count || err_data->de_count) &&
            (reset || (con && con->is_rma))) {
                con->gpu_reset_flags |= reset;
-               amdgpu_ras_reset_gpu(adev);
+               amdgpu_ras_reset_gpu(adev, false);
        }
 
        return AMDGPU_RAS_SUCCESS;
@@ -247,7 +247,7 @@ int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev,
 
        if (reset || (err_data.err_addr_cnt && con && con->is_rma)) {
                con->gpu_reset_flags |= reset;
-               amdgpu_ras_reset_gpu(adev);
+               amdgpu_ras_reset_gpu(adev, false);
        }
 
        return 0;
@@ -266,7 +266,7 @@ int amdgpu_umc_pasid_poison_handler(struct amdgpu_device *adev,
                         * let MCA notifier do page retirement.
                         */
                        kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
-                       amdgpu_ras_reset_gpu(adev);
+                       amdgpu_ras_reset_gpu(adev, false);
                }
                return ret;
        }
drivers/gpu/drm/amd/amdgpu/gfx_v11_0_3.c +1 -1
index 9cd221ed240c..07c24704c4b8 100644
@@ -98,7 +98,7 @@ static int gfx_v11_0_3_poison_consumption_handler(struct amdgpu_device *adev,
                }
 
                if (con && !con->is_rma)
-                       amdgpu_ras_reset_gpu(adev);
+                       amdgpu_ras_reset_gpu(adev, false);
        }
 
        return 0;
drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +1 -1
index b8fc9e126e0d..0935ed57a906 100644
@@ -414,7 +414,7 @@ static void nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device
                /* ras_controller_int is dedicated for nbif ras error,
                 * not the global interrupt for sync flood
                 */
-               amdgpu_ras_reset_gpu(adev);
+               amdgpu_ras_reset_gpu(adev, true);
        }
 
        amdgpu_ras_error_data_fini(&err_data);

--
2.34.1

author
#7 lore raw

PATCH 5/5 drm/amdgpu: add ras fatal flag to distingush fatal error reset

In reply to Tao Zhou

Check it in mode1 reset.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       | 32 ++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h       |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h      |  1 +
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    |  2 +-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  |  2 +-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  |  2 +-
 6 files changed, 37 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +31 -1
index 2071e30d7e56..97b770ba6424 100644
@@ -2451,6 +2451,26 @@ bool amdgpu_ras_in_recovery(struct amdgpu_device *adev)
 	return false;
 }
 
+bool amdgpu_ras_in_fatal(struct amdgpu_device *adev)
+{
+	struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev);
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+	int hive_ras_fatal = 0;
+
+	if (!amdgpu_ras_in_recovery(adev))
+		return false;
+
+	if (hive) {
+		hive_ras_fatal = atomic_read(&hive->ras_fatal);
+		amdgpu_put_xgmi_hive(hive);
+	}
+
+	if (ras && (atomic_read(&ras->in_fatal) || hive_ras_fatal))
+		return true;
+
+	return false;
+}
+
 static void amdgpu_ras_do_recovery(struct work_struct *work)
 {
 	struct amdgpu_ras *ras =
@@ -2462,6 +2482,8 @@ static void amdgpu_ras_do_recovery(struct work_struct *work)
 
 	if (hive) {
 		atomic_set(&hive->ras_recovery, 1);
+		if (atomic_read(&ras->in_fatal))
+			atomic_set(&hive->ras_fatal, 1);
 
 		/* If any device which is part of the hive received RAS fatal
 		 * error interrupt, set fatal error status on all. This
@@ -2526,8 +2548,10 @@ static void amdgpu_ras_do_recovery(struct work_struct *work)
 		amdgpu_device_gpu_recover(ras->adev, NULL, &reset_context);
 	}
 	atomic_set(&ras->in_recovery, 0);
+	atomic_set(&ras->in_fatal, 0);
 	if (hive) {
 		atomic_set(&hive->ras_recovery, 0);
+		atomic_set(&hive->ras_fatal, 0);
 		amdgpu_put_xgmi_hive(hive);
 	}
 }
@@ -2982,6 +3006,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
 	mutex_init(&con->recovery_lock);
 	INIT_WORK(&con->recovery_work, amdgpu_ras_do_recovery);
 	atomic_set(&con->in_recovery, 0);
+	atomic_set(&con->in_fatal, 0);
 	con->eeprom_control.bad_channel_bitmap = 0;
 
 	max_eeprom_records_count = amdgpu_ras_eeprom_max_record_count(&con->eeprom_control);
@@ -4006,8 +4031,13 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev, bool fatal)
 		ras->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE1_RESET;
 	}
 
-	if (atomic_cmpxchg(&ras->in_recovery, 0, 1) == 0)
+	if (atomic_cmpxchg(&ras->in_recovery, 0, 1) == 0) {
+		if (fatal)
+			atomic_set(&ras->in_fatal, 1);
+
 		amdgpu_reset_domain_schedule(ras->adev->reset_domain, &ras->recovery_work);
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
index ed5793458a70..444a7fb7fbe3 100644
@@ -489,6 +489,7 @@ struct amdgpu_ras {
 	/* gpu recovery */
 	struct work_struct recovery_work;
 	atomic_t in_recovery;
+	atomic_t in_fatal;
 	struct amdgpu_device *adev;
 	/* error handler data */
 	struct ras_err_handler_data *eh_data;
@@ -953,6 +954,7 @@ int amdgpu_ras_put_poison_req(struct amdgpu_device *adev,
 		pasid_notify pasid_fn, void *data, uint32_t reset);
 
 bool amdgpu_ras_in_recovery(struct amdgpu_device *adev);
+bool amdgpu_ras_in_fatal(struct amdgpu_device *adev);
 
 __printf(3, 4)
 void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +1 -0
index a3bfc16de6d4..a6d6272a4ec6 100644
@@ -44,6 +44,7 @@ struct amdgpu_hive_info {
 
 	struct amdgpu_reset_domain *reset_domain;
 	atomic_t ras_recovery;
+	atomic_t ras_fatal;
 	struct ras_event_manager event_mgr;
 };
 
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -1
index 04533f99f1e3..a850e7b29d9d 100644
@@ -1876,7 +1876,7 @@ static int aldebaran_mode1_reset(struct smu_context *smu)
 		/* fatal error triggered by ras, PMFW supports the flag
 		   from 68.44.0 */
 		if ((smu->smc_fw_version >= 0x00442c00) &&
-		    amdgpu_ras_in_recovery(adev))
+		    amdgpu_ras_in_fatal(adev))
 			fatal_err = 1;
 
 		param |= (fatal_err << 16);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +1 -1
index d1766a603bb9..d6c6c9a08e9d 100644
@@ -2788,7 +2788,7 @@ static void smu_v13_0_0_set_mode1_reset_param(struct smu_context *smu,
 	struct amdgpu_device *adev = smu->adev;
 
 	if ((smu->smc_fw_version >= supported_version) &&
-	    amdgpu_ras_in_recovery(adev))
+	    amdgpu_ras_in_fatal(adev))
 		/* Set RAS fatal error reset flag */
 		*param = 1 << 16;
 	else
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +1 -1
index c1d7528a6dc8..4434872bbe2e 100644
@@ -2580,7 +2580,7 @@ static int smu_v13_0_6_mode1_reset(struct smu_context *smu)
 	param = SMU_RESET_MODE_1;
 
 	/* fatal error triggered by ras, PMFW supports the flag */
-	if (amdgpu_ras_in_recovery(adev))
+	if (amdgpu_ras_in_fatal(adev))
 		fatal_err = 1;
 
 	param |= (fatal_err << 16);
Signature · 1 line
2.34.1
Reviewed-by on v1 5/5
#8 lore raw

RE: [PATCH 5/5] drm/amdgpu: add ras fatal flag to distingush fatal error reset

[AMD Official Use Only - AMD Internal Distribution Only]

Series is

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tao Zhou
Sent: Friday, May 31, 2024 18:49
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 5/5] drm/amdgpu: add ras fatal flag to distingush fatal error reset

Check it in mode1 reset.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       | 32 ++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h       |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h      |  1 +
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    |  2 +-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  |  2 +-  .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  |  2 +-
 6 files changed, 37 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +21 -0
index 2071e30d7e56..97b770ba6424 100644
@@ -2451,6 +2451,26 @@ bool amdgpu_ras_in_recovery(struct amdgpu_device *adev)
        return false;
 }
 
+bool amdgpu_ras_in_fatal(struct amdgpu_device *adev) {
+       struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev);
+       struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
+       int hive_ras_fatal = 0;
+
+       if (!amdgpu_ras_in_recovery(adev))
+               return false;
+
+       if (hive) {
+               hive_ras_fatal = atomic_read(&hive->ras_fatal);
+               amdgpu_put_xgmi_hive(hive);
+       }
+
+       if (ras && (atomic_read(&ras->in_fatal) || hive_ras_fatal))
+               return true;
+
+       return false;
+}
+
 static void amdgpu_ras_do_recovery(struct work_struct *work)  {
        struct amdgpu_ras *ras =
@@ -2462,6 +2482,8 @@ static void amdgpu_ras_do_recovery(struct work_struct *work)
 
        if (hive) {
                atomic_set(&hive->ras_recovery, 1);
+               if (atomic_read(&ras->in_fatal))
+                       atomic_set(&hive->ras_fatal, 1);
 
                /* If any device which is part of the hive received RAS fatal
                 * error interrupt, set fatal error status on all. This @@ -2526,8 +2548,10 @@ static void amdgpu_ras_do_recovery(struct work_struct *work)
                amdgpu_device_gpu_recover(ras->adev, NULL, &reset_context);
        }
        atomic_set(&ras->in_recovery, 0);
+       atomic_set(&ras->in_fatal, 0);
        if (hive) {
                atomic_set(&hive->ras_recovery, 0);
+               atomic_set(&hive->ras_fatal, 0);
                amdgpu_put_xgmi_hive(hive);
        }
 }
@@ -2982,6 +3006,7 @@ int amdgpu_ras_recovery_init(struct amdgpu_device *adev)
        mutex_init(&con->recovery_lock);
        INIT_WORK(&con->recovery_work, amdgpu_ras_do_recovery);
        atomic_set(&con->in_recovery, 0);
+       atomic_set(&con->in_fatal, 0);
        con->eeprom_control.bad_channel_bitmap = 0;

        max_eeprom_records_count = amdgpu_ras_eeprom_max_record_count(&con->eeprom_control);
@@ -4006,8 +4031,13 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev, bool fatal)
                ras->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE1_RESET;
        }

- if (atomic_cmpxchg(&ras->in_recovery, 0, 1) == 0)
+ if (atomic_cmpxchg(&ras->in_recovery, 0, 1) == 0) {
+ if (fatal)
+ atomic_set(&ras->in_fatal, 1);
+

                amdgpu_reset_domain_schedule(ras->adev->reset_domain, &ras->recovery_work);
+       }
+
        return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +2 -0
index ed5793458a70..444a7fb7fbe3 100644
@@ -489,6 +489,7 @@ struct amdgpu_ras {
        /* gpu recovery */
        struct work_struct recovery_work;
        atomic_t in_recovery;
+       atomic_t in_fatal;
        struct amdgpu_device *adev;
        /* error handler data */
        struct ras_err_handler_data *eh_data;
@@ -953,6 +954,7 @@ int amdgpu_ras_put_poison_req(struct amdgpu_device *adev,
                pasid_notify pasid_fn, void *data, uint32_t reset);
 
 bool amdgpu_ras_in_recovery(struct amdgpu_device *adev);
+bool amdgpu_ras_in_fatal(struct amdgpu_device *adev);
 
 __printf(3, 4)
 void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h

index a3bfc16de6d4..a6d6272a4ec6 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +1 -0
@@ -44,6 +44,7 @@ struct amdgpu_hive_info {
 
        struct amdgpu_reset_domain *reset_domain;
        atomic_t ras_recovery;
+       atomic_t ras_fatal;
        struct ras_event_manager event_mgr;
 };
 
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +1 -1
index 04533f99f1e3..a850e7b29d9d 100644
@@ -1876,7 +1876,7 @@ static int aldebaran_mode1_reset(struct smu_context *smu)
                /* fatal error triggered by ras, PMFW supports the flag
                   from 68.44.0 */
                if ((smu->smc_fw_version >= 0x00442c00) &&
-                   amdgpu_ras_in_recovery(adev))
+                   amdgpu_ras_in_fatal(adev))
                        fatal_err = 1;
 
                param |= (fatal_err << 16);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +1 -1
index d1766a603bb9..d6c6c9a08e9d 100644
@@ -2788,7 +2788,7 @@ static void smu_v13_0_0_set_mode1_reset_param(struct smu_context *smu,
        struct amdgpu_device *adev = smu->adev;
 
        if ((smu->smc_fw_version >= supported_version) &&
-           amdgpu_ras_in_recovery(adev))
+           amdgpu_ras_in_fatal(adev))
                /* Set RAS fatal error reset flag */
                *param = 1 << 16;
        else
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +1 -1
index c1d7528a6dc8..4434872bbe2e 100644
@@ -2580,7 +2580,7 @@ static int smu_v13_0_6_mode1_reset(struct smu_context *smu)
        param = SMU_RESET_MODE_1;
 
        /* fatal error triggered by ras, PMFW supports the flag */
-       if (amdgpu_ras_in_recovery(adev))
+       if (amdgpu_ras_in_fatal(adev))
                fatal_err = 1;
 
        param |= (fatal_err << 16);

--
2.34.1

author
#9 lore raw
In reply to Tao Zhou

[AMD Official Use Only - AMD Internal Distribution Only]

Ping for the series...

Quoted 135 lines

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Friday, May 31, 2024 6:49 PM
To: [email protected]
Cc: Zhou1, Tao <[email protected]>
Subject: [PATCH 1/5] drm/amdgpu: add RAS is_rma flag

Set the flag to true if bad page number reaches threshold.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c        |  7 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 10 ++++++----
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h |  3 +--
 4 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
index 2dc47475b8e9..616dc2387f34 100644
@@ -2940,7 +2940,6 @@ int amdgpu_ras_recovery_init(struct amdgpu_device
 *adev)
      struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
      struct ras_err_handler_data **data;
      u32  max_eeprom_records_count = 0;
-     bool exc_err_limit = false;
      int ret;
 
      if (!con || amdgpu_sriov_vf(adev))
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -2
@@ -2977,12 +2976,12 @@ int amdgpu_ras_recovery_init(struct
 amdgpu_device *adev)
       */
      if (adev->gmc.xgmi.pending_reset)
              return 0;
-     ret = amdgpu_ras_eeprom_init(&con->eeprom_control, &exc_err_limit);
+     ret = amdgpu_ras_eeprom_init(&con->eeprom_control);
      /*
       * This calling fails when exc_err_limit is true or
       * ret != 0.
       */
-     if (exc_err_limit || ret)
+     if (con->is_rma || ret)
              goto free;
 
      if (con->eeprom_control.ras_num_recs) { @@ -3033,7 +3032,7 @@ int

amdgpu_ras_recovery_init(struct amdgpu_device *adev)
* Except error threshold exceeding case, other failure cases in this
* function would not fail amdgpu driver init.
*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
-     if (!exc_err_limit)
+     if (!con->is_rma)
              ret = 0;
      else
              ret = -EINVAL;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -0
index d06c01b978cd..437c58c85639 100644
@@ -521,6 +521,7 @@ struct amdgpu_ras {
      bool update_channel_flag;
      /* Record status of smu mca debug mode */
      bool is_aca_debug_mode;
+     bool is_rma;
 
      /* Record special requirements of gpu reset caller */
      uint32_t  gpu_reset_flags;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +3 -0
index 9b789dcc2bd1..eae0a555df3c 100644
@@ -750,6 +750,9 @@ amdgpu_ras_eeprom_update_header(struct
 amdgpu_ras_eeprom_control *control)
                      control->tbl_rai.health_percent = 0;
              }
 
+             if (amdgpu_bad_page_threshold != -1)
+                     ras->is_rma = true;
+
              /* ignore the -ENOTSUPP return value */
              amdgpu_dpm_send_rma_reason(adev);
      }
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +2 -2
@@ -1321,8 +1324,7 @@ static int __read_table_ras_info(struct
 amdgpu_ras_eeprom_control *control)
      return res == RAS_TABLE_V2_1_INFO_SIZE ? 0 : res;  }
 
-int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,
-                        bool *exceed_err_limit)
+int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)
 {
      struct amdgpu_device *adev = to_amdgpu_device(control);
      unsigned char buf[RAS_TABLE_HEADER_SIZE] = { 0 }; @@ -1330,7
+1332,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control

*control,

      struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
      int res;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +2 -2
-     *exceed_err_limit = false;
+     ras->is_rma = false;
 
      if (!__is_ras_eeprom_supported(adev))
              return 0;
@@ -1422,7 +1424,7 @@ int amdgpu_ras_eeprom_init(struct
 amdgpu_ras_eeprom_control *control,
                              dev_warn(adev->dev, "GPU will be initialized
 due to bad_page_threshold = -1.");
                              res = 0;
                      } else {
-                             *exceed_err_limit = true;
+                             ras->is_rma = true;
                              dev_err(adev->dev,

"RAS records:%d exceed threshold:%d, " "GPU will not be initialized. Replace this
GPU or increase the threshold", diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h
index 6dfd667f3013..b9ebda577797 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +1 -3
@@ -129,8 +129,7 @@ struct eeprom_table_record {
      unsigned char mcumc_id;
 } __packed;
 
-int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control,
-                        bool *exceed_err_limit);
+int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control);
 
 int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control
 *control);
 
--

2.34.1