aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_bo.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-15 00:19:54 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-15 00:19:54 -0500
commit049ffa8ab33a63b3bff672d1a0ee6a35ad253fe8 (patch)
tree70f4c684818b1c9871fa800088427e40d260592e /drivers/gpu/drm/ttm/ttm_bo.c
parentc681427e5ca22925fcc1be76a2e260a11e0a8498 (diff)
parent0846c728e20a0cd1e43fb75a3015f3b176a26466 (diff)
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm updates from Dave Airlie: "This is a combo of -next and some -fixes that came in in the intervening time. Highlights: New drivers: ARM Armada driver for Marvell Armada 510 SOCs Intel: Broadwell initial support under a default off switch, Stereo/3D HDMI mode support Valleyview improvements Displayport improvements Haswell fixes initial mipi dsi panel support CRC support for debugging build with CONFIG_FB=n Radeon: enable DPM on a number of GPUs by default secondary GPU powerdown support enable HDMI audio by default Hawaii support Nouveau: dynamic pm code infrastructure reworked, does nothing major yet GK208 modesetting support MSI fixes, on by default again PMPEG improvements pageflipping fixes GMA500: minnowboard SDVO support VMware: misc fixes MSM: prime, plane and rendernodes support Tegra: rearchitected to put the drm driver into the drm subsystem. HDMI and gr2d support for tegra 114 SoC QXL: oops fix, and multi-head fixes DRM core: sysfs lifetime fixes client capability ioctl further cleanups to device midlayer more vblank timestamp fixes" * 'drm-next' of git://people.freedesktop.org/~airlied/linux: (789 commits) drm/nouveau: do not map evicted vram buffers in nouveau_bo_vma_add drm/nvc0-/gr: shift wrapping bug in nvc0_grctx_generate_r406800 drm/nouveau/pwr: fix missing mutex unlock in a failure path drm/nv40/therm: fix slowing down fan when pstate undefined drm/nv11-: synchronise flips to vblank, unless async flip requested drm/nvc0-: remove nasty fifo swmthd hack for flip completion method drm/nv10-: we no longer need to create nvsw object on user channels drm/nouveau: always queue flips relative to kernel channel activity drm/nouveau: there is no need to reserve/fence the new fb when flipping drm/nouveau: when bailing out of a pushbuf ioctl, do not remove previous fence drm/nouveau: allow nouveau_fence_ref() to be a noop drm/nvc8/mc: msi rearm is via the nvc0 method drm/ttm: Fix vma page_prot bit manipulation drm/vmwgfx: Fix a couple of compile / sparse warnings and errors drm/vmwgfx: Resource evict fixes drm/edid: compare actual vrefresh for all modes for quirks drm: shmob_drm: Convert to clk_prepare/unprepare drm/nouveau: fix 32-bit build drm/i915/opregion: fix build error on CONFIG_ACPI=n Revert "drm/radeon/audio: don't set speaker allocation on DCE4+" ...
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index f1a857ec1021..8d5a646ebe6a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -429,8 +429,20 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
429 sync_obj = driver->sync_obj_ref(bo->sync_obj); 429 sync_obj = driver->sync_obj_ref(bo->sync_obj);
430 spin_unlock(&bdev->fence_lock); 430 spin_unlock(&bdev->fence_lock);
431 431
432 if (!ret) 432 if (!ret) {
433
434 /*
435 * Make NO_EVICT bos immediately available to
436 * shrinkers, now that they are queued for
437 * destruction.
438 */
439 if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
440 bo->mem.placement &= ~TTM_PL_FLAG_NO_EVICT;
441 ttm_bo_add_to_lru(bo);
442 }
443
433 ww_mutex_unlock(&bo->resv->lock); 444 ww_mutex_unlock(&bo->resv->lock);
445 }
434 446
435 kref_get(&bo->list_kref); 447 kref_get(&bo->list_kref);
436 list_add_tail(&bo->ddestroy, &bdev->ddestroy); 448 list_add_tail(&bo->ddestroy, &bdev->ddestroy);
@@ -986,24 +998,32 @@ out_unlock:
986 return ret; 998 return ret;
987} 999}
988 1000
989static int ttm_bo_mem_compat(struct ttm_placement *placement, 1001static bool ttm_bo_mem_compat(struct ttm_placement *placement,
990 struct ttm_mem_reg *mem) 1002 struct ttm_mem_reg *mem,
1003 uint32_t *new_flags)
991{ 1004{
992 int i; 1005 int i;
993 1006
994 if (mem->mm_node && placement->lpfn != 0 && 1007 if (mem->mm_node && placement->lpfn != 0 &&
995 (mem->start < placement->fpfn || 1008 (mem->start < placement->fpfn ||
996 mem->start + mem->num_pages > placement->lpfn)) 1009 mem->start + mem->num_pages > placement->lpfn))
997 return -1; 1010 return false;
998 1011
999 for (i = 0; i < placement->num_placement; i++) { 1012 for (i = 0; i < placement->num_placement; i++) {
1000 if ((placement->placement[i] & mem->placement & 1013 *new_flags = placement->placement[i];
1001 TTM_PL_MASK_CACHING) && 1014 if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
1002 (placement->placement[i] & mem->placement & 1015 (*new_flags & mem->placement & TTM_PL_MASK_MEM))
1003 TTM_PL_MASK_MEM)) 1016 return true;
1004 return i;
1005 } 1017 }
1006 return -1; 1018
1019 for (i = 0; i < placement->num_busy_placement; i++) {
1020 *new_flags = placement->busy_placement[i];
1021 if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
1022 (*new_flags & mem->placement & TTM_PL_MASK_MEM))
1023 return true;
1024 }
1025
1026 return false;
1007} 1027}
1008 1028
1009int ttm_bo_validate(struct ttm_buffer_object *bo, 1029int ttm_bo_validate(struct ttm_buffer_object *bo,
@@ -1012,6 +1032,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
1012 bool no_wait_gpu) 1032 bool no_wait_gpu)
1013{ 1033{
1014 int ret; 1034 int ret;
1035 uint32_t new_flags;
1015 1036
1016 lockdep_assert_held(&bo->resv->lock.base); 1037 lockdep_assert_held(&bo->resv->lock.base);
1017 /* Check that range is valid */ 1038 /* Check that range is valid */
@@ -1022,8 +1043,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
1022 /* 1043 /*
1023 * Check whether we need to move buffer. 1044 * Check whether we need to move buffer.
1024 */ 1045 */
1025 ret = ttm_bo_mem_compat(placement, &bo->mem); 1046 if (!ttm_bo_mem_compat(placement, &bo->mem, &new_flags)) {
1026 if (ret < 0) {
1027 ret = ttm_bo_move_buffer(bo, placement, interruptible, 1047 ret = ttm_bo_move_buffer(bo, placement, interruptible,
1028 no_wait_gpu); 1048 no_wait_gpu);
1029 if (ret) 1049 if (ret)
@@ -1033,7 +1053,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
1033 * Use the access and other non-mapping-related flag bits from 1053 * Use the access and other non-mapping-related flag bits from
1034 * the compatible memory placement flags to the active flags 1054 * the compatible memory placement flags to the active flags
1035 */ 1055 */
1036 ttm_flag_masked(&bo->mem.placement, placement->placement[ret], 1056 ttm_flag_masked(&bo->mem.placement, new_flags,
1037 ~TTM_PL_MASK_MEMTYPE); 1057 ~TTM_PL_MASK_MEMTYPE);
1038 } 1058 }
1039 /* 1059 /*