1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include "amdgpu.h"
25#include "amdgpu_vf_error.h"
26#include "mxgpu_ai.h"
27
28#define AMDGPU_VF_ERROR_ENTRY_SIZE 16
29
30
31struct amdgpu_vf_error_buffer {
32 int read_count;
33 int write_count;
34 uint16_t code[AMDGPU_VF_ERROR_ENTRY_SIZE];
35 uint16_t flags[AMDGPU_VF_ERROR_ENTRY_SIZE];
36 uint64_t data[AMDGPU_VF_ERROR_ENTRY_SIZE];
37};
38
39struct amdgpu_vf_error_buffer admgpu_vf_errors;
40
41
42void amdgpu_vf_error_put(uint16_t sub_error_code, uint16_t error_flags, uint64_t error_data)
43{
44 int index;
45 uint16_t error_code = AMDGIM_ERROR_CODE(AMDGIM_ERROR_CATEGORY_VF, sub_error_code);
46
47 index = admgpu_vf_errors.write_count % AMDGPU_VF_ERROR_ENTRY_SIZE;
48 admgpu_vf_errors.code [index] = error_code;
49 admgpu_vf_errors.flags [index] = error_flags;
50 admgpu_vf_errors.data [index] = error_data;
51 admgpu_vf_errors.write_count ++;
52}
53
54
55void amdgpu_vf_error_trans_all(struct amdgpu_device *adev)
56{
57
58 u32 data1, data2, data3;
59 int index;
60
61 if ((NULL == adev) || (!amdgpu_sriov_vf(adev)) || (!adev->virt.ops) || (!adev->virt.ops->trans_msg)) {
62 return;
63 }
64
65
66
67
68
69
70
71
72 if (admgpu_vf_errors.write_count - admgpu_vf_errors.read_count > AMDGPU_VF_ERROR_ENTRY_SIZE) {
73 admgpu_vf_errors.read_count = admgpu_vf_errors.write_count - AMDGPU_VF_ERROR_ENTRY_SIZE;
74 }
75
76 while (admgpu_vf_errors.read_count < admgpu_vf_errors.write_count) {
77 index =admgpu_vf_errors.read_count % AMDGPU_VF_ERROR_ENTRY_SIZE;
78 data1 = AMDGIM_ERROR_CODE_FLAGS_TO_MAILBOX (admgpu_vf_errors.code[index], admgpu_vf_errors.flags[index]);
79 data2 = admgpu_vf_errors.data[index] & 0xFFFFFFFF;
80 data3 = (admgpu_vf_errors.data[index] >> 32) & 0xFFFFFFFF;
81
82 adev->virt.ops->trans_msg(adev, IDH_LOG_VF_ERROR, data1, data2, data3);
83 admgpu_vf_errors.read_count ++;
84 }
85}
86