diff options
author | Dave Airlie <airlied@redhat.com> | 2015-12-23 17:08:47 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2015-12-23 17:08:47 -0500 |
commit | 20f8e032e6dc7053ab803f488e2a8839cd2f69a6 (patch) | |
tree | 406b662934bffa205d90e9435bf96af7dc1a0cb0 /drivers/gpu/drm/amd/amdgpu | |
parent | ade1ba7346070709856d7e38f8d1a77b7aa710aa (diff) | |
parent | 5b726e06d6e8309e5c9ef4109a32caf27c71dfc8 (diff) |
Backmerge drm-fixes merge into Linus's tree into drm-next.
This merges '5b726e06d6e8309e5c9ef4109a32caf27c71dfc8' into drm-next
Just to resolve some merges to make Daniel's life easier.
Signed-off-by: DAve Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 63 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 |
3 files changed, 52 insertions, 22 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index fca4ef78589c..003959f99251 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1266,7 +1266,8 @@ struct amdgpu_cs_parser { | |||
1266 | struct ww_acquire_ctx ticket; | 1266 | struct ww_acquire_ctx ticket; |
1267 | 1267 | ||
1268 | /* user fence */ | 1268 | /* user fence */ |
1269 | struct amdgpu_user_fence uf; | 1269 | struct amdgpu_user_fence uf; |
1270 | struct amdgpu_bo_list_entry uf_entry; | ||
1270 | }; | 1271 | }; |
1271 | 1272 | ||
1272 | struct amdgpu_job { | 1273 | struct amdgpu_job { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index fa0e3276e8da..ce0254d4dcd7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -127,6 +127,37 @@ int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, | |||
127 | return 0; | 127 | return 0; |
128 | } | 128 | } |
129 | 129 | ||
130 | static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, | ||
131 | struct drm_amdgpu_cs_chunk_fence *fence_data) | ||
132 | { | ||
133 | struct drm_gem_object *gobj; | ||
134 | uint32_t handle; | ||
135 | |||
136 | handle = fence_data->handle; | ||
137 | gobj = drm_gem_object_lookup(p->adev->ddev, p->filp, | ||
138 | fence_data->handle); | ||
139 | if (gobj == NULL) | ||
140 | return -EINVAL; | ||
141 | |||
142 | p->uf.bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); | ||
143 | p->uf.offset = fence_data->offset; | ||
144 | |||
145 | if (amdgpu_ttm_tt_has_userptr(p->uf.bo->tbo.ttm)) { | ||
146 | drm_gem_object_unreference_unlocked(gobj); | ||
147 | return -EINVAL; | ||
148 | } | ||
149 | |||
150 | p->uf_entry.robj = amdgpu_bo_ref(p->uf.bo); | ||
151 | p->uf_entry.prefered_domains = AMDGPU_GEM_DOMAIN_GTT; | ||
152 | p->uf_entry.allowed_domains = AMDGPU_GEM_DOMAIN_GTT; | ||
153 | p->uf_entry.priority = 0; | ||
154 | p->uf_entry.tv.bo = &p->uf_entry.robj->tbo; | ||
155 | p->uf_entry.tv.shared = true; | ||
156 | |||
157 | drm_gem_object_unreference_unlocked(gobj); | ||
158 | return 0; | ||
159 | } | ||
160 | |||
130 | int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) | 161 | int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) |
131 | { | 162 | { |
132 | union drm_amdgpu_cs *cs = data; | 163 | union drm_amdgpu_cs *cs = data; |
@@ -207,28 +238,15 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) | |||
207 | 238 | ||
208 | case AMDGPU_CHUNK_ID_FENCE: | 239 | case AMDGPU_CHUNK_ID_FENCE: |
209 | size = sizeof(struct drm_amdgpu_cs_chunk_fence); | 240 | size = sizeof(struct drm_amdgpu_cs_chunk_fence); |
210 | if (p->chunks[i].length_dw * sizeof(uint32_t) >= size) { | 241 | if (p->chunks[i].length_dw * sizeof(uint32_t) < size) { |
211 | uint32_t handle; | ||
212 | struct drm_gem_object *gobj; | ||
213 | struct drm_amdgpu_cs_chunk_fence *fence_data; | ||
214 | |||
215 | fence_data = (void *)p->chunks[i].kdata; | ||
216 | handle = fence_data->handle; | ||
217 | gobj = drm_gem_object_lookup(p->adev->ddev, | ||
218 | p->filp, handle); | ||
219 | if (gobj == NULL) { | ||
220 | ret = -EINVAL; | ||
221 | goto free_partial_kdata; | ||
222 | } | ||
223 | |||
224 | p->uf.bo = gem_to_amdgpu_bo(gobj); | ||
225 | amdgpu_bo_ref(p->uf.bo); | ||
226 | drm_gem_object_unreference_unlocked(gobj); | ||
227 | p->uf.offset = fence_data->offset; | ||
228 | } else { | ||
229 | ret = -EINVAL; | 242 | ret = -EINVAL; |
230 | goto free_partial_kdata; | 243 | goto free_partial_kdata; |
231 | } | 244 | } |
245 | |||
246 | ret = amdgpu_cs_user_fence_chunk(p, (void *)p->chunks[i].kdata); | ||
247 | if (ret) | ||
248 | goto free_partial_kdata; | ||
249 | |||
232 | break; | 250 | break; |
233 | 251 | ||
234 | case AMDGPU_CHUNK_ID_DEPENDENCIES: | 252 | case AMDGPU_CHUNK_ID_DEPENDENCIES: |
@@ -391,6 +409,9 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p) | |||
391 | INIT_LIST_HEAD(&duplicates); | 409 | INIT_LIST_HEAD(&duplicates); |
392 | amdgpu_vm_get_pd_bo(&fpriv->vm, &p->validated, &p->vm_pd); | 410 | amdgpu_vm_get_pd_bo(&fpriv->vm, &p->validated, &p->vm_pd); |
393 | 411 | ||
412 | if (p->uf.bo) | ||
413 | list_add(&p->uf_entry.tv.head, &p->validated); | ||
414 | |||
394 | if (need_mmap_lock) | 415 | if (need_mmap_lock) |
395 | down_read(¤t->mm->mmap_sem); | 416 | down_read(¤t->mm->mmap_sem); |
396 | 417 | ||
@@ -488,8 +509,8 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bo | |||
488 | for (i = 0; i < parser->num_ibs; i++) | 509 | for (i = 0; i < parser->num_ibs; i++) |
489 | amdgpu_ib_free(parser->adev, &parser->ibs[i]); | 510 | amdgpu_ib_free(parser->adev, &parser->ibs[i]); |
490 | kfree(parser->ibs); | 511 | kfree(parser->ibs); |
491 | if (parser->uf.bo) | 512 | amdgpu_bo_unref(&parser->uf.bo); |
492 | amdgpu_bo_unref(&parser->uf.bo); | 513 | amdgpu_bo_unref(&parser->uf_entry.robj); |
493 | } | 514 | } |
494 | 515 | ||
495 | static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p, | 516 | static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 6d136b260bb3..7380f782cd14 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |||
@@ -476,6 +476,14 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, | |||
476 | if (domain == AMDGPU_GEM_DOMAIN_CPU) | 476 | if (domain == AMDGPU_GEM_DOMAIN_CPU) |
477 | goto error_unreserve; | 477 | goto error_unreserve; |
478 | } | 478 | } |
479 | list_for_each_entry(entry, &duplicates, head) { | ||
480 | domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); | ||
481 | /* if anything is swapped out don't swap it in here, | ||
482 | just abort and wait for the next CS */ | ||
483 | if (domain == AMDGPU_GEM_DOMAIN_CPU) | ||
484 | goto error_unreserve; | ||
485 | } | ||
486 | |||
479 | r = amdgpu_vm_update_page_directory(adev, bo_va->vm); | 487 | r = amdgpu_vm_update_page_directory(adev, bo_va->vm); |
480 | if (r) | 488 | if (r) |
481 | goto error_unreserve; | 489 | goto error_unreserve; |