Skip to contentSkip to conversation

drm/amdgpu: error handling for xgmi and ras

PATCH In review Evan Quan 2 participants 4 messages Mar 15, 2019 – Mar 18, 2019 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH 1/1 drm/amdgpu: error handling for xgmi and ras

This is a quick workaround. A more complete
error handling around psp_hw_start is actually
needed.

Change-Id I398efd652584e022debf237950207199a4ea78fc
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -0
index 5888e24219d9..f8d712d306f1 100644
@@ -941,6 +941,11 @@ static int psp_load_fw(struct amdgpu_device *adev)
 	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
 			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
 failed:
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+
 	kfree(psp->cmd);
 	psp->cmd = NULL;
 	return ret;
@@ -1061,6 +1066,10 @@ static int psp_resume(void *handle)
 
 failed:
 	DRM_ERROR("PSP resume failed\n");
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
 	mutex_unlock(&adev->firmware.mutex);
 	return ret;
 }
Signature · 6 lines
2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Am 15.03.19 um 09:33 schrieb Evan Quan:

Quoted 15 lines

This is a quick workaround. A more complete
error handling around psp_hw_start is actually
needed.

Change-Id I398efd652584e022debf237950207199a4ea78fc
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index 5888e24219d9..f8d712d306f1 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 947

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
@@ -941,6 +941,11 @@ static int psp_load_fw(struct amdgpu_device *adev)
  	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
  			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
  failed:
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;

No idea what that code does, but it looks really odd. Just copy&pasted typo maybe?

A simple "psp->ras.ras_initialized = 0;" in the error path should have the same effect.

Christian.

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -0
+
  	kfree(psp->cmd);
  	psp->cmd = NULL;
  	return ret;

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_resume(void *handle) · line 1075

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
@@ -1061,6 +1066,10 @@ static int psp_resume(void *handle)
 
  failed:
  	DRM_ERROR("PSP resume failed\n");
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
  	mutex_unlock(&adev->firmware.mutex);
  	return ret;
  }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 79bf427d-d1b5-2b3e-da07-e246602bfae3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#4 lore raw

Hw_init -> psp_hw_init -> psp_hw_start (failed) -> ras_pre_fini -> hw_fini -> psp_hw_fini

On psp_hw_start failure, it destroys the cmd/fence/fw buffers. But the ras/xgmi deinit was delayed to psp_hw_fini.

In ras_pre_fini, it calls the ras APIs to disable previously enabled ras features. And that needs the cmd/fence buffers and trigger a NULL pointer dereference.

Maybe "defer the cmd/fence/fw buffers destroys to psp_hw_fini also" is a more proper way..

Regards,
Evan

Quoted 45 lines

-----Original Message-----
From: Christian König <[email protected]>
Sent: 2019年3月15日 16:40
To: Quan, Evan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: error handling for xgmi and ras

Am 15.03.19 um 09:33 schrieb Evan Quan:

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device

Quoted 15 lines

This is a quick workaround. A more complete error handling around psp_hw_start is actually needed.

Change-Id I398efd652584e022debf237950207199a4ea78fc
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index 5888e24219d9..f8d712d306f1 100644
@@ -941,6 +941,11 @@ static int psp_load_fw(struct amdgpu_device

*adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 947

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
  	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
  			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
  failed:
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;

No idea what that code does, but it looks really odd. Just copy&pasted typo maybe?

A simple "psp->ras.ras_initialized = 0;" in the error path should have the same effect.

Christian.

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -0
+
  	kfree(psp->cmd);
  	psp->cmd = NULL;
  	return ret;
@@ -1061,6 +1066,10 @@ static int psp_resume(void *handle)
 
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_resume(void *handle) · line 1075

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
  failed:
  	DRM_ERROR("PSP resume failed\n");
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
  	mutex_unlock(&adev->firmware.mutex);
  	return ret;
  }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3344B57B8FBD59616C503CB7E4440-rweVpJHSKToDMgCC8P//[email protected]

author
#6 lore raw

Drop this patch as a new refined one was just sent out.

Regards,
Evan

Quoted 67 lines

-----Original Message-----
From: Quan, Evan
Sent: 2019年3月15日 17:15
To: Koenig, Christian <[email protected]>; amd- [email protected]
Subject: RE: [PATCH] drm/amdgpu: error handling for xgmi and ras

Hw_init -> psp_hw_init -> psp_hw_start (failed) -> ras_pre_fini -> hw_fini -> psp_hw_fini

On psp_hw_start failure, it destroys the cmd/fence/fw buffers. But the ras/xgmi deinit was delayed to psp_hw_fini.

In ras_pre_fini, it calls the ras APIs to disable previously enabled ras features. And that needs the cmd/fence buffers and trigger a NULL pointer dereference.

Maybe "defer the cmd/fence/fw buffers destroys to psp_hw_fini also" is a more proper way..

Regards,
Evan

Quoted 45 lines

-----Original Message-----
From: Christian König <[email protected]>
Sent: 2019年3月15日 16:40
To: Quan, Evan <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: error handling for xgmi and ras

Am 15.03.19 um 09:33 schrieb Evan Quan:

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device

Quoted 15 lines

This is a quick workaround. A more complete error handling around psp_hw_start is actually needed.

Change-Id I398efd652584e022debf237950207199a4ea78fc
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index 5888e24219d9..f8d712d306f1 100644
@@ -941,6 +941,11 @@ static int psp_load_fw(struct amdgpu_device

*adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 947

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
  	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
  			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
  failed:
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;

No idea what that code does, but it looks really odd. Just copy&pasted typo maybe?

A simple "psp->ras.ras_initialized = 0;" in the error path should have the same effect.

Christian.

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -0
+
  	kfree(psp->cmd);
  	psp->cmd = NULL;
  	return ret;
@@ -1061,6 +1066,10 @@ static int psp_resume(void *handle)
 
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_resume(void *handle) · line 1075

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -0
  failed:
  	DRM_ERROR("PSP resume failed\n");
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
+	if (psp->ras.ras_initialized)
+		psp->ras.ras_initialized = 0;
  	mutex_unlock(&adev->firmware.mutex);
  	return ret;
  }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx