|
36 | 36 | #define AMDGPU_RAS_TYPE_AMDGPU 0x2 |
37 | 37 | #define AMDGPU_RAS_TYPE_VF 0x3 |
38 | 38 |
|
39 | | -static int amdgpu_ras_query_interface_info(struct ras_core_context *ras_core, |
40 | | - struct ras_cmd_ctx *cmd) |
41 | | -{ |
42 | | - struct amdgpu_device *adev = (struct amdgpu_device *)ras_core->dev; |
43 | | - struct ras_query_interface_info_rsp *output_data = |
44 | | - (struct ras_query_interface_info_rsp *)cmd->output_buff_raw; |
45 | | - int ret; |
46 | | - |
47 | | - if (cmd->input_size != sizeof(struct ras_query_interface_info_req)) |
48 | | - return RAS_CMD__ERROR_INVALID_INPUT_SIZE; |
49 | | - |
50 | | - ret = ras_cmd_query_interface_info(ras_core, output_data); |
51 | | - if (!ret) { |
52 | | - output_data->plat_major_ver = 0; |
53 | | - output_data->plat_minor_ver = 0; |
54 | | - |
55 | | - output_data->interface_type = amdgpu_sriov_vf(adev) ? |
56 | | - RAS_CMD_INTERFACE_TYPE_VF : RAS_CMD_INTERFACE_TYPE_AMDGPU; |
57 | | - |
58 | | - cmd->output_size = sizeof(struct ras_query_interface_info_rsp); |
59 | | - } |
60 | | - |
61 | | - return ret; |
62 | | -} |
63 | | - |
64 | | -static struct ras_core_context *ras_cmd_get_ras_core(uint64_t dev_handle) |
65 | | -{ |
66 | | - struct ras_core_context *ras_core; |
67 | | - |
68 | | - if (!dev_handle || (dev_handle == RAS_CMD_DEV_HANDLE_MAGIC)) |
69 | | - return NULL; |
70 | | - |
71 | | - ras_core = (struct ras_core_context *)(uintptr_t)(dev_handle ^ RAS_CMD_DEV_HANDLE_MAGIC); |
72 | | - |
73 | | - if (ras_cmd_get_dev_handle(ras_core) == dev_handle) |
74 | | - return ras_core; |
75 | | - |
76 | | - return NULL; |
77 | | -} |
78 | | - |
79 | | -static int amdgpu_ras_get_devices_info(struct ras_core_context *ras_core, |
80 | | - struct ras_cmd_ctx *cmd) |
81 | | -{ |
82 | | - struct amdgpu_device *adev = (struct amdgpu_device *)ras_core->dev; |
83 | | - struct ras_cmd_devices_info_rsp *output_data = |
84 | | - (struct ras_cmd_devices_info_rsp *)cmd->output_buff_raw; |
85 | | - struct ras_cmd_dev_info *dev_info; |
86 | | - |
87 | | - dev_info = &output_data->devs[0]; |
88 | | - dev_info->dev_handle = ras_cmd_get_dev_handle(ras_core); |
89 | | - dev_info->oam_id = adev->smuio.funcs->get_socket_id(adev); |
90 | | - dev_info->ecc_enabled = 1; |
91 | | - dev_info->ecc_supported = 1; |
92 | | - |
93 | | - output_data->dev_num = 1; |
94 | | - output_data->version = 0; |
95 | | - cmd->output_size = sizeof(struct ras_cmd_devices_info_rsp); |
96 | | - |
97 | | - return 0; |
98 | | -} |
99 | | - |
100 | 39 | static int amdgpu_ras_trigger_error_prepare(struct ras_core_context *ras_core, |
101 | 40 | struct ras_cmd_inject_error_req *block_info) |
102 | 41 | { |
@@ -311,51 +250,34 @@ int amdgpu_ras_handle_cmd(struct ras_core_context *ras_core, struct ras_cmd_ctx |
311 | 250 | return res; |
312 | 251 | } |
313 | 252 |
|
314 | | -int amdgpu_ras_cmd_ioctl_handler(struct ras_core_context *ras_core, |
315 | | - uint8_t *cmd_buf, uint32_t buf_size) |
| 253 | +int amdgpu_ras_submit_cmd(struct ras_core_context *ras_core, struct ras_cmd_ctx *cmd) |
316 | 254 | { |
317 | | - struct ras_cmd_ctx *cmd = (struct ras_cmd_ctx *)cmd_buf; |
318 | | - struct ras_core_context *cmd_core = NULL; |
319 | | - struct ras_cmd_dev_handle *cmd_handle = NULL; |
| 255 | + struct ras_core_context *cmd_core = ras_core; |
320 | 256 | int timeout = 60; |
321 | 257 | int res; |
322 | 258 |
|
323 | 259 | cmd->cmd_res = RAS_CMD__ERROR_INVALID_CMD; |
324 | 260 | cmd->output_size = 0; |
325 | 261 |
|
326 | | - if (!ras_core_is_enabled(ras_core)) |
| 262 | + if (!ras_core_is_enabled(cmd_core)) |
327 | 263 | return RAS_CMD__ERROR_ACCESS_DENIED; |
328 | 264 |
|
329 | | - if (cmd->cmd_id == RAS_CMD__QUERY_INTERFACE_INFO) { |
330 | | - cmd->cmd_res = amdgpu_ras_query_interface_info(ras_core, cmd); |
331 | | - } else if (cmd->cmd_id == RAS_CMD__GET_DEVICES_INFO) { |
332 | | - cmd->cmd_res = amdgpu_ras_get_devices_info(ras_core, cmd); |
333 | | - } else { |
334 | | - cmd_handle = (struct ras_cmd_dev_handle *)cmd->input_buff_raw; |
335 | | - cmd_core = ras_cmd_get_ras_core(cmd_handle->dev_handle); |
336 | | - if (!cmd_core) |
337 | | - return RAS_CMD__ERROR_INVALID_INPUT_DATA; |
338 | | - |
339 | | - while (ras_core_gpu_in_reset(cmd_core)) { |
340 | | - msleep(1000); |
341 | | - if (!timeout--) |
342 | | - return RAS_CMD__ERROR_TIMEOUT; |
343 | | - } |
344 | | - |
345 | | - |
346 | | - if (!ras_core_is_enabled(cmd_core)) |
347 | | - return RAS_CMD__ERROR_ACCESS_DENIED; |
| 265 | + while (ras_core_gpu_in_reset(cmd_core)) { |
| 266 | + msleep(1000); |
| 267 | + if (!timeout--) |
| 268 | + return RAS_CMD__ERROR_TIMEOUT; |
| 269 | + } |
348 | 270 |
|
349 | | - res = amdgpu_ras_handle_cmd(cmd_core, cmd, NULL); |
350 | | - if (res == RAS_CMD__ERROR_UKNOWN_CMD) |
351 | | - res = rascore_handle_cmd(cmd_core, cmd, NULL); |
| 271 | + res = amdgpu_ras_handle_cmd(cmd_core, cmd, NULL); |
| 272 | + if (res == RAS_CMD__ERROR_UKNOWN_CMD) |
| 273 | + res = rascore_handle_cmd(cmd_core, cmd, NULL); |
352 | 274 |
|
353 | | - cmd->cmd_res = res; |
354 | | - } |
| 275 | + cmd->cmd_res = res; |
355 | 276 |
|
356 | | - if ((cmd->cmd_res == RAS_CMD__SUCCESS) && |
357 | | - ((cmd->output_size + sizeof(*cmd)) > buf_size)) { |
358 | | - RAS_INFO("Insufficient command buffer size 0x%x!\n", buf_size); |
| 277 | + if (cmd->output_size > cmd->output_buf_size) { |
| 278 | + RAS_DEV_ERR(cmd_core->dev, |
| 279 | + "Output size 0x%x exceeds output buffer size 0x%x!\n", |
| 280 | + cmd->output_size, cmd->output_buf_size); |
359 | 281 | return RAS_CMD__SUCCESS_EXEED_BUFFER; |
360 | 282 | } |
361 | 283 |
|
|
0 commit comments