drm/radeon: don't use ttm bo->offset
authorNirmoy Das <nirmoy.aiemd@gmail.com>
Wed, 24 Jun 2020 18:26:42 +0000 (20:26 +0200)
committerChristian König <christian.koenig@amd.com>
Thu, 25 Jun 2020 09:58:49 +0000 (11:58 +0200)
Calculate GPU offset in radeon_bo_gpu_offset without depending on
bo->offset.

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
Reviewed-and-tested-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/372935/
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_object.h
drivers/gpu/drm/radeon/radeon_ttm.c

index 30e32adc1fc666287e9dedd2fc030d9024558b90..b7c3fb2bfb547ffd2b64c3a9560432bc9eace6c7 100644 (file)
@@ -2828,6 +2828,7 @@ extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size
 extern void radeon_program_register_sequence(struct radeon_device *rdev,
                                             const u32 *registers,
                                             const u32 array_size);
+struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev);
 
 /*
  * vm
index d23f2ed4126ee37ca9ff2b614078bebfacd78428..60275b822f79e322f0d95150962e0d349c3a7449 100644 (file)
@@ -90,7 +90,21 @@ static inline void radeon_bo_unreserve(struct radeon_bo *bo)
  */
 static inline u64 radeon_bo_gpu_offset(struct radeon_bo *bo)
 {
-       return bo->tbo.offset;
+       struct radeon_device *rdev;
+       u64 start = 0;
+
+       rdev = radeon_get_rdev(bo->tbo.bdev);
+
+       switch (bo->tbo.mem.mem_type) {
+       case TTM_PL_TT:
+               start = rdev->mc.gtt_start;
+               break;
+       case TTM_PL_VRAM:
+               start = rdev->mc.vram_start;
+               break;
+       }
+
+       return (bo->tbo.mem.start << PAGE_SHIFT) + start;
 }
 
 static inline unsigned long radeon_bo_size(struct radeon_bo *bo)
index 5d50c9edbe806a318b5309608d4c853e0514b896..357e8e98cca96e9f1cc1a070b4c022bd2782689b 100644 (file)
@@ -56,7 +56,7 @@
 static int radeon_ttm_debugfs_init(struct radeon_device *rdev);
 static void radeon_ttm_debugfs_fini(struct radeon_device *rdev);
 
-static struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
+struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
 {
        struct radeon_mman *mman;
        struct radeon_device *rdev;
@@ -82,7 +82,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
                break;
        case TTM_PL_TT:
                man->func = &ttm_bo_manager_func;
-               man->gpu_offset = rdev->mc.gtt_start;
                man->available_caching = TTM_PL_MASK_CACHING;
                man->default_caching = TTM_PL_FLAG_CACHED;
                man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
@@ -104,7 +103,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
        case TTM_PL_VRAM:
                /* "On-card" video ram */
                man->func = &ttm_bo_manager_func;
-               man->gpu_offset = rdev->mc.vram_start;
                man->flags = TTM_MEMTYPE_FLAG_FIXED |
                             TTM_MEMTYPE_FLAG_MAPPABLE;
                man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;