[2/2] drm/amdgpu: Start using amdgpu_ras_add_bad_pages.

Submitted by Grodzovsky, Andrey on Aug. 13, 2019, 5:50 p.m.

Details

Message ID 1565718642-18107-2-git-send-email-andrey.grodzovsky@amd.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Grodzovsky, Andrey Aug. 13, 2019, 5:50 p.m.
Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 296e2d9..46517c4 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -243,15 +243,36 @@  static int gmc_v9_0_process_ras_data_cb(struct amdgpu_device *adev,
 		struct ras_err_data *err_data,
 		struct amdgpu_iv_entry *entry)
 {
+	unsigned long new_err_addr_cnt, old_err_addr_cnt = err_data->err_addr_cnt;
+
 	kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);
 	if (adev->umc.funcs->query_ras_error_count)
 		adev->umc.funcs->query_ras_error_count(adev, err_data);
 	/* umc query_ras_error_address is also responsible for clearing
 	 * error status
 	 */
-	if (adev->umc.funcs->query_ras_error_address)
+	if (adev->umc.funcs->query_ras_error_address) {
+		unsigned long *bps;
+		int i;
+
 		adev->umc.funcs->query_ras_error_address(adev, err_data);
 
+		new_err_addr_cnt = err_data->err_addr_cnt - old_err_addr_cnt;
+
+		if (new_err_addr_cnt) {
+			bps = kcalloc(new_err_addr_cnt, sizeof(*bps), GFP_KERNEL);
+			if (!bps)
+				return -ENOMEM;
+
+			for (i = 0; i < new_err_addr_cnt; i++)
+				bps[i] = err_data->err_addr[old_err_addr_cnt + i]  >> PAGE_SHIFT;
+
+			amdgpu_ras_add_bad_pages(adev, bps, new_err_addr_cnt);
+
+			kfree(bps);
+		}
+	}
+
 	/* only uncorrectable error needs gpu reset */
 	if (err_data->ue_count)
 		amdgpu_ras_reset_gpu(adev, 0);