drm/amdgpu: Prevent RAS injection with lost bus caused by DPC
Subsystems (2)
PATCH 1/1 drm/amdgpu: Prevent RAS injection with lost bus caused by DPC
When DPC events occur, the GPU bus becomes unavailable and all user-space operations should be blocked. There is a timing race where rastool may still send RAS error injection commands to the driver after bus loss, which leads unexpected failures.
Extend the readiness check in ras debugfs write handler by adding amdgpu_device_bus_status_check() to detect bus lost state. Print warning and reject injection requests to notify user-space the function is inaccessible.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
@@ -564,7 +564,7 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f,struct ras_debug_if data;int ret =0 ; -if (!amdgpu_ras_get_error_query_ready (adev)) { +if (!amdgpu_ras_get_error_query_ready (adev) ||amdgpu_device_bus_status_check (adev)) {dev_warn (adev->dev,"RAS WARN: error injection " "currently inaccessible\n" );return size;
Signature · 1 line
2.34.1
AMD General
Would it make more sense to set the RAS query ready flag for the DPC event as well?
We should keep ras_query_ready as the single flag for all RAS sysfs and debugfs nodes. This would help simplify the implementation in the RAS block. If the device is not available, then ras_query_ready should be set to false.
Regards,
Hawking
-----Original Message-----
From: Sun, Ce(Overlord) <[email protected]>
Sent: Friday, August 7, 2026 3:03 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Sun, Ce(Overlord) <[email protected]>
Subject: [PATCH] drm/amdgpu: Prevent RAS injection with lost bus caused by DPC
When DPC events occur, the GPU bus becomes unavailable and all user-space operations should be blocked. There is a timing race where rastool may still send RAS error injection commands to the driver after bus loss, which leads unexpected failures.
Extend the readiness check in ras debugfs write handler by addingamdgpu_device_bus_status_check() to detect bus lost state. Print warning and reject injection requests to notify user-space the function is inaccessible.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -1
@@ -564,7 +564,7 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f,struct ras_debug_if data;int ret =0 ; -if (!amdgpu_ras_get_error_query_ready (adev)) { +if (!amdgpu_ras_get_error_query_ready (adev) || +amdgpu_device_bus_status_check (adev)) {dev_warn (adev->dev,"RAS WARN: error injection " "currently inaccessible\n" );
return size;
--
2.34.1
AMD General
Thanks Hawking for your review. I will check if this issue can be resolved from the user-space tool side.
Regards,
Ce,Sun
________________________________
From: Zhang, Hawking <[email protected]>
Sent: Friday, August 7, 2026 4:20 PM
To: Sun, Ce(Overlord) <[email protected]>; [email protected] <[email protected]>
Cc: Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: Prevent RAS injection with lost bus caused by DPC
AMD General
Would it make more sense to set the RAS query ready flag for the DPC event as well?
We should keep ras_query_ready as the single flag for all RAS sysfs and debugfs nodes. This would help simplify the implementation in the RAS block. If the device is not available, then ras_query_ready should be set to false.
Regards,
Hawking
-----Original Message-----
From: Sun, Ce(Overlord) <[email protected]>
Sent: Friday, August 7, 2026 3:03 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Sun, Ce(Overlord) <[email protected]>
Subject: [PATCH] drm/amdgpu: Prevent RAS injection with lost bus caused by DPC
When DPC events occur, the GPU bus becomes unavailable and all user-space operations should be blocked. There is a timing race where rastool may still send RAS error injection commands to the driver after bus loss, which leads unexpected failures.
Extend the readiness check in ras debugfs write handler by addingamdgpu_device_bus_status_check() to detect bus lost state. Print warning and reject injection requests to notify user-space the function is inaccessible.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -1
@@ -564,7 +564,7 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f,struct ras_debug_if data;int ret =0 ; -if (!amdgpu_ras_get_error_query_ready (adev)) { +if (!amdgpu_ras_get_error_query_ready (adev) || +amdgpu_device_bus_status_check (adev)) {dev_warn (adev->dev,"RAS WARN: error injection " "currently inaccessible\n" );
return size;
--
2.34.1
AMD General
Quoted 41 lines
-----Original Message-----
From: Sun, Ce(Overlord) <[email protected]>
Sent: Friday, August 7, 2026 3:03 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]>; Yang, Stanley <[email protected]>; Lazar, Lijo <[email protected]>; Sun, Ce(Overlord) <[email protected]>
Subject: [PATCH] drm/amdgpu: Prevent RAS injection with lost bus caused by DPCWhen DPC events occur, the GPU bus becomes unavailable and all user-space operations should be blocked. There is a timing race where rastool may still send RAS error injection commands to the driver after bus loss, which leads unexpected failures.
Extend the readiness check in ras debugfs write handler by adding
amdgpu_device_bus_status_check()to detect bus lost state. Print warning and reject injection requests to notify user-space the function is inaccessible.Signed-off-by Ce Sun <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2
-2@@ -564,7 +564,7 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f,struct ras_debug_if data;int ret =0 ; -if (!amdgpu_ras_get_error_query_ready (adev)) { +if (!amdgpu_ras_get_error_query_ready (adev) || +amdgpu_device_bus_status_check (adev)) {dev_warn (adev->dev,"RAS WARN: error injection " "currently inaccessible\n" );return size; --2.34.1