aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorHuang Rui <ray.huang@amd.com>2018-08-02 05:23:33 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-08-27 12:09:55 -0400
commitbb7743bc205177440ba98eca2359779ba943e03b (patch)
treea7b44c1f5a4a0971c49478479998a1c8fc545418 /drivers/gpu/drm/amd/amdgpu
parentaa47d117282cc32874e2749ce8ae94262b9edddf (diff)
drm/amdgpu: move sdma definitions into amdgpu_sdma header
Demangle amdgpu.h. Furthermore, SDMA is used for moving and clearing the data buffer, so the header also need be included in ttm. Signed-off-by: Huang Rui <ray.huang@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/Makefile1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h87
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c44
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h101
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c1
5 files changed, 148 insertions, 86 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
index bfd332c95b61..e610656015b9 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -108,6 +108,7 @@ amdgpu-y += \
108 108
109# add async DMA block 109# add async DMA block
110amdgpu-y += \ 110amdgpu-y += \
111 amdgpu_sdma.o \
111 sdma_v2_4.o \ 112 sdma_v2_4.o \
112 sdma_v3_0.o \ 113 sdma_v3_0.o \
113 sdma_v4_0.o 114 sdma_v4_0.o
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 3517abb73e55..159854eaf553 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -70,6 +70,7 @@
70#include "amdgpu_mn.h" 70#include "amdgpu_mn.h"
71#include "amdgpu_gmc.h" 71#include "amdgpu_gmc.h"
72#include "amdgpu_gfx.h" 72#include "amdgpu_gfx.h"
73#include "amdgpu_sdma.h"
73#include "amdgpu_dm.h" 74#include "amdgpu_dm.h"
74#include "amdgpu_virt.h" 75#include "amdgpu_virt.h"
75#include "amdgpu_gart.h" 76#include "amdgpu_gart.h"
@@ -149,9 +150,6 @@ extern int amdgpu_cik_support;
149#define AMDGPUFB_CONN_LIMIT 4 150#define AMDGPUFB_CONN_LIMIT 4
150#define AMDGPU_BIOS_NUM_SCRATCH 16 151#define AMDGPU_BIOS_NUM_SCRATCH 16
151 152
152/* max number of IP instances */
153#define AMDGPU_MAX_SDMA_INSTANCES 2
154
155/* hard reset data */ 153/* hard reset data */
156#define AMDGPU_ASIC_RESET_DATA 0x39d5e86b 154#define AMDGPU_ASIC_RESET_DATA 0x39d5e86b
157 155
@@ -199,13 +197,6 @@ enum amdgpu_cp_irq {
199 AMDGPU_CP_IRQ_LAST 197 AMDGPU_CP_IRQ_LAST
200}; 198};
201 199
202enum amdgpu_sdma_irq {
203 AMDGPU_SDMA_IRQ_TRAP0 = 0,
204 AMDGPU_SDMA_IRQ_TRAP1,
205
206 AMDGPU_SDMA_IRQ_LAST
207};
208
209enum amdgpu_thermal_irq { 200enum amdgpu_thermal_irq {
210 AMDGPU_THERMAL_IRQ_LOW_TO_HIGH = 0, 201 AMDGPU_THERMAL_IRQ_LOW_TO_HIGH = 0,
211 AMDGPU_THERMAL_IRQ_HIGH_TO_LOW, 202 AMDGPU_THERMAL_IRQ_HIGH_TO_LOW,
@@ -265,39 +256,6 @@ amdgpu_device_ip_get_ip_block(struct amdgpu_device *adev,
265int amdgpu_device_ip_block_add(struct amdgpu_device *adev, 256int amdgpu_device_ip_block_add(struct amdgpu_device *adev,
266 const struct amdgpu_ip_block_version *ip_block_version); 257 const struct amdgpu_ip_block_version *ip_block_version);
267 258
268/* provided by hw blocks that can move/clear data. e.g., gfx or sdma */
269struct amdgpu_buffer_funcs {
270 /* maximum bytes in a single operation */
271 uint32_t copy_max_bytes;
272
273 /* number of dw to reserve per operation */
274 unsigned copy_num_dw;
275
276 /* used for buffer migration */
277 void (*emit_copy_buffer)(struct amdgpu_ib *ib,
278 /* src addr in bytes */
279 uint64_t src_offset,
280 /* dst addr in bytes */
281 uint64_t dst_offset,
282 /* number of byte to transfer */
283 uint32_t byte_count);
284
285 /* maximum bytes in a single operation */
286 uint32_t fill_max_bytes;
287
288 /* number of dw to reserve per operation */
289 unsigned fill_num_dw;
290
291 /* used for buffer clearing */
292 void (*emit_fill_buffer)(struct amdgpu_ib *ib,
293 /* value to write to memory */
294 uint32_t src_data,
295 /* dst addr in bytes */
296 uint64_t dst_offset,
297 /* number of byte to fill */
298 uint32_t byte_count);
299};
300
301/* provided by hw blocks that can write ptes, e.g., sdma */ 259/* provided by hw blocks that can write ptes, e.g., sdma */
302struct amdgpu_vm_pte_funcs { 260struct amdgpu_vm_pte_funcs {
303 /* number of dw to reserve per operation */ 261 /* number of dw to reserve per operation */
@@ -757,31 +715,6 @@ int amdgpu_device_wb_get(struct amdgpu_device *adev, u32 *wb);
757void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb); 715void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb);
758 716
759/* 717/*
760 * SDMA
761 */
762struct amdgpu_sdma_instance {
763 /* SDMA firmware */
764 const struct firmware *fw;
765 uint32_t fw_version;
766 uint32_t feature_version;
767
768 struct amdgpu_ring ring;
769 bool burst_nop;
770};
771
772struct amdgpu_sdma {
773 struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES];
774#ifdef CONFIG_DRM_AMDGPU_SI
775 //SI DMA has a difference trap irq number for the second engine
776 struct amdgpu_irq_src trap_irq_1;
777#endif
778 struct amdgpu_irq_src trap_irq;
779 struct amdgpu_irq_src illegal_inst_irq;
780 int num_instances;
781 uint32_t srbm_soft_reset;
782};
783
784/*
785 * Firmware 718 * Firmware
786 */ 719 */
787enum amdgpu_firmware_load_type { 720enum amdgpu_firmware_load_type {
@@ -1385,22 +1318,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
1385#define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8)) 1318#define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
1386#define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16)) 1319#define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
1387 1320
1388static inline struct amdgpu_sdma_instance *
1389amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
1390{
1391 struct amdgpu_device *adev = ring->adev;
1392 int i;
1393
1394 for (i = 0; i < adev->sdma.num_instances; i++)
1395 if (&adev->sdma.instance[i].ring == ring)
1396 break;
1397
1398 if (i < AMDGPU_MAX_SDMA_INSTANCES)
1399 return &adev->sdma.instance[i];
1400 else
1401 return NULL;
1402}
1403
1404/* 1321/*
1405 * ASICs macro. 1322 * ASICs macro.
1406 */ 1323 */
@@ -1462,8 +1379,6 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
1462#define amdgpu_display_page_flip_get_scanoutpos(adev, crtc, vbl, pos) (adev)->mode_info.funcs->page_flip_get_scanoutpos((adev), (crtc), (vbl), (pos)) 1379#define amdgpu_display_page_flip_get_scanoutpos(adev, crtc, vbl, pos) (adev)->mode_info.funcs->page_flip_get_scanoutpos((adev), (crtc), (vbl), (pos))
1463#define amdgpu_display_add_encoder(adev, e, s, c) (adev)->mode_info.funcs->add_encoder((adev), (e), (s), (c)) 1380#define amdgpu_display_add_encoder(adev, e, s, c) (adev)->mode_info.funcs->add_encoder((adev), (e), (s), (c))
1464#define amdgpu_display_add_connector(adev, ci, sd, ct, ib, coi, h, r) (adev)->mode_info.funcs->add_connector((adev), (ci), (sd), (ct), (ib), (coi), (h), (r)) 1381#define amdgpu_display_add_connector(adev, ci, sd, ct, ib, coi, h, r) (adev)->mode_info.funcs->add_connector((adev), (ci), (sd), (ct), (ib), (coi), (h), (r))
1465#define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib), (s), (d), (b))
1466#define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b))
1467#define amdgpu_gds_switch(adev, r, v, d, w, a) (adev)->gds.funcs->patch_gds_switch((r), (v), (d), (w), (a)) 1382#define amdgpu_gds_switch(adev, r, v, d, w, a) (adev)->gds.funcs->patch_gds_switch((r), (v), (d), (w), (a))
1468#define amdgpu_psp_check_fw_loading_status(adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i)) 1383#define amdgpu_psp_check_fw_loading_status(adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))
1469 1384
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
new file mode 100644
index 000000000000..bc9244b429ef
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
@@ -0,0 +1,44 @@
1/*
2 * Copyright 2018 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 <drm/drmP.h>
24#include "amdgpu.h"
25#include "amdgpu_sdma.h"
26
27/*
28 * GPU SDMA IP block helpers function.
29 */
30
31struct amdgpu_sdma_instance * amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
32{
33 struct amdgpu_device *adev = ring->adev;
34 int i;
35
36 for (i = 0; i < adev->sdma.num_instances; i++)
37 if (&adev->sdma.instance[i].ring == ring)
38 break;
39
40 if (i < AMDGPU_MAX_SDMA_INSTANCES)
41 return &adev->sdma.instance[i];
42 else
43 return NULL;
44}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
new file mode 100644
index 000000000000..d17503f0df8e
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
@@ -0,0 +1,101 @@
1/*
2 * Copyright 2018 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 __AMDGPU_SDMA_H__
25#define __AMDGPU_SDMA_H__
26
27/* max number of IP instances */
28#define AMDGPU_MAX_SDMA_INSTANCES 2
29
30enum amdgpu_sdma_irq {
31 AMDGPU_SDMA_IRQ_TRAP0 = 0,
32 AMDGPU_SDMA_IRQ_TRAP1,
33
34 AMDGPU_SDMA_IRQ_LAST
35};
36
37struct amdgpu_sdma_instance {
38 /* SDMA firmware */
39 const struct firmware *fw;
40 uint32_t fw_version;
41 uint32_t feature_version;
42
43 struct amdgpu_ring ring;
44 bool burst_nop;
45};
46
47struct amdgpu_sdma {
48 struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES];
49#ifdef CONFIG_DRM_AMDGPU_SI
50 //SI DMA has a difference trap irq number for the second engine
51 struct amdgpu_irq_src trap_irq_1;
52#endif
53 struct amdgpu_irq_src trap_irq;
54 struct amdgpu_irq_src illegal_inst_irq;
55 int num_instances;
56 uint32_t srbm_soft_reset;
57};
58
59/*
60 * Provided by hw blocks that can move/clear data. e.g., gfx or sdma
61 * But currently, we use sdma to move data.
62 */
63struct amdgpu_buffer_funcs {
64 /* maximum bytes in a single operation */
65 uint32_t copy_max_bytes;
66
67 /* number of dw to reserve per operation */
68 unsigned copy_num_dw;
69
70 /* used for buffer migration */
71 void (*emit_copy_buffer)(struct amdgpu_ib *ib,
72 /* src addr in bytes */
73 uint64_t src_offset,
74 /* dst addr in bytes */
75 uint64_t dst_offset,
76 /* number of byte to transfer */
77 uint32_t byte_count);
78
79 /* maximum bytes in a single operation */
80 uint32_t fill_max_bytes;
81
82 /* number of dw to reserve per operation */
83 unsigned fill_num_dw;
84
85 /* used for buffer clearing */
86 void (*emit_fill_buffer)(struct amdgpu_ib *ib,
87 /* value to write to memory */
88 uint32_t src_data,
89 /* dst addr in bytes */
90 uint64_t dst_offset,
91 /* number of byte to fill */
92 uint32_t byte_count);
93};
94
95#define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib), (s), (d), (b))
96#define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b))
97
98struct amdgpu_sdma_instance *
99amdgpu_get_sdma_instance(struct amdgpu_ring *ring);
100
101#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index fcf421263fd9..c6611cff64c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -47,6 +47,7 @@
47#include "amdgpu_object.h" 47#include "amdgpu_object.h"
48#include "amdgpu_trace.h" 48#include "amdgpu_trace.h"
49#include "amdgpu_amdkfd.h" 49#include "amdgpu_amdkfd.h"
50#include "amdgpu_sdma.h"
50#include "bif/bif_4_1_d.h" 51#include "bif/bif_4_1_d.h"
51 52
52#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) 53#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)