drm/amdgpu: add helper to convert a ttm bo to amdgpu_bo
Subsystems (2)
PATCH 1/1 drm/amdgpu: add helper to convert a ttm bo to amdgpu_bo
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 +++----- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -5
@@ -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);
@@ -891,7 +889,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);
@@ -918,7 +916,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 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +5 -0
@@ -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
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -4
@@ -44,6 +44,7 @@#include <linux/pagemap.h> #include <linux/debugfs.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 ;
@@ -1172,7 +1173,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 ;
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170919031755.30726-1-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
This is a small cleanup patch from my initial naive attempt at extracting a TTM bo in amdgpu_sync_resv(). It didn't end up being useful in that specific case, but I thought I'd send it out anyways in case you find it useful.
Regards,
Andres
Quoted 97 lines · Andres Rodriguez
Signed-off-by Andres Rodriguez <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 +++----- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-5@@ -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);@@ -891,7 +889,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);@@ -918,7 +916,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 ;drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +5
-0@@ -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 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4
-3@@ -44,6 +44,7 @@#include <linux/pagemap.h> #include <linux/debugfs.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 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo, · line 1179
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-1@@ -1172,7 +1173,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 ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 0928825e-d0ce-b7bb-59b6-e93170495af0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
It actually looks like a valid cleanup to me.
Patch is Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.
Am 19.09.2017 um 05:20 schrieb Andres Rodriguez:
Quoted 104 lines
This is a small cleanup patch from my initial naive attempt at extracting a TTM bo in
amdgpu_sync_resv(). It didn't end up being useful in that specific case, but I thought I'd send it out anyways in case you find it useful.Regards,
AndresQuoted 97 lines · Andres Rodriguez
Signed-off-by Andres Rodriguez <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 +++----- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-3@@ -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); @@ -891,7 +889,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);drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-0+ abo =ttm_to_amdgpu_bo (bo);amdgpu_vm_bo_invalidate (adev, abo, evict);amdgpu_bo_kunmap (abo);@@ -918,7 +916,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 ;drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +4
-0@@ -94,6 +94,11 @@ struct amdgpu_bo { }; }; +static inline struct amdgpu_bo *ttm_to_amdgpu_bo(structttm_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 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-0@@ -44,6 +44,7 @@#include <linux/pagemap.h> #include <linux/debugfs.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; }drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-3- 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(structttm_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(structttm_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 ; @@ -1172,7 +1173,7 @@ static int amdgpu_ttm_access_memory(struct
ttm_buffer_object*bo,
unsigned long offset, void *buf, int len, int write)
{drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-1- struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo); +struct amdgpu_bo *abo =ttm_to_amdgpu_bo (bo);
Quoted 8 lines
Quoted 4 lines
struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev); struct drm_mm_node *nodes = abo->tbo.mem.mm_node; uint32_t value = 0;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx