aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndres Rodriguez <andresx7@gmail.com>2017-09-15 21:05:19 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-10-09 16:30:19 -0400
commitb82485fd384a56c27fae44e649552eca6334237a (patch)
treee76d630f2fe71fa5a435f7abb0e45f0ac005ba7e /drivers
parent9fc8fc709b356c85034cbcb3b84c9d8b77865f52 (diff)
drm/amdgpu: add helper to convert a ttm bo to amdgpu_bo
Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Andres Rodriguez <andresx7@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.h5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c9
3 files changed, 13 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 6982baeccd14..8b4ed8a98a18 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -40,9 +40,7 @@
40static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) 40static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
41{ 41{
42 struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); 42 struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
43 struct amdgpu_bo *bo; 43 struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo);
44
45 bo = container_of(tbo, struct amdgpu_bo, tbo);
46 44
47 amdgpu_bo_kunmap(bo); 45 amdgpu_bo_kunmap(bo);
48 46
@@ -884,7 +882,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
884 if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) 882 if (!amdgpu_ttm_bo_is_amdgpu_bo(bo))
885 return; 883 return;
886 884
887 abo = container_of(bo, struct amdgpu_bo, tbo); 885 abo = ttm_to_amdgpu_bo(bo);
888 amdgpu_vm_bo_invalidate(adev, abo, evict); 886 amdgpu_vm_bo_invalidate(adev, abo, evict);
889 887
890 amdgpu_bo_kunmap(abo); 888 amdgpu_bo_kunmap(abo);
@@ -911,7 +909,7 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
911 if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) 909 if (!amdgpu_ttm_bo_is_amdgpu_bo(bo))
912 return 0; 910 return 0;
913 911
914 abo = container_of(bo, struct amdgpu_bo, tbo); 912 abo = ttm_to_amdgpu_bo(bo);
915 913
916 /* Remember that this BO was accessed by the CPU */ 914 /* Remember that this BO was accessed by the CPU */
917 abo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; 915 abo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 39b6bf6fb051..c26ef53604af 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -94,6 +94,11 @@ struct amdgpu_bo {
94 }; 94 };
95}; 95};
96 96
97static inline struct amdgpu_bo *ttm_to_amdgpu_bo(struct ttm_buffer_object *tbo)
98{
99 return container_of(tbo, struct amdgpu_bo, tbo);
100}
101
97/** 102/**
98 * amdgpu_mem_type_to_domain - return domain corresponding to mem_type 103 * amdgpu_mem_type_to_domain - return domain corresponding to mem_type
99 * @mem_type: ttm memory type 104 * @mem_type: ttm memory type
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 1f68a146e26c..10952c3e5eb6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -44,6 +44,7 @@
44#include <linux/debugfs.h> 44#include <linux/debugfs.h>
45#include <linux/iommu.h> 45#include <linux/iommu.h>
46#include "amdgpu.h" 46#include "amdgpu.h"
47#include "amdgpu_object.h"
47#include "amdgpu_trace.h" 48#include "amdgpu_trace.h"
48#include "bif/bif_4_1_d.h" 49#include "bif/bif_4_1_d.h"
49 50
@@ -209,7 +210,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
209 placement->num_busy_placement = 1; 210 placement->num_busy_placement = 1;
210 return; 211 return;
211 } 212 }
212 abo = container_of(bo, struct amdgpu_bo, tbo); 213 abo = ttm_to_amdgpu_bo(bo);
213 switch (bo->mem.mem_type) { 214 switch (bo->mem.mem_type) {
214 case TTM_PL_VRAM: 215 case TTM_PL_VRAM:
215 if (adev->mman.buffer_funcs && 216 if (adev->mman.buffer_funcs &&
@@ -257,7 +258,7 @@ gtt:
257 258
258static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp) 259static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp)
259{ 260{
260 struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo); 261 struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
261 262
262 if (amdgpu_ttm_tt_get_usermm(bo->ttm)) 263 if (amdgpu_ttm_tt_get_usermm(bo->ttm))
263 return -EPERM; 264 return -EPERM;
@@ -484,7 +485,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo,
484 int r; 485 int r;
485 486
486 /* Can't move a pinned BO */ 487 /* Can't move a pinned BO */
487 abo = container_of(bo, struct amdgpu_bo, tbo); 488 abo = ttm_to_amdgpu_bo(bo);
488 if (WARN_ON_ONCE(abo->pin_count > 0)) 489 if (WARN_ON_ONCE(abo->pin_count > 0))
489 return -EINVAL; 490 return -EINVAL;
490 491
@@ -1142,7 +1143,7 @@ static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo,
1142 unsigned long offset, 1143 unsigned long offset,
1143 void *buf, int len, int write) 1144 void *buf, int len, int write)
1144{ 1145{
1145 struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo); 1146 struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
1146 struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev); 1147 struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
1147 struct drm_mm_node *nodes = abo->tbo.mem.mm_node; 1148 struct drm_mm_node *nodes = abo->tbo.mem.mm_node;
1148 uint32_t value = 0; 1149 uint32_t value = 0;