]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdgpu: add helper to convert a ttm bo to amdgpu_bo
authorAndres Rodriguez <andresx7@gmail.com>
Sat, 16 Sep 2017 01:05:19 +0000 (21:05 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 9 Oct 2017 20:30:19 +0000 (16:30 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 6982baeccd1491737b027a33a6e77364b0811e8f..8b4ed8a98a18f9393f1edb9e7ea3b13eb53489fe 100644 (file)
@@ -40,9 +40,7 @@
 static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 {
        struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
-       struct amdgpu_bo *bo;
-
-       bo = container_of(tbo, struct amdgpu_bo, tbo);
+       struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo);
 
        amdgpu_bo_kunmap(bo);
 
@@ -884,7 +882,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
        if (!amdgpu_ttm_bo_is_amdgpu_bo(bo))
                return;
 
-       abo = container_of(bo, struct amdgpu_bo, tbo);
+       abo = ttm_to_amdgpu_bo(bo);
        amdgpu_vm_bo_invalidate(adev, abo, evict);
 
        amdgpu_bo_kunmap(abo);
@@ -911,7 +909,7 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
        if (!amdgpu_ttm_bo_is_amdgpu_bo(bo))
                return 0;
 
-       abo = container_of(bo, struct amdgpu_bo, tbo);
+       abo = ttm_to_amdgpu_bo(bo);
 
        /* Remember that this BO was accessed by the CPU */
        abo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
index 39b6bf6fb051fe2ee890f06d6a1066e9db4f58c2..c26ef53604af5166f0082a7f4745236af414b499 100644 (file)
@@ -94,6 +94,11 @@ struct amdgpu_bo {
        };
 };
 
+static inline struct amdgpu_bo *ttm_to_amdgpu_bo(struct ttm_buffer_object *tbo)
+{
+       return container_of(tbo, struct amdgpu_bo, tbo);
+}
+
 /**
  * amdgpu_mem_type_to_domain - return domain corresponding to mem_type
  * @mem_type:  ttm memory type
index 1f68a146e26c00d7a663f9065dd7bb1218f25b75..10952c3e5eb6dcc73b0e9c4859240c890de6ba9b 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/debugfs.h>
 #include <linux/iommu.h>
 #include "amdgpu.h"
+#include "amdgpu_object.h"
 #include "amdgpu_trace.h"
 #include "bif/bif_4_1_d.h"
 
@@ -209,7 +210,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
                placement->num_busy_placement = 1;
                return;
        }
-       abo = container_of(bo, struct amdgpu_bo, tbo);
+       abo = ttm_to_amdgpu_bo(bo);
        switch (bo->mem.mem_type) {
        case TTM_PL_VRAM:
                if (adev->mman.buffer_funcs &&
@@ -257,7 +258,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
 
 static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp)
 {
-       struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo);
+       struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
 
        if (amdgpu_ttm_tt_get_usermm(bo->ttm))
                return -EPERM;
@@ -484,7 +485,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo,
        int r;
 
        /* Can't move a pinned BO */
-       abo = container_of(bo, struct amdgpu_bo, tbo);
+       abo = ttm_to_amdgpu_bo(bo);
        if (WARN_ON_ONCE(abo->pin_count > 0))
                return -EINVAL;
 
@@ -1142,7 +1143,7 @@ static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo,
                                    unsigned long offset,
                                    void *buf, int len, int write)
 {
-       struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo);
+       struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
        struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
        struct drm_mm_node *nodes = abo->tbo.mem.mm_node;
        uint32_t value = 0;