drm/i915: ttm for stolen region
Subsystems (3)
v2 cover drm/i915: ttm for stolen region
This series refactors i915's stolen memory region to use ttm.
v2: handle disabled stolen similar to legacy version.
relying on ttm to fail allocs works fine, but is dmesg noisy and causes testing dmesg warning regressions.
Robert Beckett (5):
drm/i915: instantiate ttm ranger manager for stolen memory drm/i915: sanitize mem_flags for stolen buffers drm/i915: ttm move/clear logic fix
drm/i915: ttm backend dont provide mmap_offset for kernel buffers drm/i915: stolen memory use ttm backend
drivers/gpu/drm/i915/display/intel_fbc.c | 78 ++-- .../gpu/drm/i915/gem/i915_gem_object_types.h | 2 - drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 407 ++++++------------ drivers/gpu/drm/i915/gem/i915_gem_stolen.h | 21 +- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 32 +- drivers/gpu/drm/i915/gem/i915_gem_ttm.h | 7 + drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 33 +- drivers/gpu/drm/i915/gt/intel_rc6.c | 4 +- drivers/gpu/drm/i915/gt/selftest_reset.c | 16 +- drivers/gpu/drm/i915/i915_debugfs.c | 7 +- drivers/gpu/drm/i915/i915_drv.h | 5 - drivers/gpu/drm/i915/intel_region_ttm.c | 67 ++- drivers/gpu/drm/i915/intel_region_ttm.h | 8 +- drivers/gpu/drm/i915/selftests/mock_region.c | 3 +- 14 files changed, 319 insertions(+), 371 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/5 drm/i915: instantiate ttm ranger manager for stolen memory
prepare for ttm based stolen region by using ttm range manager as the resource manager for stolen region.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 6 ++-- drivers/gpu/drm/i915/intel_region_ttm.c | 31 +++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +4 -2
@@ -58,11 +58,13 @@ i915_ttm_region(struct ttm_device *bdev, int ttm_mem_type)struct drm_i915_private *i915 =container_of (bdev,typeof (*i915), bdev);/* There's some room for optimization here... */ -GEM_BUG_ON (ttm_mem_type !=I915_PL_SYSTEM && - ttm_mem_type <I915_PL_LMEM0 ); +GEM_BUG_ON (ttm_mem_type ==I915_PL_GGTT ); +if (ttm_mem_type ==I915_PL_SYSTEM )return intel_memory_region_lookup (i915,INTEL_MEMORY_SYSTEM ,0 ); +if (ttm_mem_type ==I915_PL_STOLEN ) +return i915->mm.stolen_region;return intel_memory_region_lookup (i915,INTEL_MEMORY_LOCAL , ttm_mem_type -I915_PL_LMEM0 );
drivers/gpu/drm/i915/intel_region_ttm.c +23 -8
@@ -49,7 +49,7 @@ void intel_region_ttm_device_fini(struct drm_i915_private *dev_priv)/* * Map the i915 memory regions to TTM memory types. We use the -* driver-private types for now, reserving TTM_PL_VRAM for stolen +* driver-private types for now, reserving I915_PL_STOLEN for stolen * memory and TTM_PL_TT for GGTT use if decided to implement this. */ int intel_region_to_ttm_type (const struct intel_memory_region *mem)
@@ -58,11 +58,17 @@ int intel_region_to_ttm_type(const struct intel_memory_region *mem)GEM_BUG_ON (mem->type !=INTEL_MEMORY_LOCAL && mem->type !=INTEL_MEMORY_MOCK && - mem->type !=INTEL_MEMORY_SYSTEM ); + mem->type !=INTEL_MEMORY_SYSTEM && + mem->type !=INTEL_MEMORY_STOLEN_SYSTEM && + mem->type !=INTEL_MEMORY_STOLEN_LOCAL );if (mem->type ==INTEL_MEMORY_SYSTEM )return TTM_PL_SYSTEM ; +if (mem->type ==INTEL_MEMORY_STOLEN_SYSTEM || + mem->type ==INTEL_MEMORY_STOLEN_LOCAL ) +return I915_PL_STOLEN ; + type = mem->instance +TTM_PL_PRIV ;GEM_BUG_ON (type >=TTM_NUM_MEM_TYPES );
@@ -86,10 +92,16 @@ int intel_region_ttm_init(struct intel_memory_region *mem)int mem_type =intel_region_to_ttm_type (mem);int ret; - ret =i915_ttm_buddy_man_init (bdev, mem_type, false, -resource_size (&mem->region), - mem->io_size, - mem->min_page_size,PAGE_SIZE ); +if (mem_type ==I915_PL_STOLEN ) { + ret =ttm_range_man_init (bdev, mem_type, false, +resource_size (&mem->region) >>PAGE_SHIFT ); + mem->is_range_manager = true; + }else { + ret =i915_ttm_buddy_man_init (bdev, mem_type, false, +resource_size (&mem->region), + mem->io_size, + mem->min_page_size,PAGE_SIZE ); + }if (ret)return ret;
@@ -109,6 +121,7 @@ int intel_region_ttm_init(struct intel_memory_region *mem)int intel_region_ttm_fini (struct intel_memory_region *mem) {struct ttm_resource_manager *man = mem->region_private; +int mem_type =intel_region_to_ttm_type (mem);int ret = -EBUSY ;int count;
@@ -139,8 +152,10 @@ int intel_region_ttm_fini(struct intel_memory_region *mem)if (ret || !man)return ret; - ret =i915_ttm_buddy_man_fini (&mem->i915->bdev, -intel_region_to_ttm_type (mem)); +if (mem_type ==I915_PL_STOLEN ) + ret =ttm_range_man_fini (&mem->i915->bdev, mem_type); +else + ret =i915_ttm_buddy_man_fini (&mem->i915->bdev, mem_type);GEM_WARN_ON (ret); mem->region_private =NULL ;
Signature · 1 line
2.25.1
PATCH v2 2/5 drm/i915: sanitize mem_flags for stolen buffers
In reply to Robert Beckettstolen regions are not page backed or considered iomem.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +3 -2
@@ -122,8 +122,9 @@ void i915_ttm_adjust_gem_after_move(struct drm_i915_gem_object *obj) obj->mem_flags &= ~(I915_BO_FLAG_STRUCT_PAGE |I915_BO_FLAG_IOMEM ); - obj->mem_flags |=i915_ttm_cpu_maps_iomem (bo->resource) ?I915_BO_FLAG_IOMEM : -I915_BO_FLAG_STRUCT_PAGE ; +if (obj->mm.region->id !=INTEL_REGION_STOLEN_SMEM ) + obj->mem_flags |=i915_ttm_cpu_maps_iomem (bo->resource) ?I915_BO_FLAG_IOMEM : +I915_BO_FLAG_STRUCT_PAGE ; cache_level =i915_ttm_cache_level (to_i915 (bo->base.dev), bo->resource, bo->ttm);
Signature · 1 line
2.25.1
Re: [PATCH v2 2/5] drm/i915: sanitize mem_flags for stolen buffers
Quoted 1 line · Robert Beckett
stolen regions are not page backed or considered iomem.
thus...
A little more elaborate commit message please.
Quoted 2 lines
Signed-off-by Robert Beckett <[email protected]>
Quoted 26 lines
---
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +0
-0@@ -122,8 +122,9 @@ void i915_ttm_adjust_gem_after_move(struct drm_i915_gem_object *obj)
obj->mem_flags &= ~(I915_BO_FLAG_STRUCT_PAGE |I915_BO_FLAG_IOMEM);
- obj->mem_flags |=i915_ttm_cpu_maps_iomem(bo->resource)?I915_BO_FLAG_IOMEM:
- I915_BO_FLAG_STRUCT_PAGE;
+ if (obj->mm.region->id!=INTEL_REGION_STOLEN_SMEM) + obj->mem_flags |= i915_ttm_cpu_maps_iomem(bo-Quoted 1 line
resource) ?
I915_BO_FLAG_IOMEM:+ I915_BO_FLAG_STRUCT_PAGE;
cache_level = i915_ttm_cache_level(to_i915(bo->base.dev), bo-Quoted 1 line
resource,
bo->ttm);
PATCH v2 3/5 drm/i915: ttm move/clear logic fix
In reply to Robert Beckettttm managed buffers start off with system resource definitions and ttm_tt tracking structures allocated (though unpopulated).
currently this prevents clearing of buffers on first move to desired placements.
The desired behaviour is to clear user allocated buffers and any kernel buffers that specifically requests it only.
Make the logic match the desired behaviour.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +21 -1
@@ -3,6 +3,7 @@* Copyright © 2021 Intel Corporation */ +#include "drm/ttm/ttm_tt.h" #include <drm/ttm/ttm_bo_driver.h> #include "i915_deps.h"
@@ -470,6 +471,25 @@ __i915_ttm_move(struct ttm_buffer_object *bo,return fence; } +static bool +allow_clear (struct drm_i915_gem_object *obj,struct ttm_tt *ttm,struct ttm_resource *dst_mem) +{ +/* never clear stolen */ +if (dst_mem->mem_type ==I915_PL_STOLEN ) +return false; +/* +* we want to clear user buffers and any kernel buffers +* that specifically request clearing. +*/ +if (obj->flags &I915_BO_ALLOC_USER ) +return true; + +if (ttm && ttm->page_flags &TTM_TT_FLAG_ZERO_ALLOC ) +return true; + +return false; +} +/** * i915_ttm_move - The TTM move callback used by i915. * @bo: The buffer object.
@@ -520,7 +540,7 @@ int i915_ttm_move(struct ttm_buffer_object *bo, bool evict,return PTR_ERR (dst_rsgt); clear = !i915_ttm_cpu_maps_iomem (bo->resource) && (!ttm || !ttm_tt_is_populated (ttm)); -if (!(clear && ttm && !(ttm->page_flags &TTM_TT_FLAG_ZERO_ALLOC ))) { +if (!clear ||allow_clear (obj, ttm, dst_mem)) {struct i915_deps deps;i915_deps_init (&deps,GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
Signature · 1 line
2.25.1
Re: [PATCH v2 3/5] drm/i915: ttm move/clear logic fix
Quoted 6 lines · Robert Beckett
ttm managed buffers start off with system resource definitions and
ttm_tt
tracking structures allocated (though unpopulated). currently this prevents clearing of buffers on first move to desired placements.
Quoted 6 lines
The desired behaviour is to clear user allocated buffers and any kernel
buffers that specifically requests it only.
Make the logic match the desired behaviour.Signed-off-by Robert Beckett <[email protected]>
Quoted 58 lines
---
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 22
+++++++++++++++++++-1 file changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +0
-0@@ -3,6 +3,7 @@* Copyright © 2021 Intel Corporation */
+#include "drm/ttm/ttm_tt.h"
#include <drm/ttm/ttm_bo_driver.h>
#include "i915_deps.h"drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +0
-0@@ -470,6 +471,25 @@ __i915_ttm_move(struct ttm_buffer_object *bo, return fence; }drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +2
-0+static bool +allow_clear(struct drm_i915_gem_object *obj, struct ttm_tt *ttm,struct
ttm_resource*dst_mem)drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +17
-0+{ + /* never clear stolen */ + if (dst_mem->mem_type == I915_PL_STOLEN) + return false; + /* + * we want to clear user buffers and any kernel buffers + * that specifically request clearing. + */ + if (obj->flags & I915_BO_ALLOC_USER) + return true; + + if (ttm && ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC) + return true; + + return false; +} +/**
*i915_ttm_move- The TTM move callback used by i915.
* @bo: The buffer object.drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +0
-0@@ -520,7 +540,7 @@ int i915_ttm_move(struct ttm_buffer_object *bo,bool evict, return PTR_ERR(dst_rsgt);
clear = !i915_ttm_cpu_maps_iomem(bo->resource) && (!ttm || !ttm_tt_is_populated(ttm));
- if (!(clear && ttm && !(ttm->page_flags &TTM_TT_FLAG_ZERO_ALLOC))) {
+ if (!clear ||allow_clear(obj, ttm, dst_mem)) { structi915_depsdeps;
i915_deps_init(&deps,GFP_KERNEL|__GFP_NORETRY|__GFP_NOWARN);
PATCH v2 4/5 drm/i915: ttm backend dont provide mmap_offset for kernel buffers
In reply to Robert Beckettstolen/kernel buffers should not be mmapable by userland. do not provide callbacks to facilitate this for these buffers.
--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 32 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +27 -5
@@ -1092,8 +1092,8 @@ static void i915_ttm_unmap_virtual(struct drm_i915_gem_object *obj)ttm_bo_unmap_virtual (i915_gem_to_ttm (obj)); } -static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { - .name ="i915_gem_object_ttm" , +static const struct drm_i915_gem_object_ops i915_gem_ttm_user_obj_ops = { + .name ="i915_gem_object_ttm_user" , .flags =I915_GEM_OBJECT_IS_SHRINKABLE |I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST ,
@@ -1111,6 +1111,21 @@ static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { .mmap_ops = &vm_ops_ttm, }; +static const struct drm_i915_gem_object_ops i915_gem_ttm_kern_obj_ops = { + .name ="i915_gem_object_ttm_kern" , + .flags =I915_GEM_OBJECT_IS_SHRINKABLE | +I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST , + + .get_pages = i915_ttm_get_pages, + .put_pages = i915_ttm_put_pages, + .truncate = i915_ttm_truncate, + .shrink = i915_ttm_shrink, + + .adjust_lru = i915_ttm_adjust_lru, + .delayed_free = i915_ttm_delayed_free, + .migrate = i915_ttm_migrate, +}; +void i915_ttm_bo_destroy (struct ttm_buffer_object *bo) {struct drm_i915_gem_object *obj =i915_ttm_to_gem (bo);
@@ -1165,10 +1180,19 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, .no_wait_gpu = false, };enum ttm_bo_type bo_type; +const struct drm_i915_gem_object_ops *ops;int ret;drm_gem_private_object_init (&i915->drm, &obj->base, size); -i915_gem_object_init (obj, &i915_gem_ttm_obj_ops, &lock_class, flags); + +if (flags &I915_BO_ALLOC_USER &&intel_region_to_ttm_type (mem) !=I915_PL_STOLEN ) { + bo_type = ttm_bo_type_device; + ops = &i915_gem_ttm_user_obj_ops; + }else { + bo_type = ttm_bo_type_kernel; + ops = &i915_gem_ttm_kern_obj_ops; + } +i915_gem_object_init (obj, ops, &lock_class, flags); obj->bo_offset = offset;
@@ -1178,8 +1202,6 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,INIT_RADIX_TREE (&obj->ttm.get_io_page.radix,GFP_KERNEL | __GFP_NOWARN);mutex_init (&obj->ttm.get_io_page.lock); - bo_type = (obj->flags &I915_BO_ALLOC_USER ) ? ttm_bo_type_device : - ttm_bo_type_kernel; obj->base.vma_node.driver_private =i915_gem_to_ttm (obj);
Signature · 1 line
2.25.1
Re: [PATCH v2 4/5] drm/i915: ttm backend dont provide mmap_offset for kernel buffers
Quoted 37 lines · Robert Beckett
stolen/kernel buffers should not be mmapable by userland. do not provide callbacks to facilitate this for these buffers.
Signed-off-by Robert Beckett <[email protected]>---
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 32 +++++++++++++++++++++-- --1 file changed, 27 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-0@@ -1092,8 +1092,8 @@ static void i915_ttm_unmap_virtual(struct drm_i915_gem_object *obj) ttm_bo_unmap_virtual(i915_gem_to_ttm(obj)); }drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1
-2-static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { - .name = "i915_gem_object_ttm", +static const struct drm_i915_gem_object_ops
i915_gem_ttm_user_obj_ops= {
+ .name = "i915_gem_object_ttm_user", .flags =I915_GEM_OBJECT_IS_SHRINKABLE|I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST,drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-0@@ -1111,6 +1111,21 @@ static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { .mmap_ops = &vm_ops_ttm, };
+static const structdrm_i915_gem_object_opsi915_gem_ttm_kern_obj_ops= {
+ .name = "i915_gem_object_ttm_kern",
+ .flags =I915_GEM_OBJECT_IS_SHRINKABLE| +I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST,
drivers/gpu/drm/i915/gem/i915_gem_ttm.c static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { · line 1127
Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +10
-0+ + .get_pages = i915_ttm_get_pages, + .put_pages = i915_ttm_put_pages, + .truncate = i915_ttm_truncate, + .shrink = i915_ttm_shrink, + + .adjust_lru = i915_ttm_adjust_lru, + .delayed_free = i915_ttm_delayed_free, + .migrate = i915_ttm_migrate, +};
Do we really need two different ops here?
Since if we don't have mmap ops, basically that tells GEM it should do the mmapping rather than TTM.
That might of course come in handy for the shmem backend, but I don't fully follow why we need this for stolen.
Also for the framebuffer handed over from BIOS to fbdev, Does that need mmapping and if so, how do we handle that?
/Thomas
Quoted 40 lines
+
voidi915_ttm_bo_destroy(struct ttm_buffer_object *bo){
structdrm_i915_gem_object*obj =i915_ttm_to_gem(bo);drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1
-0@@ -1165,10 +1180,19 @@ int __i915_gem_ttm_object_init(structintel_memory_region *mem, .no_wait_gpu = false, }; enum ttm_bo_type bo_type; + const struct drm_i915_gem_object_ops *ops; int ret;
drm_gem_private_object_init(&i915->drm,&obj->base, size); - i915_gem_object_init(obj,&i915_gem_ttm_obj_ops,&lock_class, flags);
+
+ if (flags &I915_BO_ALLOC_USER&&intel_region_to_ttm_type(mem)!=I915_PL_STOLEN) {
+ bo_type =ttm_bo_type_device;
+ ops =&i915_gem_ttm_user_obj_ops;
+ } else {
+ bo_type =ttm_bo_type_kernel;
+ ops =&i915_gem_ttm_kern_obj_ops;
+ }
+ i915_gem_object_init(obj, ops,&lock_class, flags);
obj->bo_offset = offset;drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-0@@ -1178,8 +1202,6 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
INIT_RADIX_TREE(&obj->ttm.get_io_page.radix,GFP_KERNEL|__GFP_NOWARN);
mutex_init(&obj->ttm.get_io_page.lock);
- bo_type = (obj->flags&I915_BO_ALLOC_USER) ?ttm_bo_type_device:
- ttm_bo_type_kernel;
obj->base.vma_node.driver_private =i915_gem_to_ttm(obj);
Re: [PATCH v2 4/5] drm/i915: ttm backend dont provide mmap_offset for kernel buffers
Quoted 51 lines · Thomas Hellström
Quoted 37 lines · Robert Beckett
stolen/kernel buffers should not be mmapable by userland. do not provide callbacks to facilitate this for these buffers.
Signed-off-by Robert Beckett <[email protected]>--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 32 +++++++++++++++++++++-- -- 1 file changed, 27 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_ttm.c +2
-2@@ -1092,8 +1092,8 @@ static void i915_ttm_unmap_virtual(struct drm_i915_gem_object *obj) ttm_bo_unmap_virtual(i915_gem_to_ttm(obj)); } -static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { - .name = "i915_gem_object_ttm", +static const struct drm_i915_gem_object_ops i915_gem_ttm_user_obj_ops = { + .name = "i915_gem_object_ttm_user", .flags = I915_GEM_OBJECT_IS_SHRINKABLE |
I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST,drivers/gpu/drm/i915/gem/i915_gem_ttm.c +4
-0@@ -1111,6 +1111,21 @@ static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { .mmap_ops = &vm_ops_ttm, }; +static const struct drm_i915_gem_object_ops i915_gem_ttm_kern_obj_ops = { + .name = "i915_gem_object_ttm_kern", + .flags = I915_GEM_OBJECT_IS_SHRINKABLE | + I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST,drivers/gpu/drm/i915/gem/i915_gem_ttm.c static const struct drm_i915_gem_object_ops · line 1129
Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +10
-0+ + .get_pages = i915_ttm_get_pages, + .put_pages = i915_ttm_put_pages, + .truncate = i915_ttm_truncate, + .shrink = i915_ttm_shrink, + + .adjust_lru = i915_ttm_adjust_lru, + .delayed_free = i915_ttm_delayed_free, + .migrate = i915_ttm_migrate, +};Do we really need two different ops here?
Quoted 5 lines
Since if we don't have mmap ops, basically that tells GEM it should do the mmapping rather than TTM.
That might of course come in handy for the shmem backend, but I don't fully follow why we need this for stolen.
the main rationale for doing this was to avoid drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c:can_mmap() presuming that is can use I915_MMAP_TYPE_FIXED
As the original backend also did not have mmap_offset handlers for stolen, this seemed like a reasonable design.
If desired, we could add a special case for the testing logic, but those special cases have tendency to multiply.
Quoted 4 lines
Also for the framebuffer handed over from BIOS to fbdev, Does that need mmapping and if so, how do we handle that?
I'm not sure of the usecase there. Do you know of any igt test that tests this? I can investigate further if you do not.
Quoted 48 lines
/Thomas
Quoted 40 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1
-0+ void i915_ttm_bo_destroy(struct ttm_buffer_object *bo){
structdrm_i915_gem_object*obj =i915_ttm_to_gem(bo);drivers/gpu/drm/i915/gem/i915_gem_ttm.c +10
-1@@ -1165,10 +1180,19 @@ int __i915_gem_ttm_object_init(structintel_memory_region *mem, .no_wait_gpu = false, }; enum ttm_bo_type bo_type; + const struct drm_i915_gem_object_ops *ops; int ret; drm_gem_private_object_init(&i915->drm, &obj->base, size); - i915_gem_object_init(obj, &i915_gem_ttm_obj_ops, &lock_class, flags); + + if (flags & I915_BO_ALLOC_USER &&intel_region_to_ttm_type (mem) !=I915_PL_STOLEN ) { + bo_type = ttm_bo_type_device; + ops = &i915_gem_ttm_user_obj_ops; + } else { + bo_type = ttm_bo_type_kernel; + ops = &i915_gem_ttm_kern_obj_ops; + } + i915_gem_object_init(obj, ops, &lock_class, flags);obj->bo_offset = offset;
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-1@@ -1178,8 +1202,6 @@ int __i915_gem_ttm_object_init(structintel_memory_region *mem, INIT_RADIX_TREE(&obj->ttm.get_io_page.radix, GFP_KERNEL | __GFP_NOWARN); mutex_init(&obj->ttm.get_io_page.lock); - bo_type = (obj->flags & I915_BO_ALLOC_USER) ?
ttm_bo_type_device:
- ttm_bo_type_kernel;obj->base.vma_node.driver_private =
i915_gem_to_ttm(obj);
Re: [PATCH v2 4/5] drm/i915: ttm backend dont provide mmap_offset for kernel buffers
Sorry for late reply,
Quoted 78 lines · Robert Beckett
Quoted 54 lines · Thomas Hellström
Quoted 40 lines · Robert Beckett
stolen/kernel buffers should not be mmapable by userland. do not provide callbacks to facilitate this for these buffers.
Signed-off-by Robert Beckett <[email protected]>---
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 32
+++++++++++++++++++++--
--1 file changed, 27 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-0@@ -1092,8 +1092,8 @@ static void i915_ttm_unmap_virtual(struct drm_i915_gem_object *obj) ttm_bo_unmap_virtual(i915_gem_to_ttm(obj)); }
-static const structdrm_i915_gem_object_opsi915_gem_ttm_obj_ops= {
- .name = "i915_gem_object_ttm",
+static const structdrm_i915_gem_object_opsi915_gem_ttm_user_obj_ops= {
+ .name = "i915_gem_object_ttm_user",
.flags =I915_GEM_OBJECT_IS_SHRINKABLE|I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST,drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-0@@ -1111,6 +1111,21 @@ static const struct
drm_i915_gem_object_opsi915_gem_ttm_obj_ops= {
.mmap_ops =&vm_ops_ttm,
};
+static const structdrm_i915_gem_object_opsi915_gem_ttm_kern_obj_ops= {
+ .name = "i915_gem_object_ttm_kern",
+ .flags =I915_GEM_OBJECT_IS_SHRINKABLE| +I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST,drivers/gpu/drm/i915/gem/i915_gem_ttm.c static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = { · line 1127
Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +10
-0+ + .get_pages = i915_ttm_get_pages, + .put_pages = i915_ttm_put_pages, + .truncate = i915_ttm_truncate, + .shrink = i915_ttm_shrink, + + .adjust_lru = i915_ttm_adjust_lru, + .delayed_free = i915_ttm_delayed_free, + .migrate = i915_ttm_migrate, +};Do we really need two different ops here?
Quoted 7 lines
Since if we don't have mmap ops, basically that tells GEM it should do
the mmapping rather than TTM.That might of course come in handy for the shmem backend, but I don't
fully follow why we need this for stolen.the main rationale for doing this was to avoid drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c:can_mmap() presuming
that is can useI915_MMAP_TYPE_FIXEDAs the original backend also did not have
mmap_offsethandlers for stolen, this seemed like a reasonable design.If desired, we could add a special case for the testing logic, but those
special cases have tendency to multiply.Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Also for the framebuffer handed over from BIOS to fbdev, Does that need
mmapping and if so, how do we handle that?I'm not sure of the usecase there. Do you know of any igt test that tests this? I can investigate further if you do not.
It would be if we the fbdev driver at startup inherits some image that bios has preloaded into stolen, and then a client tries to write into it. Not sure that this is a real use case though, or whether, in that case, that takes a separate path for user-space mappings.
/Thomas
Quoted 53 lines
Quoted 53 lines
/Thomas
Quoted 44 lines
+
voidi915_ttm_bo_destroy(struct ttm_buffer_object *bo){
structdrm_i915_gem_object*obj =i915_ttm_to_gem(bo);drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1
-0@@ -1165,10 +1180,19 @@ int __i915_gem_ttm_object_init(structintel_memory_region *mem, .no_wait_gpu = false, }; enum ttm_bo_type bo_type; + const struct drm_i915_gem_object_ops *ops; int ret;
drm_gem_private_object_init(&i915->drm,&obj->base, size);
- i915_gem_object_init(obj,&i915_gem_ttm_obj_ops,&lock_class,
flags);
+
+ if (flags &I915_BO_ALLOC_USER&&intel_region_to_ttm_type(mem)!=I915_PL_STOLEN) { + bo_type =ttm_bo_type_device;
+ ops =&i915_gem_ttm_user_obj_ops; + } else {
+ bo_type =ttm_bo_type_kernel;
+ ops =&i915_gem_ttm_kern_obj_ops; + }
+ i915_gem_object_init(obj, ops,&lock_class, flags);
obj->bo_offset = offset;drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0
-0@@ -1178,8 +1202,6 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
INIT_RADIX_TREE(&obj->ttm.get_io_page.radix,GFP_KERNEL|__GFP_NOWARN);
mutex_init(&obj->ttm.get_io_page.lock);
- bo_type = (obj->flags&I915_BO_ALLOC_USER) ?ttm_bo_type_device:
- ttm_bo_type_kernel;
obj->base.vma_node.driver_private =i915_gem_to_ttm(obj);
PATCH v2 5/5 drm/i915: stolen memory use ttm backend
In reply to Robert Beckettrefactor stolen memory region to use ttm.
this necessitates using ttm resources to track reserved stolen regions instead of drm_mm_nodes.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 78 ++-- .../gpu/drm/i915/gem/i915_gem_object_types.h | 2 - drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 407 ++++++------------ drivers/gpu/drm/i915/gem/i915_gem_stolen.h | 21 +- drivers/gpu/drm/i915/gem/i915_gem_ttm.h | 7 + drivers/gpu/drm/i915/gt/intel_rc6.c | 4 +- drivers/gpu/drm/i915/gt/selftest_reset.c | 16 +- drivers/gpu/drm/i915/i915_debugfs.c | 7 +- drivers/gpu/drm/i915/i915_drv.h | 5 - drivers/gpu/drm/i915/intel_region_ttm.c | 36 +- drivers/gpu/drm/i915/intel_region_ttm.h | 8 +- drivers/gpu/drm/i915/selftests/mock_region.c | 3 +- 12 files changed, 241 insertions(+), 353 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +46 -32
@@ -38,6 +38,7 @@* forcibly disable it to allow proper screen updates. */ +#include "gem/i915_gem_stolen.h" #include <linux/string_helpers.h> #include <drm/drm_fourcc.h>
@@ -51,6 +52,7 @@#include "intel_display_types.h" #include "intel_fbc.h" #include "intel_frontbuffer.h" +#include "gem/i915_gem_region.h" #define for_each_fbc_id (__dev_priv, __fbc_id) \ for ((__fbc_id) = INTEL_FBC_A; (__fbc_id) < I915_MAX_FBCS; (__fbc_id)++) \
@@ -93,8 +95,8 @@ struct intel_fbc {unsigned int possible_framebuffer_bits;unsigned int busy_bits; -struct drm_mm_node compressed_fb; -struct drm_mm_node compressed_llb; +struct ttm_resource *compressed_fb; +struct ttm_resource *compressed_llb;enum intel_fbc_id id;
@@ -332,16 +334,20 @@ static void i8xx_fbc_nuke(struct intel_fbc *fbc)static void i8xx_fbc_program_cfb (struct intel_fbc *fbc) {struct drm_i915_private *i915 = fbc->i915; +u64 fb_offset =i915_gem_stolen_reserve_offset (fbc->compressed_fb); +u64 llb_offset =i915_gem_stolen_reserve_offset (fbc->compressed_llb); +GEM_BUG_ON (fb_offset ==I915_BO_INVALID_OFFSET ); +GEM_BUG_ON (llb_offset ==I915_BO_INVALID_OFFSET );GEM_BUG_ON (range_overflows_end_t (u64, i915->dsm.start, - fbc->compressed_fb.start,U32_MAX )); + fb_offset,U32_MAX ));GEM_BUG_ON (range_overflows_end_t (u64, i915->dsm.start, - fbc->compressed_llb.start,U32_MAX )); + llb_offset,U32_MAX ));intel_de_write (i915,FBC_CFB_BASE , - i915->dsm.start + fbc->compressed_fb.start); + i915->dsm.start + fb_offset);intel_de_write (i915,FBC_LL_BASE , - i915->dsm.start + fbc->compressed_llb.start); + i915->dsm.start + llb_offset); }static const struct intel_fbc_funcs i8xx_fbc_funcs = {
@@ -449,8 +455,10 @@ static bool g4x_fbc_is_compressing(struct intel_fbc *fbc)static void g4x_fbc_program_cfb (struct intel_fbc *fbc) {struct drm_i915_private *i915 = fbc->i915; +u64 fb_offset =i915_gem_stolen_reserve_offset (fbc->compressed_fb); -intel_de_write (i915,DPFC_CB_BASE , fbc->compressed_fb.start); +GEM_BUG_ON (fb_offset ==I915_BO_INVALID_OFFSET ); +intel_de_write (i915,DPFC_CB_BASE , fb_offset); }static const struct intel_fbc_funcs g4x_fbc_funcs = {
@@ -500,8 +508,10 @@ static bool ilk_fbc_is_compressing(struct intel_fbc *fbc)static void ilk_fbc_program_cfb (struct intel_fbc *fbc) {struct drm_i915_private *i915 = fbc->i915; +u64 fb_offset =i915_gem_stolen_reserve_offset (fbc->compressed_fb); -intel_de_write (i915,ILK_DPFC_CB_BASE (fbc->id), fbc->compressed_fb.start); +GEM_BUG_ON (fb_offset ==I915_BO_INVALID_OFFSET ); +intel_de_write (i915,ILK_DPFC_CB_BASE (fbc->id), fb_offset); }static const struct intel_fbc_funcs ilk_fbc_funcs = {
@@ -741,21 +751,24 @@ static int find_compression_limit(struct intel_fbc *fbc, {struct drm_i915_private *i915 = fbc->i915;u64 end =intel_fbc_stolen_end (i915); -int ret, limit = min_limit; +int limit = min_limit; +struct ttm_resource *res; size /= limit;/* Try to over-allocate to reduce reallocations and fragmentation. */ - ret =i915_gem_stolen_insert_node_in_range (i915, &fbc->compressed_fb, - size <<=1 ,4096 ,0 , end); -if (ret ==0 ) + res =i915_gem_stolen_reserve_range (i915, size <<=1 ,0 , end); +if (!IS_ERR (res)) { + fbc->compressed_fb = res;return limit; + }for (; limit <=intel_fbc_max_limit (i915); limit <<=1 ) { - ret =i915_gem_stolen_insert_node_in_range (i915, &fbc->compressed_fb, - size >>=1 ,4096 ,0 , end); -if (ret ==0 ) + res =i915_gem_stolen_reserve_range (i915, size >>=1 ,0 , end); +if (!IS_ERR (res)) { + fbc->compressed_fb = res;return limit; + } }return 0 ;
@@ -766,17 +779,18 @@ static int intel_fbc_alloc_cfb(struct intel_fbc *fbc, {struct drm_i915_private *i915 = fbc->i915;int ret; +struct ttm_resource *res; -drm_WARN_ON (&i915->drm, -drm_mm_node_allocated (&fbc->compressed_fb)); -drm_WARN_ON (&i915->drm, -drm_mm_node_allocated (&fbc->compressed_llb)); +drm_WARN_ON (&i915->drm, fbc->compressed_fb); +drm_WARN_ON (&i915->drm, fbc->compressed_llb);if (DISPLAY_VER (i915) <5 && !IS_G4X (i915)) { - ret =i915_gem_stolen_insert_node (i915, &fbc->compressed_llb, -4096 ,4096 ); -if (ret) + res =i915_gem_stolen_reserve_range (i915,4096 ,I915_GEM_STOLEN_BIAS ,0 ); +if (IS_ERR (res)) { + ret =PTR_ERR (res); goto err; + } + fbc->compressed_llb = res; } ret =find_compression_limit (fbc, size, min_limit);
@@ -790,15 +804,14 @@ static int intel_fbc_alloc_cfb(struct intel_fbc *fbc,drm_dbg_kms (&i915->drm,"reserved %llu bytes of contiguous stolen space for FBC, limit: %d\n" , - fbc->compressed_fb.size, fbc->limit); +i915_gem_stolen_reserve_size (fbc->compressed_fb), fbc->limit);return 0 ; err_llb: -if (drm_mm_node_allocated (&fbc->compressed_llb)) -i915_gem_stolen_remove_node (i915, &fbc->compressed_llb); +i915_gem_stolen_release_range (i915,fetch_and_zero (&fbc->compressed_llb)); err: -if (drm_mm_initialized (&i915->mm.stolen)) +if (IS_ERR (res) && (PTR_ERR (res) == -ENOMEM ||PTR_ERR (res) == -ENXIO ))drm_info_once (&i915->drm,"not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n" , size);return -ENOSPC ; }
@@ -815,10 +828,10 @@ static void __intel_fbc_cleanup_cfb(struct intel_fbc *fbc)if (WARN_ON (intel_fbc_hw_is_active (fbc)))return ; -if (drm_mm_node_allocated (&fbc->compressed_llb)) -i915_gem_stolen_remove_node (i915, &fbc->compressed_llb); -if (drm_mm_node_allocated (&fbc->compressed_fb)) -i915_gem_stolen_remove_node (i915, &fbc->compressed_fb); +if (fbc->compressed_llb) +i915_gem_stolen_release_range (i915,fetch_and_zero (&fbc->compressed_llb)); +if (fbc->compressed_fb) +i915_gem_stolen_release_range (i915,fetch_and_zero (&fbc->compressed_fb)); }void intel_fbc_cleanup (struct drm_i915_private *i915)
@@ -1022,9 +1035,10 @@ static bool intel_fbc_is_cfb_ok(const struct intel_plane_state *plane_state) {struct intel_plane *plane =to_intel_plane (plane_state->uapi.plane);struct intel_fbc *fbc = plane->fbc; +u64 fb_size =i915_gem_stolen_reserve_size (fbc->compressed_fb);return intel_fbc_min_limit (plane_state) <= fbc->limit && -intel_fbc_cfb_size (plane_state) <= fbc->compressed_fb.size * fbc->limit; +intel_fbc_cfb_size (plane_state) <= fb_size * fbc->limit; }static bool intel_fbc_is_ok (const struct intel_plane_state *plane_state)
@@ -1703,7 +1717,7 @@ void intel_fbc_init(struct drm_i915_private *i915) {enum intel_fbc_id fbc_id; -if (!drm_mm_initialized (&i915->mm.stolen)) +if (!i915->mm.stolen_region)mkwrite_device_info (i915)->display.fbc_mask =0 ;if (need_fbc_vtd_wa (i915))
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +0 -2
@@ -629,8 +629,6 @@ struct drm_i915_gem_object { } userptr;#endif -struct drm_mm_node *stolen; -resource_size_t bo_offset;unsigned long scratch;
drivers/gpu/drm/i915/gem/i915_gem_stolen.c +125 -282
508 lines not on this page · raw message
drivers/gpu/drm/i915/gem/i915_gem_stolen.h +11 -10
@@ -10,17 +10,9 @@struct drm_i915_private ;struct drm_mm_node ; +struct ttm_resource ;struct drm_i915_gem_object ; -int i915_gem_stolen_insert_node (struct drm_i915_private *dev_priv, -struct drm_mm_node *node,u64 size, -unsigned alignment); -int i915_gem_stolen_insert_node_in_range (struct drm_i915_private *dev_priv, -struct drm_mm_node *node,u64 size, -unsigned alignment,u64 start, -u64 end); -void i915_gem_stolen_remove_node (struct drm_i915_private *dev_priv, -struct drm_mm_node *node);struct intel_memory_region *i915_gem_stolen_smem_setup (struct drm_i915_private *i915,u16 type,u16 instance);
@@ -32,7 +24,16 @@ struct drm_i915_gem_object * i915_gem_object_create_stolen(struct drm_i915_private *dev_priv, resource_size_t size); -bool i915_gem_object_is_stolen (const struct drm_i915_gem_object *obj); +u64 i915_gem_object_stolen_offset (struct drm_i915_gem_object *obj); +bool i915_gem_object_is_stolen (struct drm_i915_gem_object *obj); +struct ttm_resource * +i915_gem_stolen_reserve_range (struct drm_i915_private *i915, +resource_size_t size, +u64 start,u64 end); +u64 i915_gem_stolen_reserve_offset (struct ttm_resource *res); +u64 i915_gem_stolen_reserve_size (struct ttm_resource *res); +void i915_gem_stolen_release_range (struct drm_i915_private *i915, +struct ttm_resource *res);#define I915_GEM_STOLEN_BIAS SZ_128K
drivers/gpu/drm/i915/gem/i915_gem_ttm.h +7 -0
@@ -49,6 +49,13 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,resource_size_t size, resource_size_t page_size, unsigned int flags); +int i915_gem_ttm_object_init_in_place (struct intel_memory_region *mem, +struct drm_i915_gem_object *obj, +resource_size_t size, +resource_size_t page_size, +unsigned int flags, +u64 start, +u64 end);/* Internal I915 TTM declarations and definitions below. */
drivers/gpu/drm/i915/gt/intel_rc6.c +2 -2
@@ -355,9 +355,9 @@ static int vlv_rc6_init(struct intel_rc6 *rc6)GEM_BUG_ON (range_overflows_end_t (u64, i915->dsm.start, - pctx->stolen->start, +i915_gem_object_stolen_offset (pctx),U32_MAX )); - pctx_paddr = i915->dsm.start + pctx->stolen->start; + pctx_paddr = i915->dsm.start +i915_gem_object_stolen_offset (pctx);intel_uncore_write (uncore,VLV_PCBR , pctx_paddr); out:
drivers/gpu/drm/i915/gt/selftest_reset.c +9 -7
@@ -6,6 +6,7 @@#include <linux/crc32.h> #include "gem/i915_gem_stolen.h" +#include "intel_region_ttm.h" #include "i915_memcpy.h" #include "i915_selftest.h"
@@ -83,6 +84,7 @@ __igt_reset_stolen(struct intel_gt *gt,dma_addr_t dma = (dma_addr_t )dsm->start + (page <<PAGE_SHIFT );void __iomem *s;void *in; +bool busy; ggtt->vm.insert_page(&ggtt->vm, dma, ggtt->error_capture.start,
@@ -93,9 +95,9 @@ __igt_reset_stolen(struct intel_gt *gt, ggtt->error_capture.start, PAGE_SIZE); -if (!__drm_mm_interval_first (>->i915->mm.stolen, - page <<PAGE_SHIFT , - ((page +1 ) <<PAGE_SHIFT ) -1 )) + busy =intel_region_ttm_range_busy (gt->i915->mm.stolen_region, +PFN_PHYS (page),PAGE_SIZE ); +if (!busy)memset_io (s,STACK_MAGIC ,PAGE_SIZE ); in = (void __force *)s;
@@ -124,6 +126,7 @@ __igt_reset_stolen(struct intel_gt *gt,void __iomem *s;void *in;u32 x; +bool busy; ggtt->vm.insert_page(&ggtt->vm, dma, ggtt->error_capture.start,
@@ -139,10 +142,9 @@ __igt_reset_stolen(struct intel_gt *gt, in = tmp; x =crc32_le (0 , in,PAGE_SIZE ); -if (x != crc[page] && - !__drm_mm_interval_first (>->i915->mm.stolen, - page <<PAGE_SHIFT , - ((page +1 ) <<PAGE_SHIFT ) -1 )) { + busy =intel_region_ttm_range_busy (gt->i915->mm.stolen_region, +PFN_PHYS (page),PAGE_SIZE ); +if (x != crc[page] && !busy) {pr_debug ("unused stolen page %pa modified by GPU reset\n" , &page);if (count++ ==0 )
drivers/gpu/drm/i915/i915_debugfs.c +5 -2
@@ -32,6 +32,7 @@#include <drm/drm_debugfs.h> +#include "gem/i915_gem_region.h" #include "gem/i915_gem_context.h" #include "gt/intel_gt.h" #include "gt/intel_gt_buffer_pool.h"
@@ -157,6 +158,7 @@ i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)struct drm_i915_private *dev_priv =to_i915 (obj->base.dev);struct i915_vma *vma;int pin_count =0 ; +u64 offset; seq_printf(m, "%pK: %c%c%c %8zdKiB %02x %02x %s%s%s", &obj->base,
@@ -241,8 +243,9 @@ i915_debugfs_describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)spin_unlock (&obj->vma.lock);seq_printf (m," (pinned x %d)" , pin_count); -if (i915_gem_object_is_stolen (obj)) -seq_printf (m," (stolen: %08llx)" , obj->stolen->start); + offset =i915_gem_object_stolen_offset (obj); +if (offset !=I915_BO_INVALID_OFFSET ) +seq_printf (m," (stolen: %08llx)" , offset);if (i915_gem_object_is_framebuffer (obj))seq_printf (m," (fb)" ); }
drivers/gpu/drm/i915/i915_drv.h +0 -5
@@ -231,11 +231,6 @@ struct i915_gem_mm {* support stolen. */ struct intel_memory_region *stolen_region; -/** Memory allocator for GTT stolen memory */ -struct drm_mm stolen; -/** Protects the usage of the GTT stolen memory allocator. This is -* always the inner lock when overlapping with struct_mutex. */ -struct mutex stolen_lock;/* Protects bound_list/unbound_list and #drm_i915_gem_object.mm.link */ spinlock_t obj_lock;
drivers/gpu/drm/i915/intel_region_ttm.c +29 -7
@@ -189,11 +189,12 @@ intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem, } } -#ifdef CONFIG_DRM_I915_SELFTEST /** * intel_region_ttm_resource_alloc - Allocate memory resources from a region * @mem: The memory region, * @size: The requested size in bytes +* @start: start of allowed range +* @end: end of allowed range * @flags: Allocation flags * * This functionality is provided only for callers that need to allocate
@@ -207,8 +208,9 @@ intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,*/ struct ttm_resource *intel_region_ttm_resource_alloc (struct intel_memory_region *mem, -resource_size_t offset,resource_size_t size, +u64 start, +u64 end,unsigned int flags) {struct ttm_resource_manager *man = mem->region_private;
@@ -219,9 +221,9 @@ intel_region_ttm_resource_alloc(struct intel_memory_region *mem,if (flags &I915_BO_ALLOC_CONTIGUOUS ) place.flags |=TTM_PL_FLAG_CONTIGUOUS ; -if (offset !=I915_BO_INVALID_OFFSET ) { - place.fpfn = offset >>PAGE_SHIFT ; - place.lpfn = place.fpfn + (size >>PAGE_SHIFT ); +if (start || end) { + place.fpfn =PFN_DOWN (start); + place.lpfn =PFN_UP (end); }else if (mem->io_size && mem->io_size < mem->total) {if (flags &I915_BO_ALLOC_GPU_ONLY ) { place.flags |=TTM_PL_FLAG_TOPDOWN ;
@@ -242,8 +244,6 @@ intel_region_ttm_resource_alloc(struct intel_memory_region *mem,return ret ?ERR_PTR (ret) : res; } -#endif -/** * intel_region_ttm_resource_free - Free a resource allocated from a resource manager * @mem: The region the resource was allocated from.
@@ -261,3 +261,25 @@ void intel_region_ttm_resource_free(struct intel_memory_region *mem, man->func->free (man, res); } + +/** +* intel_region_ttm_range_busy - check whether range has any allocations +* @mem: The region to check +* @start: the start of the range to check +* @size: size of the range to check +* +* Return: true if something is alloceted within the region, false otherwise. +*/ +bool intel_region_ttm_range_busy (struct intel_memory_region *mem, +u64 start,u64 size) +{ +struct ttm_resource *dummy; + + dummy =intel_region_ttm_resource_alloc (mem, size, start, start + size, +I915_BO_ALLOC_CONTIGUOUS ); +if (IS_ERR (dummy)) +return true; + +intel_region_ttm_resource_free (mem, dummy); +return false; +}
drivers/gpu/drm/i915/intel_region_ttm.h +5 -3
@@ -29,15 +29,17 @@ intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,void intel_region_ttm_resource_free (struct intel_memory_region *mem,struct ttm_resource *res); +bool intel_region_ttm_range_busy (struct intel_memory_region *mem, +u64 start,u64 size); +int intel_region_to_ttm_type (const struct intel_memory_region *mem);struct ttm_device_funcs *i915_ttm_driver (void ); -#ifdef CONFIG_DRM_I915_SELFTEST struct ttm_resource *intel_region_ttm_resource_alloc (struct intel_memory_region *mem, -resource_size_t offset,resource_size_t size, +u64 start, +u64 end,unsigned int flags); -#endif #endif /* _INTEL_REGION_TTM_H_ */
drivers/gpu/drm/i915/selftests/mock_region.c +2 -1
@@ -26,8 +26,9 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj)int err; obj->mm.res =intel_region_ttm_resource_alloc (obj->mm.region, - obj->bo_offset, obj->base.size, + obj->bo_offset, + obj->bo_offset + obj->base.size, obj->flags);if (IS_ERR (obj->mm.res))return PTR_ERR (obj->mm.res);
Signature · 1 line
2.25.1
Patchwork
CI[Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915: ttm for stolen region (rev2)
In reply to Robert Beckett== Series Details ==
== Series Details ==
Series: drm/i915: ttm for stolen region (rev2)
URL : https://patchwork.freedesktop.org/series/102540/
State : warning
== Summary ==
Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: ttm for stolen region (rev2)
In reply to Robert Beckett== Series Details ==
== Series Details ==
Series: drm/i915: ttm for stolen region (rev2)
URL : https://patchwork.freedesktop.org/series/102540/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_11489 -> Patchwork_102540v2
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_102540v2 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_102540v2, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/index.html
Participating hosts (46 -> 47)
------------------------------
Additional (3): fi-icl-u2 bat-adls-5 fi-pnv-d510
Missing (2): fi-bsw-cyan fi-bdw-samus
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_102540v2:
### IGT changes ###
#### Possible regressions ####
* igt@runner@aborted:
- fi-cfl-8700k: NOTRUN -> [FAIL][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-cfl-8700k/igt@[email protected]
- fi-hsw-g3258: NOTRUN -> [FAIL][2]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-hsw-g3258/igt@[email protected]
- fi-bxt-dsi: NOTRUN -> [FAIL][3]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-bxt-dsi/igt@[email protected]
- fi-adl-ddr5: NOTRUN -> [FAIL][4]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-adl-ddr5/igt@[email protected]
- fi-cfl-guc: NOTRUN -> [FAIL][5]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-cfl-guc/igt@[email protected]
- fi-glk-j4005: NOTRUN -> [FAIL][6]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-glk-j4005/igt@[email protected]
#### Warnings ####
* igt@runner@aborted:
- fi-apl-guc: [FAIL][7] ([i915#4312]) -> [FAIL][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11489/fi-apl-guc/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-apl-guc/igt@[email protected]
- fi-bdw-5557u: [FAIL][9] ([i915#4312]) -> [FAIL][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11489/fi-bdw-5557u/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-bdw-5557u/igt@[email protected]
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@runner@aborted:
- {fi-jsl-1}: NOTRUN -> [FAIL][11]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-jsl-1/igt@[email protected]
- {fi-ehl-2}: NOTRUN -> [FAIL][12]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-ehl-2/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_102540v2 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c:
- fi-pnv-d510: NOTRUN -> [SKIP][13] ([fdo#109271] / [i915#5341])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-pnv-d510/igt@[email protected]
* igt@prime_vgem@basic-userptr:
- fi-pnv-d510: NOTRUN -> [SKIP][14] ([fdo#109271]) +39 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-pnv-d510/igt@[email protected]
* igt@runner@aborted:
- fi-rkl-11600: NOTRUN -> [FAIL][15] ([i915#5602])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-rkl-11600/igt@[email protected]
- fi-bsw-kefka: NOTRUN -> [FAIL][16] ([i915#3690])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-bsw-kefka/igt@[email protected]
- fi-cfl-8109u: NOTRUN -> [FAIL][17] ([i915#5602])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-cfl-8109u/igt@[email protected]
- fi-icl-u2: NOTRUN -> [FAIL][18] ([i915#3690])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-icl-u2/igt@[email protected]
- fi-bsw-nick: NOTRUN -> [FAIL][19] ([i915#3690])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-bsw-nick/igt@[email protected]
- fi-kbl-soraka: NOTRUN -> [FAIL][20] ([i915#5602])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-kbl-soraka/igt@[email protected]
- fi-kbl-7500u: NOTRUN -> [FAIL][21] ([i915#5602])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-kbl-7500u/igt@[email protected]
- fi-kbl-guc: NOTRUN -> [FAIL][22] ([i915#5602])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-kbl-guc/igt@[email protected]
- fi-rkl-guc: NOTRUN -> [FAIL][23] ([i915#5602])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-rkl-guc/igt@[email protected]
- fi-tgl-1115g4: NOTRUN -> [FAIL][24] ([i915#3690])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-tgl-1115g4/igt@[email protected]
- fi-kbl-7567u: NOTRUN -> [FAIL][25] ([i915#5602])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-kbl-7567u/igt@[email protected]
- fi-skl-guc: NOTRUN -> [FAIL][26] ([i915#5602])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-skl-guc/igt@[email protected]
- fi-skl-6700k2: NOTRUN -> [FAIL][27] ([i915#5602])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-skl-6700k2/igt@[email protected]
- fi-bsw-n3050: NOTRUN -> [FAIL][28] ([i915#3690])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-bsw-n3050/igt@[email protected]
- fi-tgl-u2: NOTRUN -> [FAIL][29] ([i915#3690])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/fi-tgl-u2/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#3690]: https://gitlab.freedesktop.org/drm/intel/issues/3690
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4897]: https://gitlab.freedesktop.org/drm/intel/issues/4897
[i915#5341]: https://gitlab.freedesktop.org/drm/intel/issues/5341
[i915#5602]: https://gitlab.freedesktop.org/drm/intel/issues/5602
Build changes
-------------
* Linux: CI_DRM_11489 -> Patchwork_102540v2
CI-20190529: 20190529
CI_DRM_11489: 0e90e7484c1e92567d0c7a0c6b4cfcbc1bbd0015 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6420: a3885810ccc0ce9e6552a20c910a0a322eca466c @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_102540v2: 102540v2 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
6dc5d68ada66 drm/i915: stolen memory use ttm backend5a741abbe505 drm/i915: ttm backend dont provide mmap_offset for kernel buffers 441819a03ff4 drm/i915: ttm move/clear logic fix1ae24ce27e84 drm/i915: sanitize mem_flags for stolen buffers f4694b2f65f0 drm/i915: instantiate ttm ranger manager for stolen memory
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102540v2/index.html