drm/amdgpu: normalize error return of RAS command wrapper functions

User-space read/write syscalls interpret positive driver return values
as successful transfer sizes. Our current RAS wrappers return positive
error codes, so we must convert them to standard negative error codes.

Signed-off-by: Ce Sun <cesun102@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Ce Sun 2026-07-23 14:41:37 +08:00 committed by Alex Deucher
parent 9ba8e75d2e
commit b84d8db29e
2 changed files with 4 additions and 4 deletions

View File

@ -1436,7 +1436,7 @@ static int amdgpu_uniras_clear_badpages_info(struct amdgpu_device *adev)
&req, sizeof(req), NULL, 0);
if (ret) {
dev_err(adev->dev, "Failed to clear bad pages info, ret: %d\n", ret);
return ret;
return -EINVAL;
}
return 0;
@ -1536,7 +1536,7 @@ static int amdgpu_uniras_error_inject(struct amdgpu_device *adev,
inject_req.method = info->value;
return amdgpu_ras_mgr_handle_ras_cmd(adev, RAS_CMD__INJECT_ERROR,
&inject_req, sizeof(inject_req), &rsp, sizeof(rsp));
&inject_req, sizeof(inject_req), &rsp, sizeof(rsp)) ? -EINVAL : 0;
}
/* wrapper of psp_ras_trigger_error */

View File

@ -526,7 +526,7 @@ static ssize_t amdgpu_ras_cper_debugfs_read(struct file *f, char __user *buf,
snapshot_req, sizeof(struct ras_cmd_cper_snapshot_req),
snapshot_rsp, sizeof(struct ras_cmd_cper_snapshot_rsp));
if (r)
return r;
return -EINVAL;
if (!snapshot_rsp->total_cper_num) {
if (!read_header)
@ -568,7 +568,7 @@ static ssize_t amdgpu_ras_cper_debugfs_read(struct file *f, char __user *buf,
record_rsp,
sizeof(struct ras_cmd_cper_record_rsp));
if (r)
return r;
return -EINVAL;
if (!record_rsp->real_data_size || !record_rsp->real_cper_num)
break;