diff options
author | Oded Gabbay <oded.gabbay@gmail.com> | 2015-06-12 14:35:14 -0400 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2015-07-20 02:16:47 -0400 |
commit | 130e0371b7d454bb4a861253c822b9f911ad5d19 (patch) | |
tree | a2ec6267c5d4eff7caf1caa469e61402c3c0cd29 /drivers/gpu/drm/amd/amdgpu | |
parent | 22801f76fa59870aed2c0b8a4eb6c8d6993347ae (diff) |
drm/amdgpu: Add H/W agnostic amdgpu <--> amdkfd interface
This patch adds an interface file between amdgpu and amdkfd. This
interface file is H/W agnostic, thus containing functions that
operate the same for any AMD APU/GPU H/W generation.
The functions in this interface mirror (some) of the functions in
radeon_kfd.c (the radeon<-->amdkfd interface file). The main functions
are:
- amdgpu_amdkfd_init - initialize the amdkfd module
- amdgpu_amdkfd_load_interface - load the H/W interface according to the
currently probed device
- amdgpu_amdkfd_device_probe - probe the device in amdkfd
- amdgpu_amdkfd_device_init - initialize the device in amdkfd
- amdgpu_amdkfd_interrupt - call the ISR of amdkfd
- amdgpu_amdkfd_suspend - suspend callback from amdgpu
- amdgpu_amdkfd_resume - resume callback from amdgpu
This patch also modifies the relevant amdgpu files, to use this new
interface.
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/Makefile | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 262 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 64 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/cik.c | 11 |
8 files changed, 362 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 616dfd4a1398..891f02c21de6 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile | |||
@@ -71,6 +71,10 @@ amdgpu-y += \ | |||
71 | amdgpu_vce.o \ | 71 | amdgpu_vce.o \ |
72 | vce_v3_0.o | 72 | vce_v3_0.o |
73 | 73 | ||
74 | # add amdkfd interfaces | ||
75 | amdgpu-y += \ | ||
76 | amdgpu_amdkfd.o | ||
77 | |||
74 | amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o | 78 | amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o |
75 | amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o | 79 | amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o |
76 | amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o | 80 | amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 01657830b470..f3791e0d27d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -2011,6 +2011,9 @@ struct amdgpu_device { | |||
2011 | /* tracking pinned memory */ | 2011 | /* tracking pinned memory */ |
2012 | u64 vram_pin_size; | 2012 | u64 vram_pin_size; |
2013 | u64 gart_pin_size; | 2013 | u64 gart_pin_size; |
2014 | |||
2015 | /* amdkfd interface */ | ||
2016 | struct kfd_dev *kfd; | ||
2014 | }; | 2017 | }; |
2015 | 2018 | ||
2016 | bool amdgpu_device_is_px(struct drm_device *dev); | 2019 | bool amdgpu_device_is_px(struct drm_device *dev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c new file mode 100644 index 000000000000..2071a9b757f7 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | |||
@@ -0,0 +1,262 @@ | |||
1 | /* | ||
2 | * Copyright 2014 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 | #include "amdgpu_amdkfd.h" | ||
24 | #include "amdgpu_family.h" | ||
25 | #include <drm/drmP.h> | ||
26 | #include "amdgpu.h" | ||
27 | #include <linux/module.h> | ||
28 | |||
29 | const struct kfd2kgd_calls *kfd2kgd; | ||
30 | const struct kgd2kfd_calls *kgd2kfd; | ||
31 | bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**); | ||
32 | |||
33 | bool amdgpu_amdkfd_init(void) | ||
34 | { | ||
35 | #if defined(CONFIG_HSA_AMD_MODULE) | ||
36 | bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**); | ||
37 | |||
38 | kgd2kfd_init_p = symbol_request(kgd2kfd_init); | ||
39 | |||
40 | if (kgd2kfd_init_p == NULL) | ||
41 | return false; | ||
42 | #endif | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | bool amdgpu_amdkfd_load_interface(struct amdgpu_device *rdev) | ||
47 | { | ||
48 | #if defined(CONFIG_HSA_AMD_MODULE) | ||
49 | bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**); | ||
50 | #endif | ||
51 | |||
52 | switch (rdev->asic_type) { | ||
53 | case CHIP_KAVERI: | ||
54 | default: | ||
55 | return false; | ||
56 | } | ||
57 | |||
58 | #if defined(CONFIG_HSA_AMD_MODULE) | ||
59 | kgd2kfd_init_p = symbol_request(kgd2kfd_init); | ||
60 | |||
61 | if (kgd2kfd_init_p == NULL) { | ||
62 | kfd2kgd = NULL; | ||
63 | return false; | ||
64 | } | ||
65 | |||
66 | if (!kgd2kfd_init_p(KFD_INTERFACE_VERSION, &kgd2kfd)) { | ||
67 | symbol_put(kgd2kfd_init); | ||
68 | kfd2kgd = NULL; | ||
69 | kgd2kfd = NULL; | ||
70 | |||
71 | return false; | ||
72 | } | ||
73 | |||
74 | return true; | ||
75 | #elif defined(CONFIG_HSA_AMD) | ||
76 | if (!kgd2kfd_init(KFD_INTERFACE_VERSION, &kgd2kfd)) { | ||
77 | kfd2kgd = NULL; | ||
78 | kgd2kfd = NULL; | ||
79 | return false; | ||
80 | } | ||
81 | |||
82 | return true; | ||
83 | #else | ||
84 | kfd2kgd = NULL; | ||
85 | return false; | ||
86 | #endif | ||
87 | } | ||
88 | |||
89 | void amdgpu_amdkfd_fini(void) | ||
90 | { | ||
91 | if (kgd2kfd) { | ||
92 | kgd2kfd->exit(); | ||
93 | symbol_put(kgd2kfd_init); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | void amdgpu_amdkfd_device_probe(struct amdgpu_device *rdev) | ||
98 | { | ||
99 | if (kgd2kfd) | ||
100 | rdev->kfd = kgd2kfd->probe((struct kgd_dev *)rdev, | ||
101 | rdev->pdev, kfd2kgd); | ||
102 | } | ||
103 | |||
104 | void amdgpu_amdkfd_device_init(struct amdgpu_device *rdev) | ||
105 | { | ||
106 | if (rdev->kfd) { | ||
107 | struct kgd2kfd_shared_resources gpu_resources = { | ||
108 | .compute_vmid_bitmap = 0xFF00, | ||
109 | |||
110 | .first_compute_pipe = 1, | ||
111 | .compute_pipe_count = 4 - 1, | ||
112 | }; | ||
113 | |||
114 | amdgpu_doorbell_get_kfd_info(rdev, | ||
115 | &gpu_resources.doorbell_physical_address, | ||
116 | &gpu_resources.doorbell_aperture_size, | ||
117 | &gpu_resources.doorbell_start_offset); | ||
118 | |||
119 | kgd2kfd->device_init(rdev->kfd, &gpu_resources); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | void amdgpu_amdkfd_device_fini(struct amdgpu_device *rdev) | ||
124 | { | ||
125 | if (rdev->kfd) { | ||
126 | kgd2kfd->device_exit(rdev->kfd); | ||
127 | rdev->kfd = NULL; | ||
128 | } | ||
129 | } | ||
130 | |||
131 | void amdgpu_amdkfd_interrupt(struct amdgpu_device *rdev, | ||
132 | const void *ih_ring_entry) | ||
133 | { | ||
134 | if (rdev->kfd) | ||
135 | kgd2kfd->interrupt(rdev->kfd, ih_ring_entry); | ||
136 | } | ||
137 | |||
138 | void amdgpu_amdkfd_suspend(struct amdgpu_device *rdev) | ||
139 | { | ||
140 | if (rdev->kfd) | ||
141 | kgd2kfd->suspend(rdev->kfd); | ||
142 | } | ||
143 | |||
144 | int amdgpu_amdkfd_resume(struct amdgpu_device *rdev) | ||
145 | { | ||
146 | int r = 0; | ||
147 | |||
148 | if (rdev->kfd) | ||
149 | r = kgd2kfd->resume(rdev->kfd); | ||
150 | |||
151 | return r; | ||
152 | } | ||
153 | |||
154 | u32 pool_to_domain(enum kgd_memory_pool p) | ||
155 | { | ||
156 | switch (p) { | ||
157 | case KGD_POOL_FRAMEBUFFER: return AMDGPU_GEM_DOMAIN_VRAM; | ||
158 | default: return AMDGPU_GEM_DOMAIN_GTT; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, | ||
163 | void **mem_obj, uint64_t *gpu_addr, | ||
164 | void **cpu_ptr) | ||
165 | { | ||
166 | struct amdgpu_device *rdev = (struct amdgpu_device *)kgd; | ||
167 | struct kgd_mem **mem = (struct kgd_mem **) mem_obj; | ||
168 | int r; | ||
169 | |||
170 | BUG_ON(kgd == NULL); | ||
171 | BUG_ON(gpu_addr == NULL); | ||
172 | BUG_ON(cpu_ptr == NULL); | ||
173 | |||
174 | *mem = kmalloc(sizeof(struct kgd_mem), GFP_KERNEL); | ||
175 | if ((*mem) == NULL) | ||
176 | return -ENOMEM; | ||
177 | |||
178 | r = amdgpu_bo_create(rdev, size, PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_GTT, | ||
179 | AMDGPU_GEM_CREATE_CPU_GTT_USWC, NULL, &(*mem)->bo); | ||
180 | if (r) { | ||
181 | dev_err(rdev->dev, | ||
182 | "failed to allocate BO for amdkfd (%d)\n", r); | ||
183 | return r; | ||
184 | } | ||
185 | |||
186 | /* map the buffer */ | ||
187 | r = amdgpu_bo_reserve((*mem)->bo, true); | ||
188 | if (r) { | ||
189 | dev_err(rdev->dev, "(%d) failed to reserve bo for amdkfd\n", r); | ||
190 | goto allocate_mem_reserve_bo_failed; | ||
191 | } | ||
192 | |||
193 | r = amdgpu_bo_pin((*mem)->bo, AMDGPU_GEM_DOMAIN_GTT, | ||
194 | &(*mem)->gpu_addr); | ||
195 | if (r) { | ||
196 | dev_err(rdev->dev, "(%d) failed to pin bo for amdkfd\n", r); | ||
197 | goto allocate_mem_pin_bo_failed; | ||
198 | } | ||
199 | *gpu_addr = (*mem)->gpu_addr; | ||
200 | |||
201 | r = amdgpu_bo_kmap((*mem)->bo, &(*mem)->cpu_ptr); | ||
202 | if (r) { | ||
203 | dev_err(rdev->dev, | ||
204 | "(%d) failed to map bo to kernel for amdkfd\n", r); | ||
205 | goto allocate_mem_kmap_bo_failed; | ||
206 | } | ||
207 | *cpu_ptr = (*mem)->cpu_ptr; | ||
208 | |||
209 | amdgpu_bo_unreserve((*mem)->bo); | ||
210 | |||
211 | return 0; | ||
212 | |||
213 | allocate_mem_kmap_bo_failed: | ||
214 | amdgpu_bo_unpin((*mem)->bo); | ||
215 | allocate_mem_pin_bo_failed: | ||
216 | amdgpu_bo_unreserve((*mem)->bo); | ||
217 | allocate_mem_reserve_bo_failed: | ||
218 | amdgpu_bo_unref(&(*mem)->bo); | ||
219 | |||
220 | return r; | ||
221 | } | ||
222 | |||
223 | void free_gtt_mem(struct kgd_dev *kgd, void *mem_obj) | ||
224 | { | ||
225 | struct kgd_mem *mem = (struct kgd_mem *) mem_obj; | ||
226 | |||
227 | BUG_ON(mem == NULL); | ||
228 | |||
229 | amdgpu_bo_reserve(mem->bo, true); | ||
230 | amdgpu_bo_kunmap(mem->bo); | ||
231 | amdgpu_bo_unpin(mem->bo); | ||
232 | amdgpu_bo_unreserve(mem->bo); | ||
233 | amdgpu_bo_unref(&(mem->bo)); | ||
234 | kfree(mem); | ||
235 | } | ||
236 | |||
237 | uint64_t get_vmem_size(struct kgd_dev *kgd) | ||
238 | { | ||
239 | struct amdgpu_device *rdev = | ||
240 | (struct amdgpu_device *)kgd; | ||
241 | |||
242 | BUG_ON(kgd == NULL); | ||
243 | |||
244 | return rdev->mc.real_vram_size; | ||
245 | } | ||
246 | |||
247 | uint64_t get_gpu_clock_counter(struct kgd_dev *kgd) | ||
248 | { | ||
249 | struct amdgpu_device *rdev = (struct amdgpu_device *)kgd; | ||
250 | |||
251 | if (rdev->asic_funcs->get_gpu_clock_counter) | ||
252 | return rdev->asic_funcs->get_gpu_clock_counter(rdev); | ||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd) | ||
257 | { | ||
258 | struct amdgpu_device *rdev = (struct amdgpu_device *)kgd; | ||
259 | |||
260 | /* The sclk is in quantas of 10kHz */ | ||
261 | return rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.sclk / 100; | ||
262 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h new file mode 100644 index 000000000000..c81242e84aba --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Copyright 2014 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 | /* amdgpu_amdkfd.h defines the private interface between amdgpu and amdkfd. */ | ||
24 | |||
25 | #ifndef AMDGPU_AMDKFD_H_INCLUDED | ||
26 | #define AMDGPU_AMDKFD_H_INCLUDED | ||
27 | |||
28 | #include <linux/types.h> | ||
29 | #include <kgd_kfd_interface.h> | ||
30 | |||
31 | struct amdgpu_device; | ||
32 | |||
33 | struct kgd_mem { | ||
34 | struct amdgpu_bo *bo; | ||
35 | uint64_t gpu_addr; | ||
36 | void *cpu_ptr; | ||
37 | }; | ||
38 | |||
39 | bool amdgpu_amdkfd_init(void); | ||
40 | void amdgpu_amdkfd_fini(void); | ||
41 | |||
42 | bool amdgpu_amdkfd_load_interface(struct amdgpu_device *rdev); | ||
43 | |||
44 | void amdgpu_amdkfd_suspend(struct amdgpu_device *rdev); | ||
45 | int amdgpu_amdkfd_resume(struct amdgpu_device *rdev); | ||
46 | void amdgpu_amdkfd_interrupt(struct amdgpu_device *rdev, | ||
47 | const void *ih_ring_entry); | ||
48 | void amdgpu_amdkfd_device_probe(struct amdgpu_device *rdev); | ||
49 | void amdgpu_amdkfd_device_init(struct amdgpu_device *rdev); | ||
50 | void amdgpu_amdkfd_device_fini(struct amdgpu_device *rdev); | ||
51 | |||
52 | struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void); | ||
53 | |||
54 | /* Shared API */ | ||
55 | int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, | ||
56 | void **mem_obj, uint64_t *gpu_addr, | ||
57 | void **cpu_ptr); | ||
58 | void free_gtt_mem(struct kgd_dev *kgd, void *mem_obj); | ||
59 | uint64_t get_vmem_size(struct kgd_dev *kgd); | ||
60 | uint64_t get_gpu_clock_counter(struct kgd_dev *kgd); | ||
61 | |||
62 | uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd); | ||
63 | |||
64 | #endif /* AMDGPU_AMDKFD_H_INCLUDED */ | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 56da962231fc..115906f5fda0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | |||
@@ -44,6 +44,8 @@ | |||
44 | #include "amdgpu.h" | 44 | #include "amdgpu.h" |
45 | #include "amdgpu_irq.h" | 45 | #include "amdgpu_irq.h" |
46 | 46 | ||
47 | #include "amdgpu_amdkfd.h" | ||
48 | |||
47 | /* | 49 | /* |
48 | * KMS wrapper. | 50 | * KMS wrapper. |
49 | * - 3.0.0 - initial driver | 51 | * - 3.0.0 - initial driver |
@@ -527,12 +529,15 @@ static int __init amdgpu_init(void) | |||
527 | driver->num_ioctls = amdgpu_max_kms_ioctl; | 529 | driver->num_ioctls = amdgpu_max_kms_ioctl; |
528 | amdgpu_register_atpx_handler(); | 530 | amdgpu_register_atpx_handler(); |
529 | 531 | ||
532 | amdgpu_amdkfd_init(); | ||
533 | |||
530 | /* let modprobe override vga console setting */ | 534 | /* let modprobe override vga console setting */ |
531 | return drm_pci_init(driver, pdriver); | 535 | return drm_pci_init(driver, pdriver); |
532 | } | 536 | } |
533 | 537 | ||
534 | static void __exit amdgpu_exit(void) | 538 | static void __exit amdgpu_exit(void) |
535 | { | 539 | { |
540 | amdgpu_amdkfd_fini(); | ||
536 | drm_pci_exit(driver, pdriver); | 541 | drm_pci_exit(driver, pdriver); |
537 | amdgpu_unregister_atpx_handler(); | 542 | amdgpu_unregister_atpx_handler(); |
538 | } | 543 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c index db5422e65ec5..fb44dd2231b1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <drm/drmP.h> | 24 | #include <drm/drmP.h> |
25 | #include "amdgpu.h" | 25 | #include "amdgpu.h" |
26 | #include "amdgpu_ih.h" | 26 | #include "amdgpu_ih.h" |
27 | #include "amdgpu_amdkfd.h" | ||
27 | 28 | ||
28 | /** | 29 | /** |
29 | * amdgpu_ih_ring_alloc - allocate memory for the IH ring | 30 | * amdgpu_ih_ring_alloc - allocate memory for the IH ring |
@@ -199,6 +200,12 @@ restart_ih: | |||
199 | rmb(); | 200 | rmb(); |
200 | 201 | ||
201 | while (adev->irq.ih.rptr != wptr) { | 202 | while (adev->irq.ih.rptr != wptr) { |
203 | u32 ring_index = adev->irq.ih.rptr >> 2; | ||
204 | |||
205 | /* Before dispatching irq to IP blocks, send it to amdkfd */ | ||
206 | amdgpu_amdkfd_interrupt(adev, | ||
207 | (const void *) &adev->irq.ih.ring[ring_index]); | ||
208 | |||
202 | amdgpu_ih_decode_iv(adev, &entry); | 209 | amdgpu_ih_decode_iv(adev, &entry); |
203 | adev->irq.ih.rptr &= adev->irq.ih.ptr_mask; | 210 | adev->irq.ih.rptr &= adev->irq.ih.ptr_mask; |
204 | 211 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 5533434c7a8f..8c40a9671b9f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/vga_switcheroo.h> | 34 | #include <linux/vga_switcheroo.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/pm_runtime.h> | 36 | #include <linux/pm_runtime.h> |
37 | #include "amdgpu_amdkfd.h" | ||
37 | 38 | ||
38 | #if defined(CONFIG_VGA_SWITCHEROO) | 39 | #if defined(CONFIG_VGA_SWITCHEROO) |
39 | bool amdgpu_has_atpx(void); | 40 | bool amdgpu_has_atpx(void); |
@@ -61,6 +62,8 @@ int amdgpu_driver_unload_kms(struct drm_device *dev) | |||
61 | 62 | ||
62 | pm_runtime_get_sync(dev->dev); | 63 | pm_runtime_get_sync(dev->dev); |
63 | 64 | ||
65 | amdgpu_amdkfd_device_fini(adev); | ||
66 | |||
64 | amdgpu_acpi_fini(adev); | 67 | amdgpu_acpi_fini(adev); |
65 | 68 | ||
66 | amdgpu_device_fini(adev); | 69 | amdgpu_device_fini(adev); |
@@ -118,6 +121,10 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) | |||
118 | "Error during ACPI methods call\n"); | 121 | "Error during ACPI methods call\n"); |
119 | } | 122 | } |
120 | 123 | ||
124 | amdgpu_amdkfd_load_interface(adev); | ||
125 | amdgpu_amdkfd_device_probe(adev); | ||
126 | amdgpu_amdkfd_device_init(adev); | ||
127 | |||
121 | if (amdgpu_device_is_px(dev)) { | 128 | if (amdgpu_device_is_px(dev)) { |
122 | pm_runtime_use_autosuspend(dev->dev); | 129 | pm_runtime_use_autosuspend(dev->dev); |
123 | pm_runtime_set_autosuspend_delay(dev->dev, 5000); | 130 | pm_runtime_set_autosuspend_delay(dev->dev, 5000); |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c index 341c56681841..b3b66a0d5ff7 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik.c +++ b/drivers/gpu/drm/amd/amdgpu/cik.c | |||
@@ -64,6 +64,8 @@ | |||
64 | #include "oss/oss_2_0_d.h" | 64 | #include "oss/oss_2_0_d.h" |
65 | #include "oss/oss_2_0_sh_mask.h" | 65 | #include "oss/oss_2_0_sh_mask.h" |
66 | 66 | ||
67 | #include "amdgpu_amdkfd.h" | ||
68 | |||
67 | /* | 69 | /* |
68 | * Indirect registers accessor | 70 | * Indirect registers accessor |
69 | */ | 71 | */ |
@@ -2448,14 +2450,21 @@ static int cik_common_suspend(void *handle) | |||
2448 | { | 2450 | { |
2449 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2451 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
2450 | 2452 | ||
2453 | amdgpu_amdkfd_suspend(adev); | ||
2454 | |||
2451 | return cik_common_hw_fini(adev); | 2455 | return cik_common_hw_fini(adev); |
2452 | } | 2456 | } |
2453 | 2457 | ||
2454 | static int cik_common_resume(void *handle) | 2458 | static int cik_common_resume(void *handle) |
2455 | { | 2459 | { |
2460 | int r; | ||
2456 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2461 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
2457 | 2462 | ||
2458 | return cik_common_hw_init(adev); | 2463 | r = cik_common_hw_init(adev); |
2464 | if (r) | ||
2465 | return r; | ||
2466 | |||
2467 | return amdgpu_amdkfd_resume(adev); | ||
2459 | } | 2468 | } |
2460 | 2469 | ||
2461 | static bool cik_common_is_idle(void *handle) | 2470 | static bool cik_common_is_idle(void *handle) |