diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2018-06-12 06:07:33 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-06-19 14:51:22 -0400 |
commit | 5e9244ff585239630f15f8ad8e676bc91a94ca9e (patch) | |
tree | 09c68e9128f2e0f221cf4105d75427e32772b9a6 | |
parent | 34d6d59986abb1d2cb5415a49b6c50f51ba1d2e4 (diff) |
drm/amdgpu: Refactor amdgpu_vram_mgr_bo_invisible_size helper
Preparation for the following fix, no functional change intended.
Cc: stable@vger.kernel.org
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 16 |
3 files changed, 19 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 026140f08ee9..3526efa8960e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -762,8 +762,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, | |||
762 | domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); | 762 | domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); |
763 | if (domain == AMDGPU_GEM_DOMAIN_VRAM) { | 763 | if (domain == AMDGPU_GEM_DOMAIN_VRAM) { |
764 | adev->vram_pin_size += amdgpu_bo_size(bo); | 764 | adev->vram_pin_size += amdgpu_bo_size(bo); |
765 | if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) | 765 | adev->invisible_pin_size += amdgpu_vram_mgr_bo_invisible_size(bo); |
766 | adev->invisible_pin_size += amdgpu_bo_size(bo); | ||
767 | } else if (domain == AMDGPU_GEM_DOMAIN_GTT) { | 766 | } else if (domain == AMDGPU_GEM_DOMAIN_GTT) { |
768 | adev->gart_pin_size += amdgpu_bo_size(bo); | 767 | adev->gart_pin_size += amdgpu_bo_size(bo); |
769 | } | 768 | } |
@@ -793,8 +792,7 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo) | |||
793 | 792 | ||
794 | if (bo->tbo.mem.mem_type == TTM_PL_VRAM) { | 793 | if (bo->tbo.mem.mem_type == TTM_PL_VRAM) { |
795 | adev->vram_pin_size -= amdgpu_bo_size(bo); | 794 | adev->vram_pin_size -= amdgpu_bo_size(bo); |
796 | if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) | 795 | adev->invisible_pin_size -= amdgpu_vram_mgr_bo_invisible_size(bo); |
797 | adev->invisible_pin_size -= amdgpu_bo_size(bo); | ||
798 | } else if (bo->tbo.mem.mem_type == TTM_PL_TT) { | 796 | } else if (bo->tbo.mem.mem_type == TTM_PL_TT) { |
799 | adev->gart_pin_size -= amdgpu_bo_size(bo); | 797 | adev->gart_pin_size -= amdgpu_bo_size(bo); |
800 | } | 798 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index e969c879d87e..e5da4654b630 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | |||
@@ -73,6 +73,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem); | |||
73 | uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man); | 73 | uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man); |
74 | int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man); | 74 | int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man); |
75 | 75 | ||
76 | u64 amdgpu_vram_mgr_bo_invisible_size(struct amdgpu_bo *bo); | ||
76 | uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man); | 77 | uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man); |
77 | uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man); | 78 | uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man); |
78 | 79 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 9c47e860e5e6..ae0049c6c52c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | |||
@@ -97,6 +97,22 @@ static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev, | |||
97 | } | 97 | } |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * amdgpu_vram_mgr_bo_invisible_size - CPU invisible BO size | ||
101 | * | ||
102 | * @bo: &amdgpu_bo buffer object (must be in VRAM) | ||
103 | * | ||
104 | * Returns: | ||
105 | * How much of the given &amdgpu_bo buffer object lies in CPU invisible VRAM. | ||
106 | */ | ||
107 | u64 amdgpu_vram_mgr_bo_invisible_size(struct amdgpu_bo *bo) | ||
108 | { | ||
109 | if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) | ||
110 | return amdgpu_bo_size(bo); | ||
111 | |||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | /** | ||
100 | * amdgpu_vram_mgr_new - allocate new ranges | 116 | * amdgpu_vram_mgr_new - allocate new ranges |
101 | * | 117 | * |
102 | * @man: TTM memory type manager | 118 | * @man: TTM memory type manager |