All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guchun Chen <guchun.chen@amd.com>
To: amd-gfx@lists.freedesktop.org, alexander.deucher@amd.com,
	Hawking.Zhang@amd.com, Dennis.Li@amd.com,
	andrey.grodzovsky@amd.com, Tao.Zhou1@amd.com,
	John.Clements@amd.com, lijo.lazar@amd.com,
	christian.koenig@amd.com, stanley.yang@amd.com
Cc: Guchun Chen <guchun.chen@amd.com>
Subject: [PATCH 06/12] drm/amdgpu: schedule ras recovery when reaching bad page threshold
Date: Tue, 28 Jul 2020 15:49:28 +0800	[thread overview]
Message-ID: <20200728074934.12490-7-guchun.chen@amd.com> (raw)
In-Reply-To: <20200728074934.12490-1-guchun.chen@amd.com>

Once the bad page saved to eeprom reaches the configured
threshold, ras recovery will be issued to notify user.

v2: Fix spelling typo.

Signed-off-by: Guchun Chen <guchun.chen@amd.com>
---
 .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c    | 37 ++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
index 67995b66d7d4..d24bf65f6dd7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
@@ -394,8 +394,10 @@ int amdgpu_ras_eeprom_process_recods(struct amdgpu_ras_eeprom_control *control,
 	int i, ret = 0;
 	struct i2c_msg *msgs, *msg;
 	unsigned char *buffs, *buff;
+	bool sched_ras_recovery = false;
 	struct eeprom_table_record *record;
 	struct amdgpu_device *adev = to_amdgpu_device(control);
+	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
 	if (adev->asic_type != CHIP_VEGA20 && adev->asic_type != CHIP_ARCTURUS)
 		return 0;
@@ -413,11 +415,30 @@ int amdgpu_ras_eeprom_process_recods(struct amdgpu_ras_eeprom_control *control,
 		goto free_buff;
 	}
 
+	/*
+	 * If saved bad pages number exceeds the bad page threshold for
+	 * the whole VRAM, update table header to mark the BAD GPU tag
+	 * and schedule one ras recovery after eeprom write is done,
+	 * this can avoid the missing for latest records.
+	 *
+	 * This new header will be picked up and checked in the bootup
+	 * by ras recovery, which may break bootup process to notify
+	 * user this GPU is in bad state and to retire such GPU for
+	 * further check.
+	 */
+	if (write && (amdgpu_bad_page_threshold != 0) &&
+		((control->num_recs + num) >= ras->bad_page_cnt_threshold)) {
+		dev_warn(adev->dev,
+			"Saved bad pages(%d) reaches threshold value(%d).\n",
+			control->num_recs + num, ras->bad_page_cnt_threshold);
+		control->tbl_hdr.header = EEPROM_TABLE_HDR_BAD;
+		sched_ras_recovery = true;
+	}
+
 	/* In case of overflow just start from beginning to not lose newest records */
 	if (write && (control->next_addr + EEPROM_TABLE_RECORD_SIZE * num > EEPROM_SIZE_BYTES))
 		control->next_addr = EEPROM_RECORD_START;
 
-
 	/*
 	 * TODO Currently makes EEPROM writes for each record, this creates
 	 * internal fragmentation. Optimized the code to do full page write of
@@ -493,6 +514,20 @@ int amdgpu_ras_eeprom_process_recods(struct amdgpu_ras_eeprom_control *control,
 		__update_tbl_checksum(control, records, num, old_hdr_byte_sum);
 
 		__update_table_header(control, buffs);
+
+		if (sched_ras_recovery) {
+			/*
+			 * Before scheduling ras recovery, assert the related
+			 * flag first, which shall bypass common bad page
+			 * reservation execution in amdgpu_ras_reset_gpu.
+			 */
+			amdgpu_ras_get_context(adev)->flags |=
+				AMDGPU_RAS_FLAG_SKIP_BAD_PAGE_RESV;
+
+			dev_warn(adev->dev, "Conduct ras recovery due to bad "
+				"page threshold reached.\n");
+			amdgpu_ras_reset_gpu(adev);
+		}
 	} else if (!__validate_tbl_checksum(control, records, num)) {
 		DRM_WARN("EEPROM Table checksum mismatch!");
 		/* TODO Uncomment when EEPROM read/write is relliable */
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2020-07-28  7:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28  7:49 [PATCH 00/12] BAD GPU retirement policy by total bad pages Guchun Chen
2020-07-28  7:49 ` [PATCH 01/12] drm/amdgpu: add bad page count threshold in module parameter Guchun Chen
2020-07-28  7:49 ` [PATCH 02/12] drm/amdgpu: validate bad page threshold in ras Guchun Chen
2020-07-28  7:49 ` [PATCH 03/12] drm/amdgpu: add bad gpu tag definition Guchun Chen
2020-07-28  7:49 ` [PATCH 04/12] drm/amdgpu: break driver init process when it's bad GPU Guchun Chen
2020-07-28  9:43   ` Li, Dennis
2020-07-28 14:11     ` Chen, Guchun
2020-07-28  7:49 ` [PATCH 05/12] drm/amdgpu: skip bad page reservation once issuing from eeprom write Guchun Chen
2020-07-28  7:49 ` Guchun Chen [this message]
2020-07-28  7:49 ` [PATCH 07/12] drm/amdgpu: break GPU recovery once it's in bad state Guchun Chen
2020-07-28  7:49 ` [PATCH 08/12] drm/amdgpu: restore ras flags when user resets eeprom Guchun Chen
2020-07-28  7:49 ` [PATCH 09/12] drm/amdgpu: define one macro for RAS's sysfs/debugfs name Guchun Chen
2020-07-28  7:55   ` Christian König
2020-07-28  8:00     ` Chen, Guchun
2020-07-28  7:49 ` [PATCH 10/12] drm/amdgpu: decouple sysfs creating of bad page node Guchun Chen
2020-07-28  7:49 ` [PATCH 11/12] drm/amdgpu: disable page reservation when amdgpu_bad_page_threshold = 0 Guchun Chen
2020-07-28  7:49 ` [PATCH 12/12] drm/amdgpu: reset eeprom once specifying one bigger threshold Guchun Chen
2020-07-29  2:56 [PATCH 00/12] BAD GPU retirement policy by total bad pages Guchun Chen
2020-07-29  2:56 ` [PATCH 06/12] drm/amdgpu: schedule ras recovery when reaching bad page threshold Guchun Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200728074934.12490-7-guchun.chen@amd.com \
    --to=guchun.chen@amd.com \
    --cc=Dennis.Li@amd.com \
    --cc=Hawking.Zhang@amd.com \
    --cc=John.Clements@amd.com \
    --cc=Tao.Zhou1@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=andrey.grodzovsky@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=lijo.lazar@amd.com \
    --cc=stanley.yang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.