diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-05-02 12:48:26 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-05-02 12:48:26 -0400 |
commit | 0337966d121ebebf73a1c346123e8112796e684e (patch) | |
tree | c0d4388591e72dc5a26ee976a9cbca70f6bafbbd /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |
parent | 7c5bb4ac2b76d2a09256aec8a7d584bf3e2b0466 (diff) | |
parent | 8a038b83e012097a7ac6cfb9f6c5fac1da8fad6e (diff) |
Merge branch 'next' into for-linus
Prepare input updates for 4.12 merge window.
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index bf79b73e1538..be80a4a68d7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -323,6 +323,7 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | |||
323 | struct amdgpu_bo *bo; | 323 | struct amdgpu_bo *bo; |
324 | enum ttm_bo_type type; | 324 | enum ttm_bo_type type; |
325 | unsigned long page_align; | 325 | unsigned long page_align; |
326 | u64 initial_bytes_moved; | ||
326 | size_t acc_size; | 327 | size_t acc_size; |
327 | int r; | 328 | int r; |
328 | 329 | ||
@@ -363,11 +364,33 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | |||
363 | 364 | ||
364 | bo->flags = flags; | 365 | bo->flags = flags; |
365 | 366 | ||
367 | #ifdef CONFIG_X86_32 | ||
368 | /* XXX: Write-combined CPU mappings of GTT seem broken on 32-bit | ||
369 | * See https://bugs.freedesktop.org/show_bug.cgi?id=84627 | ||
370 | */ | ||
371 | bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; | ||
372 | #elif defined(CONFIG_X86) && !defined(CONFIG_X86_PAT) | ||
373 | /* Don't try to enable write-combining when it can't work, or things | ||
374 | * may be slow | ||
375 | * See https://bugs.freedesktop.org/show_bug.cgi?id=88758 | ||
376 | */ | ||
377 | |||
378 | #ifndef CONFIG_COMPILE_TEST | ||
379 | #warning Please enable CONFIG_MTRR and CONFIG_X86_PAT for better performance \ | ||
380 | thanks to write-combining | ||
381 | #endif | ||
382 | |||
383 | if (bo->flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) | ||
384 | DRM_INFO_ONCE("Please enable CONFIG_MTRR and CONFIG_X86_PAT for " | ||
385 | "better performance thanks to write-combining\n"); | ||
386 | bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; | ||
387 | #else | ||
366 | /* For architectures that don't support WC memory, | 388 | /* For architectures that don't support WC memory, |
367 | * mask out the WC flag from the BO | 389 | * mask out the WC flag from the BO |
368 | */ | 390 | */ |
369 | if (!drm_arch_can_wc_memory()) | 391 | if (!drm_arch_can_wc_memory()) |
370 | bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; | 392 | bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; |
393 | #endif | ||
371 | 394 | ||
372 | amdgpu_fill_placement_to_bo(bo, placement); | 395 | amdgpu_fill_placement_to_bo(bo, placement); |
373 | /* Kernel allocation are uninterruptible */ | 396 | /* Kernel allocation are uninterruptible */ |
@@ -379,12 +402,25 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | |||
379 | locked = ww_mutex_trylock(&bo->tbo.ttm_resv.lock); | 402 | locked = ww_mutex_trylock(&bo->tbo.ttm_resv.lock); |
380 | WARN_ON(!locked); | 403 | WARN_ON(!locked); |
381 | } | 404 | } |
405 | |||
406 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); | ||
382 | r = ttm_bo_init(&adev->mman.bdev, &bo->tbo, size, type, | 407 | r = ttm_bo_init(&adev->mman.bdev, &bo->tbo, size, type, |
383 | &bo->placement, page_align, !kernel, NULL, | 408 | &bo->placement, page_align, !kernel, NULL, |
384 | acc_size, sg, resv ? resv : &bo->tbo.ttm_resv, | 409 | acc_size, sg, resv ? resv : &bo->tbo.ttm_resv, |
385 | &amdgpu_ttm_bo_destroy); | 410 | &amdgpu_ttm_bo_destroy); |
386 | if (unlikely(r != 0)) | 411 | amdgpu_cs_report_moved_bytes(adev, |
412 | atomic64_read(&adev->num_bytes_moved) - initial_bytes_moved); | ||
413 | |||
414 | if (unlikely(r != 0)) { | ||
415 | if (!resv) | ||
416 | ww_mutex_unlock(&bo->tbo.resv->lock); | ||
387 | return r; | 417 | return r; |
418 | } | ||
419 | |||
420 | bo->tbo.priority = ilog2(bo->tbo.num_pages); | ||
421 | if (kernel) | ||
422 | bo->tbo.priority *= 2; | ||
423 | bo->tbo.priority = min(bo->tbo.priority, (unsigned)(TTM_MAX_BO_PRIORITY - 1)); | ||
388 | 424 | ||
389 | if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && | 425 | if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && |
390 | bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { | 426 | bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { |
@@ -408,7 +444,8 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | |||
408 | return 0; | 444 | return 0; |
409 | 445 | ||
410 | fail_unreserve: | 446 | fail_unreserve: |
411 | ww_mutex_unlock(&bo->tbo.resv->lock); | 447 | if (!resv) |
448 | ww_mutex_unlock(&bo->tbo.resv->lock); | ||
412 | amdgpu_bo_unref(&bo); | 449 | amdgpu_bo_unref(&bo); |
413 | return r; | 450 | return r; |
414 | } | 451 | } |
@@ -472,7 +509,16 @@ int amdgpu_bo_create(struct amdgpu_device *adev, | |||
472 | return r; | 509 | return r; |
473 | 510 | ||
474 | if (amdgpu_need_backup(adev) && (flags & AMDGPU_GEM_CREATE_SHADOW)) { | 511 | if (amdgpu_need_backup(adev) && (flags & AMDGPU_GEM_CREATE_SHADOW)) { |
512 | if (!resv) { | ||
513 | r = ww_mutex_lock(&(*bo_ptr)->tbo.resv->lock, NULL); | ||
514 | WARN_ON(r != 0); | ||
515 | } | ||
516 | |||
475 | r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr)); | 517 | r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr)); |
518 | |||
519 | if (!resv) | ||
520 | ww_mutex_unlock(&(*bo_ptr)->tbo.resv->lock); | ||
521 | |||
476 | if (r) | 522 | if (r) |
477 | amdgpu_bo_unref(bo_ptr); | 523 | amdgpu_bo_unref(bo_ptr); |
478 | } | 524 | } |
@@ -849,6 +895,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer, | |||
849 | } | 895 | } |
850 | 896 | ||
851 | void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, | 897 | void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, |
898 | bool evict, | ||
852 | struct ttm_mem_reg *new_mem) | 899 | struct ttm_mem_reg *new_mem) |
853 | { | 900 | { |
854 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); | 901 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); |
@@ -861,6 +908,10 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, | |||
861 | abo = container_of(bo, struct amdgpu_bo, tbo); | 908 | abo = container_of(bo, struct amdgpu_bo, tbo); |
862 | amdgpu_vm_bo_invalidate(adev, abo); | 909 | amdgpu_vm_bo_invalidate(adev, abo); |
863 | 910 | ||
911 | /* remember the eviction */ | ||
912 | if (evict) | ||
913 | atomic64_inc(&adev->num_evictions); | ||
914 | |||
864 | /* update statistics */ | 915 | /* update statistics */ |
865 | if (!new_mem) | 916 | if (!new_mem) |
866 | return; | 917 | return; |