drm/radeon: track pinned memory (v2)
Subsystems (2)
PATCH 1/4 drm/radeon: track pinned memory (v2)
So we know how large an allocation we can allow.
v2: incorporate Michel's comments
--- drivers/gpu/drm/radeon/radeon.h | 4 ++++ drivers/gpu/drm/radeon/radeon_object.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon.h +4 -0
@@ -2348,6 +2348,10 @@ struct radeon_device {struct dev_pm_domain vga_pm_domain;bool have_disp_power_ref; + +/* tracking pinned memory */ +u64 vram_pin_size; +u64 gart_pin_size; };bool radeon_is_px (struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_object.c +13 -3
@@ -306,9 +306,13 @@ int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset, bo->pin_count =1 ;if (gpu_addr !=NULL ) *gpu_addr =radeon_bo_gpu_offset (bo); - } -if (unlikely (r !=0 )) +if (domain ==RADEON_GEM_DOMAIN_VRAM ) + bo->rdev->vram_pin_size +=radeon_bo_size (bo); +else + bo->rdev->gart_pin_size +=radeon_bo_size (bo); + }else {dev_err (bo->rdev->dev,"%p pin failed\n" , bo); + }return r; }
@@ -331,8 +335,14 @@ int radeon_bo_unpin(struct radeon_bo *bo)for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT ; r =ttm_bo_validate (&bo->tbo, &bo->placement, false, false); -if (unlikely (r !=0 )) +if (likely (r ==0 )) { +if (bo->tbo.mem.mem_type ==TTM_PL_VRAM ) + bo->rdev->vram_pin_size -=radeon_bo_size (bo); +else + bo->rdev->gart_pin_size -=radeon_bo_size (bo); + }else {dev_err (bo->rdev->dev,"%p validate failed for unpin\n" , bo); + }return r; }
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/4 drm/radeon: use vram/gart pinned size in radeon_gem_info_ioctl
Gives a more accurate limit than the previous code.
--- drivers/gpu/drm/radeon/radeon_gem.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +4 -7
@@ -209,18 +209,15 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data,struct radeon_device *rdev = dev->dev_private;struct drm_radeon_gem_info *args = data;struct ttm_mem_type_manager *man; -unsigned i; man = &rdev->mman.bdev.man[TTM_PL_VRAM ]; args->vram_size = rdev->mc.real_vram_size; args->vram_visible = (u64 )man->size <<PAGE_SHIFT ; -if (rdev->stollen_vga_memory) - args->vram_visible -=radeon_bo_size (rdev->stollen_vga_memory); - args->vram_visible -=radeon_fbdev_total_size (rdev); - args->gart_size = rdev->mc.gtt_size -4096 -RADEON_IB_POOL_SIZE *64 *1024 ; -for (i =0 ; i <RADEON_NUM_RINGS ; ++i) - args->gart_size -= rdev->ring[i].ring_size; + args->vram_visible -= rdev->vram_pin_size; + args->gart_size = rdev->mc.gtt_size; + args->gart_size -= rdev->gart_pin_size; +return 0 ; }
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/4 drm/radeon: use vram/gart pinned size in radeon_do_test_moves
In reply to Alex DeucherGives more accurate count and prevents failures when we can't allocate memory for the tests.
--- drivers/gpu/drm/radeon/radeon_test.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/radeon/radeon_test.c +1 -7
@@ -56,13 +56,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)/* Number of tests = * (Total GTT - IB pool - writeback page - ring buffers) / test size */ - n = rdev->mc.gtt_size -RADEON_IB_POOL_SIZE *64 *1024 ; -for (i =0 ; i <RADEON_NUM_RINGS ; ++i) - n -= rdev->ring[i].ring_size; -if (rdev->wb.wb_obj) - n -=RADEON_GPU_PAGE_SIZE ; -if (rdev->ih.ring_obj) - n -= rdev->ih.ring_size; + n = rdev->mc.gtt_size - rdev->gart_pin_size; n /= size; gtt_obj =kzalloc (n *sizeof (*gtt_obj),GFP_KERNEL );
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/4 drm/radeon: remove visible vram size limit on bo allocation (v3)
In reply to Alex DeucherNow that fallback to gtt is fixed for cpu access, we can remove this limit.
bug:
https://bugs.freedesktop.org/show_bug.cgi?id=78717
v2: use new gart_pin_size to accurately track available gtt.
v3: fix comment
--- drivers/gpu/drm/radeon/radeon.h | 2 +- drivers/gpu/drm/radeon/radeon_gem.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -1
@@ -546,7 +546,7 @@ struct radeon_gem {int radeon_gem_init (struct radeon_device *rdev);void radeon_gem_fini (struct radeon_device *rdev); -int radeon_gem_object_create (struct radeon_device *rdev,int size, +int radeon_gem_object_create (struct radeon_device *rdev,unsigned long size,int alignment,int initial_domain,u32 flags,bool discardable,bool kernel,struct drm_gem_object **obj);
drivers/gpu/drm/radeon/radeon_gem.c +9 -5
@@ -40,7 +40,7 @@ void radeon_gem_object_free(struct drm_gem_object *gobj) } } -int radeon_gem_object_create (struct radeon_device *rdev,int size, +int radeon_gem_object_create (struct radeon_device *rdev,unsigned long size,int alignment,int initial_domain,u32 flags,bool discardable,bool kernel,struct drm_gem_object **obj)
@@ -55,10 +55,14 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size, alignment =PAGE_SIZE ; } -/* maximun bo size is the minimun btw visible vram and gtt size */ - max_size =min (rdev->mc.visible_vram_size, rdev->mc.gtt_size); +/* Maximum bo size is the unpinned gtt size since we use the gtt to +* handle vram to system pool migrations. We could probably remove +* this check altogether with a little additional work to support +* splitting vram <-> system transfers into multiple steps. +*/ + max_size = rdev->mc.gtt_size - rdev->gart_pin_size;if (size > max_size) { -DRM_DEBUG ("Allocation size %dMb bigger than %ldMb limit\n" , +DRM_DEBUG ("Allocation size %ldMb bigger than %ldMb limit\n" , size >>20 , max_size >>20 );return -ENOMEM ; }
@@ -72,7 +76,7 @@ retry: initial_domain |=RADEON_GEM_DOMAIN_GTT ; goto retry; } -DRM_ERROR ("Failed to allocate GEM object (%d, %d, %u, %d)\n" , +DRM_ERROR ("Failed to allocate GEM object (%ld, %d, %u, %d)\n" , size, initial_domain, alignment, r); }return r;
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/4] drm/radeon: remove visible vram size limit on bo allocation (v3)
Quoted 8 lines · Alex Deucher
Now that fallback to gtt is fixed for cpu access, we can remove this limit.
bug:
https://bugs.freedesktop.org/show_bug.cgi?id=78717v2: use new
gart_pin_sizeto accurately track available gtt.
v3: fix comment
[...]
drivers/gpu/drm/radeon/radeon_gem.c int radeon_gem_object_create(struct radeon_device *rdev, int size, · line 63
Quoted 12 lines
drivers/gpu/drm/radeon/radeon_gem.c +6
-2@@ -55,10 +55,14 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size, alignment =PAGE_SIZE ; } -/* maximun bo size is the minimun btw visible vram and gtt size */ - max_size =min (rdev->mc.visible_vram_size, rdev->mc.gtt_size); +/* Maximum bo size is the unpinned gtt size since we use the gtt to +* handle vram to system pool migrations. We could probably remove +* this check altogether with a little additional work to support +* splitting vram <-> system transfers into multiple steps. +*/ + max_size = rdev->mc.gtt_size - rdev->gart_pin_size;
Actually, the the check couldn't be removed even then, but would need to be replaced by a check against the VRAM size or something like that. Maybe just drop the second sentence of the comment?
Either way though, the series is
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/4] drm/radeon: remove visible vram size limit on bo allocation (v3)
Quoted 16 lines · Michel Dänzer
Quoted 8 lines · Alex Deucher
Now that fallback to gtt is fixed for cpu access, we can remove this limit.
bug:
https://bugs.freedesktop.org/show_bug.cgi?id=78717v2: use new
gart_pin_sizeto accurately track available gtt.
v3: fix comment[...]
Quoted 4 lines
drivers/gpu/drm/radeon/radeon_gem.c +0
-0@@ -55,10 +55,14 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size, alignment =PAGE_SIZE ; }
Quoted 12 lines
drivers/gpu/drm/radeon/radeon_gem.c int radeon_gem_object_create(struct radeon_device *rdev, int size, · line 63
Quoted 8 lines
drivers/gpu/drm/radeon/radeon_gem.c +6
-2-/* maximun bo size is the minimun btw visible vram and gtt size */ - max_size =min (rdev->mc.visible_vram_size, rdev->mc.gtt_size); +/* Maximum bo size is the unpinned gtt size since we use the gtt to +* handle vram to system pool migrations. We could probably remove +* this check altogether with a little additional work to support +* splitting vram <-> system transfers into multiple steps. +*/ + max_size = rdev->mc.gtt_size - rdev->gart_pin_size;Actually, the the check couldn't be removed even then, but would need to be replaced by a check against the VRAM size or something like that. Maybe just drop the second sentence of the comment?
Done.
Thanks!
Quoted 9 lines
Either way though, the series is
Reviewed-by Michel Dänzer <[email protected]>--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel