aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index c1c407f7cca3..a753598a5e35 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -655,31 +655,52 @@ retry_pre_get:
655 return 0; 655 return 0;
656} 656}
657 657
658static uint32_t ttm_bo_select_caching(struct ttm_mem_type_manager *man,
659 uint32_t cur_placement,
660 uint32_t proposed_placement)
661{
662 uint32_t caching = proposed_placement & TTM_PL_MASK_CACHING;
663 uint32_t result = proposed_placement & ~TTM_PL_MASK_CACHING;
664
665 /**
666 * Keep current caching if possible.
667 */
668
669 if ((cur_placement & caching) != 0)
670 result |= (cur_placement & caching);
671 else if ((man->default_caching & caching) != 0)
672 result |= man->default_caching;
673 else if ((TTM_PL_FLAG_CACHED & caching) != 0)
674 result |= TTM_PL_FLAG_CACHED;
675 else if ((TTM_PL_FLAG_WC & caching) != 0)
676 result |= TTM_PL_FLAG_WC;
677 else if ((TTM_PL_FLAG_UNCACHED & caching) != 0)
678 result |= TTM_PL_FLAG_UNCACHED;
679
680 return result;
681}
682
683
658static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man, 684static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man,
659 bool disallow_fixed, 685 bool disallow_fixed,
660 uint32_t mem_type, 686 uint32_t mem_type,
661 uint32_t mask, uint32_t *res_mask) 687 uint32_t proposed_placement,
688 uint32_t *masked_placement)
662{ 689{
663 uint32_t cur_flags = ttm_bo_type_flags(mem_type); 690 uint32_t cur_flags = ttm_bo_type_flags(mem_type);
664 691
665 if ((man->flags & TTM_MEMTYPE_FLAG_FIXED) && disallow_fixed) 692 if ((man->flags & TTM_MEMTYPE_FLAG_FIXED) && disallow_fixed)
666 return false; 693 return false;
667 694
668 if ((cur_flags & mask & TTM_PL_MASK_MEM) == 0) 695 if ((cur_flags & proposed_placement & TTM_PL_MASK_MEM) == 0)
669 return false; 696 return false;
670 697
671 if ((mask & man->available_caching) == 0) 698 if ((proposed_placement & man->available_caching) == 0)
672 return false; 699 return false;
673 if (mask & man->default_caching)
674 cur_flags |= man->default_caching;
675 else if (mask & TTM_PL_FLAG_CACHED)
676 cur_flags |= TTM_PL_FLAG_CACHED;
677 else if (mask & TTM_PL_FLAG_WC)
678 cur_flags |= TTM_PL_FLAG_WC;
679 else
680 cur_flags |= TTM_PL_FLAG_UNCACHED;
681 700
682 *res_mask = cur_flags; 701 cur_flags |= (proposed_placement & man->available_caching);
702
703 *masked_placement = cur_flags;
683 return true; 704 return true;
684} 705}
685 706
@@ -723,6 +744,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
723 if (!type_ok) 744 if (!type_ok)
724 continue; 745 continue;
725 746
747 cur_flags = ttm_bo_select_caching(man, bo->mem.placement,
748 cur_flags);
749
726 if (mem_type == TTM_PL_SYSTEM) 750 if (mem_type == TTM_PL_SYSTEM)
727 break; 751 break;
728 752
@@ -779,6 +803,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
779 proposed_placement, &cur_flags)) 803 proposed_placement, &cur_flags))
780 continue; 804 continue;
781 805
806 cur_flags = ttm_bo_select_caching(man, bo->mem.placement,
807 cur_flags);
808
782 ret = ttm_bo_mem_force_space(bdev, mem, mem_type, 809 ret = ttm_bo_mem_force_space(bdev, mem, mem_type,
783 interruptible, no_wait); 810 interruptible, no_wait);
784 811