diff options
author | Gavin Wan <Gavin.Wan@amd.com> | 2017-06-23 13:55:15 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-07-14 11:05:52 -0400 |
commit | 890419409a3aba2ca7185a824e47d8ded8df11a2 (patch) | |
tree | 0b9575763284a062e87738446a7c77c44095fb98 | |
parent | 8e1b90cc44181405418071a13ead5892c3879239 (diff) |
drm/amdgpu: Support passing amdgpu critical error to host via GPU Mailbox.
This feature works for SRIOV enviroment. For non-SRIOV enviroment, the
trans_error function does nothing.
The error information includes error_code (16bit), error_flags(16bit)
and error_data(64bit). Since there are not many errors, we keep the
errors in an array and transfer all errors to Host before amdgpu
initialization function (amdgpu_device_init) exit.
Signed-off-by: Gavin Wan <Gavin.Wan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/Makefile | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.c | 85 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.h | 62 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 46 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h | 4 |
9 files changed, 200 insertions, 26 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index faea6349228f..658bac0cdc5e 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile | |||
@@ -25,7 +25,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ | |||
25 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ | 25 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ |
26 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ | 26 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ |
27 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ | 27 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ |
28 | amdgpu_queue_mgr.o | 28 | amdgpu_queue_mgr.o amdgpu_vf_error.o |
29 | 29 | ||
30 | # add asic specific block | 30 | # add asic specific block |
31 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ | 31 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index ae4387fd2b65..88e45c6d36ea 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include "bif/bif_4_1_d.h" | 53 | #include "bif/bif_4_1_d.h" |
54 | #include <linux/pci.h> | 54 | #include <linux/pci.h> |
55 | #include <linux/firmware.h> | 55 | #include <linux/firmware.h> |
56 | #include "amdgpu_vf_error.h" | ||
56 | 57 | ||
57 | MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); | 58 | MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); |
58 | MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); | 59 | MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); |
@@ -2134,6 +2135,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2134 | r = amdgpu_atombios_init(adev); | 2135 | r = amdgpu_atombios_init(adev); |
2135 | if (r) { | 2136 | if (r) { |
2136 | dev_err(adev->dev, "amdgpu_atombios_init failed\n"); | 2137 | dev_err(adev->dev, "amdgpu_atombios_init failed\n"); |
2138 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL, 0, 0); | ||
2137 | goto failed; | 2139 | goto failed; |
2138 | } | 2140 | } |
2139 | 2141 | ||
@@ -2144,6 +2146,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2144 | if (amdgpu_vpost_needed(adev)) { | 2146 | if (amdgpu_vpost_needed(adev)) { |
2145 | if (!adev->bios) { | 2147 | if (!adev->bios) { |
2146 | dev_err(adev->dev, "no vBIOS found\n"); | 2148 | dev_err(adev->dev, "no vBIOS found\n"); |
2149 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0); | ||
2147 | r = -EINVAL; | 2150 | r = -EINVAL; |
2148 | goto failed; | 2151 | goto failed; |
2149 | } | 2152 | } |
@@ -2151,6 +2154,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2151 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); | 2154 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); |
2152 | if (r) { | 2155 | if (r) { |
2153 | dev_err(adev->dev, "gpu post error!\n"); | 2156 | dev_err(adev->dev, "gpu post error!\n"); |
2157 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_GPU_POST_ERROR, 0, 0); | ||
2154 | goto failed; | 2158 | goto failed; |
2155 | } | 2159 | } |
2156 | } else { | 2160 | } else { |
@@ -2162,7 +2166,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2162 | r = amdgpu_atombios_get_clock_info(adev); | 2166 | r = amdgpu_atombios_get_clock_info(adev); |
2163 | if (r) { | 2167 | if (r) { |
2164 | dev_err(adev->dev, "amdgpu_atombios_get_clock_info failed\n"); | 2168 | dev_err(adev->dev, "amdgpu_atombios_get_clock_info failed\n"); |
2165 | return r; | 2169 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, 0, 0); |
2170 | goto failed; | ||
2166 | } | 2171 | } |
2167 | /* init i2c buses */ | 2172 | /* init i2c buses */ |
2168 | amdgpu_atombios_i2c_init(adev); | 2173 | amdgpu_atombios_i2c_init(adev); |
@@ -2172,6 +2177,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2172 | r = amdgpu_fence_driver_init(adev); | 2177 | r = amdgpu_fence_driver_init(adev); |
2173 | if (r) { | 2178 | if (r) { |
2174 | dev_err(adev->dev, "amdgpu_fence_driver_init failed\n"); | 2179 | dev_err(adev->dev, "amdgpu_fence_driver_init failed\n"); |
2180 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_FENCE_INIT_FAIL, 0, 0); | ||
2175 | goto failed; | 2181 | goto failed; |
2176 | } | 2182 | } |
2177 | 2183 | ||
@@ -2181,6 +2187,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2181 | r = amdgpu_init(adev); | 2187 | r = amdgpu_init(adev); |
2182 | if (r) { | 2188 | if (r) { |
2183 | dev_err(adev->dev, "amdgpu_init failed\n"); | 2189 | dev_err(adev->dev, "amdgpu_init failed\n"); |
2190 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, 0, 0); | ||
2184 | amdgpu_fini(adev); | 2191 | amdgpu_fini(adev); |
2185 | goto failed; | 2192 | goto failed; |
2186 | } | 2193 | } |
@@ -2200,6 +2207,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2200 | r = amdgpu_ib_pool_init(adev); | 2207 | r = amdgpu_ib_pool_init(adev); |
2201 | if (r) { | 2208 | if (r) { |
2202 | dev_err(adev->dev, "IB initialization failed (%d).\n", r); | 2209 | dev_err(adev->dev, "IB initialization failed (%d).\n", r); |
2210 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r); | ||
2203 | goto failed; | 2211 | goto failed; |
2204 | } | 2212 | } |
2205 | 2213 | ||
@@ -2244,12 +2252,14 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2244 | r = amdgpu_late_init(adev); | 2252 | r = amdgpu_late_init(adev); |
2245 | if (r) { | 2253 | if (r) { |
2246 | dev_err(adev->dev, "amdgpu_late_init failed\n"); | 2254 | dev_err(adev->dev, "amdgpu_late_init failed\n"); |
2255 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_AMDGPU_LATE_INIT_FAIL, 0, r); | ||
2247 | goto failed; | 2256 | goto failed; |
2248 | } | 2257 | } |
2249 | 2258 | ||
2250 | return 0; | 2259 | return 0; |
2251 | 2260 | ||
2252 | failed: | 2261 | failed: |
2262 | amdgpu_vf_error_trans_all(adev); | ||
2253 | if (runtime) | 2263 | if (runtime) |
2254 | vga_switcheroo_fini_domain_pm_ops(adev->dev); | 2264 | vga_switcheroo_fini_domain_pm_ops(adev->dev); |
2255 | return r; | 2265 | return r; |
@@ -2937,6 +2947,7 @@ out: | |||
2937 | } | 2947 | } |
2938 | } else { | 2948 | } else { |
2939 | dev_err(adev->dev, "asic resume failed (%d).\n", r); | 2949 | dev_err(adev->dev, "asic resume failed (%d).\n", r); |
2950 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_ASIC_RESUME_FAIL, 0, r); | ||
2940 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { | 2951 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { |
2941 | if (adev->rings[i] && adev->rings[i]->sched.thread) { | 2952 | if (adev->rings[i] && adev->rings[i]->sched.thread) { |
2942 | kthread_unpark(adev->rings[i]->sched.thread); | 2953 | kthread_unpark(adev->rings[i]->sched.thread); |
@@ -2947,12 +2958,16 @@ out: | |||
2947 | drm_helper_resume_force_mode(adev->ddev); | 2958 | drm_helper_resume_force_mode(adev->ddev); |
2948 | 2959 | ||
2949 | ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched); | 2960 | ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched); |
2950 | if (r) | 2961 | if (r) { |
2951 | /* bad news, how to tell it to userspace ? */ | 2962 | /* bad news, how to tell it to userspace ? */ |
2952 | dev_info(adev->dev, "GPU reset failed\n"); | 2963 | dev_info(adev->dev, "GPU reset failed\n"); |
2953 | else | 2964 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_GPU_RESET_FAIL, 0, r); |
2965 | } | ||
2966 | else { | ||
2954 | dev_info(adev->dev, "GPU reset successed!\n"); | 2967 | dev_info(adev->dev, "GPU reset successed!\n"); |
2968 | } | ||
2955 | 2969 | ||
2970 | amdgpu_vf_error_trans_all(adev); | ||
2956 | return r; | 2971 | return r; |
2957 | } | 2972 | } |
2958 | 2973 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.c new file mode 100644 index 000000000000..45ac91861965 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
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 | /* struct error_entry - amdgpu VF error information. */ | ||
31 | struct 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 | |||
39 | struct amdgpu_vf_error_buffer admgpu_vf_errors; | ||
40 | |||
41 | |||
42 | void 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 | |||
55 | void amdgpu_vf_error_trans_all(struct amdgpu_device *adev) | ||
56 | { | ||
57 | /* u32 pf2vf_flags = 0; */ | ||
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 | TODO: Enable these code when pv2vf_info is merged | ||
66 | AMDGPU_FW_VRAM_PF2VF_READ (adev, feature_flags, &pf2vf_flags); | ||
67 | if (!(pf2vf_flags & AMDGIM_FEATURE_ERROR_LOG_COLLECT)) { | ||
68 | return; | ||
69 | } | ||
70 | */ | ||
71 | /* The errors are overlay of array, correct read_count as full. */ | ||
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 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.h new file mode 100644 index 000000000000..2a3278ec76ba --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __VF_ERROR_H__ | ||
25 | #define __VF_ERROR_H__ | ||
26 | |||
27 | #define AMDGIM_ERROR_CODE_FLAGS_TO_MAILBOX(c,f) (((c & 0xFFFF) << 16) | (f & 0xFFFF)) | ||
28 | #define AMDGIM_ERROR_CODE(t,c) (((t&0xF)<<12)|(c&0xFFF)) | ||
29 | |||
30 | /* Please keep enum same as AMD GIM driver */ | ||
31 | enum AMDGIM_ERROR_VF { | ||
32 | AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL = 0, | ||
33 | AMDGIM_ERROR_VF_NO_VBIOS, | ||
34 | AMDGIM_ERROR_VF_GPU_POST_ERROR, | ||
35 | AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, | ||
36 | AMDGIM_ERROR_VF_FENCE_INIT_FAIL, | ||
37 | |||
38 | AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, | ||
39 | AMDGIM_ERROR_VF_IB_INIT_FAIL, | ||
40 | AMDGIM_ERROR_VF_AMDGPU_LATE_INIT_FAIL, | ||
41 | AMDGIM_ERROR_VF_ASIC_RESUME_FAIL, | ||
42 | AMDGIM_ERROR_VF_GPU_RESET_FAIL, | ||
43 | |||
44 | AMDGIM_ERROR_VF_TEST, | ||
45 | AMDGIM_ERROR_VF_MAX | ||
46 | }; | ||
47 | |||
48 | enum AMDGIM_ERROR_CATEGORY { | ||
49 | AMDGIM_ERROR_CATEGORY_NON_USED = 0, | ||
50 | AMDGIM_ERROR_CATEGORY_GIM, | ||
51 | AMDGIM_ERROR_CATEGORY_PF, | ||
52 | AMDGIM_ERROR_CATEGORY_VF, | ||
53 | AMDGIM_ERROR_CATEGORY_VBIOS, | ||
54 | AMDGIM_ERROR_CATEGORY_MONITOR, | ||
55 | |||
56 | AMDGIM_ERROR_CATEGORY_MAX | ||
57 | }; | ||
58 | |||
59 | void amdgpu_vf_error_put(uint16_t sub_error_code, uint16_t error_flags, uint64_t error_data); | ||
60 | void amdgpu_vf_error_trans_all (struct amdgpu_device *adev); | ||
61 | |||
62 | #endif /* __VF_ERROR_H__ */ | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h index 9e1062edb76e..e5b1baf387c1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | |||
@@ -43,6 +43,7 @@ struct amdgpu_virt_ops { | |||
43 | int (*req_full_gpu)(struct amdgpu_device *adev, bool init); | 43 | int (*req_full_gpu)(struct amdgpu_device *adev, bool init); |
44 | int (*rel_full_gpu)(struct amdgpu_device *adev, bool init); | 44 | int (*rel_full_gpu)(struct amdgpu_device *adev, bool init); |
45 | int (*reset_gpu)(struct amdgpu_device *adev); | 45 | int (*reset_gpu)(struct amdgpu_device *adev); |
46 | void (*trans_msg)(struct amdgpu_device *adev, u32 req, u32 data1, u32 data2, u32 data3); | ||
46 | }; | 47 | }; |
47 | 48 | ||
48 | /* GPU virtualization */ | 49 | /* GPU virtualization */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c index bde3ca3c21c1..2812d88a8bdd 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | |||
@@ -72,21 +72,6 @@ static void xgpu_ai_mailbox_set_valid(struct amdgpu_device *adev, bool val) | |||
72 | reg); | 72 | reg); |
73 | } | 73 | } |
74 | 74 | ||
75 | static void xgpu_ai_mailbox_trans_msg(struct amdgpu_device *adev, | ||
76 | enum idh_request req) | ||
77 | { | ||
78 | u32 reg; | ||
79 | |||
80 | reg = RREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, | ||
81 | mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0)); | ||
82 | reg = REG_SET_FIELD(reg, BIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0, | ||
83 | MSGBUF_DATA, req); | ||
84 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0), | ||
85 | reg); | ||
86 | |||
87 | xgpu_ai_mailbox_set_valid(adev, true); | ||
88 | } | ||
89 | |||
90 | static int xgpu_ai_mailbox_rcv_msg(struct amdgpu_device *adev, | 75 | static int xgpu_ai_mailbox_rcv_msg(struct amdgpu_device *adev, |
91 | enum idh_event event) | 76 | enum idh_event event) |
92 | { | 77 | { |
@@ -154,13 +139,25 @@ static int xgpu_ai_poll_msg(struct amdgpu_device *adev, enum idh_event event) | |||
154 | return r; | 139 | return r; |
155 | } | 140 | } |
156 | 141 | ||
157 | 142 | static void xgpu_ai_mailbox_trans_msg (struct amdgpu_device *adev, | |
158 | static int xgpu_ai_send_access_requests(struct amdgpu_device *adev, | 143 | enum idh_request req, u32 data1, u32 data2, u32 data3) { |
159 | enum idh_request req) | 144 | u32 reg; |
160 | { | ||
161 | int r; | 145 | int r; |
162 | 146 | ||
163 | xgpu_ai_mailbox_trans_msg(adev, req); | 147 | reg = RREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, |
148 | mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0)); | ||
149 | reg = REG_SET_FIELD(reg, BIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0, | ||
150 | MSGBUF_DATA, req); | ||
151 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0), | ||
152 | reg); | ||
153 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW1), | ||
154 | data1); | ||
155 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW2), | ||
156 | data2); | ||
157 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW3), | ||
158 | data3); | ||
159 | |||
160 | xgpu_ai_mailbox_set_valid(adev, true); | ||
164 | 161 | ||
165 | /* start to poll ack */ | 162 | /* start to poll ack */ |
166 | r = xgpu_ai_poll_ack(adev); | 163 | r = xgpu_ai_poll_ack(adev); |
@@ -168,6 +165,14 @@ static int xgpu_ai_send_access_requests(struct amdgpu_device *adev, | |||
168 | pr_err("Doesn't get ack from pf, continue\n"); | 165 | pr_err("Doesn't get ack from pf, continue\n"); |
169 | 166 | ||
170 | xgpu_ai_mailbox_set_valid(adev, false); | 167 | xgpu_ai_mailbox_set_valid(adev, false); |
168 | } | ||
169 | |||
170 | static int xgpu_ai_send_access_requests(struct amdgpu_device *adev, | ||
171 | enum idh_request req) | ||
172 | { | ||
173 | int r; | ||
174 | |||
175 | xgpu_ai_mailbox_trans_msg(adev, req, 0, 0, 0); | ||
171 | 176 | ||
172 | /* start to check msg if request is idh_req_gpu_init_access */ | 177 | /* start to check msg if request is idh_req_gpu_init_access */ |
173 | if (req == IDH_REQ_GPU_INIT_ACCESS || | 178 | if (req == IDH_REQ_GPU_INIT_ACCESS || |
@@ -342,4 +347,5 @@ const struct amdgpu_virt_ops xgpu_ai_virt_ops = { | |||
342 | .req_full_gpu = xgpu_ai_request_full_gpu_access, | 347 | .req_full_gpu = xgpu_ai_request_full_gpu_access, |
343 | .rel_full_gpu = xgpu_ai_release_full_gpu_access, | 348 | .rel_full_gpu = xgpu_ai_release_full_gpu_access, |
344 | .reset_gpu = xgpu_ai_request_reset, | 349 | .reset_gpu = xgpu_ai_request_reset, |
350 | .trans_msg = xgpu_ai_mailbox_trans_msg, | ||
345 | }; | 351 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h index 9aefc44d2c34..1e91b9a1c591 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h | |||
@@ -31,7 +31,9 @@ enum idh_request { | |||
31 | IDH_REL_GPU_INIT_ACCESS, | 31 | IDH_REL_GPU_INIT_ACCESS, |
32 | IDH_REQ_GPU_FINI_ACCESS, | 32 | IDH_REQ_GPU_FINI_ACCESS, |
33 | IDH_REL_GPU_FINI_ACCESS, | 33 | IDH_REL_GPU_FINI_ACCESS, |
34 | IDH_REQ_GPU_RESET_ACCESS | 34 | IDH_REQ_GPU_RESET_ACCESS, |
35 | |||
36 | IDH_LOG_VF_ERROR = 200, | ||
35 | }; | 37 | }; |
36 | 38 | ||
37 | enum idh_event { | 39 | enum idh_event { |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c index 171a658135b5..c25a831f94ec 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | |||
@@ -613,4 +613,5 @@ const struct amdgpu_virt_ops xgpu_vi_virt_ops = { | |||
613 | .req_full_gpu = xgpu_vi_request_full_gpu_access, | 613 | .req_full_gpu = xgpu_vi_request_full_gpu_access, |
614 | .rel_full_gpu = xgpu_vi_release_full_gpu_access, | 614 | .rel_full_gpu = xgpu_vi_release_full_gpu_access, |
615 | .reset_gpu = xgpu_vi_request_reset, | 615 | .reset_gpu = xgpu_vi_request_reset, |
616 | .trans_msg = NULL, /* Does not need to trans VF errors to host. */ | ||
616 | }; | 617 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h index 2db741131bc6..c791d73d2d54 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h | |||
@@ -32,7 +32,9 @@ enum idh_request { | |||
32 | IDH_REL_GPU_INIT_ACCESS, | 32 | IDH_REL_GPU_INIT_ACCESS, |
33 | IDH_REQ_GPU_FINI_ACCESS, | 33 | IDH_REQ_GPU_FINI_ACCESS, |
34 | IDH_REL_GPU_FINI_ACCESS, | 34 | IDH_REL_GPU_FINI_ACCESS, |
35 | IDH_REQ_GPU_RESET_ACCESS | 35 | IDH_REQ_GPU_RESET_ACCESS, |
36 | |||
37 | IDH_LOG_VF_ERROR = 200, | ||
36 | }; | 38 | }; |
37 | 39 | ||
38 | /* VI mailbox messages data */ | 40 | /* VI mailbox messages data */ |