aboutsummaryrefslogtreecommitdiffstats
path: root/amdgpu
diff options
context:
space:
mode:
authorMarek Olšák2015-05-29 12:13:41 -0500
committerAlex Deucher2015-08-05 12:47:50 -0500
commit194d5c2ee442b0f5020b33dd419f0b4d9e6b9001 (patch)
tree7002d9593cbbdad2bc9d0d914e1ecff9df6f9d02 /amdgpu
parent2a344a8d8a7af0b242b262866742c253cd55d334 (diff)
downloadexternal-libdrm-194d5c2ee442b0f5020b33dd419f0b4d9e6b9001.tar.gz
external-libdrm-194d5c2ee442b0f5020b33dd419f0b4d9e6b9001.tar.xz
external-libdrm-194d5c2ee442b0f5020b33dd419f0b4d9e6b9001.zip
amdgpu: remove amdgpu_ib
Not useful if we're gonna use BO handles directly. Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'amdgpu')
-rw-r--r--amdgpu/amdgpu.h13
-rw-r--r--amdgpu/amdgpu_cs.c72
-rw-r--r--amdgpu/amdgpu_internal.h7
3 files changed, 22 insertions, 70 deletions
diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index bef7bf58..cb30c0ae 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -125,13 +125,6 @@ typedef struct amdgpu_bo *amdgpu_bo_handle;
125 */ 125 */
126typedef struct amdgpu_bo_list *amdgpu_bo_list_handle; 126typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
127 127
128/**
129 * Define handle to be used when dealing with command
130 * buffers (a.k.a. ibs)
131 *
132 */
133typedef struct amdgpu_ib *amdgpu_ib_handle;
134
135 128
136/*--------------------------------------------------------------------------*/ 129/*--------------------------------------------------------------------------*/
137/* -------------------------- Structures ---------------------------------- */ 130/* -------------------------- Structures ---------------------------------- */
@@ -305,7 +298,7 @@ struct amdgpu_gds_alloc_info {
305*/ 298*/
306struct amdgpu_cs_ib_alloc_result { 299struct amdgpu_cs_ib_alloc_result {
307 /** IB allocation handle */ 300 /** IB allocation handle */
308 amdgpu_ib_handle handle; 301 amdgpu_bo_handle handle;
309 302
310 /** Assigned GPU VM MC Address of command buffer */ 303 /** Assigned GPU VM MC Address of command buffer */
311 uint64_t mc_address; 304 uint64_t mc_address;
@@ -325,7 +318,7 @@ struct amdgpu_cs_ib_info {
325 uint64_t flags; 318 uint64_t flags;
326 319
327 /** Handle of command buffer */ 320 /** Handle of command buffer */
328 amdgpu_ib_handle ib_handle; 321 amdgpu_bo_handle bo_handle;
329 322
330 /** 323 /**
331 * Size of Command Buffer to be submitted. 324 * Size of Command Buffer to be submitted.
@@ -964,7 +957,7 @@ int amdgpu_cs_alloc_ib(amdgpu_context_handle context,
964 * \sa amdgpu_cs_alloc_ib() 957 * \sa amdgpu_cs_alloc_ib()
965 * 958 *
966*/ 959*/
967int amdgpu_cs_free_ib(amdgpu_ib_handle handle); 960int amdgpu_cs_free_ib(amdgpu_bo_handle handle);
968 961
969/** 962/**
970 * Send request to submit command buffers to hardware. 963 * Send request to submit command buffers to hardware.
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index 326e3d32..1429f26b 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -42,17 +42,21 @@
42 * 42 *
43 * \return 0 on success otherwise POSIX Error code 43 * \return 0 on success otherwise POSIX Error code
44*/ 44*/
45static int amdgpu_cs_create_ib(amdgpu_context_handle context, 45int amdgpu_cs_alloc_ib(amdgpu_context_handle context,
46 enum amdgpu_cs_ib_size ib_size, 46 enum amdgpu_cs_ib_size ib_size,
47 amdgpu_ib_handle *ib) 47 struct amdgpu_cs_ib_alloc_result *output)
48{ 48{
49 struct amdgpu_bo_alloc_request alloc_buffer; 49 struct amdgpu_bo_alloc_request alloc_buffer = {};
50 struct amdgpu_bo_alloc_result info; 50 struct amdgpu_bo_alloc_result info;
51 int r; 51 int r;
52 void *cpu; 52 void *cpu;
53 struct amdgpu_ib *new_ib;
54 53
55 memset(&alloc_buffer, 0, sizeof(alloc_buffer)); 54 if (NULL == context)
55 return -EINVAL;
56 if (NULL == output)
57 return -EINVAL;
58 if (ib_size >= AMDGPU_CS_IB_SIZE_NUM)
59 return -EINVAL;
56 60
57 switch (ib_size) { 61 switch (ib_size) {
58 case amdgpu_cs_ib_size_4K: 62 case amdgpu_cs_ib_size_4K:
@@ -89,18 +93,9 @@ static int amdgpu_cs_create_ib(amdgpu_context_handle context,
89 return r; 93 return r;
90 } 94 }
91 95
92 new_ib = malloc(sizeof(struct amdgpu_ib)); 96 output->handle = info.buf_handle;
93 if (NULL == new_ib) { 97 output->cpu = cpu;
94 amdgpu_bo_cpu_unmap(info.buf_handle); 98 output->mc_address = info.virtual_mc_base_address;
95 amdgpu_bo_free(info.buf_handle);
96 return -ENOMEM;
97 }
98
99 new_ib->context = context;
100 new_ib->buf_handle = info.buf_handle;
101 new_ib->cpu = cpu;
102 new_ib->virtual_mc_base_address = info.virtual_mc_base_address;
103 *ib = new_ib;
104 return 0; 99 return 0;
105} 100}
106 101
@@ -111,47 +106,18 @@ static int amdgpu_cs_create_ib(amdgpu_context_handle context,
111 * 106 *
112 * \return 0 on success otherwise POSIX Error code 107 * \return 0 on success otherwise POSIX Error code
113*/ 108*/
114int amdgpu_cs_free_ib(amdgpu_ib_handle ib) 109int amdgpu_cs_free_ib(amdgpu_bo_handle bo)
115{ 110{
116 int r; 111 int r;
117 112
118 if (!ib) 113 if (!bo)
119 return -EINVAL; 114 return -EINVAL;
120 115
121 r = amdgpu_bo_cpu_unmap(ib->buf_handle); 116 r = amdgpu_bo_cpu_unmap(bo);
122 if (r) 117 if (r)
123 return r; 118 return r;
124 119
125 r = amdgpu_bo_free(ib->buf_handle); 120 return amdgpu_bo_free(bo);
126 if (r)
127 return r;
128
129 free(ib);
130 return 0;
131}
132
133int amdgpu_cs_alloc_ib(amdgpu_context_handle context,
134 enum amdgpu_cs_ib_size ib_size,
135 struct amdgpu_cs_ib_alloc_result *output)
136{
137 int r;
138 amdgpu_ib_handle ib;
139
140 if (NULL == context)
141 return -EINVAL;
142 if (NULL == output)
143 return -EINVAL;
144 if (ib_size >= AMDGPU_CS_IB_SIZE_NUM)
145 return -EINVAL;
146
147 r = amdgpu_cs_create_ib(context, ib_size, &ib);
148 if (!r) {
149 output->handle = ib;
150 output->cpu = ib->cpu;
151 output->mc_address = ib->virtual_mc_base_address;
152 }
153
154 return r;
155} 121}
156 122
157/** 123/**
@@ -346,8 +312,8 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
346 312
347 ib = &ibs_request->ibs[i]; 313 ib = &ibs_request->ibs[i];
348 314
349 chunk_data[i].ib_data.handle = ib->ib_handle->buf_handle->handle; 315 chunk_data[i].ib_data.handle = ib->bo_handle->handle;
350 chunk_data[i].ib_data.va_start = ib->ib_handle->virtual_mc_base_address 316 chunk_data[i].ib_data.va_start = ib->bo_handle->virtual_mc_base_address
351 + ib->offset_dw * 4; 317 + ib->offset_dw * 4;
352 chunk_data[i].ib_data.ib_bytes = ib->size * 4; 318 chunk_data[i].ib_data.ib_bytes = ib->size * 4;
353 chunk_data[i].ib_data.ip_type = ibs_request->ip_type; 319 chunk_data[i].ib_data.ip_type = ibs_request->ip_type;
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index a4c29894..ee1cb61c 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -111,13 +111,6 @@ struct amdgpu_context {
111 uint32_t id; 111 uint32_t id;
112}; 112};
113 113
114struct amdgpu_ib {
115 amdgpu_context_handle context;
116 amdgpu_bo_handle buf_handle;
117 void *cpu;
118 uint64_t virtual_mc_base_address;
119};
120
121/** 114/**
122 * Functions. 115 * Functions.
123 */ 116 */