drm_mm range manager fixes, take 2
Subsystems (15)
The goal of this series is to fix top-down allocations to be allocated from the top and aligned correctly, introduce bottom-up allocations, and speed up searches and tighten evictions.
More polish on the test cases to reduce code duplication and to improve expectation checking. And a little more polish on the patches leading up to the fixes.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/40 drm/i915: Use the MRU stack search after evicting
When we evict from the GTT to make room for an object, the hole we create is put onto the MRU stack inside the drm_mm range manager. On the next search pass, we can speed up a PIN_HIGH allocation by referencing that stack for the new hole.
v2: Pull together the 3 identical implements (ahem, a couple were outdated) into a common routine for allocating a node and evicting as necessary.
--- drivers/gpu/drm/i915/gvt/aperture_gm.c | 33 +++++----------- drivers/gpu/drm/i915/i915_gem_gtt.c | 72 ++++++++++++++++++++++++---------- drivers/gpu/drm/i915/i915_gem_gtt.h | 5 +++ drivers/gpu/drm/i915/i915_vma.c | 40 ++----------------- 4 files changed, 70 insertions(+), 80 deletions(-)
drivers/gpu/drm/i915/gvt/aperture_gm.c +10 -23
@@ -48,47 +48,34 @@ static int alloc_gm(struct intel_vgpu *vgpu, bool high_gm) {struct intel_gvt *gvt = vgpu->gvt;struct drm_i915_private *dev_priv = gvt->dev_priv; -u32 alloc_flag, search_flag; +unsigned int flags;u64 start, end, size;struct drm_mm_node *node; -int retried =0 ;int ret;if (high_gm) { - search_flag =DRM_MM_SEARCH_BELOW ; - alloc_flag =DRM_MM_CREATE_TOP ; node = &vgpu->gm.high_gm_node; size =vgpu_hidden_sz (vgpu); start =gvt_hidden_gmadr_base (gvt); end =gvt_hidden_gmadr_end (gvt); + flags =PIN_HIGH ; }else { - search_flag =DRM_MM_SEARCH_DEFAULT ; - alloc_flag =DRM_MM_CREATE_DEFAULT ; node = &vgpu->gm.low_gm_node; size =vgpu_aperture_sz (vgpu); start =gvt_aperture_gmadr_base (gvt); end =gvt_aperture_gmadr_end (gvt); + flags =PIN_MAPPABLE ; }mutex_lock (&dev_priv->drm.struct_mutex); -search_again: - ret =drm_mm_insert_node_in_range_generic (&dev_priv->ggtt.base.mm, - node, size,4096 , -I915_COLOR_UNEVICTABLE , - start, end, search_flag, - alloc_flag); -if (ret) { - ret =i915_gem_evict_something (&dev_priv->ggtt.base, - size,4096 , -I915_COLOR_UNEVICTABLE , - start, end,0 ); -if (ret ==0 && ++retried <3 ) - goto search_again; - -gvt_err ("fail to alloc %s gm space from host, retried %d\n" , - high_gm ?"high" :"low" , retried); - } + ret =i915_gem_gtt_insert (&dev_priv->ggtt.base, node, + size,4096 ,I915_COLOR_UNEVICTABLE , + start, end, flags);mutex_unlock (&dev_priv->drm.struct_mutex); +if (ret) +gvt_err ("fail to alloc %s gm space from host\n" , + high_gm ?"high" :"low" ); +return ret; }
drivers/gpu/drm/i915/i915_gem_gtt.c +51 -21
90 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_gtt.h +5 -0
@@ -520,6 +520,11 @@ int __must_check i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj,void i915_gem_gtt_finish_pages (struct drm_i915_gem_object *obj,struct sg_table *pages); +int i915_gem_gtt_insert (struct i915_address_space *vm, +struct drm_mm_node *node, +u64 size,u64 alignment,unsigned long colour, +u64 start,u64 end,unsigned int flags); +/* Flags used by pin/bind&friends. */ #define PIN_NONBLOCK BIT(0)#define PIN_MAPPABLE BIT(1)
drivers/gpu/drm/i915/i915_vma.c +4 -36
@@ -410,43 +410,11 @@ i915_vma_insert(struct i915_vma *vma, u64 size, u64 alignment, u64 flags) goto err_unpin; } }else { -u32 search_flag, alloc_flag; - -if (flags &PIN_HIGH ) { - search_flag =DRM_MM_SEARCH_BELOW ; - alloc_flag =DRM_MM_CREATE_TOP ; - }else { - search_flag =DRM_MM_SEARCH_DEFAULT ; - alloc_flag =DRM_MM_CREATE_DEFAULT ; - } - -/* We only allocate in PAGE_SIZE/GTT_PAGE_SIZE (4096) chunks, -* so we know that we always have a minimum alignment of 4096. -* The drm_mm range manager is optimised to return results -* with zero alignment, so where possible use the optimal -* path. -*/ -if (alignment <=4096 ) - alignment =0 ; - -search_free: - ret =drm_mm_insert_node_in_range_generic (&vma->vm->mm, - &vma->node, - size, alignment, - obj->cache_level, - start, end, - search_flag, - alloc_flag); -if (ret) { - ret =i915_gem_evict_something (vma->vm, size, alignment, - obj->cache_level, - start, end, - flags); -if (ret ==0 ) - goto search_free; - + ret =i915_gem_gtt_insert (vma->vm, &vma->node, + size, alignment, obj->cache_level, + start, end, flags); +if (ret) goto err_unpin; - }GEM_BUG_ON (vma->node.start < start);GEM_BUG_ON (vma->node.start + vma->node.size > end);
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 01/40] drm/i915: Use the MRU stack search after evicting
Quoted 11 lines · Chris Wilson
When we evict from the GTT to make room for an object, the hole we create is put onto the MRU stack inside the
drm_mmrange manager. On the next search pass, we can speed up aPIN_HIGHallocation by referencing that stack for the new hole.v2: Pull together the 3 identical implements (ahem, a couple were outdated) into a common routine for allocating a node and evicting as necessary.
Signed-off-by Chris Wilson <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]> #v1
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/40 drm/i915: Simplify i915_gtt_color_adjust()
In reply to Chris WilsonIf we remember that node_list is a circular list containing the fake head_node, we can use a simple list_next_entry() and skip the NULL check for the allocated check against the head_node.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -4
@@ -2707,10 +2707,8 @@ static void i915_gtt_color_adjust(struct drm_mm_node *node,if (node->color != color) *start +=4096 ; - node =list_first_entry_or_null (&node->node_list, - struct drm_mm_node, - node_list); -if (node && node->allocated && node->color != color) + node =list_next_entry (node, node_list); +if (node->allocated && node->color != color) *end -=4096 ; }
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 3/40 drm: Add drm_mm_for_each_node_safe()
In reply to Chris WilsonA complement to drm_mm_for_each_node(), wraps list_for_each_entry_safe() for walking the list of nodes safe against removal.
--- drivers/gpu/drm/drm_mm.c | 9 ++++----- include/drm/drm_mm.h | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_mm.c +4 -5
@@ -138,7 +138,7 @@ static void show_leaks(struct drm_mm *mm)if (!buf)return ; -list_for_each_entry (node, &mm->head_node.node_list, node_list) { +list_for_each_entry (node,__drm_mm_nodes (mm), node_list) {struct stack_trace trace = { .entries = entries, .max_entries =STACKDEPTH
@@ -320,8 +320,7 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)if (hole->start < end)return -ENOSPC ; }else { - hole =list_entry (&mm->head_node.node_list, -typeof (*hole), node_list); + hole =list_entry (__drm_mm_nodes (mm),typeof (*hole), node_list); } hole =list_last_entry (&hole->node_list,typeof (*hole), node_list);
@@ -884,7 +883,7 @@ EXPORT_SYMBOL(drm_mm_scan_remove_block);*/ bool drm_mm_clean (struct drm_mm * mm) { -struct list_head *head = &mm->head_node.node_list; +struct list_head *head =__drm_mm_nodes (mm);return (head->next->next == head); }
@@ -930,7 +929,7 @@ EXPORT_SYMBOL(drm_mm_init);*/ void drm_mm_takedown (struct drm_mm *mm) { -if (WARN (!list_empty (&mm->head_node.node_list), +if (WARN (!list_empty (__drm_mm_nodes (mm)),"Memory manager not clean during takedown.\n" ))show_leaks (mm);
include/drm/drm_mm.h +16 -3
@@ -179,6 +179,8 @@ static inline u64 drm_mm_hole_node_end(struct drm_mm_node *hole_node)return __drm_mm_hole_node_end (hole_node); } +#define __drm_mm_nodes (mm) (&(mm)->head_node.node_list) +/** * drm_mm_for_each_node - iterator to walk over all allocated nodes * @entry: drm_mm_node structure to assign to in each iteration step
@@ -187,9 +189,20 @@ static inline u64 drm_mm_hole_node_end(struct drm_mm_node *hole_node)* This iterator walks over all nodes in the range allocator. It is implemented * with list_for_each, so not save against removal of elements. */ -#define drm_mm_for_each_node (entry, mm) list_for_each_entry(entry, \ - &(mm)->head_node.node_list, \ - node_list) +#define drm_mm_for_each_node (entry, mm) \ + list_for_each_entry(entry, __drm_mm_nodes(mm), node_list) + +/** +* drm_mm_for_each_node_safe - iterator to walk over all allocated nodes +* @entry: drm_mm_node structure to assign to in each iteration step +* @next: drm_mm_node structure to store the next step +* @mm: drm_mm allocator to walk +* +* This iterator walks over all nodes in the range allocator. It is implemented +* with list_for_each_safe, so save against removal of elements. +*/ +#define drm_mm_for_each_node_safe (entry, next, mm) \ + list_for_each_entry_safe(entry, next, __drm_mm_nodes(mm), node_list)#define __drm_mm_for_each_hole (entry, mm, hole_start, hole_end, backwards) \ for (entry = list_entry((backwards) ? (mm)->hole_stack.prev : (mm)->hole_stack.next, struct drm_mm_node, hole_stack); \
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerRe: [PATCH v2 03/40] drm: Add drm_mm_for_each_node_safe()
Quoted 3 lines · Chris Wilson
A complement to
drm_mm_for_each_node(), wrapslist_for_each_entry_safe()for walking the list of nodes safe against removal.
Most of the diff is about __drm_mm_nodes(mm), which could be split into own patch and keep the R-b's.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 03/40] drm: Add drm_mm_for_each_node_safe()
Quoted 7 lines · Joonas Lahtinen
Quoted 3 lines · Chris Wilson
A complement to
drm_mm_for_each_node(), wrapslist_for_each_entry_safe()for walking the list of nodes safe against removal.Most of the diff is about __drm_mm_nodes(mm), which could be split into own patch and keep the R-b's.
Added a note and applied to drm-misc, thanks.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 4/40 drm: Constify the drm_mm API
In reply to Chris WilsonMark up the pointers as constant through the API where appropriate.
--- drivers/gpu/drm/drm_mm.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- include/drm/drm_mm.h | 27 +++++++++++++-------------- 3 files changed, 26 insertions(+), 27 deletions(-)
drivers/gpu/drm/drm_mm.c +12 -12
@@ -174,9 +174,9 @@ INTERVAL_TREE_DEFINE(struct drm_mm_node, rb, START, LAST, static inline, drm_mm_interval_tree)struct drm_mm_node * -__drm_mm_interval_first (struct drm_mm *mm,u64 start,u64 last) +__drm_mm_interval_first (const struct drm_mm *mm,u64 start,u64 last) { -return drm_mm_interval_tree_iter_first (&mm->interval_tree, +return drm_mm_interval_tree_iter_first ((struct rb_root *)&mm->interval_tree, start, last); }EXPORT_SYMBOL (__drm_mm_interval_first);
@@ -881,9 +881,9 @@ EXPORT_SYMBOL(drm_mm_scan_remove_block);* True if the allocator is completely free, false if there's still a node * allocated in it. */ -bool drm_mm_clean (struct drm_mm * mm) +bool drm_mm_clean (const struct drm_mm *mm) { -struct list_head *head =__drm_mm_nodes (mm); +const struct list_head *head =__drm_mm_nodes (mm);return (head->next->next == head); }
@@ -897,7 +897,7 @@ EXPORT_SYMBOL(drm_mm_clean);* * Note that @mm must be cleared to 0 before calling this function. */ -void drm_mm_init (struct drm_mm * mm,u64 start,u64 size) +void drm_mm_init (struct drm_mm *mm,u64 start,u64 size) {INIT_LIST_HEAD (&mm->hole_stack); mm->scanned_blocks =0 ;
@@ -936,8 +936,8 @@ void drm_mm_takedown(struct drm_mm *mm) }EXPORT_SYMBOL (drm_mm_takedown); -static u64 drm_mm_debug_hole (struct drm_mm_node *entry, -const char *prefix) +static u64 drm_mm_debug_hole (const struct drm_mm_node *entry, +const char *prefix) {u64 hole_start, hole_end, hole_size;
@@ -958,9 +958,9 @@ static u64 drm_mm_debug_hole(struct drm_mm_node *entry,* @mm: drm_mm allocator to dump * @prefix: prefix to use for dumping to dmesg */ -void drm_mm_debug_table (struct drm_mm *mm,const char *prefix) +void drm_mm_debug_table (const struct drm_mm *mm,const char *prefix) { -struct drm_mm_node *entry; +const struct drm_mm_node *entry;u64 total_used =0 , total_free =0 , total =0 ; total_free +=drm_mm_debug_hole (&mm->head_node, prefix);
@@ -979,7 +979,7 @@ void drm_mm_debug_table(struct drm_mm *mm, const char *prefix)EXPORT_SYMBOL (drm_mm_debug_table);#if defined(CONFIG_DEBUG_FS ) -static u64 drm_mm_dump_hole (struct seq_file *m,struct drm_mm_node *entry) +static u64 drm_mm_dump_hole (struct seq_file *m,const struct drm_mm_node *entry) {u64 hole_start, hole_end, hole_size;
@@ -1000,9 +1000,9 @@ static u64 drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry)* @m: seq_file to dump to * @mm: drm_mm allocator to dump */ -int drm_mm_dump_table (struct seq_file *m,struct drm_mm *mm) +int drm_mm_dump_table (struct seq_file *m,const struct drm_mm *mm) { -struct drm_mm_node *entry; +const struct drm_mm_node *entry;u64 total_used =0 , total_free =0 , total =0 ; total_free +=drm_mm_dump_hole (m, &mm->head_node);
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -2699,7 +2699,7 @@ void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj,dma_unmap_sg (kdev, pages->sgl, pages->nents,PCI_DMA_BIDIRECTIONAL ); } -static void i915_gtt_color_adjust (struct drm_mm_node *node, +static void i915_gtt_color_adjust (const struct drm_mm_node *node,unsigned long color,u64 *start,u64 *end)
include/drm/drm_mm.h +13 -14
@@ -102,7 +102,8 @@ struct drm_mm {u64 scan_end;struct drm_mm_node *prev_scanned_node; -void (*color_adjust)(struct drm_mm_node *node,unsigned long color, +void (*color_adjust)(const struct drm_mm_node *node, +unsigned long color,u64 *start,u64 *end); };
@@ -116,7 +117,7 @@ struct drm_mm {* Returns: * True if the @node is allocated. */ -static inline bool drm_mm_node_allocated (struct drm_mm_node *node) +static inline bool drm_mm_node_allocated (const struct drm_mm_node *node) {return node->allocated; }
@@ -131,12 +132,12 @@ static inline bool drm_mm_node_allocated(struct drm_mm_node *node)* Returns: * True if the @mm is initialized. */ -static inline bool drm_mm_initialized (struct drm_mm *mm) +static inline bool drm_mm_initialized (const struct drm_mm *mm) {return mm->hole_stack.next; } -static inline u64 __drm_mm_hole_node_start (struct drm_mm_node *hole_node) +static inline u64 __drm_mm_hole_node_start (const struct drm_mm_node *hole_node) {return hole_node->start + hole_node->size; }
@@ -152,13 +153,13 @@ static inline u64 __drm_mm_hole_node_start(struct drm_mm_node *hole_node)* Returns: * Start of the subsequent hole. */ -static inline u64 drm_mm_hole_node_start (struct drm_mm_node *hole_node) +static inline u64 drm_mm_hole_node_start (const struct drm_mm_node *hole_node) {BUG_ON (!hole_node->hole_follows);return __drm_mm_hole_node_start (hole_node); } -static inline u64 __drm_mm_hole_node_end (struct drm_mm_node *hole_node) +static inline u64 __drm_mm_hole_node_end (const struct drm_mm_node *hole_node) {return list_next_entry (hole_node, node_list)->start; }
@@ -174,7 +175,7 @@ static inline u64 __drm_mm_hole_node_end(struct drm_mm_node *hole_node)* Returns: * End of the subsequent hole. */ -static inline u64 drm_mm_hole_node_end (struct drm_mm_node *hole_node) +static inline u64 drm_mm_hole_node_end (const struct drm_mm_node *hole_node) {return __drm_mm_hole_node_end (hole_node); }
@@ -314,14 +315,12 @@ static inline int drm_mm_insert_node_in_range(struct drm_mm *mm,void drm_mm_remove_node (struct drm_mm_node *node);void drm_mm_replace_node (struct drm_mm_node *old,struct drm_mm_node *new); -void drm_mm_init (struct drm_mm *mm, -u64 start, -u64 size); +void drm_mm_init (struct drm_mm *mm,u64 start,u64 size);void drm_mm_takedown (struct drm_mm *mm); -bool drm_mm_clean (struct drm_mm *mm); +bool drm_mm_clean (const struct drm_mm *mm);struct drm_mm_node * -__drm_mm_interval_first (struct drm_mm *mm,u64 start,u64 last); +__drm_mm_interval_first (const struct drm_mm *mm,u64 start,u64 last);/** * drm_mm_for_each_node_in_range - iterator to walk over a range of
@@ -355,9 +354,9 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm,bool drm_mm_scan_add_block (struct drm_mm_node *node);bool drm_mm_scan_remove_block (struct drm_mm_node *node); -void drm_mm_debug_table (struct drm_mm *mm,const char *prefix); +void drm_mm_debug_table (const struct drm_mm *mm,const char *prefix);#ifdef CONFIG_DEBUG_FS -int drm_mm_dump_table (struct seq_file *m,struct drm_mm *mm); +int drm_mm_dump_table (struct seq_file *m,const struct drm_mm *mm);#endif #endif
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 04/40] drm: Constify the drm_mm API
Quoted 3 lines · Chris Wilson
Mark up the pointers as constant through the API where appropriate.
Signed-off-by Chris Wilson <[email protected]>
Ok merged this and the patch right before, then Chris told me on irc that I need to stop because he's mixing a v3 of this series. -Daniel
Quoted 200 lines
--- drivers/gpu/drm/drm_mm.c | 24 ++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- include/drm/drm_mm.h | 27 +++++++++++++-------------- 3 files changed, 26 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_mm.c +12
-12@@ -174,9 +174,9 @@ INTERVAL_TREE_DEFINE(struct drm_mm_node, rb, START, LAST, static inline, drm_mm_interval_tree)struct drm_mm_node * -__drm_mm_interval_first (struct drm_mm *mm,u64 start,u64 last) +__drm_mm_interval_first (const struct drm_mm *mm,u64 start,u64 last) { -return drm_mm_interval_tree_iter_first (&mm->interval_tree, +return drm_mm_interval_tree_iter_first ((struct rb_root *)&mm->interval_tree, start, last); }EXPORT_SYMBOL (__drm_mm_interval_first);@@ -881,9 +881,9 @@ EXPORT_SYMBOL(drm_mm_scan_remove_block);* True if the allocator is completely free, false if there's still a node * allocated in it. */ -bool drm_mm_clean (struct drm_mm * mm) +bool drm_mm_clean (const struct drm_mm *mm) { -struct list_head *head =__drm_mm_nodes (mm); +const struct list_head *head =__drm_mm_nodes (mm);return (head->next->next == head); }@@ -897,7 +897,7 @@ EXPORT_SYMBOL(drm_mm_clean);* * Note that @mm must be cleared to 0 before calling this function. */ -void drm_mm_init (struct drm_mm * mm,u64 start,u64 size) +void drm_mm_init (struct drm_mm *mm,u64 start,u64 size) {INIT_LIST_HEAD (&mm->hole_stack); mm->scanned_blocks =0 ;@@ -936,8 +936,8 @@ void drm_mm_takedown(struct drm_mm *mm) }EXPORT_SYMBOL (drm_mm_takedown); -static u64 drm_mm_debug_hole (struct drm_mm_node *entry, -const char *prefix) +static u64 drm_mm_debug_hole (const struct drm_mm_node *entry, +const char *prefix) {u64 hole_start, hole_end, hole_size;@@ -958,9 +958,9 @@ static u64 drm_mm_debug_hole(struct drm_mm_node *entry,* @mm: drm_mm allocator to dump * @prefix: prefix to use for dumping to dmesg */ -void drm_mm_debug_table (struct drm_mm *mm,const char *prefix) +void drm_mm_debug_table (const struct drm_mm *mm,const char *prefix) { -struct drm_mm_node *entry; +const struct drm_mm_node *entry;u64 total_used =0 , total_free =0 , total =0 ; total_free +=drm_mm_debug_hole (&mm->head_node, prefix);@@ -979,7 +979,7 @@ void drm_mm_debug_table(struct drm_mm *mm, const char *prefix)EXPORT_SYMBOL (drm_mm_debug_table);#if defined(CONFIG_DEBUG_FS ) -static u64 drm_mm_dump_hole (struct seq_file *m,struct drm_mm_node *entry) +static u64 drm_mm_dump_hole (struct seq_file *m,const struct drm_mm_node *entry) {u64 hole_start, hole_end, hole_size;@@ -1000,9 +1000,9 @@ static u64 drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry)* @m: seq_file to dump to * @mm: drm_mm allocator to dump */ -int drm_mm_dump_table (struct seq_file *m,struct drm_mm *mm) +int drm_mm_dump_table (struct seq_file *m,const struct drm_mm *mm) { -struct drm_mm_node *entry; +const struct drm_mm_node *entry;u64 total_used =0 , total_free =0 , total =0 ; total_free +=drm_mm_dump_hole (m, &mm->head_node);drivers/gpu/drm/i915/i915_gem_gtt.c +1
-1@@ -2699,7 +2699,7 @@ void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj,dma_unmap_sg (kdev, pages->sgl, pages->nents,PCI_DMA_BIDIRECTIONAL ); } -static void i915_gtt_color_adjust (struct drm_mm_node *node, +static void i915_gtt_color_adjust (const struct drm_mm_node *node,unsigned long color,u64 *start,u64 *end)include/drm/drm_mm.h +13
-14@@ -102,7 +102,8 @@ struct drm_mm {u64 scan_end;struct drm_mm_node *prev_scanned_node; -void (*color_adjust)(struct drm_mm_node *node,unsigned long color, +void (*color_adjust)(const struct drm_mm_node *node, +unsigned long color,u64 *start,u64 *end); };@@ -116,7 +117,7 @@ struct drm_mm {* Returns: * True if the @node is allocated. */ -static inline bool drm_mm_node_allocated (struct drm_mm_node *node) +static inline bool drm_mm_node_allocated (const struct drm_mm_node *node) {return node->allocated; }@@ -131,12 +132,12 @@ static inline bool drm_mm_node_allocated(struct drm_mm_node *node)* Returns: * True if the @mm is initialized. */ -static inline bool drm_mm_initialized (struct drm_mm *mm) +static inline bool drm_mm_initialized (const struct drm_mm *mm) {return mm->hole_stack.next; } -static inline u64 __drm_mm_hole_node_start (struct drm_mm_node *hole_node) +static inline u64 __drm_mm_hole_node_start (const struct drm_mm_node *hole_node) {return hole_node->start + hole_node->size; }@@ -152,13 +153,13 @@ static inline u64 __drm_mm_hole_node_start(struct drm_mm_node *hole_node)* Returns: * Start of the subsequent hole. */ -static inline u64 drm_mm_hole_node_start (struct drm_mm_node *hole_node) +static inline u64 drm_mm_hole_node_start (const struct drm_mm_node *hole_node) {BUG_ON (!hole_node->hole_follows);return __drm_mm_hole_node_start (hole_node); } -static inline u64 __drm_mm_hole_node_end (struct drm_mm_node *hole_node) +static inline u64 __drm_mm_hole_node_end (const struct drm_mm_node *hole_node) {return list_next_entry (hole_node, node_list)->start; }@@ -174,7 +175,7 @@ static inline u64 __drm_mm_hole_node_end(struct drm_mm_node *hole_node)* Returns: * End of the subsequent hole. */ -static inline u64 drm_mm_hole_node_end (struct drm_mm_node *hole_node) +static inline u64 drm_mm_hole_node_end (const struct drm_mm_node *hole_node) {return __drm_mm_hole_node_end (hole_node); }@@ -314,14 +315,12 @@ static inline int drm_mm_insert_node_in_range(struct drm_mm *mm,void drm_mm_remove_node (struct drm_mm_node *node);void drm_mm_replace_node (struct drm_mm_node *old,struct drm_mm_node *new); -void drm_mm_init (struct drm_mm *mm, -u64 start, -u64 size); +void drm_mm_init (struct drm_mm *mm,u64 start,u64 size);void drm_mm_takedown (struct drm_mm *mm); -bool drm_mm_clean (struct drm_mm *mm); +bool drm_mm_clean (const struct drm_mm *mm);struct drm_mm_node * -__drm_mm_interval_first (struct drm_mm *mm,u64 start,u64 last); +__drm_mm_interval_first (const struct drm_mm *mm,u64 start,u64 last);/** * drm_mm_for_each_node_in_range - iterator to walk over a range of @@ -355,9 +354,9 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm,bool drm_mm_scan_add_block (struct drm_mm_node *node);bool drm_mm_scan_remove_block (struct drm_mm_node *node); -void drm_mm_debug_table (struct drm_mm *mm,const char *prefix); +void drm_mm_debug_table (const struct drm_mm *mm,const char *prefix);#ifdef CONFIG_DEBUG_FS -int drm_mm_dump_table (struct seq_file *m,struct drm_mm *mm); +int drm_mm_dump_table (struct seq_file *m,const struct drm_mm *mm);#endif #endif Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 5/40 drm: Compile time enabling for asserts in drm_mm
In reply to Chris WilsonUse CONFIG_DRM_DEBUG_MM to conditionally enable the internal and validation checking using BUG_ON. Ideally these paths should all be exercised by CI selftests (with the asserts enabled).
--- drivers/gpu/drm/drm_mm.c | 45 +++++++++++++++++++++++---------------------- include/drm/drm_mm.h | 8 +++++++- 2 files changed, 30 insertions(+), 23 deletions(-)
drivers/gpu/drm/drm_mm.c +23 -22
@@ -237,7 +237,7 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,u64 adj_start = hole_start;u64 adj_end = hole_end; -BUG_ON (node->allocated); +DRM_MM_BUG_ON (node->allocated);if (mm->color_adjust) mm->color_adjust (hole_node, color, &adj_start, &adj_end);
@@ -258,8 +258,8 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, } } -BUG_ON (adj_start < hole_start); -BUG_ON (adj_end > hole_end); +DRM_MM_BUG_ON (adj_start < hole_start); +DRM_MM_BUG_ON (adj_end > hole_end);if (adj_start == hole_start) { hole_node->hole_follows =0 ;
@@ -276,7 +276,7 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,drm_mm_interval_tree_add_node (hole_node, node); -BUG_ON (node->start + node->size > adj_end); +DRM_MM_BUG_ON (node->start + node->size > adj_end); node->hole_follows =0 ;if (__drm_mm_hole_node_start (node) < hole_end) {
@@ -409,7 +409,7 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,u64 adj_start = hole_start;u64 adj_end = hole_end; -BUG_ON (!hole_node->hole_follows || node->allocated); +DRM_MM_BUG_ON (!hole_node->hole_follows || node->allocated);if (adj_start < start) adj_start = start;
@@ -450,10 +450,10 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,drm_mm_interval_tree_add_node (hole_node, node); -BUG_ON (node->start < start); -BUG_ON (node->start < adj_start); -BUG_ON (node->start + node->size > adj_end); -BUG_ON (node->start + node->size > end); +DRM_MM_BUG_ON (node->start < start); +DRM_MM_BUG_ON (node->start < adj_start); +DRM_MM_BUG_ON (node->start + node->size > adj_end); +DRM_MM_BUG_ON (node->start + node->size > end); node->hole_follows =0 ;if (__drm_mm_hole_node_start (node) < hole_end) {
@@ -519,22 +519,21 @@ void drm_mm_remove_node(struct drm_mm_node *node)struct drm_mm *mm = node->mm;struct drm_mm_node *prev_node; -if (WARN_ON (!node->allocated)) -return ; - -BUG_ON (node->scanned_block || node->scanned_prev_free - || node->scanned_next_free); +DRM_MM_BUG_ON (!node->allocated); +DRM_MM_BUG_ON (node->scanned_block || + node->scanned_prev_free || + node->scanned_next_free); prev_node = list_entry(node->node_list.prev, struct drm_mm_node, node_list);if (node->hole_follows) { -BUG_ON (__drm_mm_hole_node_start (node) == -__drm_mm_hole_node_end (node)); +DRM_MM_BUG_ON (__drm_mm_hole_node_start (node) == +__drm_mm_hole_node_end (node));list_del (&node->hole_stack); }else -BUG_ON (__drm_mm_hole_node_start (node) != -__drm_mm_hole_node_end (node)); +DRM_MM_BUG_ON (__drm_mm_hole_node_start (node) != +__drm_mm_hole_node_end (node));if (!prev_node->hole_follows) {
@@ -578,7 +577,7 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,u64 adj_end;u64 best_size; -BUG_ON (mm->scanned_blocks); +DRM_MM_BUG_ON (mm->scanned_blocks); best =NULL ; best_size = ~0UL ;
@@ -622,7 +621,7 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_u64 adj_end;u64 best_size; -BUG_ON (mm->scanned_blocks); +DRM_MM_BUG_ON (mm->scanned_blocks); best =NULL ; best_size = ~0UL ;
@@ -668,6 +667,8 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_*/ void drm_mm_replace_node (struct drm_mm_node *old,struct drm_mm_node *new) { +DRM_MM_BUG_ON (!old->allocated); +list_replace (&old->node_list, &new->node_list);list_replace (&old->hole_stack, &new->hole_stack);rb_replace_node (&old->rb, &new->rb, &old->mm->interval_tree);
@@ -798,7 +799,7 @@ bool drm_mm_scan_add_block(struct drm_mm_node *node) mm->scanned_blocks++; -BUG_ON (node->scanned_block); +DRM_MM_BUG_ON (node->scanned_block); node->scanned_block =1 ; prev_node = list_entry(node->node_list.prev, struct drm_mm_node,
@@ -859,7 +860,7 @@ bool drm_mm_scan_remove_block(struct drm_mm_node *node) mm->scanned_blocks--; -BUG_ON (!node->scanned_block); +DRM_MM_BUG_ON (!node->scanned_block); node->scanned_block =0 ; prev_node = list_entry(node->node_list.prev, struct drm_mm_node,
include/drm/drm_mm.h +7 -1
@@ -48,6 +48,12 @@#include <linux/stackdepot.h> #endif +#ifdef CONFIG_DRM_DEBUG_MM +#define DRM_MM_BUG_ON (expr) BUG_ON(expr) +#else +#define DRM_MM_BUG_ON (expr) BUILD_BUG_ON_INVALID(expr) +#endif +enum drm_mm_search_flags {DRM_MM_SEARCH_DEFAULT =0 ,DRM_MM_SEARCH_BEST =1 <<0 ,
@@ -155,7 +161,7 @@ static inline u64 __drm_mm_hole_node_start(const struct drm_mm_node *hole_node)*/ static inline u64 drm_mm_hole_node_start (const struct drm_mm_node *hole_node) { -BUG_ON (!hole_node->hole_follows); +DRM_MM_BUG_ON (!hole_node->hole_follows);return __drm_mm_hole_node_start (hole_node); }
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 6/40 drm: Add some kselftests for the DRM range manager (struct drm_mm)
In reply to Chris WilsonFirst we introduce a smattering of infrastructure for writing selftests. The idea is that we have a test module that exercises a particular portion of the exported API, and that module provides a set of tests that can either be run as an ensemble via kselftest or individually via an igt harness (in this case igt/drm_mm). To accommodate selecting individual tests, we export a boolean parameter to control selection of each test - that is hidden inside a bunch of reusable boilerplate macros to keep writing the tests simple.
v2: Choose a random random_seed unless one is specified by the user.
v3: More parameters to control max_iterations and max_prime of the tests.
Testcase: igt/drm_mm
--- drivers/gpu/drm/Kconfig | 13 +++ drivers/gpu/drm/Makefile | 2 + drivers/gpu/drm/selftests/drm_mm_selftests.h | 8 ++ drivers/gpu/drm/selftests/drm_selftest.c | 109 ++++++++++++++++++++++++++ drivers/gpu/drm/selftests/drm_selftest.h | 41 ++++++++++ drivers/gpu/drm/selftests/test-drm_mm.c | 55 +++++++++++++ tools/testing/selftests/drivers/gpu/drm_mm.sh | 15 ++++ 7 files changed, 243 insertions(+) create mode 100644 drivers/gpu/drm/selftests/drm_mm_selftests.h create mode 100644 drivers/gpu/drm/selftests/drm_selftest.c create mode 100644 drivers/gpu/drm/selftests/drm_selftest.h create mode 100644 drivers/gpu/drm/selftests/test-drm_mm.c create mode 100755 tools/testing/selftests/drivers/gpu/drm_mm.sh
drivers/gpu/drm/Kconfig +13 -0
@@ -48,6 +48,19 @@ config DRM_DEBUG_MM If in doubt, say "N". +config DRM_DEBUG_MM_SELFTEST + tristate "kselftests for DRM range manager (struct drm_mm)" + depends on DRM + depends on DEBUG_KERNEL + default n + help + This option provides a kernel module that can be used to test + the DRM range manager (drm_mm) and its API. This option is not + useful for distributions or general kernels, but only for kernel + developers working on DRM and associated drivers. + + If in doubt, say "N". + config DRM_KMS_HELPER tristate depends on DRM
drivers/gpu/drm/Makefile +2 -0
@@ -18,6 +18,8 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ drm_plane.o drm_color_mgmt.o drm_print.o \ drm_dumb_buffers.o drm_mode_config.o +obj-$(CONFIG_DRM_DEBUG_MM_SELFTEST) += selftests/test-drm_mm.o + drm-$(CONFIG_COMPAT) += drm_ioc32.o drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o drm-$(CONFIG_PCI) += ati_pcigart.o
drivers/gpu/drm/selftests/drm_mm_selftests.h new file +8 -0
@@ -0,0 +1,8 @@ +/* List each unit test as selftest(name, function) +* +* The name is used as both an enum and expanded as igt__name to create +* a module parameter. It must be unique and legal for a C identifier. +* +* Tests are executed in order by igt/drm_mm +*/ +selftest (sanitycheck, igt_sanitycheck)/* keep first (selfcheck for igt) */
drivers/gpu/drm/selftests/drm_selftest.c new file +109 -0
109 lines not on this page · raw message
drivers/gpu/drm/selftests/drm_selftest.h new file +41 -0
41 lines not on this page · raw message
drivers/gpu/drm/selftests/test-drm_mm.c new file +55 -0
55 lines not on this page · raw message
tools/testing/selftests/drivers/gpu/drm_mm.sh new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# Runs API tests for struct drm_mm (DRM range manager) + +if ! /sbin/modprobe -n -q test-drm_mm; then + echo "drivers/gpu/drm_mm: [skip]" + exit 77 +fi + +if /sbin/modprobe -q test-drm_mm; then + /sbin/modprobe -q -r test-drm_mm + echo "drivers/gpu/drm_mm: ok" +else + echo "drivers/gpu/drm_mm: [FAIL]" + exit 1 +fi
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 7/40 drm: Add a simple generator of random permutations
In reply to Chris WilsonWhen testing, we want a random but yet reproducible order in which to process elements. Here we create an array which is a random (using the Tausworthe PRNG) permutation of the order in which to execute.
v2: Tidier code by David Herrmann
--- drivers/gpu/drm/Kconfig | 6 ++++++ drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/lib/drm_random.c | 41 ++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/lib/drm_random.h | 21 ++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 drivers/gpu/drm/lib/drm_random.c create mode 100644 drivers/gpu/drm/lib/drm_random.h
drivers/gpu/drm/Kconfig +6 -0
@@ -52,6 +52,7 @@ config DRM_DEBUG_MM_SELFTEST tristate "kselftests for DRM range manager (struct drm_mm)" depends on DRM depends on DEBUG_KERNEL + select DRM_LIB_RANDOM default n help This option provides a kernel module that can be used to test
@@ -334,3 +335,8 @@ config DRM_SAVAGE chipset. If M is selected the module will be called savage. endif # DRM_LEGACY + +config DRM_LIB_RANDOM + bool + default n +
drivers/gpu/drm/Makefile +1 -0
@@ -18,6 +18,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ drm_plane.o drm_color_mgmt.o drm_print.o \ drm_dumb_buffers.o drm_mode_config.o +drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o obj-$(CONFIG_DRM_DEBUG_MM_SELFTEST) += selftests/test-drm_mm.o drm-$(CONFIG_COMPAT) += drm_ioc32.o
drivers/gpu/drm/lib/drm_random.c new file +41 -0
41 lines not on this page · raw message
drivers/gpu/drm/lib/drm_random.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef __DRM_RANDOM_H__ +#define __DRM_RANDOM_H + +#include <linux/random.h> + +#define RND_STATE_INITIALIZER (seed__) ({ \ + struct rnd_state state__; \ + prandom_seed_state(&state__, (seed__)); \ + state__; \ +}) + +#define RND_STATE (name__, seed__) \ + struct rnd_state name__ = RND_STATE_INITIALIZER(seed__) + +unsigned int *drm_random_order (unsigned int count, +struct rnd_state *state); +void drm_random_reorder (unsigned int *order, +unsigned int count, +struct rnd_state *state); + +#endif /* __DRM_RANDOM_H__ */
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 07/40] drm: Add a simple generator of random permutations
Quoted 9 lines · Chris Wilson
When testing, we want a random but yet reproducible order in which to process elements. Here we create an array which is a random (using the Tausworthe PRNG) permutation of the order in which to execute.
v2: Tidier code by David Herrmann
Signed-off-by Chris Wilson <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc David Herrmann <[email protected]>
<SNIP>
Quoted 4 lines
drivers/gpu/drm/lib/drm_random.c new file +3
-0@@ -0,0 +1,41 @@ +#include <linux/bitops.h> +#include <linux/kernel.h> +#include <linux/random.h>
drivers/gpu/drm/lib/drm_random.c line 13
Quoted 10 lines
drivers/gpu/drm/lib/drm_random.c new file +10
-0+#include <linux/slab.h> +#include <linux/types.h> + +#include "drm_random.h" + +static inline u32 prandom_u32_max_state (u32 ep_ro,struct rnd_state *state) +{ +return upper_32_bits ((u64 )prandom_u32_state (state) * ep_ro); +} +
To be submitted upstream. If you prefix the function here, there won't be a conflict when the upstream part gets merged.
Quoted 5 lines
drivers/gpu/drm/lib/drm_random.h new file +4
-0+++ b/drivers/gpu/drm/lib/drm_random.h@@ -0,0 +1,21 @@ +#ifndef __DRM_RANDOM_H__ +#define __DRM_RANDOM_H +
drivers/gpu/drm/lib/drm_random.h line 13
Quoted 10 lines
drivers/gpu/drm/lib/drm_random.h new file +10
-0+#include <linux/random.h> + +#define RND_STATE_INITIALIZER (seed__) ({ \ + struct rnd_state state__; \ + prandom_seed_state(&state__, (seed__)); \ + state__; \ +}) + +#define RND_STATE (name__, seed__) \ + struct rnd_state name__ = RND_STATE_INITIALIZER(seed__)
For upstream submission too. Same comment as above.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 8/40 drm: Add a simple prime number generator
In reply to Chris WilsonPrime numbers are interesting for testing components that use multiplies and divides, such as testing struct drm_mm alignment computations.
--- drivers/gpu/drm/Kconfig | 4 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/lib/drm_prime_numbers.c | 175 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/lib/drm_prime_numbers.h | 10 ++ 4 files changed, 190 insertions(+) create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.c create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.h
drivers/gpu/drm/Kconfig +4 -0
@@ -53,6 +53,7 @@ config DRM_DEBUG_MM_SELFTEST depends on DRM depends on DEBUG_KERNEL select DRM_LIB_RANDOM + select DRM_LIB_PRIMES default n help This option provides a kernel module that can be used to test
@@ -340,3 +341,6 @@ config DRM_LIB_RANDOM bool default n +config DRM_LIB_PRIMES + bool + default n
drivers/gpu/drm/Makefile +1 -0
@@ -19,6 +19,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ drm_dumb_buffers.o drm_mode_config.o drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o +obj-$(CONFIG_DRM_LIB_PRIMES) += lib/drm_prime_numbers.o obj-$(CONFIG_DRM_DEBUG_MM_SELFTEST) += selftests/test-drm_mm.o drm-$(CONFIG_COMPAT) += drm_ioc32.o
drivers/gpu/drm/lib/drm_prime_numbers.c new file +175 -0
175 lines not on this page · raw message
drivers/gpu/drm/lib/drm_prime_numbers.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef __DRM_PRIMES_H__ +#define __DRM_PRIMES_H__ + +bool drm_is_prime_number (unsigned long x); +unsigned long drm_next_prime_number (unsigned long x); + +#define drm_for_each_prime (prime, max) \ + for (prime = 1; prime < (max); prime = drm_next_prime_number(prime)) + +#endif /* __DRM_PRIMES_H__ */
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 08/40] drm: Add a simple prime number generator
Quoted 4 lines · Chris Wilson
Prime numbers are interesting for testing components that use multiplies and divides, such as testing struct
drm_mmalignment computations.Signed-off-by Chris Wilson <[email protected]>
Quoted 8 lines
--- drivers/gpu/drm/Kconfig | 4 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/lib/drm_prime_numbers.c | 175 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/lib/drm_prime_numbers.h | 10 ++ 4 files changed, 190 insertions(+) create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.c create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.h
Hm, why not put this in lib/ ? Don't see anything DRM-specific here at first glance and this might be useful to others. Or others might come up with improvements and they'll be more likely to discover it outside of DRM.
Same for the random permutations patch.
Thanks,
Lukas
Quoted 236 lines
drivers/gpu/drm/Kconfig +4
-0@@ -53,6 +53,7 @@ config DRM_DEBUG_MM_SELFTEST depends on DRM depends on DEBUG_KERNEL select DRM_LIB_RANDOM + select DRM_LIB_PRIMES default n help This option provides a kernel module that can be used to test@@ -340,3 +341,6 @@ config DRM_LIB_RANDOM bool default n +config DRM_LIB_PRIMES + bool + default ndrivers/gpu/drm/Makefile +1
-0@@ -19,6 +19,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ drm_dumb_buffers.o drm_mode_config.o drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o +obj-$(CONFIG_DRM_LIB_PRIMES) += lib/drm_prime_numbers.o obj-$(CONFIG_DRM_DEBUG_MM_SELFTEST) += selftests/test-drm_mm.o drm-$(CONFIG_COMPAT) += drm_ioc32.odrivers/gpu/drm/lib/drm_prime_numbers.c new file +175
-0@@ -0,0 +1,175 @@ +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/slab.h> + +#include "drm_prime_numbers.h" + +static DEFINE_MUTEX (lock); + +static struct primes { +struct rcu_head rcu; +unsigned long last, sz; +unsigned long primes[]; +}__rcu *primes; + +static bool slow_is_prime_number (unsigned long x) +{ +unsigned long y =int_sqrt (x) +1 ; + +while (y >1 ) { +if ((x % y) ==0 ) +break ; + y--; + } + +return y ==1 ; +} + +static unsigned long slow_next_prime_number (unsigned long x) +{ +for (;;) { +if (slow_is_prime_number (++x)) +return x; + } +} + +static unsigned long mark_multiples (unsigned long x, +unsigned long *p, +unsigned long start, +unsigned long end) +{ +unsigned long m; + + m =2 * x; +if (m < start) + m = (start / x +1 ) * x; + +while (m < end) { +__clear_bit (m, p); + m += x; + } + +return x; +} + +static struct primes *expand (unsigned long x) +{ +unsigned long sz, y, prev; +struct primes *p, *new; + + sz = x * x; +if (sz < x) +return NULL ; + +mutex_lock (&lock); + p =rcu_dereference_protected (primes,lockdep_is_held (&lock)); +if (p && x < p->last) + goto unlock; + + sz =round_up (sz,BITS_PER_LONG ); + new =kmalloc (sizeof (*new) + sz /sizeof (long ),GFP_KERNEL ); +if (!new) { + p =NULL ; + goto unlock; + } + +/* Where memory permits, track the primes using the +* Sieve of Eratosthenes. +*/ +if (p) { + prev = p->sz; +memcpy (new->primes, p->primes, prev /BITS_PER_LONG ); + }else { + prev =0 ; + } +memset (new->primes + prev /BITS_PER_LONG , +0xff , (sz - prev) /sizeof (long )); +for (y =2UL ; y < sz; y =find_next_bit (new->primes, sz, y +1 )) + new->last =mark_multiples (y, new->primes, prev, sz); + new->sz = sz; + +rcu_assign_pointer (primes, new); +if (p) +kfree_rcu (p, rcu); + p = new; + +unlock: +mutex_unlock (&lock); +return p; +} + +unsigned long drm_next_prime_number (unsigned long x) +{ +struct primes *p; + +if (x <2 ) +return 2 ; + +rcu_read_lock (); + p =rcu_dereference (primes); +if (!p || x >= p->last) { +rcu_read_unlock (); + + p =expand (x); +if (!p) +return slow_next_prime_number (x); + +rcu_read_lock (); + } + + x =find_next_bit (p->primes, p->last, x +1 ); +rcu_read_unlock (); + +return x; +} +EXPORT_SYMBOL (drm_next_prime_number); + +bool drm_is_prime_number (unsigned long x) +{ +struct primes *p; +bool result; + +switch (x) { +case 0 : +return false; +case 1 : +case 2 : +case 3 : +return true; + } + +rcu_read_lock (); + p =rcu_dereference (primes); +if (!p || x >= p->last) { +rcu_read_unlock (); + + p =expand (x); +if (!p) +return slow_is_prime_number (x); + +rcu_read_lock (); + } + + result =test_bit (x, p->primes); +rcu_read_unlock (); + +return result; +} +EXPORT_SYMBOL (drm_is_prime_number); + +static int __init drm_primes_init (void ) +{ +return 0 ; +} + +static void __exit drm_primes_exit(void) +{ +if (primes) +kfree_rcu (primes, rcu); +} + +module_init (drm_primes_init); +module_exit (drm_primes_exit); + +MODULE_AUTHOR ("Intel Corporation" ); +MODULE_LICENSE ("GPL" );drivers/gpu/drm/lib/drm_prime_numbers.h new file +10
-0@@ -0,0 +1,10 @@ +#ifndef __DRM_PRIMES_H__ +#define __DRM_PRIMES_H__ + +bool drm_is_prime_number (unsigned long x); +unsigned long drm_next_prime_number (unsigned long x); + +#define drm_for_each_prime (prime, max) \ + for (prime = 1; prime < (max); prime = drm_next_prime_number(prime)) + +#endif /* __DRM_PRIMES_H__ */ Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 08/40] drm: Add a simple prime number generator
Quoted 14 lines · Lukas Wunner
Quoted 4 lines · Chris Wilson
Prime numbers are interesting for testing components that use multiplies and divides, such as testing struct
drm_mmalignment computations.Signed-off-by Chris Wilson <[email protected]>Quoted 8 lines
--- drivers/gpu/drm/Kconfig | 4 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/lib/drm_prime_numbers.c | 175 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/lib/drm_prime_numbers.h | 10 ++ 4 files changed, 190 insertions(+) create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.c create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.h
Quoted 4 lines
Hm, why not put this in
lib/? Don't see anything DRM-specific here at first glance and this might be useful to others. Or others might come up with improvements and they'll be more likely to discover it outside of DRM.
Because that is a 3+ month cycle before I can then apply the testcases, and without the testscases do you want the bugfixes?
If I put in in drm/lib then lift it, I can use it immediately and drop the local copy once merged.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 08/40] drm: Add a simple prime number generator
Quoted 15 lines · Chris Wilson
Quoted 14 lines · Lukas Wunner
Quoted 12 lines · Chris Wilson
Prime numbers are interesting for testing components that use multiplies and divides, such as testing struct
drm_mmalignment computations.Signed-off-by Chris Wilson <[email protected]>--- drivers/gpu/drm/Kconfig | 4 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/lib/drm_prime_numbers.c | 175 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/lib/drm_prime_numbers.h | 10 ++ 4 files changed, 190 insertions(+) create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.c create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.h
Quoted 7 lines
Quoted 4 lines
Hm, why not put this in
lib/? Don't see anything DRM-specific here at first glance and this might be useful to others. Or others might come up with improvements and they'll be more likely to discover it outside of DRM.Because that is a 3+ month cycle before I can then apply the testcases, and without the testscases do you want the bugfixes?
Do patches for lib/ have to go through a different tree? Don't think so, I've seen e.g. changes to lib/ucs2_string.c go through the EFI tree. It seems to me lib/ is sort of free for all.
Quoted 2 lines
If I put in in drm/lib then lift it, I can use it immediately and drop the local copy once merged.
That is also workable of course. Anyway, it was just a suggestion.
Thanks,
Lukas
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 08/40] drm: Add a simple prime number generator
Quoted 21 lines · Lukas Wunner
Quoted 20 lines · Chris Wilson
Quoted 18 lines · Lukas Wunner
Quoted 4 lines · Chris Wilson
Prime numbers are interesting for testing components that use multiplies and divides, such as testing struct
drm_mmalignment computations.Signed-off-by Chris Wilson <[email protected]>Quoted 8 lines
--- drivers/gpu/drm/Kconfig | 4 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/lib/drm_prime_numbers.c | 175 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/lib/drm_prime_numbers.h | 10 ++ 4 files changed, 190 insertions(+) create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.c create mode 100644 drivers/gpu/drm/lib/drm_prime_numbers.hHm, why not put this in
lib/? Don't see anything DRM-specific here at first glance and this might be useful to others. Or others might come up with improvements and they'll be more likely to discover it outside of DRM.
Quoted 7 lines
Quoted 2 lines
Because that is a 3+ month cycle before I can then apply the testcases, and without the testscases do you want the bugfixes?
Do patches for
lib/have to go through a different tree? Don't think so, I've seen e.g. changes tolib/ucs2_string.cgo through the EFI tree. It seems to melib/is sort of free for all.
Hmm, I was expecting to shepherd them through say Andrew Morton. lib/random32.c is maintained by David Miller, so definitely would like to present a simple set of pre-reviewed patches.
But it looks like we could create lib/prime_numbers.c without too much consternation.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 lib: Add a simple prime number generator
In reply to Chris WilsonPrime numbers are interesting for testing components that use multiplies and divides, such as testing DRM's struct drm_mm alignment computations.
v2: Move to lib/, add selftest
--- include/linux/prime_numbers.h | 13 +++ lib/Kconfig | 7 ++ lib/Makefile | 2 + lib/prime_numbers.c | 230 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 include/linux/prime_numbers.h create mode 100644 lib/prime_numbers.c
include/linux/prime_numbers.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __LINUX_PRIME_NUMBERS_H +#define __LINUX_PRIME_NUMBERS_H + +#include <linux/types.h> + +bool is_prime_number (unsigned long x); +unsigned long next_prime_number (unsigned long x); + +/* A useful white-lie here is that 1 is prime. */ +#define for_each_prime_number (prime, max) \ + for (prime = 1; prime < (max); prime = next_prime_number(prime)) + +#endif /* !__LINUX_PRIME_NUMBERS_H */
lib/Kconfig +7 -0
@@ -550,4 +550,11 @@ config STACKDEPOT config SBITMAP bool +config PRIME_NUMBERS + tristate "Prime number generator" + default n + help + Provides a helper module to generate prime numbers. Useful for writing + test code, especially when checking multiplication and divison. + endmenu
lib/Makefile +2 -0
@@ -197,6 +197,8 @@ obj-$(CONFIG_ASN1) += asn1_decoder.o obj-$(CONFIG_FONT_SUPPORT) += fonts/ +obj-$(CONFIG_PRIME_NUMBERS) += prime_numbers.o + hostprogs-y := gen_crc32table clean-files := crc32table.h
lib/prime_numbers.c new file +230 -0
230 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] lib: Add a simple prime number generator
Quoted 79 lines · Chris Wilson
Prime numbers are interesting for testing components that use multiplies and divides, such as testing DRM's struct
drm_mmalignment computations.v2: Move to
lib/, add selftestSigned-off-by Chris Wilson <[email protected]>Cc Lukas Wunner <[email protected]>--- include/linux/prime_numbers.h | 13 +++ lib/Kconfig | 7 ++ lib/Makefile | 2 + lib/prime_numbers.c | 230 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 include/linux/prime_numbers.h create mode 100644 lib/prime_numbers.cinclude/linux/prime_numbers.h new file +13
-0@@ -0,0 +1,13 @@ +#ifndef __LINUX_PRIME_NUMBERS_H +#define __LINUX_PRIME_NUMBERS_H + +#include <linux/types.h> + +bool is_prime_number (unsigned long x); +unsigned long next_prime_number (unsigned long x); + +/* A useful white-lie here is that 1 is prime. */ +#define for_each_prime_number (prime, max) \ + for (prime = 1; prime < (max); prime = next_prime_number(prime)) + +#endif /* !__LINUX_PRIME_NUMBERS_H */ lib/Kconfig +7
-0@@ -550,4 +550,11 @@ config STACKDEPOT config SBITMAP bool +config PRIME_NUMBERS + tristate "Prime number generator" + default n + help + Provides a helper module to generate prime numbers. Useful for writing + test code, especially when checking multiplication and divison. + endmenulib/Makefile +2
-0@@ -197,6 +197,8 @@ obj-$(CONFIG_ASN1) += asn1_decoder.o obj-$(CONFIG_FONT_SUPPORT) += fonts/ +obj-$(CONFIG_PRIME_NUMBERS) += prime_numbers.o + hostprogs-y := gen_crc32table clean-files := crc32table.hlib/prime_numbers.c new file +9
-0@@ -0,0 +1,230 @@ +#define pr_fmt (fmt) "prime numbers: " #fmt + +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/prime_numbers.h> +#include <linux/slab.h> +#include <linux/vmalloc.h> + +struct primes {
lib/prime_numbers.c line 19
Quoted 10 lines
lib/prime_numbers.c new file +10
-0+struct rcu_head rcu; +unsigned long last, sz; +unsigned long primes[]; +}; + +#if BITS_PER_LONG ==64 +static const struct primes small_primes = { + .last =61 , + .sz =64 , + .primes = { 0x28208a20a08a28ae }
Ugh, extracted this from primes[0] and forgot the mark up skips 0,1
lib/prime_numbers.c line 180
Quoted 3 lines
lib/prime_numbers.c new file +3
-0+for (last =0 , x =2 ; x < max; x++) { +bool slow =slow_is_prime_number (x); +bool fast =slow_is_prime_number (x);
Which didn't help!
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 1/1 lib: Add a simple prime number generator
In reply to Chris WilsonPrime numbers are interesting for testing components that use multiplies and divides, such as testing DRM's struct drm_mm alignment computations.
v2: Move to lib/, add selftest
v3: Fix initial constants (exclude 0/1 from being primes)
--- include/linux/prime_numbers.h | 13 +++ lib/Kconfig | 7 ++ lib/Makefile | 2 + lib/prime_numbers.c | 230 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 include/linux/prime_numbers.h create mode 100644 lib/prime_numbers.c
include/linux/prime_numbers.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __LINUX_PRIME_NUMBERS_H +#define __LINUX_PRIME_NUMBERS_H + +#include <linux/types.h> + +bool is_prime_number (unsigned long x); +unsigned long next_prime_number (unsigned long x); + +/* A useful white-lie here is that 1 is prime. */ +#define for_each_prime_number (prime, max) \ + for (prime = 1; prime < (max); prime = next_prime_number(prime)) + +#endif /* !__LINUX_PRIME_NUMBERS_H */
lib/Kconfig +7 -0
@@ -550,4 +550,11 @@ config STACKDEPOT config SBITMAP bool +config PRIME_NUMBERS + tristate "Prime number generator" + default n + help + Provides a helper module to generate prime numbers. Useful for writing + test code, especially when checking multiplication and divison. + endmenu
lib/Makefile +2 -0
@@ -197,6 +197,8 @@ obj-$(CONFIG_ASN1) += asn1_decoder.o obj-$(CONFIG_FONT_SUPPORT) += fonts/ +obj-$(CONFIG_PRIME_NUMBERS) += prime_numbers.o + hostprogs-y := gen_crc32table clean-files := crc32table.h
lib/prime_numbers.c new file +230 -0
230 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
kbuild test robot
build botRe: [PATCH v3] lib: Add a simple prime number generator
url: https://github.com/0day-ci/linux/commits/Chris-Wilson/lib-Add-a-simple-prime-number-generator/20161217-013805 reproduce:
Hi Chris,
[auto build test WARNING on linus/master]
[also build test WARNING on v4.9 next-20161216]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Chris-Wilson/lib-Add-a-simple-prime-number-generator/20161217-013805
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__sparse warnings: (new ones prefixed by >>)
include/linux/compiler.h:253:8: sparse: attribute 'no_sanitize_address': unknown attribute
>> lib/prime_numbers.c:220:20: sparse: incompatible types in comparison expression (different address spaces)
vim +220 lib/prime_numbers.c
204 return -EINVAL;
205 }
206 last = x;
207 }
208
209 pr_info("selftest(%lu) passed, last prime was %lu", x, last);
210 return 0;
211 }
212
213 static int __init primes_init(void)
214 {
215 return selftest(selftest_max);
216 }
217
218 static void __exit primes_exit(void)
219 {
> 220 if (primes != &small_primes)
221 kfree_rcu((struct primes *)primes, rcu);
222 }
223
224 module_init(primes_init);
225 module_exit(primes_exit);
226
227 module_param_named(selftest, selftest_max, ulong, 0400);
228
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 9/40 drm: kselftest for drm_mm_init()
In reply to Chris WilsonSimple first test to just exercise initialisation of struct drm_mm.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 114 +++++++++++++++++++++++++++ 2 files changed, 115 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -6,3 +6,4 @@* Tests are executed in order by igt/drm_mm */ selftest(sanitycheck, igt_sanitycheck) /* keep first (selfcheck for igt) */ +selftest (init, igt_init)
drivers/gpu/drm/selftests/test-drm_mm.c +114 -0
120 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 09/40] drm: kselftest for drm_mm_init()
Quoted 3 lines · Chris Wilson
Simple first test to just exercise initialisation of struct
drm_mm.Signed-off-by Chris Wilson <[email protected]>
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 10/40 drm: kselftest for drm_mm_debug()
In reply to Chris WilsonSimple test to just exercise calling the debug dumper on the drm_mm.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 35 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -7,3 +7,4 @@*/ selftest(sanitycheck, igt_sanitycheck) /* keep first (selfcheck for igt) */ selftest(init, igt_init) +selftest (debug, igt_debug)
drivers/gpu/drm/selftests/test-drm_mm.c +35 -0
@@ -138,6 +138,41 @@ static int igt_init(void *ignored)return ret; } +static int igt_debug (void *ignored) +{ +struct drm_mm mm; +struct drm_mm_node nodes[2 ]; +int ret; + +/* Create a small drm_mm with a couple of nodes and a few holes, and +* check that the debug iterator doesn't explode over a trivial drm_mm. +*/ + +drm_mm_init (&mm,0 ,4096 ); + +memset (nodes,0 ,sizeof (nodes)); + nodes[0 ].start =512 ; + nodes[0 ].size =1024 ; + ret =drm_mm_reserve_node (&mm, &nodes[0 ]); +if (ret) { +pr_err ("failed to reserve node[0] {start=%lld, size=%lld)\n" , + nodes[0 ].start, nodes[0 ].size); +return ret; + } + + nodes[1 ].size =1024 ; + nodes[1 ].start =4096 -512 - nodes[1 ].size; + ret =drm_mm_reserve_node (&mm, &nodes[1 ]); +if (ret) { +pr_err ("failed to reserve node[1] {start=%lld, size=%lld)\n" , + nodes[1 ].start, nodes[1 ].size); +return ret; + } + +drm_mm_debug_table (&mm, __func__); +return 0 ; +} +#include "drm_selftest.c" static int __init test_drm_mm_init (void )
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 10/40] drm: kselftest for drm_mm_debug()
Quoted 3 lines · Chris Wilson
Simple test to just exercise calling the debug dumper on the
drm_mm.Signed-off-by Chris Wilson <[email protected]>
This is rather meta already. Not entirely sure how good of a selftest this is when we do not validate the generated output, or do you at the runner side?
Code itself is (but I'm unsure of the usefulness as is);
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 10/40] drm: kselftest for drm_mm_debug()
Quoted 8 lines · Joonas Lahtinen
Quoted 3 lines · Chris Wilson
Simple test to just exercise calling the debug dumper on the
drm_mm.Signed-off-by Chris Wilson <[email protected]>This is rather meta already. Not entirely sure how good of a selftest this is when we do not validate the generated output, or do you at the runner side?
No, it is just to ensure we have coverage of that function. All it does is make sure it doesn't explode, under very tame circumstances.
I thought of doing a few mocks to capture the output and decided that was asking a little too much for a debug function. Still don't have coverage for the debugfs dumper...
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 11/40 drm: kselftest for drm_mm_reserve_node()
In reply to Chris WilsonExercise drm_mm_reserve_node(), check that we can't reserve an already occupied range and that the lists are correct after reserving/removing.
v2: Check for invalid node reservation.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 279 +++++++++++++++++++++++++++ 2 files changed, 280 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -8,3 +8,4 @@ selftest(sanitycheck, igt_sanitycheck) /* keep first (selfcheck for igt) */ selftest(init, igt_init) selftest(debug, igt_debug) +selftest (reserve, igt_reserve)
drivers/gpu/drm/selftests/test-drm_mm.c +279 -0
297 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 12/40 drm: kselftest for drm_mm_insert_node()
In reply to Chris WilsonExercise drm_mm_insert_node(), check that we can't overfill a range and that the lists are correct after reserving/removing.
v2: Extract helpers for the repeated tests
v3: Iterate over all allocation flags
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 220 +++++++++++++++++++++++++++ 2 files changed, 221 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -9,3 +9,4 @@ selftest(sanitycheck, igt_sanitycheck) /* keep first (selfcheck for igt) */ selftest(init, igt_init) selftest(debug, igt_debug) selftest(reserve, igt_reserve) +selftest (insert, igt_insert)
drivers/gpu/drm/selftests/test-drm_mm.c +220 -0
232 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 12/40] drm: kselftest for drm_mm_insert_node()
Quoted 7 lines · Chris Wilson
Exercise
drm_mm_insert_node(), check that we can't overfill a range and that the lists are correct after reserving/removing.v2: Extract helpers for the repeated tests
v3: Iterate over all allocation flagsSigned-off-by Chris Wilson <[email protected]>
<SNIP>
Quoted 1 line
+static u64
misaligned(struct drm_mm_node *node, u64 alignment)
I'm not sure if 'misalignment' would be better name or not. This makes me think of bool returning one.
drivers/gpu/drm/selftests/test-drm_mm.c static int igt_reserve(void *ignored) · line 503
Quoted 7 lines
drivers/gpu/drm/selftests/test-drm_mm.c +7
-0+static bool expect_insert_fail (struct drm_mm *mm,u64 size) +{ +struct drm_mm_node tmp = {}; +int err; + + err =drm_mm_insert_node (mm, &tmp, size,0 ,DRM_MM_SEARCH_DEFAULT ); + if (err != -ENOSPC) {
For speed (this function gets called a lot);
if (likely(err == -ENOSPC))
return true;
Quoted 2 lines
drivers/gpu/drm/selftests/test-drm_mm.c +2
-0+static int __igt_insert (unsigned int count,u64 size) +{
<SNIP>
drivers/gpu/drm/selftests/test-drm_mm.c static int igt_reserve(void *ignored) · line 566
Quoted 13 lines
drivers/gpu/drm/selftests/test-drm_mm.c +12
-0+for (mode = insert_modes; mode->name; mode++) { +for (n =0 ; n < count; n++) { + node = &nodes[n]; + err =drm_mm_insert_node_generic (&mm, node, size,0 , n, + mode->search_flags, + mode->create_flags); +if (err || !assert_node (node, &mm, size,0 , n)) { +pr_err ("%s insert failed, size %llu step %d\n" , + mode->name, size, n); + ret = err ?: -EINVAL ; + goto out; + }
This construct is three times in this patch; Could be expect_insert_generic?
Apart from nitpicks, no complaints; was much easier to review now!
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 12/40] drm: kselftest for drm_mm_insert_node()
Quoted 35 lines · Joonas Lahtinen
Quoted 7 lines · Chris Wilson
Exercise
drm_mm_insert_node(), check that we can't overfill a range and that the lists are correct after reserving/removing.v2: Extract helpers for the repeated tests
v3: Iterate over all allocation flagsSigned-off-by Chris Wilson <[email protected]><SNIP>
Quoted 1 line
+static u64
misaligned(struct drm_mm_node *node, u64 alignment)I'm not sure if 'misalignment' would be better name or not. This makes me think of bool returning one.
drivers/gpu/drm/selftests/test-drm_mm.c static int igt_reserve(void *ignored) · line 503
Quoted 7 lines
drivers/gpu/drm/selftests/test-drm_mm.c +7
-0+static bool expect_insert_fail (struct drm_mm *mm,u64 size) +{ +struct drm_mm_node tmp = {}; +int err; + + err =drm_mm_insert_node (mm, &tmp, size,0 ,DRM_MM_SEARCH_DEFAULT ); + if (err != -ENOSPC) {For speed (this function gets called a lot);
if (likely(err ==
-ENOSPC))return true;Quoted 2 lines
drivers/gpu/drm/selftests/test-drm_mm.c +2
-0+static int __igt_insert (unsigned int count,u64 size) +{<SNIP>
Quoted 1 line
Quoted 15 lines
drivers/gpu/drm/selftests/test-drm_mm.c static int igt_reserve(void *ignored) · line 566
Quoted 12 lines
drivers/gpu/drm/selftests/test-drm_mm.c +12
-0+for (mode = insert_modes; mode->name; mode++) { +for (n =0 ; n < count; n++) { + node = &nodes[n]; + err =drm_mm_insert_node_generic (&mm, node, size,0 , n, + mode->search_flags, + mode->create_flags); +if (err || !assert_node (node, &mm, size,0 , n)) { +pr_err ("%s insert failed, size %llu step %d\n" , + mode->name, size, n); + ret = err ?: -EINVAL ; + goto out; + }This construct is three times in this patch; Could be
expect_insert_generic?
In this patch alone, indeed it gets used again and again. I resisted making it an insert and check function simply because I didn't want to fall into the trap of using it everywhere and so missing out exercising drm_mm_insert_node and friends.
However, 3 occurences of the same in one patch...
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 13/40 drm: kselftest for drm_mm_replace_node()
In reply to Chris WilsonReuse drm_mm_insert_node() with a temporary node to exercise drm_mm_replace_node(). We use the previous test in order to exercise the various lists following replacement.
v2: Check that we copy across the important (user) details of the node. The internal details (such as lists and hole tracking) we hope to detect errors by exercise.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 64 +++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 6 deletions(-)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -10,3 +10,4 @@ selftest(init, igt_init) selftest(debug, igt_debug) selftest(reserve, igt_reserve) selftest(insert, igt_insert) +selftest (replace, igt_replace)
drivers/gpu/drm/selftests/test-drm_mm.c +58 -6
102 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 14/40 drm: kselftest for drm_mm_insert_node_in_range()
In reply to Chris WilsonExercise drm_mm_insert_node_in_range(), check that we only allocate from the specified range.
v2: Use all allocation flags
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 246 +++++++++++++++++++++++++++ 2 files changed, 247 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -11,3 +11,4 @@ selftest(debug, igt_debug) selftest(reserve, igt_reserve) selftest(insert, igt_insert) selftest(replace, igt_replace) +selftest (insert_range, igt_insert_range)
drivers/gpu/drm/selftests/test-drm_mm.c +246 -0
252 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 14/40] drm: kselftest for drm_mm_insert_node_in_range()
Quoted 6 lines · Chris Wilson
Exercise
drm_mm_insert_node_in_range(), check that we only allocate from the specified range.v2: Use all allocation flags
Signed-off-by Chris Wilson <[email protected]>
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 15/40 drm: kselftest for drm_mm and alignment
In reply to Chris WilsonCheck that we can request alignment to any power-of-two or prime using a plain drm_mm_node_insert(), and also handle a reasonable selection of primes.
v2: Exercise all allocation flags
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 3 + drivers/gpu/drm/selftests/test-drm_mm.c | 110 +++++++++++++++++++++++++++ 2 files changed, 113 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +3 -0
@@ -12,3 +12,6 @@ selftest(reserve, igt_reserve) selftest(insert, igt_insert) selftest(replace, igt_replace) selftest(insert_range, igt_insert_range) +selftest(align, igt_align) +selftest(align32, igt_align32) +selftest (align64, igt_align64)
drivers/gpu/drm/selftests/test-drm_mm.c +110 -0
116 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 16/40 drm: kselftest for drm_mm and eviction
In reply to Chris WilsonCheck that we add arbitrary blocks to the eviction scanner in order to find the first minimal hole that matches our request.
v2: Refactor out some common eviction code for later
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 337 +++++++++++++++++++++++++++ 2 files changed, 338 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -15,3 +15,4 @@ selftest(insert_range, igt_insert_range) selftest(align, igt_align) selftest(align32, igt_align32) selftest(align64, igt_align64) +selftest (evict, igt_evict)
drivers/gpu/drm/selftests/test-drm_mm.c +337 -0
349 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 17/40 drm: kselftest for drm_mm and range restricted eviction
In reply to Chris WilsonCheck that we add arbitrary blocks to a restrited eviction scanner in order to find the first minimal hole that matches our request.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 113 ++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 4 deletions(-)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -16,3 +16,4 @@ selftest(align, igt_align) selftest(align32, igt_align32) selftest(align64, igt_align64) selftest(evict, igt_evict) +selftest (evict_range, igt_evict_range)
drivers/gpu/drm/selftests/test-drm_mm.c +109 -4
155 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 18/40 drm: kselftest for drm_mm and top-down allocation
In reply to Chris WilsonCheck that if we request top-down allocation from drm_mm_insert_node() we receive the next available hole from the top.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 123 +++++++++++++++++++++++++++ 2 files changed, 124 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -17,3 +17,4 @@ selftest(align32, igt_align32) selftest(align64, igt_align64) selftest(evict, igt_evict) selftest(evict_range, igt_evict_range) +selftest (topdown, igt_topdown)
drivers/gpu/drm/selftests/test-drm_mm.c +123 -0
129 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 19/40 drm: kselftest for drm_mm and color adjustment
In reply to Chris WilsonCheck that after applying the driver's color adjustment, fitting of the node and its alignment are still correct.
v2: s/no_color_touching/separate_adjacent_colors/
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 185 +++++++++++++++++++++++++++ 2 files changed, 186 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -18,3 +18,4 @@ selftest(align64, igt_align64) selftest(evict, igt_evict) selftest(evict_range, igt_evict_range) selftest(topdown, igt_topdown) +selftest (color, igt_color)
drivers/gpu/drm/selftests/test-drm_mm.c +185 -0
191 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 20/40 drm: kselftest for drm_mm and color eviction
In reply to Chris WilsonCheck that after applying the driver's color adjustment, eviction scanning find a suitable hole.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 159 +++++++++++++++++++++++++++ 2 files changed, 160 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -19,3 +19,4 @@ selftest(evict, igt_evict) selftest(evict_range, igt_evict_range) selftest(topdown, igt_topdown) selftest(color, igt_color) +selftest (color_evict, igt_color_evict)
drivers/gpu/drm/selftests/test-drm_mm.c +159 -0
165 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 20/40] drm: kselftest for drm_mm and color eviction
Quoted 4 lines · Chris Wilson
Check that after applying the driver's color adjustment, eviction scanning find a suitable hole.
Signed-off-by Chris Wilson <[email protected]>
<SNIP>
drivers/gpu/drm/selftests/test-drm_mm.c static int igt_color(void *ignored) · line 1840
Quoted 8 lines
drivers/gpu/drm/selftests/test-drm_mm.c +8
-0+static int evict_color (struct drm_mm *mm, + struct evict_node *nodes, + unsigned int *order, + unsigned int count, + unsigned int size, + unsigned int alignment, + unsigned long color, + const struct insert_mode *mode)
expect_evict_color? evict_color gave me an impression of single-way action (when reading the next patch).
Just a nitpick, so;
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 20/40] drm: kselftest for drm_mm and color eviction
Quoted 8 lines · Joonas Lahtinen
Quoted 4 lines · Chris Wilson
Check that after applying the driver's color adjustment, eviction scanning find a suitable hole.
Signed-off-by Chris Wilson <[email protected]><SNIP>
Quoted 11 lines
drivers/gpu/drm/selftests/test-drm_mm.c static int igt_color(void *ignored) · line 1840
Quoted 8 lines
drivers/gpu/drm/selftests/test-drm_mm.c +8
-0+static int evict_color (struct drm_mm *mm, + struct evict_node *nodes, + unsigned int *order, + unsigned int count, + unsigned int size, + unsigned int alignment, + unsigned long color, + const struct insert_mode *mode)
expect_evict_color?evict_colorgave me an impression of single-way action (when reading the next patch).
I thought of this and evict_something() as being the final level test runner (with the callers iterating over various paramters). expect_insert_fail/expect_insert_in_range_fail definitely are the single action check result matches expectations (return bool). Not convinced these two fall into the same category, so I'll leave as is. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 21/40 drm: kselftest for drm_mm and restricted color eviction
In reply to Chris WilsonCheck that after applying the driver's color adjustment, restricted eviction scanning find a suitable hole.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 119 ++++++++++++++++++++++++++- 2 files changed, 116 insertions(+), 4 deletions(-)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -20,3 +20,4 @@ selftest(evict_range, igt_evict_range) selftest(topdown, igt_topdown) selftest(color, igt_color) selftest(color_evict, igt_color_evict) +selftest (color_evict_range, igt_color_evict_range)
drivers/gpu/drm/selftests/test-drm_mm.c +115 -4
161 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 21/40] drm: kselftest for drm_mm and restricted color eviction
Quoted 4 lines · Chris Wilson
Check that after applying the driver's color adjustment, restricted eviction scanning find a suitable hole.
Signed-off-by Chris Wilson <[email protected]>
<SNIP>
Quoted 2 lines
drivers/gpu/drm/selftests/test-drm_mm.c +2
-0+static int igt_color_evict_range (void *ignored) +{
<SNIP>
drivers/gpu/drm/selftests/test-drm_mm.c static int igt_color_evict(void *ignored) · line 2055
Quoted 12 lines
drivers/gpu/drm/selftests/test-drm_mm.c +12
-0+for (mode = evict_modes; mode->name; mode++) { +for (n =1 ; n <= range_size; n <<=1 ) { +drm_random_reorder (order, range_size, &prng); + err =evict_color (&mm, range_start, range_end, + nodes, order, total_size, + n, 1, color++, + mode); +if (err) { +pr_err ("%s evict_color(size=%u) failed for range [%x, %x]\n" , + mode->name, n, range_start, range_end); + goto out; + }
This evict_color + error check again repeats, could maybe be helper.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 22/40 drm/i915: Build DRM range manager selftests for CI
In reply to Chris WilsonBuild the struct drm_mm selftests so that we can trivially run them within our CI.
"Enable debug, become developer." - Joonas Lahtinen
--- drivers/gpu/drm/i915/Kconfig.debug | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/Kconfig.debug +1 -0
@@ -24,6 +24,7 @@ config DRM_I915_DEBUG select X86_MSR # used by igt/pm_rpm select DRM_VGEM # used by igt/prime_vgem (dmabuf interop checks) select DRM_DEBUG_MM if DRM=y + select DRM_DEBUG_MM_SELFTEST select DRM_I915_SW_FENCE_DEBUG_OBJECTS default n help
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 23/40 drm: Promote drm_mm alignment to u64
In reply to Chris WilsonIn places (e.g. i915.ko), the alignment is exported to userspace as u64 and there now exists hardware for which we can indeed utilize a u64 alignment. As such, we need to keep 64bit integers throughout when handling alignment.
Testcase: igt/drm_mm/align64
Testcase: igt/gem_exec_alignment
--- drivers/gpu/drm/drm_mm.c | 37 +++++++++++++++------------------ drivers/gpu/drm/selftests/test-drm_mm.c | 4 ++-- include/drm/drm_mm.h | 16 +++++++------- 3 files changed, 27 insertions(+), 30 deletions(-)
drivers/gpu/drm/drm_mm.c +17 -20
@@ -93,12 +93,12 @@static struct drm_mm_node *drm_mm_search_free_generic (const struct drm_mm *mm,u64 size, -unsigned alignment, +u64 alignment,unsigned long color,enum drm_mm_search_flags flags); static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, u64 size, - unsigned alignment, + u64 alignment, unsigned long color, u64 start, u64 end,
@@ -227,7 +227,7 @@ static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node,static void drm_mm_insert_helper (struct drm_mm_node *hole_node,struct drm_mm_node *node, -u64 size,unsigned alignment, +u64 size,u64 alignment,unsigned long color,enum drm_mm_allocator_flags flags) {
@@ -246,10 +246,9 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, adj_start = adj_end - size;if (alignment) { -u64 tmp = adj_start; -unsigned rem; +u64 rem; - rem =do_div (tmp, alignment); +div64_u64_rem (adj_start, alignment, &rem);if (rem) {if (flags &DRM_MM_CREATE_TOP ) adj_start -= rem;
@@ -376,7 +375,7 @@ EXPORT_SYMBOL(drm_mm_reserve_node);* 0 on success, -ENOSPC if there's no suitable hole. */ int drm_mm_insert_node_generic (struct drm_mm *mm,struct drm_mm_node *node, -u64 size,unsigned alignment, +u64 size,u64 alignment,unsigned long color,enum drm_mm_search_flags sflags,enum drm_mm_allocator_flags aflags)
@@ -398,7 +397,7 @@ EXPORT_SYMBOL(drm_mm_insert_node_generic);static void drm_mm_insert_helper_range (struct drm_mm_node *hole_node,struct drm_mm_node *node, -u64 size,unsigned alignment, +u64 size,u64 alignment,unsigned long color,u64 start,u64 end,enum drm_mm_allocator_flags flags)
@@ -423,10 +422,9 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, adj_start = adj_end - size;if (alignment) { -u64 tmp = adj_start; -unsigned rem; +u64 rem; - rem =do_div (tmp, alignment); +div64_u64_rem (adj_start, alignment, &rem);if (rem) {if (flags &DRM_MM_CREATE_TOP ) adj_start -= rem;
@@ -482,7 +480,7 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,* 0 on success, -ENOSPC if there's no suitable hole. */ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *node, - u64 size, unsigned alignment, + u64 size, u64 alignment, unsigned long color, u64 start, u64 end, enum drm_mm_search_flags sflags,
@@ -548,16 +546,15 @@ void drm_mm_remove_node(struct drm_mm_node *node) }EXPORT_SYMBOL (drm_mm_remove_node); -static int check_free_hole (u64 start,u64 end,u64 size,unsigned alignment) +static int check_free_hole (u64 start,u64 end,u64 size,u64 alignment) {if (end - start < size)return 0 ;if (alignment) { -u64 tmp = start; -unsigned rem; +u64 rem; - rem =do_div (tmp, alignment); +div64_u64_rem (start, alignment, &rem);if (rem) start += alignment - rem; }
@@ -567,7 +564,7 @@ static int check_free_hole(u64 start, u64 end, u64 size, unsigned alignment)static struct drm_mm_node *drm_mm_search_free_generic (const struct drm_mm *mm,u64 size, -unsigned alignment, +u64 alignment,unsigned long color,enum drm_mm_search_flags flags) {
@@ -609,7 +606,7 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, u64 size, - unsigned alignment, + u64 alignment, unsigned long color, u64 start, u64 end,
@@ -729,7 +726,7 @@ EXPORT_SYMBOL(drm_mm_replace_node);*/ void drm_mm_init_scan (struct drm_mm *mm,u64 size, -unsigned alignment, +u64 alignment,unsigned long color) { mm->scan_color = color;
@@ -762,7 +759,7 @@ EXPORT_SYMBOL(drm_mm_init_scan);*/ void drm_mm_init_scan_with_range (struct drm_mm *mm,u64 size, -unsigned alignment, +u64 alignment,unsigned long color,u64 start,u64 end)
drivers/gpu/drm/selftests/test-drm_mm.c +2 -2
@@ -1086,7 +1086,7 @@ static int igt_align64(void *ignored)static void show_scan (const struct drm_mm *scan) { -pr_info ("scan: hit [%llx, %llx], size=%lld, align=%d, color=%ld\n" , +pr_info ("scan: hit [%llx, %llx], size=%lld, align=%lld, color=%ld\n" , scan->scan_hit_start, scan->scan_hit_end, scan->scan_size, scan->scan_alignment, scan->scan_color); }
@@ -1148,7 +1148,7 @@ static bool evict_nodes(struct drm_mm *mm,list_del (&e->link); }if (list_empty (evict_list)) { -pr_err ("Failed to find eviction: size=%lld [avail=%d], align=%d (color=%lu)\n" , +pr_err ("Failed to find eviction: size=%lld [avail=%d], align=%lld (color=%lu)\n" , mm->scan_size, count, mm->scan_alignment, mm->scan_color);
include/drm/drm_mm.h +8 -8
@@ -98,12 +98,12 @@ struct drm_mm {struct rb_root interval_tree; unsigned int scan_check_range : 1; -unsigned scan_alignment; +unsigned int scanned_blocks;unsigned long scan_color; +u64 scan_alignment;u64 scan_size;u64 scan_hit_start;u64 scan_hit_end; -unsigned scanned_blocks;u64 scan_start;u64 scan_end;struct drm_mm_node *prev_scanned_node;
@@ -249,7 +249,7 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node);int drm_mm_insert_node_generic (struct drm_mm *mm,struct drm_mm_node *node,u64 size, -unsigned alignment, +u64 alignment,unsigned long color,enum drm_mm_search_flags sflags,enum drm_mm_allocator_flags aflags);
@@ -272,7 +272,7 @@ int drm_mm_insert_node_generic(struct drm_mm *mm,static inline int drm_mm_insert_node (struct drm_mm *mm,struct drm_mm_node *node,u64 size, -unsigned alignment, +u64 alignment,enum drm_mm_search_flags flags) { return drm_mm_insert_node_generic(mm, node, size, alignment, 0, flags,
@@ -282,7 +282,7 @@ static inline int drm_mm_insert_node(struct drm_mm *mm, int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *node, u64 size, - unsigned alignment, + u64 alignment, unsigned long color, u64 start, u64 end,
@@ -309,7 +309,7 @@ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm,static inline int drm_mm_insert_node_in_range (struct drm_mm *mm,struct drm_mm_node *node,u64 size, -unsigned alignment, +u64 alignment,u64 start,u64 end,enum drm_mm_search_flags flags)
@@ -349,11 +349,11 @@ __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last);void drm_mm_init_scan (struct drm_mm *mm,u64 size, -unsigned alignment, +u64 alignment,unsigned long color);void drm_mm_init_scan_with_range (struct drm_mm *mm,u64 size, -unsigned alignment, +u64 alignment,unsigned long color,u64 start,u64 end);
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 24/40 drm: Fix kerneldoc for drm_mm_scan_remove_block()
In reply to Chris WilsonThe nodes must be removed in the *reverse* order. This is correct in the overview, but backwards in the function description. Whilst here add Intel's copyright statement and tweak some formatting.
--- drivers/gpu/drm/drm_mm.c | 34 ++++++++++++++++++---------------- include/drm/drm_mm.h | 19 +++++++++++++------ 2 files changed, 31 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_mm.c +18 -16
@@ -1,6 +1,7 @@/************************************************************************** * * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA. +* Copyright 2016 Intel Corporation * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a
@@ -31,9 +32,9 @@* class implementation for more advanced memory managers. * * Note that the algorithm used is quite simple and there might be substantial -* performance gains if a smarter free list is implemented. Currently it is just an -* unordered stack of free regions. This could easily be improved if an RB-tree -* is used instead. At least if we expect heavy fragmentation. +* performance gains if a smarter free list is implemented. Currently it is +* just an unordered stack of free regions. This could easily be improved if +* an RB-tree is used instead. At least if we expect heavy fragmentation. * * Aligned allocations can also see improvement. *
@@ -67,7 +68,7 @@* where an object needs to be created which exactly matches the firmware's * scanout target. As long as the range is still free it can be inserted anytime * after the allocator is initialized, which helps with avoiding looped -* depencies in the driver load sequence. +* dependencies in the driver load sequence. * * drm_mm maintains a stack of most recently freed holes, which of all * simplistic datastructures seems to be a fairly decent approach to clustering
@@ -78,14 +79,14 @@* * drm_mm supports a few features: Alignment and range restrictions can be * supplied. Further more every &drm_mm_node has a color value (which is just an -* opaqua unsigned long) which in conjunction with a driver callback can be used +* opaque unsigned long) which in conjunction with a driver callback can be used * to implement sophisticated placement restrictions. The i915 DRM driver uses * this to implement guard pages between incompatible caching domains in the * graphics TT. * -* Two behaviors are supported for searching and allocating: bottom-up and top-down. -* The default is bottom-up. Top-down allocation can be used if the memory area -* has different restrictions, or just to reduce fragmentation. +* Two behaviors are supported for searching and allocating: bottom-up and +* top-down. The default is bottom-up. Top-down allocation can be used if the +* memory area has different restrictions, or just to reduce fragmentation. * * Finally iteration helpers to walk all nodes and all holes are provided as are * some basic allocator dumpers for debugging.
@@ -510,7 +511,7 @@ EXPORT_SYMBOL(drm_mm_insert_node_in_range_generic);* * This just removes a node from its drm_mm allocator. The node does not need to * be cleared again before it can be re-inserted into this or any other drm_mm -* allocator. It is a bug to call this function on a un-allocated node. +* allocator. It is a bug to call this function on a unallocated node. */ void drm_mm_remove_node (struct drm_mm_node *node) {
@@ -689,16 +690,16 @@ EXPORT_SYMBOL(drm_mm_replace_node);* efficient when we simply start to select all objects from the tail of an LRU * until there's a suitable hole: Especially for big objects or nodes that * otherwise have special allocation constraints there's a good chance we evict -* lots of (smaller) objects unecessarily. +* lots of (smaller) objects unnecessarily. * * The DRM range allocator supports this use-case through the scanning * interfaces. First a scan operation needs to be initialized with -* drm_mm_init_scan() or drm_mm_init_scan_with_range(). The the driver adds +* drm_mm_init_scan() or drm_mm_init_scan_with_range(). The driver adds * objects to the roaster (probably by walking an LRU list, but this can be * freely implemented) until a suitable hole is found or there's no further -* evitable object. +* evictable object. * -* The the driver must walk through all objects again in exactly the reverse +* The driver must walk through all objects again in exactly the reverse * order to restore the allocator state. Note that while the allocator is used * in the scan mode no other operation is allowed. *
@@ -838,9 +839,10 @@ EXPORT_SYMBOL(drm_mm_scan_add_block);* drm_mm_scan_remove_block - remove a node from the scan list * @node: drm_mm_node to remove * -* Nodes _must_ be removed in the exact same order from the scan list as they -* have been added, otherwise the internal state of the memory manager will be -* corrupted. +* Nodes _must_ be removed in exactly the reverse order from the scan list as +* they have been added (e.g. using list_add as they are added and then +* list_for_each over that eviction list to remove), otherwise the internal +* state of the memory manager will be corrupted. * * When the scan list is empty, the selected memory nodes can be freed. An * immediately following drm_mm_search_free with !DRM_MM_SEARCH_BEST will then
include/drm/drm_mm.h +13 -6
@@ -1,6 +1,7 @@/************************************************************************** * * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX. USA. +* Copyright 2016 Intel Corporation * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a
@@ -117,7 +118,10 @@ struct drm_mm {* drm_mm_node_allocated - checks whether a node is allocated * @node: drm_mm_node to check * -* Drivers should use this helpers for proper encapusulation of drm_mm +* Drivers are required to clear a node prior to using it with the +* drm_mm range manager. +* +* Drivers should use this helper for proper encapsulation of drm_mm * internals. * * Returns:
@@ -132,7 +136,10 @@ static inline bool drm_mm_node_allocated(const struct drm_mm_node *node)* drm_mm_initialized - checks whether an allocator is initialized * @mm: drm_mm to check * -* Drivers should use this helpers for proper encapusulation of drm_mm +* Drivers should clear the struct drm_mm prior to initialisation if they +* want to use this function. +* +* Drivers should use this helper for proper encapsulation of drm_mm * internals. * * Returns:
@@ -152,8 +159,8 @@ static inline u64 __drm_mm_hole_node_start(const struct drm_mm_node *hole_node)* drm_mm_hole_node_start - computes the start of the hole following @node * @hole_node: drm_mm_node which implicitly tracks the following hole * -* This is useful for driver-sepific debug dumpers. Otherwise drivers should not -* inspect holes themselves. Drivers must check first whether a hole indeed +* This is useful for driver-specific debug dumpers. Otherwise drivers should +* not inspect holes themselves. Drivers must check first whether a hole indeed * follows by looking at node->hole_follows. * * Returns:
@@ -174,8 +181,8 @@ static inline u64 __drm_mm_hole_node_end(const struct drm_mm_node *hole_node)* drm_mm_hole_node_end - computes the end of the hole following @node * @hole_node: drm_mm_node which implicitly tracks the following hole * -* This is useful for driver-sepific debug dumpers. Otherwise drivers should not -* inspect holes themselves. Drivers must check first whether a hole indeed +* This is useful for driver-specific debug dumpers. Otherwise drivers should +* not inspect holes themselves. Drivers must check first whether a hole indeed * follows by looking at node->hole_follows. * * Returns:
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 24/40] drm: Fix kerneldoc for drm_mm_scan_remove_block()
Quoted 5 lines · Chris Wilson
The nodes must be removed in the *reverse* order. This is correct in the overview, but backwards in the function description. Whilst here add Intel's copyright statement and tweak some formatting.
Signed-off-by Chris Wilson <[email protected]>
It's like a Christmas gift for Daniel.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 25/40 drm: Detect overflow in drm_mm_reserve_node()
In reply to Chris WilsonProtect ourselves from a caller passing in node.start + node.size that will overflow and trick us into reserving that node.
--- drivers/gpu/drm/drm_mm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_mm.c +2 -3
@@ -308,10 +308,9 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)u64 hole_start, hole_end;u64 adj_start, adj_end; -if (WARN_ON (node->size ==0 )) -return -EINVAL ; - end = node->start + node->size; +if (unlikely (end <= node->start)) +return -ENOSPC ;/* Find the relevant hole to add our node to */ hole = drm_mm_interval_tree_iter_first(&mm->interval_tree,
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 25/40] drm: Detect overflow in drm_mm_reserve_node()
Quoted 4 lines · Chris Wilson
Protect ourselves from a caller passing in node.start + node.size that will overflow and trick us into reserving that node.
Signed-off-by Chris Wilson <[email protected]>
I was about to suggest an additional check (but didn't). A combined check is much more clever.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 26/40 drm: Simplify drm_mm_clean()
In reply to Chris WilsonSince commit ea7b1dd44867 ("drm: mm: track free areas implicitly"), to test whether there are any nodes allocated within the range manager, we merely have to ask whether the node_list is empty.
--- drivers/gpu/drm/drm_mm.c | 19 +------------------ include/drm/drm_mm.h | 14 +++++++++++++- 2 files changed, 14 insertions(+), 19 deletions(-)
drivers/gpu/drm/drm_mm.c +1 -18
@@ -873,22 +873,6 @@ bool drm_mm_scan_remove_block(struct drm_mm_node *node)EXPORT_SYMBOL (drm_mm_scan_remove_block);/** -* drm_mm_clean - checks whether an allocator is clean -* @mm: drm_mm allocator to check -* -* Returns: -* True if the allocator is completely free, false if there's still a node -* allocated in it. -*/ -bool drm_mm_clean (const struct drm_mm *mm) -{ -const struct list_head *head =__drm_mm_nodes (mm); - -return (head->next->next == head); -} -EXPORT_SYMBOL (drm_mm_clean); - -/** * drm_mm_init - initialize a drm-mm allocator * @mm: the drm_mm structure to initialize * @start: start of the range managed by @mm
@@ -928,10 +912,9 @@ EXPORT_SYMBOL(drm_mm_init);*/ void drm_mm_takedown (struct drm_mm *mm) { -if (WARN (!list_empty (__drm_mm_nodes (mm)), +if (WARN (!drm_mm_clean (mm),"Memory manager not clean during takedown.\n" ))show_leaks (mm); - }EXPORT_SYMBOL (drm_mm_takedown);
include/drm/drm_mm.h +13 -1
@@ -330,7 +330,19 @@ void drm_mm_remove_node(struct drm_mm_node *node);void drm_mm_replace_node (struct drm_mm_node *old,struct drm_mm_node *new);void drm_mm_init (struct drm_mm *mm,u64 start,u64 size);void drm_mm_takedown (struct drm_mm *mm); -bool drm_mm_clean (const struct drm_mm *mm); + +/** +* drm_mm_clean - checks whether an allocator is clean +* @mm: drm_mm allocator to check +* +* Returns: +* True if the allocator is completely free, false if there's still a node +* allocated in it. +*/ +static inline bool drm_mm_clean (const struct drm_mm *mm) +{ +return list_empty (__drm_mm_nodes (mm)); +}struct drm_mm_node *__drm_mm_interval_first (const struct drm_mm *mm,u64 start,u64 last);
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 27/40 drm: Add asserts to catch overflow in drm_mm_init() and drm_mm_init_scan()
In reply to Chris WilsonA simple assert to ensure that we don't overflow start + size when initialising the drm_mm, or its scanner.
In future, we may want to switch to tracking the value of ranges (rather than size) so that we can cover the full u64, for example like resource tracking.
--- drivers/gpu/drm/drm_mm.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_mm.c +7 -0
@@ -729,6 +729,8 @@ void drm_mm_init_scan(struct drm_mm *mm,u64 alignment, unsigned long color) { + DRM_MM_BUG_ON(size == 0); + mm->scan_color = color; mm->scan_alignment = alignment; mm->scan_size = size;
@@ -764,6 +766,9 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm, u64 start, u64 end) { +DRM_MM_BUG_ON (start >= end); +DRM_MM_BUG_ON (size ==0 || size > end - start); + mm->scan_color = color; mm->scan_alignment = alignment; mm->scan_size = size;
@@ -882,6 +887,8 @@ EXPORT_SYMBOL(drm_mm_scan_remove_block);*/ void drm_mm_init (struct drm_mm *mm,u64 start,u64 size) { +DRM_MM_BUG_ON (start + size <= start); +INIT_LIST_HEAD (&mm->hole_stack); mm->scanned_blocks =0 ;
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 27/40] drm: Add asserts to catch overflow in drm_mm_init() and drm_mm_init_scan()
Quoted 8 lines · Chris Wilson
A simple assert to ensure that we don't overflow start + size when initialising the
drm_mm, or its scanner.In future, we may want to switch to tracking the value of ranges (rather than size) so that we can cover the full u64, for example like resource tracking.
Signed-off-by Chris Wilson <[email protected]>
<SNIP>
drivers/gpu/drm/drm_mm.c void drm_mm_init_scan(struct drm_mm *mm, · line 732
Quoted 5 lines
drivers/gpu/drm/drm_mm.c +1
-0@@ -729,6 +729,8 @@ void drm_mm_init_scan(struct drm_mm *mm, u64 alignment, unsigned long color) { +DRM_MM_BUG_ON (size ==0 );
Nitpicking, DIM will complain that this should be !size.
drivers/gpu/drm/drm_mm.c void drm_mm_init_scan_with_range(struct drm_mm *mm, · line 768
Quoted 8 lines
drivers/gpu/drm/drm_mm.c +1
-0+ > mm->scan_color = color; > mm->scan_alignment = alignment; > mm->scan_size = size;@@ -764,6 +766,9 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm, u64 start, u64 end) {
Ditto, could have simply DRM_MM_BUG_ON(!size);
Regards, Joonas
Quoted 3 lines
drivers/gpu/drm/drm_mm.c +3
-0+DRM_MM_BUG_ON (start >= end); +DRM_MM_BUG_ON (size ==0 || size > end - start); +
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 28/40 drm: Extract struct drm_mm_scan from struct drm_mm
In reply to Chris WilsonThe scan state occupies a large proportion of the struct drm_mm and is rarely used and only contains temporary state. That makes it suitable to moving to its struct and onto the stack of the callers.
--- drivers/gpu/drm/drm_mm.c | 124 ++++++++++++++++++-------------- drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 7 +- drivers/gpu/drm/i915/i915_gem_evict.c | 19 +++-- drivers/gpu/drm/selftests/test-drm_mm.c | 45 ++++++------ include/drm/drm_mm.h | 43 +++++++---- 5 files changed, 138 insertions(+), 100 deletions(-)
drivers/gpu/drm/drm_mm.c +70 -54
@@ -574,7 +574,7 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,u64 adj_end;u64 best_size; -DRM_MM_BUG_ON (mm->scanned_blocks); +DRM_MM_BUG_ON (mm->scan_active); best =NULL ; best_size = ~0UL ;
@@ -618,7 +618,7 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_u64 adj_end;u64 best_size; -DRM_MM_BUG_ON (mm->scanned_blocks); +DRM_MM_BUG_ON (mm->scan_active); best =NULL ; best_size = ~0UL ;
@@ -693,7 +693,7 @@ EXPORT_SYMBOL(drm_mm_replace_node);* * The DRM range allocator supports this use-case through the scanning * interfaces. First a scan operation needs to be initialized with -* drm_mm_init_scan() or drm_mm_init_scan_with_range(). The driver adds +* drm_mm_scan_init() or drm_mm_scan_init_with_range(). The driver adds * objects to the roaster (probably by walking an LRU list, but this can be * freely implemented) until a suitable hole is found or there's no further * evictable object.
@@ -710,7 +710,8 @@ EXPORT_SYMBOL(drm_mm_replace_node);*/ /** -* drm_mm_init_scan - initialize lru scanning +* drm_mm_scan_init - initialize lru scanning +* @scan: scan state * @mm: drm_mm to scan * @size: size of the allocation * @alignment: alignment of the allocation
@@ -724,26 +725,33 @@ EXPORT_SYMBOL(drm_mm_replace_node);* As long as the scan list is non-empty, no other operations than * adding/removing nodes to/from the scan list are allowed. */ -void drm_mm_init_scan (struct drm_mm *mm, +void drm_mm_scan_init (struct drm_mm_scan *scan, +struct drm_mm *mm,u64 size,u64 alignment,unsigned long color) {DRM_MM_BUG_ON (size ==0 ); +DRM_MM_BUG_ON (mm->scan_active); - mm->scan_color = color; - mm->scan_alignment = alignment; - mm->scan_size = size; - mm->scanned_blocks =0 ; - mm->scan_hit_start =0 ; - mm->scan_hit_end =0 ; - mm->scan_check_range =0 ; - mm->prev_scanned_node =NULL ; + scan->mm = mm; + + scan->color = color; + scan->alignment = alignment; + scan->size = size; + + scan->check_range =0 ; + + scan->hit_start =U64_MAX ; + scan->hit_end =0 ; + + scan->prev_scanned_node =NULL ; } -EXPORT_SYMBOL (drm_mm_init_scan); +EXPORT_SYMBOL (drm_mm_scan_init);/** -* drm_mm_init_scan - initialize range-restricted lru scanning +* drm_mm_scan_init_with_range - initialize range-restricted lru scanning +* @scan: scan state * @mm: drm_mm to scan * @size: size of the allocation * @alignment: alignment of the allocation
@@ -759,7 +767,8 @@ EXPORT_SYMBOL(drm_mm_init_scan);* As long as the scan list is non-empty, no other operations than * adding/removing nodes to/from the scan list are allowed. */ -void drm_mm_init_scan_with_range(struct drm_mm *mm, +void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, + struct drm_mm *mm, u64 size, u64 alignment, unsigned long color,
@@ -768,19 +777,25 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm, {DRM_MM_BUG_ON (start >= end);DRM_MM_BUG_ON (size ==0 || size > end - start); +DRM_MM_BUG_ON (mm->scan_active); + + scan->mm = mm; + + scan->color = color; + scan->alignment = alignment; + scan->size = size; + +DRM_MM_BUG_ON (end <= start); + scan->range_start = start; + scan->range_end = end; + scan->check_range =1 ; - mm->scan_color = color; - mm->scan_alignment = alignment; - mm->scan_size = size; - mm->scanned_blocks =0 ; - mm->scan_hit_start =0 ; - mm->scan_hit_end =0 ; - mm->scan_start = start; - mm->scan_end = end; - mm->scan_check_range =1 ; - mm->prev_scanned_node =NULL ; + scan->hit_start =U64_MAX ; + scan->hit_end =0 ; + + scan->prev_scanned_node =NULL ; } -EXPORT_SYMBOL (drm_mm_init_scan_with_range); +EXPORT_SYMBOL (drm_mm_scan_init_with_range);/** * drm_mm_scan_add_block - add a node to the scan list
@@ -792,46 +807,46 @@ EXPORT_SYMBOL(drm_mm_init_scan_with_range);* Returns: * True if a hole has been found, false otherwise. */ -bool drm_mm_scan_add_block (struct drm_mm_node *node) +bool drm_mm_scan_add_block (struct drm_mm_scan *scan, +struct drm_mm_node *node) { -struct drm_mm *mm = node->mm; +struct drm_mm *mm = scan->mm;struct drm_mm_node *prev_node;u64 hole_start, hole_end;u64 adj_start, adj_end; - mm->scanned_blocks++; - +DRM_MM_BUG_ON (node->mm != mm); +DRM_MM_BUG_ON (!node->allocated);DRM_MM_BUG_ON (node->scanned_block); node->scanned_block =1 ; + mm->scan_active++; - prev_node = list_entry(node->node_list.prev, struct drm_mm_node, - node_list); + prev_node =list_prev_entry (node, node_list); node->scanned_preceeds_hole = prev_node->hole_follows; prev_node->hole_follows =1 ;list_del (&node->node_list); node->node_list.prev = &prev_node->node_list; - node->node_list.next = &mm->prev_scanned_node->node_list; - mm->prev_scanned_node = node; + node->node_list.next = &scan->prev_scanned_node->node_list; + scan->prev_scanned_node = node; adj_start = hole_start =drm_mm_hole_node_start (prev_node); adj_end = hole_end =drm_mm_hole_node_end (prev_node); -if (mm->scan_check_range) { -if (adj_start < mm->scan_start) - adj_start = mm->scan_start; -if (adj_end > mm->scan_end) - adj_end = mm->scan_end; +if (scan->check_range) { +if (adj_start < scan->range_start) + adj_start = scan->range_start; +if (adj_end > scan->range_end) + adj_end = scan->range_end; }if (mm->color_adjust) - mm->color_adjust (prev_node, mm->scan_color, - &adj_start, &adj_end); + mm->color_adjust (prev_node, scan->color, &adj_start, &adj_end);if (check_free_hole (adj_start, adj_end, - mm->scan_size, mm->scan_alignment)) { - mm->scan_hit_start = hole_start; - mm->scan_hit_end = hole_end; + scan->size, scan->alignment)) { + scan->hit_start = hole_start; + scan->hit_end = hole_end;return true; }
@@ -856,24 +871,25 @@ EXPORT_SYMBOL(drm_mm_scan_add_block);* True if this block should be evicted, false otherwise. Will always * return false when no hole has been found. */ -bool drm_mm_scan_remove_block (struct drm_mm_node *node) +bool drm_mm_scan_remove_block (struct drm_mm_scan *scan, +struct drm_mm_node *node) { -struct drm_mm *mm = node->mm;struct drm_mm_node *prev_node; - mm->scanned_blocks--; - +DRM_MM_BUG_ON (node->mm != scan->mm);DRM_MM_BUG_ON (!node->scanned_block); node->scanned_block =0 ; - prev_node = list_entry(node->node_list.prev, struct drm_mm_node, - node_list); +DRM_MM_BUG_ON (!node->mm->scan_active); + node->mm->scan_active--; + + prev_node =list_prev_entry (node, node_list); prev_node->hole_follows = node->scanned_preceeds_hole;list_add (&node->node_list, &prev_node->node_list); -return (drm_mm_hole_node_end (node) > mm->scan_hit_start && - node->start < mm->scan_hit_end); +return (drm_mm_hole_node_end (node) > scan->hit_start && + node->start < scan->hit_end); }EXPORT_SYMBOL (drm_mm_scan_remove_block);
@@ -890,7 +906,7 @@ void drm_mm_init(struct drm_mm *mm, u64 start, u64 size)DRM_MM_BUG_ON (start + size <= start);INIT_LIST_HEAD (&mm->hole_stack); - mm->scanned_blocks =0 ; + mm->scan_active =0 ;/* Clever trick to avoid a special case in the free hole tracking. */ INIT_LIST_HEAD (&mm->head_node.node_list);
drivers/gpu/drm/etnaviv/etnaviv_mmu.c +4 -3
@@ -113,6 +113,7 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu,while (1 ) {struct etnaviv_vram_mapping *m, *n; +struct drm_mm_scan scan;struct list_head list;bool found;
@@ -134,7 +135,7 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu, }/* Try to retire some entries */ -drm_mm_init_scan (&mmu->mm, size,0 ,0 ); +drm_mm_scan_init (&scan, &mmu->mm, size,0 ,0 ); found =0 ;INIT_LIST_HEAD (&list);
@@ -151,7 +152,7 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu,continue ;list_add (&free->scan_node, &list); -if (drm_mm_scan_add_block (&free->vram_node)) { +if (drm_mm_scan_add_block (&scan, &free->vram_node)) { found = true;break ; }
@@ -171,7 +172,7 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu,* can leave the block pinned. */ list_for_each_entry_safe (m, n, &list, scan_node) -if (!drm_mm_scan_remove_block (&m->vram_node)) +if (!drm_mm_scan_remove_block (&scan, &m->vram_node))list_del_init (&m->scan_node);/*
drivers/gpu/drm/i915/i915_gem_evict.c +12 -7
@@ -51,7 +51,10 @@ static bool ggtt_is_idle(struct drm_i915_private *dev_priv) }static bool -mark_free (struct i915_vma *vma,unsigned int flags,struct list_head *unwind) +mark_free (struct drm_mm_scan *scan, +struct i915_vma *vma, +unsigned int flags, +struct list_head *unwind) {if (i915_vma_is_pinned (vma))return false;
@@ -63,7 +66,7 @@ mark_free(struct i915_vma *vma, unsigned int flags, struct list_head *unwind)return false;list_add (&vma->exec_list, unwind); -return drm_mm_scan_add_block (&vma->node); +return drm_mm_scan_add_block (scan, &vma->node); }/**
@@ -97,6 +100,7 @@ i915_gem_evict_something(struct i915_address_space *vm, unsigned flags) {struct drm_i915_private *dev_priv = vm->i915; +struct drm_mm_scan scan;struct list_head eviction_list;struct list_head *phases[] = { &vm->inactive_list,
@@ -123,11 +127,12 @@ i915_gem_evict_something(struct i915_address_space *vm,* object on the TAIL. */ if (start !=0 || end != vm->total) { -drm_mm_init_scan_with_range (&vm->mm, min_size, +drm_mm_scan_init_with_range (&scan, &vm->mm, min_size, alignment, cache_level, start, end); }else -drm_mm_init_scan (&vm->mm, min_size, alignment, cache_level); +drm_mm_scan_init (&scan, &vm->mm, min_size, + alignment, cache_level);/* Retire before we search the active list. Although we have * reasonable accuracy in our retirement lists, we may have
@@ -144,13 +149,13 @@ i915_gem_evict_something(struct i915_address_space *vm, phase = phases;do {list_for_each_entry (vma, *phase, vm_link) -if (mark_free (vma, flags, &eviction_list)) +if (mark_free (&scan, vma, flags, &eviction_list)) goto found; }while (*++phase);/* Nothing found, clean up and bail out! */ list_for_each_entry_safe (vma, next, &eviction_list, exec_list) { - ret =drm_mm_scan_remove_block (&vma->node); + ret =drm_mm_scan_remove_block (&scan, &vma->node);BUG_ON (ret);INIT_LIST_HEAD (&vma->exec_list);
@@ -199,7 +204,7 @@ i915_gem_evict_something(struct i915_address_space *vm,* of any of our objects, thus corrupting the list). */ list_for_each_entry_safe (vma, next, &eviction_list, exec_list) { -if (drm_mm_scan_remove_block (&vma->node)) +if (drm_mm_scan_remove_block (&scan, &vma->node))__i915_vma_pin (vma);else list_del_init (&vma->exec_list);
drivers/gpu/drm/selftests/test-drm_mm.c +24 -21
142 lines not on this page · raw message
include/drm/drm_mm.h +28 -15
66 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 29/40 drm: Rename prev_node to hole in drm_mm_scan_add_block()
In reply to Chris WilsonAcknowledging that we were building up the hole was more useful to me when reading the code, than knowing the relationship between this node and the previous node.
--- drivers/gpu/drm/drm_mm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_mm.c +8 -8
@@ -811,7 +811,7 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, struct drm_mm_node *node) {struct drm_mm *mm = scan->mm; -struct drm_mm_node *prev_node; +struct drm_mm_node *hole;u64 hole_start, hole_end;u64 adj_start, adj_end;
@@ -821,17 +821,17 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, node->scanned_block =1 ; mm->scan_active++; - prev_node =list_prev_entry (node, node_list); + hole =list_prev_entry (node, node_list); - node->scanned_preceeds_hole = prev_node->hole_follows; - prev_node->hole_follows =1 ; + node->scanned_preceeds_hole = hole->hole_follows; + hole->hole_follows =1 ;list_del (&node->node_list); - node->node_list.prev = &prev_node->node_list; + node->node_list.prev = &hole->node_list; node->node_list.next = &scan->prev_scanned_node->node_list; scan->prev_scanned_node = node; - adj_start = hole_start =drm_mm_hole_node_start (prev_node); - adj_end = hole_end =drm_mm_hole_node_end (prev_node); + adj_start = hole_start =drm_mm_hole_node_start (hole); + adj_end = hole_end =drm_mm_hole_node_end (hole);if (scan->check_range) {if (adj_start < scan->range_start)
@@ -841,7 +841,7 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, }if (mm->color_adjust) - mm->color_adjust (prev_node, scan->color, &adj_start, &adj_end); + mm->color_adjust (hole, scan->color, &adj_start, &adj_end);if (check_free_hole (adj_start, adj_end, scan->size, scan->alignment)) {
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 29/40] drm: Rename prev_node to hole in drm_mm_scan_add_block()
Quoted 5 lines · Chris Wilson
Acknowledging that we were building up the hole was more useful to me when reading the code, than knowing the relationship between this node and the previous node.
Signed-off-by Chris Wilson <[email protected]>
I'm not purely against, so if you think it's more intuitive;
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 30/40 drm: Unconditionally do the range check in drm_mm_scan_add_block()
In reply to Chris WilsonDoing the check is trivial (low cost in comparison to overall eviction) and helps simplify the code.
--- drivers/gpu/drm/drm_mm.c | 53 +++-------------------------------- drivers/gpu/drm/i915/i915_gem_evict.c | 10 ++----- include/drm/drm_mm.h | 33 ++++++++++++++++++---- 3 files changed, 34 insertions(+), 62 deletions(-)
drivers/gpu/drm/drm_mm.c +4 -49
@@ -710,46 +710,6 @@ EXPORT_SYMBOL(drm_mm_replace_node);*/ /** -* drm_mm_scan_init - initialize lru scanning -* @scan: scan state -* @mm: drm_mm to scan -* @size: size of the allocation -* @alignment: alignment of the allocation -* @color: opaque tag value to use for the allocation -* -* This simply sets up the scanning routines with the parameters for the desired -* hole. Note that there's no need to specify allocation flags, since they only -* change the place a node is allocated from within a suitable hole. -* -* Warning: -* As long as the scan list is non-empty, no other operations than -* adding/removing nodes to/from the scan list are allowed. -*/ -void drm_mm_scan_init (struct drm_mm_scan *scan, -struct drm_mm *mm, -u64 size, -u64 alignment, -unsigned long color) -{ -DRM_MM_BUG_ON (size ==0 ); -DRM_MM_BUG_ON (mm->scan_active); - - scan->mm = mm; - - scan->color = color; - scan->alignment = alignment; - scan->size = size; - - scan->check_range =0 ; - - scan->hit_start =U64_MAX ; - scan->hit_end =0 ; - - scan->prev_scanned_node =NULL ; -} -EXPORT_SYMBOL (drm_mm_scan_init); - -/** * drm_mm_scan_init_with_range - initialize range-restricted lru scanning * @scan: scan state * @mm: drm_mm to scan
@@ -788,7 +748,6 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,DRM_MM_BUG_ON (end <= start); scan->range_start = start; scan->range_end = end; - scan->check_range =1 ; scan->hit_start =U64_MAX ; scan->hit_end =0 ;
@@ -830,15 +789,11 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, node->node_list.next = &scan->prev_scanned_node->node_list; scan->prev_scanned_node = node; - adj_start = hole_start =drm_mm_hole_node_start (hole); - adj_end = hole_end =drm_mm_hole_node_end (hole); + hole_start =drm_mm_hole_node_start (hole); + hole_end =drm_mm_hole_node_end (hole); -if (scan->check_range) { -if (adj_start < scan->range_start) - adj_start = scan->range_start; -if (adj_end > scan->range_end) - adj_end = scan->range_end; - } + adj_start =max (hole_start, scan->range_start); + adj_end =min (hole_end, scan->range_end);if (mm->color_adjust) mm->color_adjust (hole, scan->color, &adj_start, &adj_end);
drivers/gpu/drm/i915/i915_gem_evict.c +3 -7
@@ -126,13 +126,9 @@ i915_gem_evict_something(struct i915_address_space *vm,* On each list, the oldest objects lie at the HEAD with the freshest * object on the TAIL. */ -if (start !=0 || end != vm->total) { -drm_mm_scan_init_with_range (&scan, &vm->mm, min_size, - alignment, cache_level, - start, end); - }else -drm_mm_scan_init (&scan, &vm->mm, min_size, - alignment, cache_level); +drm_mm_scan_init_with_range (&scan, &vm->mm, + min_size, alignment, cache_level, + start, end);/* Retire before we search the active list. Although we have * reasonable accuracy in our retirement lists, we may have
include/drm/drm_mm.h +27 -6
@@ -120,7 +120,6 @@ struct drm_mm_scan {struct drm_mm_node *prev_scanned_node;unsigned long color; - bool check_range : 1; };/**
@@ -375,11 +374,6 @@ __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last); node__ && node__->start < (end__); \ node__ = list_next_entry(node__, node_list)) -void drm_mm_scan_init (struct drm_mm_scan *scan, -struct drm_mm *mm, -u64 size, -u64 alignment, -unsigned long color); void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, struct drm_mm *mm, u64 size,
@@ -387,6 +381,33 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,unsigned long color, u64 start, u64 end); + +/** +* drm_mm_scan_init - initialize lru scanning +* @scan: scan state +* @mm: drm_mm to scan +* @size: size of the allocation +* @alignment: alignment of the allocation +* @color: opaque tag value to use for the allocation +* +* This simply sets up the scanning routines with the parameters for the desired +* hole. Note that there's no need to specify allocation flags, since they only +* change the place a node is allocated from within a suitable hole. +* +* Warning: +* As long as the scan list is non-empty, no other operations than +* adding/removing nodes to/from the scan list are allowed. +*/ +static inline void drm_mm_scan_init (struct drm_mm_scan *scan, +struct drm_mm *mm, +u64 size, +u64 alignment, +unsigned long color) +{ +drm_mm_scan_init_with_range (scan, mm, size, alignment, color, +0 ,U64_MAX ); +} +bool drm_mm_scan_add_block (struct drm_mm_scan *scan,struct drm_mm_node *node); bool drm_mm_scan_remove_block(struct drm_mm_scan *scan,
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 31/40 drm: Fix application of color vs range restriction when scanning drm_mm
In reply to Chris WilsonThe range restriction should be applied after the color adjustment, or else we may inadvertently apply the color adjustment to the restricted hole (and not against its neighbours).
--- drivers/gpu/drm/drm_mm.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_mm.c +9 -6
@@ -772,6 +772,7 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan,struct drm_mm *mm = scan->mm;struct drm_mm_node *hole;u64 hole_start, hole_end; +u64 col_start, col_end;u64 adj_start, adj_end;DRM_MM_BUG_ON (node->mm != mm);
@@ -789,14 +790,16 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, node->node_list.next = &scan->prev_scanned_node->node_list; scan->prev_scanned_node = node; - hole_start =drm_mm_hole_node_start (hole); - hole_end =drm_mm_hole_node_end (hole); - - adj_start =max (hole_start, scan->range_start); - adj_end =min (hole_end, scan->range_end); + hole_start =__drm_mm_hole_node_start (hole); + hole_end =__drm_mm_hole_node_end (hole); + col_start = hole_start; + col_end = hole_end;if (mm->color_adjust) - mm->color_adjust (hole, scan->color, &adj_start, &adj_end); + mm->color_adjust (hole, scan->color, &col_start, &col_end); + + adj_start =max (col_start, scan->range_start); + adj_end =min (col_end, scan->range_end);if (check_free_hole (adj_start, adj_end, scan->size, scan->alignment)) {
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 32/40 drm: Compute tight evictions for drm_mm_scan
In reply to Chris WilsonCompute the minimal required hole during scan and only evict those nodes that overlap. This enables us to reduce the number of nodes we need to evict to the bare minimum.
--- drivers/gpu/drm/drm_mm.c | 60 +++++++++++++++++++++++++++------ drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 2 +- drivers/gpu/drm/i915/i915_gem_evict.c | 3 +- drivers/gpu/drm/selftests/test-drm_mm.c | 10 +++--- include/drm/drm_mm.h | 22 ++++++------ 5 files changed, 71 insertions(+), 26 deletions(-)
drivers/gpu/drm/drm_mm.c +50 -10
@@ -718,10 +718,10 @@ EXPORT_SYMBOL(drm_mm_replace_node);* @color: opaque tag value to use for the allocation * @start: start of the allowed range for the allocation * @end: end of the allowed range for the allocation +* @flags: flags to specify how the allocation will be performed afterwards * * This simply sets up the scanning routines with the parameters for the desired -* hole. Note that there's no need to specify allocation flags, since they only -* change the place a node is allocated from within a suitable hole. +* hole. * * Warning: * As long as the scan list is non-empty, no other operations than
@@ -733,7 +733,8 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,u64 alignment, unsigned long color, u64 start, - u64 end) + u64 end, + unsigned int flags) { DRM_MM_BUG_ON(start >= end);DRM_MM_BUG_ON (size ==0 || size > end - start);
@@ -744,6 +745,7 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, scan->color = color; scan->alignment = alignment; scan->size = size; + scan->flags = flags;DRM_MM_BUG_ON (end <= start); scan->range_start = start;
@@ -778,7 +780,7 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan,DRM_MM_BUG_ON (node->mm != mm);DRM_MM_BUG_ON (!node->allocated);DRM_MM_BUG_ON (node->scanned_block); - node->scanned_block =1 ; + node->scanned_block = true; mm->scan_active++; hole =list_prev_entry (node, node_list);
@@ -800,15 +802,53 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, adj_start =max (col_start, scan->range_start); adj_end =min (col_end, scan->range_end); +if (adj_end <= adj_start || adj_end - adj_start < scan->size) +return false; + +if (scan->flags ==DRM_MM_CREATE_TOP ) + adj_start = adj_end - scan->size; + +if (scan->alignment) { +u64 rem; + +div64_u64_rem (adj_start, scan->alignment, &rem); +if (rem) { + adj_start -= rem; +if (scan->flags !=DRM_MM_CREATE_TOP ) + adj_start += scan->alignment; +if (adj_start <max (col_start, scan->range_start) || +min (col_end, scan->range_end) - adj_start < scan->size) +return false; + +if (adj_end <= adj_start || + adj_end - adj_start < scan->size) +return false; + } + } -if (check_free_hole (adj_start, adj_end, - scan->size, scan->alignment)) { +if (mm->color_adjust) { +/* If allocations need adjusting due to neighbouring colours, +* we do not have enough information to decide if we need +* to evict nodes on either side of [adj_start, adj_end]. +* What almost works is +* hit_start = adj_start + (hole_start - col_start); +* hit_end = adj_start + scan->size + (hole_end - col_end); +* but because the decision is only made on the final hole, +* we may underestimate the required adjustments for an +* interior allocation. +*/ scan->hit_start = hole_start; scan->hit_end = hole_end; -return true; + }else { + scan->hit_start = adj_start; + scan->hit_end = adj_start + scan->size; } -return false; +DRM_MM_BUG_ON (scan->hit_start >= scan->hit_end); +DRM_MM_BUG_ON (scan->hit_start < hole_start); +DRM_MM_BUG_ON (scan->hit_end > hole_end); + +return true; }EXPORT_SYMBOL (drm_mm_scan_add_block);
@@ -836,7 +876,7 @@ bool drm_mm_scan_remove_block(struct drm_mm_scan *scan,DRM_MM_BUG_ON (node->mm != scan->mm);DRM_MM_BUG_ON (!node->scanned_block); - node->scanned_block =0 ; + node->scanned_block = false;DRM_MM_BUG_ON (!node->mm->scan_active); node->mm->scan_active--;
@@ -846,7 +886,7 @@ bool drm_mm_scan_remove_block(struct drm_mm_scan *scan, prev_node->hole_follows = node->scanned_preceeds_hole;list_add (&node->node_list, &prev_node->node_list); -return (drm_mm_hole_node_end (node) > scan->hit_start && +return (node->start + node->size > scan->hit_start && node->start < scan->hit_end); }EXPORT_SYMBOL (drm_mm_scan_remove_block);
drivers/gpu/drm/etnaviv/etnaviv_mmu.c +1 -1
@@ -135,7 +135,7 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu, }/* Try to retire some entries */ -drm_mm_scan_init (&scan, &mmu->mm, size,0 ,0 ); +drm_mm_scan_init (&scan, &mmu->mm, size,0 ,0 ,0 ); found =0 ;INIT_LIST_HEAD (&list);
drivers/gpu/drm/i915/i915_gem_evict.c +2 -1
@@ -128,7 +128,8 @@ i915_gem_evict_something(struct i915_address_space *vm,*/ drm_mm_scan_init_with_range (&scan, &vm->mm, min_size, alignment, cache_level, - start, end); + start, end, + flags &PIN_HIGH ?DRM_MM_CREATE_TOP :0 );/* Retire before we search the active list. Although we have * reasonable accuracy in our retirement lists, we may have
drivers/gpu/drm/selftests/test-drm_mm.c +6 -4
@@ -1169,7 +1169,7 @@ static bool evict_nothing(struct drm_mm *mm,struct drm_mm_node *node;unsigned int n; -drm_mm_scan_init (&scan, mm,1 ,0 ,0 ); +drm_mm_scan_init (&scan, mm,1 ,0 ,0 ,0 );for (n =0 ; n < total_size; n++) { e = &nodes[n];list_add (&e->link, &evict_list);
@@ -1216,7 +1216,7 @@ static bool evict_everything(struct drm_mm *mm,unsigned int n;int err; -drm_mm_scan_init (&scan, mm, total_size,0 ,0 ); +drm_mm_scan_init (&scan, mm, total_size,0 ,0 ,0 );for (n =0 ; n < total_size; n++) { e = &nodes[n];list_add (&e->link, &evict_list);
@@ -1266,7 +1266,8 @@ static int evict_something(struct drm_mm *mm,drm_mm_scan_init_with_range (&scan, mm, size, alignment,0 , - range_start, range_end); + range_start, range_end, + mode->create_flags);if (!evict_nodes (&scan, nodes, order, count, &evict_list))
@@ -1850,7 +1851,8 @@ static int evict_color(struct drm_mm *mm,drm_mm_scan_init_with_range (&scan, mm, size, alignment, color, - range_start, range_end); + range_start, range_end, + mode->create_flags);if (!evict_nodes (&scan, nodes, order, count, &evict_list))
include/drm/drm_mm.h +12 -10
@@ -120,6 +120,7 @@ struct drm_mm_scan {struct drm_mm_node *prev_scanned_node;unsigned long color; +unsigned int flags; };/**
@@ -376,11 +377,9 @@ __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last);void drm_mm_scan_init_with_range (struct drm_mm_scan *scan,struct drm_mm *mm, -u64 size, -u64 alignment, -unsigned long color, -u64 start, -u64 end); +u64 size,u64 alignment,unsigned long color, +u64 start,u64 end, +unsigned int flags);/** * drm_mm_scan_init - initialize lru scanning
@@ -389,10 +388,10 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,* @size: size of the allocation * @alignment: alignment of the allocation * @color: opaque tag value to use for the allocation +* @flags: flags to specify how the allocation will be performed afterwards * * This simply sets up the scanning routines with the parameters for the desired -* hole. Note that there's no need to specify allocation flags, since they only -* change the place a node is allocated from within a suitable hole. +* hole. * * Warning: * As long as the scan list is non-empty, no other operations than
@@ -402,10 +401,13 @@ static inline void drm_mm_scan_init(struct drm_mm_scan *scan,struct drm_mm *mm, u64 size, u64 alignment, - unsigned long color) + unsigned long color, + unsigned int flags) { -drm_mm_scan_init_with_range (scan ,mm ,size ,alignment ,color , - 0, U64_MAX); +drm_mm_scan_init_with_range (scan ,mm , +size ,alignment ,color , + 0, U64_MAX, +flags ); } bool drm_mm_scan_add_block(struct drm_mm_scan *scan,
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 33/40 drm: Optimise power-of-two alignments in drm_mm_scan_add_block()
In reply to Chris WilsonFor power-of-two alignments, we can avoid the 64bit divide and do a simple bitwise add instead.
v2: s/alignment_mask/remainder_mask/
--- drivers/gpu/drm/drm_mm.c | 9 ++++++++- include/drm/drm_mm.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_mm.c +8 -1
@@ -742,8 +742,12 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, scan->mm = mm; +if (alignment <=1 ) + alignment =0 ; + scan->color = color; scan->alignment = alignment; + scan->remainder_mask =is_power_of_2 (alignment) ? alignment -1 :0 ; scan->size = size; scan->flags = flags;
@@ -811,7 +815,10 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan,if (scan->alignment) {u64 rem; -div64_u64_rem (adj_start, scan->alignment, &rem); +if (likely (scan->remainder_mask)) + rem = adj_start & scan->remainder_mask; +else +div64_u64_rem (adj_start, scan->alignment, &rem);if (rem) { adj_start -= rem;if (scan->flags !=DRM_MM_CREATE_TOP )
include/drm/drm_mm.h +1 -0
@@ -110,6 +110,7 @@ struct drm_mm_scan {u64 size;u64 alignment; +u64 remainder_mask;u64 range_start;u64 range_end;
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 34/40 drm: Simplify drm_mm scan-list manipulation
In reply to Chris WilsonSince we mandate a strict reverse-order of drm_mm_scan_remove_block() after drm_mm_scan_add_block() we can further simplify the list manipulations when generating the temporary scan-hole.
v2: Highlight the games being played with the lists to track the scan holes without allocation.
--- drivers/gpu/drm/drm_mm.c | 35 ++++++++++++++++++----------------- include/drm/drm_mm.h | 7 +------ 2 files changed, 19 insertions(+), 23 deletions(-)
drivers/gpu/drm/drm_mm.c +18 -17
@@ -518,9 +518,7 @@ void drm_mm_remove_node(struct drm_mm_node *node)struct drm_mm_node *prev_node;DRM_MM_BUG_ON (!node->allocated); -DRM_MM_BUG_ON (node->scanned_block || - node->scanned_prev_free || - node->scanned_next_free); +DRM_MM_BUG_ON (node->scanned_block); prev_node = list_entry(node->node_list.prev, struct drm_mm_node, node_list);
@@ -757,8 +755,6 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, scan->hit_start =U64_MAX ; scan->hit_end =0 ; - - scan->prev_scanned_node =NULL ; }EXPORT_SYMBOL (drm_mm_scan_init_with_range);
@@ -787,14 +783,14 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, node->scanned_block = true; mm->scan_active++; +/* Remove this block from the node_list so that we enlarge the hole +* (distance between the end of our previous node and the start of +* or next), without poisoning the link so that we can restore it +* later in drm_mm_scan_remove_block(). +*/ hole =list_prev_entry (node, node_list); - - node->scanned_preceeds_hole = hole->hole_follows; - hole->hole_follows =1 ; -list_del (&node->node_list); - node->node_list.prev = &hole->node_list; - node->node_list.next = &scan->prev_scanned_node->node_list; - scan->prev_scanned_node = node; +DRM_MM_BUG_ON (list_next_entry (hole, node_list) != node); +__list_del_entry (&node->node_list); hole_start =__drm_mm_hole_node_start (hole); hole_end =__drm_mm_hole_node_end (hole);
@@ -888,9 +884,17 @@ bool drm_mm_scan_remove_block(struct drm_mm_scan *scan,DRM_MM_BUG_ON (!node->mm->scan_active); node->mm->scan_active--; +/* During drm_mm_scan_add_block() we decoupled this node leaving +* its pointers intact. Now that the caller is walking back along +* the eviction list we can restore this block into its rightful +* place on the full node_list. To confirm that the caller is walking +* backwards correctly we check that prev_node->next == node->next, +* i.e. both believe the same node should be on the other side of the +* hole. +*/ prev_node =list_prev_entry (node, node_list); - - prev_node->hole_follows = node->scanned_preceeds_hole; +DRM_MM_BUG_ON (list_next_entry (prev_node, node_list) != +list_next_entry (node, node_list));list_add (&node->node_list, &prev_node->node_list); return (node->start + node->size > scan->hit_start &&
@@ -917,9 +921,6 @@ void drm_mm_init(struct drm_mm *mm, u64 start, u64 size)INIT_LIST_HEAD (&mm->head_node.node_list); mm->head_node.allocated =0 ; mm->head_node.hole_follows =1 ; - mm->head_node.scanned_block =0 ; - mm->head_node.scanned_prev_free =0 ; - mm->head_node.scanned_next_free =0 ; mm->head_node.mm = mm; mm->head_node.start = start + size; mm->head_node.size = start - mm->head_node.start;
include/drm/drm_mm.h +1 -6
@@ -74,11 +74,8 @@ struct drm_mm_node {struct list_head hole_stack;struct rb_node rb; unsigned hole_follows : 1; - unsigned scanned_block : 1; - unsigned scanned_prev_free : 1; - unsigned scanned_next_free : 1; - unsigned scanned_preceeds_hole : 1; unsigned allocated : 1; + bool scanned_block : 1;unsigned long color;u64 start;u64 size;
@@ -118,8 +115,6 @@ struct drm_mm_scan {u64 hit_start;u64 hit_end; -struct drm_mm_node *prev_scanned_node; -unsigned long color;unsigned int flags; };
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 34/40] drm: Simplify drm_mm scan-list manipulation
Quoted 8 lines · Chris Wilson
Since we mandate a strict reverse-order of
drm_mm_scan_remove_block()afterdrm_mm_scan_add_block()we can further simplify the list manipulations when generating the temporary scan-hole.v2: Highlight the games being played with the lists to track the scan holes without allocation.
Signed-off-by Chris Wilson <[email protected]>
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 35/40 drm: Apply tight eviction scanning to color_adjust
In reply to Chris WilsonUsing mm->color_adjust makes the eviction scanner much tricker since we don't know the actual neighbours of the target hole until after it is created (after scanning is complete). To work out whether we need to evict the neighbours because they impact upon the hole, we have to then check the hole afterwards - requiring an extra step in the user of the eviction scanner when they apply color_adjust.
v2: Massage kerneldoc.
--- drivers/gpu/drm/drm_mm.c | 76 ++++++++++++++++++++++----------- drivers/gpu/drm/i915/i915_gem_evict.c | 7 +++ drivers/gpu/drm/selftests/test-drm_mm.c | 20 ++++++++- include/drm/drm_mm.h | 1 + 4 files changed, 77 insertions(+), 27 deletions(-)
drivers/gpu/drm/drm_mm.c +51 -25
@@ -692,19 +692,21 @@ EXPORT_SYMBOL(drm_mm_replace_node);* The DRM range allocator supports this use-case through the scanning * interfaces. First a scan operation needs to be initialized with * drm_mm_scan_init() or drm_mm_scan_init_with_range(). The driver adds -* objects to the roaster (probably by walking an LRU list, but this can be -* freely implemented) until a suitable hole is found or there's no further -* evictable object. +* objects to the roster (probably by walking an LRU list, but this can be +* freely implemented) (using drm_mm_scan_add_block()) until a suitable hole +* is found or there are no further evictable objects. * * The driver must walk through all objects again in exactly the reverse * order to restore the allocator state. Note that while the allocator is used * in the scan mode no other operation is allowed. * -* Finally the driver evicts all objects selected in the scan. Adding and -* removing an object is O(1), and since freeing a node is also O(1) the overall -* complexity is O(scanned_objects). So like the free stack which needs to be -* walked before a scan operation even begins this is linear in the number of -* objects. It doesn't seem to hurt badly. +* Finally the driver evicts all objects selected (drm_mm_scan_remove_block() +* reported true) in the scan, and any overlapping nodes after color adjustment +* (drm_mm_scan_evict_color()). Adding and removing an object is O(1), and +* since freeing a node is also O(1) the overall complexity is +* O(scanned_objects). So like the free stack which needs to be walked before a +* scan operation even begins this is linear in the number of objects. It +* doesn't seem to hurt too badly. */ /**
@@ -829,23 +831,8 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, } } -if (mm->color_adjust) { -/* If allocations need adjusting due to neighbouring colours, -* we do not have enough information to decide if we need -* to evict nodes on either side of [adj_start, adj_end]. -* What almost works is -* hit_start = adj_start + (hole_start - col_start); -* hit_end = adj_start + scan->size + (hole_end - col_end); -* but because the decision is only made on the final hole, -* we may underestimate the required adjustments for an -* interior allocation. -*/ - scan->hit_start = hole_start; - scan->hit_end = hole_end; - }else { - scan->hit_start = adj_start; - scan->hit_end = adj_start + scan->size; - } + scan->hit_start = adj_start; + scan->hit_end = adj_start + scan->size;DRM_MM_BUG_ON (scan->hit_start >= scan->hit_end);DRM_MM_BUG_ON (scan->hit_start < hole_start);
@@ -903,6 +890,45 @@ bool drm_mm_scan_remove_block(struct drm_mm_scan *scan,EXPORT_SYMBOL (drm_mm_scan_remove_block);/** +* drm_mm_scan_color_evict - evict overlapping nodes on either side of hole +* @scan: drm_mm scan with target hole +* +* After completing an eviction scan and removing the selected nodes, we may +* need to remove a few more nodes from either side of the target hole if +* mm.color_adjust is being used. +* +* Returns: +* A node to evict, or NULL if there are no overlapping nodes. +*/ +struct drm_mm_node *drm_mm_scan_color_evict (struct drm_mm_scan *scan) +{ +struct drm_mm *mm = scan->mm; +struct drm_mm_node *hole; +u64 hole_start, hole_end; + +DRM_MM_BUG_ON (list_empty (&mm->hole_stack)); + +if (!mm->color_adjust) +return NULL ; + + hole =list_first_entry (&mm->hole_stack,typeof (*hole), hole_stack); + hole_start =__drm_mm_hole_node_start (hole); + hole_end =__drm_mm_hole_node_end (hole); + +DRM_MM_BUG_ON (hole_start > scan->hit_start); +DRM_MM_BUG_ON (hole_end < scan->hit_end); + + mm->color_adjust (hole, scan->color, &hole_start, &hole_end); +if (hole_start > scan->hit_start) +return hole; +if (hole_end < scan->hit_end) +return list_next_entry (hole, node_list); + +return NULL ; +} +EXPORT_SYMBOL (drm_mm_scan_color_evict); + +/** * drm_mm_init - initialize a drm-mm allocator * @mm: the drm_mm structure to initialize * @start: start of the range managed by @mm
drivers/gpu/drm/i915/i915_gem_evict.c +7 -0
@@ -108,6 +108,7 @@ i915_gem_evict_something(struct i915_address_space *vm,NULL , }, **phase;struct i915_vma *vma, *next; +struct drm_mm_node *node;int ret;lockdep_assert_held (&vm->i915->drm.struct_mutex);
@@ -218,6 +219,12 @@ i915_gem_evict_something(struct i915_address_space *vm,if (ret ==0 ) ret =i915_vma_unbind (vma); } + +while (ret ==0 && (node =drm_mm_scan_color_evict (&scan))) { + vma = container_of(node, struct i915_vma, node); + ret =i915_vma_unbind (vma); + } +return ret; }
drivers/gpu/drm/selftests/test-drm_mm.c +18 -2
@@ -1132,6 +1132,7 @@ static bool evict_nodes(struct drm_mm_scan *scan,struct evict_node *nodes, unsigned int *order, unsigned int count, + bool use_color, struct list_head *evict_list) { struct evict_node *e, *en;
@@ -1156,6 +1157,21 @@ static bool evict_nodes(struct drm_mm_scan *scan,list_for_each_entry (e, evict_list, link)drm_mm_remove_node (&e->node); +if (use_color) { +struct drm_mm_node *node; + +while ((node =drm_mm_scan_color_evict (scan))) { + e =container_of (node,typeof (*e), node); +drm_mm_remove_node (&e->node); +list_add (&e->link, evict_list); + } + }else { +if (drm_mm_scan_color_evict (scan)) { +pr_err ("drm_mm_scan_color_evict unexpectedly reported overlapping nodes!\n" ); +return false; + } + } +return true; }
@@ -1269,7 +1285,7 @@ static int evict_something(struct drm_mm *mm, range_start, range_end, mode->create_flags);if (!evict_nodes (&scan, - nodes, order, count, + nodes, order, count, false, &evict_list))return -EINVAL ;
@@ -1854,7 +1870,7 @@ static int evict_color(struct drm_mm *mm, range_start, range_end, mode->create_flags);if (!evict_nodes (&scan, - nodes, order, count, + nodes, order, count, true, &evict_list))return -EINVAL ;
include/drm/drm_mm.h +1 -0
@@ -410,6 +410,7 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, struct drm_mm_node *node);bool drm_mm_scan_remove_block (struct drm_mm_scan *scan,struct drm_mm_node *node); +struct drm_mm_node *drm_mm_scan_color_evict (struct drm_mm_scan *scan);void drm_mm_debug_table (const struct drm_mm *mm,const char *prefix);#ifdef CONFIG_DEBUG_FS
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 35/40] drm: Apply tight eviction scanning to color_adjust
Quoted 10 lines · Chris Wilson
Using
mm->color_adjustmakes the eviction scanner much tricker since we don't know the actual neighbours of the target hole until after it is created (after scanning is complete). To work out whether we need to evict the neighbours because they impact upon the hole, we have to then check the hole afterwards - requiring an extra step in the user of the eviction scanner when they applycolor_adjust.v2: Massage kerneldoc.
Signed-off-by Chris Wilson <[email protected]>
It's not optimal as a separate function, but good for now.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 35/40] drm: Apply tight eviction scanning to color_adjust
Quoted 8 lines · Joonas Lahtinen
Quoted 7 lines · Chris Wilson
Using
mm->color_adjustmakes the eviction scanner much tricker since we don't know the actual neighbours of the target hole until after it is created (after scanning is complete). To work out whether we need to evict the neighbours because they impact upon the hole, we have to then check the hole afterwards - requiring an extra step in the user of the eviction scanner when they applycolor_adjust.
Quoted 5 lines
Quoted 3 lines
v2: Massage kerneldoc.
Signed-off-by Chris Wilson <[email protected]>It's not optimal as a separate function, but good for now.
Yes, it's nasty that it requires a separate step by the caller to catch for residual overlap. The problem is that we do require the mm.color_adjust to be performed to tell if the user thinks there will be overlap - and that requires the final state of the hole and its neighbours.
Alternatives I considered were just a color_expand parameter and always evicting the neighbouring nodes (but that is not great for us as most of our nodes have one colour). Or I considered searching the node list to find the overlaps and flag them (presuming eviction happened as we intended). They all seemed to be worse than just asking the user to check after eviction if they are using color_adjust.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 36/40 drm: Wrap drm_mm_node.hole_follows
In reply to Chris WilsonInsulate users from changed to the internal hole tracking within struct drm_mm_node by using an accessor for hole_follows.
--- drivers/gpu/drm/drm_mm.c | 12 ++++++------ drivers/gpu/drm/i915/i915_vma.c | 4 ++-- drivers/gpu/drm/selftests/test-drm_mm.c | 18 ++++++++++-------- include/drm/drm_mm.h | 22 +++++++++++++++++++--- 4 files changed, 37 insertions(+), 19 deletions(-)
drivers/gpu/drm/drm_mm.c +6 -6
@@ -323,7 +323,7 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node) } hole =list_last_entry (&hole->node_list,typeof (*hole), node_list); -if (!hole->hole_follows) +if (!drm_mm_hole_follows (hole))return -ENOSPC ; adj_start = hole_start =__drm_mm_hole_node_start (hole);
@@ -408,7 +408,7 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,u64 adj_start = hole_start;u64 adj_end = hole_end; -DRM_MM_BUG_ON (!hole_node->hole_follows || node->allocated); +DRM_MM_BUG_ON (!drm_mm_hole_follows (hole_node) || node->allocated);if (adj_start < start) adj_start = start;
@@ -523,16 +523,16 @@ void drm_mm_remove_node(struct drm_mm_node *node) prev_node = list_entry(node->node_list.prev, struct drm_mm_node, node_list); -if (node->hole_follows) { +if (drm_mm_hole_follows (node)) {DRM_MM_BUG_ON (__drm_mm_hole_node_start (node) ==__drm_mm_hole_node_end (node));list_del (&node->hole_stack); - }else + }else {DRM_MM_BUG_ON (__drm_mm_hole_node_start (node) !=__drm_mm_hole_node_end (node)); + } - -if (!prev_node->hole_follows) { +if (!drm_mm_hole_follows (prev_node)) { prev_node->hole_follows =1 ;list_add (&prev_node->hole_stack, &mm->hole_stack); }else
drivers/gpu/drm/i915/i915_vma.c +2 -2
@@ -322,11 +322,11 @@ bool i915_gem_valid_gtt_space(struct i915_vma *vma, unsigned long cache_level)GEM_BUG_ON (list_empty (&node->node_list)); other =list_prev_entry (node, node_list); -if (color_differs (other, cache_level) && !other->hole_follows) +if (color_differs (other, cache_level) && !drm_mm_hole_follows (other))return false; other =list_next_entry (node, node_list); -if (color_differs (other, cache_level) && !node->hole_follows) +if (color_differs (other, cache_level) && !drm_mm_hole_follows (node))return false;return true;
drivers/gpu/drm/selftests/test-drm_mm.c +10 -8
@@ -42,7 +42,7 @@ static bool assert_no_holes(const struct drm_mm *mm) }drm_mm_for_each_node (hole, mm) { -if (hole->hole_follows) { +if (drm_mm_hole_follows (hole)) {pr_err ("Hole follows node, expected none!\n" );return false; }
@@ -104,7 +104,7 @@ static bool assert_continuous(const struct drm_mm *mm, u64 size)return false; } -if (node->hole_follows) { +if (drm_mm_hole_follows (node)) {pr_err ("node[%ld] is followed by a hole!\n" , n);return false; }
@@ -787,7 +787,8 @@ static bool assert_contiguous_in_range(struct drm_mm *mm,return false; } -if (node->hole_follows &&drm_mm_hole_node_end (node) < end) { +if (drm_mm_hole_follows (node) && +drm_mm_hole_node_end (node) < end) {pr_err ("node %d is followed by a hole!\n" , n);return false; }
@@ -1307,11 +1308,12 @@ static int evict_something(struct drm_mm *mm, err = -EINVAL ; } -if (!assert_node (&tmp, mm, size, alignment,0 ) || tmp.hole_follows) { +if (!assert_node (&tmp, mm, size, alignment,0 ) || +drm_mm_hole_follows (&tmp)) {pr_err ("Inserted did not fill the eviction hole: size=%lld [%d], align=%d [rem=%lld], start=%llx, hole-follows?=%d\n" , tmp.size, size, alignment,misaligned (&tmp, alignment), - tmp.start, tmp.hole_follows); + tmp.start,drm_mm_hole_follows (&tmp)); err = -EINVAL ; }
@@ -1590,7 +1592,7 @@ static int igt_topdown(void *ignored) goto out; } -if (nodes[n].hole_follows) { +if (drm_mm_hole_follows (&nodes[n])) {pr_err ("hole after topdown insert %d, start=%llx\n, size=%u" , n, nodes[n].start, size); goto out;
@@ -1624,7 +1626,7 @@ static int igt_topdown(void *ignored) goto out; } -if (node->hole_follows) { +if (drm_mm_hole_follows (node)) {pr_err ("hole after topdown insert %d/%d, start=%llx\n" , m, n, node->start); goto out;
@@ -1679,7 +1681,7 @@ static void separate_adjacent_colors(const struct drm_mm_node *node,static bool colors_abutt (const struct drm_mm_node *node) { -if (!node->hole_follows && +if (!drm_mm_hole_follows (node) &&list_next_entry (node, node_list)->allocated) { pr_err("colors abutt; %ld [%llx + %llx] is next to %ld [%llx + %llx]!\n", node->color, node->start, node->size,
include/drm/drm_mm.h +19 -3
@@ -155,6 +155,22 @@ static inline bool drm_mm_initialized(const struct drm_mm *mm)return mm->hole_stack.next; } +/** +* drm_mm_hole_follows - checks whether a hole follows this node +* @node: drm_mm_node to check +* +* Holes are embedded into the drm_mm using the tail of a drm_mm_node. +* If you wish to know whether a hole follows this particular node, +* query this function. +* +* Returns: +* True if a hole follows the @node. +*/ +static inline bool drm_mm_hole_follows (const struct drm_mm_node *node) +{ +return node->hole_follows; +} +static inline u64 __drm_mm_hole_node_start (const struct drm_mm_node *hole_node) {return hole_node->start + hole_node->size;
@@ -166,14 +182,14 @@ static inline u64 __drm_mm_hole_node_start(const struct drm_mm_node *hole_node)* * This is useful for driver-specific debug dumpers. Otherwise drivers should * not inspect holes themselves. Drivers must check first whether a hole indeed -* follows by looking at node->hole_follows. +* follows by looking at drm_mm_hole_follows() * * Returns: * Start of the subsequent hole. */ static inline u64 drm_mm_hole_node_start (const struct drm_mm_node *hole_node) { -DRM_MM_BUG_ON (!hole_node->hole_follows); +DRM_MM_BUG_ON (!drm_mm_hole_follows (hole_node));return __drm_mm_hole_node_start (hole_node); }
@@ -188,7 +204,7 @@ static inline u64 __drm_mm_hole_node_end(const struct drm_mm_node *hole_node)* * This is useful for driver-specific debug dumpers. Otherwise drivers should * not inspect holes themselves. Drivers must check first whether a hole indeed -* follows by looking at node->hole_follows. +* follows by looking at drm_mm_hole_follows(). * * Returns: * End of the subsequent hole.
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 36/40] drm: Wrap drm_mm_node.hole_follows
Quoted 1 line · Chris Wilson
Insulate users from changed to the internal hole tracking within
changes ----------------^
Quoted 3 lines
struct
drm_mm_nodeby using an accessor forhole_follows.Signed-off-by Chris Wilson <[email protected]>
The function name could be soemthing beginning with drm_mm_node...
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 36/40] drm: Wrap drm_mm_node.hole_follows
Quoted 10 lines · Joonas Lahtinen
Quoted 1 line · Chris Wilson
Insulate users from changed to the internal hole tracking within
changes ----------------^
Quoted 3 lines
struct
drm_mm_nodeby using an accessor forhole_follows.Signed-off-by Chris Wilson <[email protected]>The function name could be soemthing beginning with
drm_mm_node...
Didn't like it as drm_mm_node_hole_follows(), and rationalised it away as saying this is really drm_mm state that happens to be hidden away inside the user's drm_mm_node. I guess we should look at some /* private */ markup. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerRe: [PATCH v2 36/40] drm: Wrap drm_mm_node.hole_follows
Quoted 11 lines · Chris Wilson
Quoted 10 lines · Joonas Lahtinen
Quoted 2 lines · Chris Wilson
Insulate users from changed to the internal hole tracking within
changes ----------------^
Quoted 3 lines
struct
drm_mm_nodeby using an accessor forhole_follows.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Chris Wilson <[email protected]>The function name could be soemthing beginning with
drm_mm_node...Didn't like it as
drm_mm_node_hole_follows(), and rationalised it away as saying this is reallydrm_mmstate that happens to be hidden away inside the user'sdrm_mm_node. I guess we should look at some /* private */ markup.
That makes sense now that you mention it.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 37/40 drm: Apply range restriction after color adjustment when allocation
In reply to Chris Wilsonmm->color_adjust() compares the hole with its neighbouring nodes. They only abutt before we restrict the hole, so we have to apply color_adjust before we apply the range restriction.
--- drivers/gpu/drm/drm_mm.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_mm.c +6 -10
@@ -410,14 +410,12 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,DRM_MM_BUG_ON (!drm_mm_hole_follows (hole_node) || node->allocated); -if (adj_start < start) - adj_start = start; -if (adj_end > end) - adj_end = end; -if (mm->color_adjust) mm->color_adjust (hole_node, color, &adj_start, &adj_end); + adj_start =max (adj_start, start); + adj_end =min (adj_end, end); +if (flags &DRM_MM_CREATE_TOP ) adj_start = adj_end - size;
@@ -625,17 +623,15 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_ flags & DRM_MM_SEARCH_BELOW) {u64 hole_size = adj_end - adj_start; -if (adj_start < start) - adj_start = start; -if (adj_end > end) - adj_end = end; -if (mm->color_adjust) { mm->color_adjust (entry, color, &adj_start, &adj_end);if (adj_end <= adj_start)continue ; } + adj_start =max (adj_start, start); + adj_end =min (adj_end, end); +if (!check_free_hole (adj_start, adj_end, size, alignment))continue ;
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 37/40] drm: Apply range restriction after color adjustment when allocation
Quoted 5 lines · Chris Wilson
mm->color_adjust()compares the hole with its neighbouring nodes. They only abutt before we restrict the hole, so we have to applycolor_adjustbefore we apply the range restriction.Signed-off-by Chris Wilson <[email protected]>
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 38/40 drm: Use drm_mm_insert_node_in_range_generic() for everyone
In reply to Chris WilsonRemove a superfluous helper as drm_mm_insert_node is equivalent to insert_node_in_range with a range of (0, U64_MAX).
--- drivers/gpu/drm/drm_mm.c | 166 ++++------------------------------------------- include/drm/drm_mm.h | 90 +++++++++++++++---------- 2 files changed, 67 insertions(+), 189 deletions(-)
drivers/gpu/drm/drm_mm.c +11 -155
@@ -92,11 +92,6 @@* some basic allocator dumpers for debugging. */ -static struct drm_mm_node *drm_mm_search_free_generic (const struct drm_mm *mm, -u64 size, -u64 alignment, -unsigned long color, -enum drm_mm_search_flags flags); static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, u64 size, u64 alignment,
@@ -230,6 +225,7 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,struct drm_mm_node *node, u64 size, u64 alignment, unsigned long color, + u64 range_start, u64 range_end, enum drm_mm_allocator_flags flags) { struct drm_mm *mm = hole_node->mm;
@@ -238,11 +234,14 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,u64 adj_start = hole_start;u64 adj_end = hole_end; -DRM_MM_BUG_ON (node->allocated); +DRM_MM_BUG_ON (!drm_mm_hole_follows (hole_node) || node->allocated);if (mm->color_adjust) mm->color_adjust (hole_node, color, &adj_start, &adj_end); + adj_start =max (adj_start, range_start); + adj_end =min (adj_end, range_end); +if (flags &DRM_MM_CREATE_TOP ) adj_start = adj_end - size;
@@ -258,9 +257,6 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, } } -DRM_MM_BUG_ON (adj_start < hole_start); -DRM_MM_BUG_ON (adj_end > hole_end); -if (adj_start == hole_start) { hole_node->hole_follows =0 ;list_del (&hole_node->hole_stack);
@@ -276,7 +272,10 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,drm_mm_interval_tree_add_node (hole_node, node); +DRM_MM_BUG_ON (node->start < range_start); +DRM_MM_BUG_ON (node->start < adj_start);DRM_MM_BUG_ON (node->start + node->size > adj_end); +DRM_MM_BUG_ON (node->start + node->size > range_end); node->hole_follows =0 ;if (__drm_mm_hole_node_start (node) < hole_end) {
@@ -360,107 +359,6 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)EXPORT_SYMBOL (drm_mm_reserve_node);/** -* drm_mm_insert_node_generic - search for space and insert @node -* @mm: drm_mm to allocate from -* @node: preallocate node to insert -* @size: size of the allocation -* @alignment: alignment of the allocation -* @color: opaque tag value to use for this node -* @sflags: flags to fine-tune the allocation search -* @aflags: flags to fine-tune the allocation behavior -* -* The preallocated node must be cleared to 0. -* -* Returns: -* 0 on success, -ENOSPC if there's no suitable hole. -*/ -int drm_mm_insert_node_generic (struct drm_mm *mm,struct drm_mm_node *node, -u64 size,u64 alignment, -unsigned long color, -enum drm_mm_search_flags sflags, -enum drm_mm_allocator_flags aflags) -{ -struct drm_mm_node *hole_node; - -if (WARN_ON (size ==0 )) -return -EINVAL ; - - hole_node =drm_mm_search_free_generic (mm, size, alignment, - color, sflags); -if (!hole_node) -return -ENOSPC ; - -drm_mm_insert_helper (hole_node, node, size, alignment, color, aflags); -return 0 ; -} -EXPORT_SYMBOL (drm_mm_insert_node_generic); - -static void drm_mm_insert_helper_range (struct drm_mm_node *hole_node, -struct drm_mm_node *node, -u64 size,u64 alignment, -unsigned long color, -u64 start,u64 end, -enum drm_mm_allocator_flags flags) -{ -struct drm_mm *mm = hole_node->mm; -u64 hole_start =drm_mm_hole_node_start (hole_node); -u64 hole_end =drm_mm_hole_node_end (hole_node); -u64 adj_start = hole_start; -u64 adj_end = hole_end; - -DRM_MM_BUG_ON (!drm_mm_hole_follows (hole_node) || node->allocated); - -if (mm->color_adjust) - mm->color_adjust (hole_node, color, &adj_start, &adj_end); - - adj_start =max (adj_start, start); - adj_end =min (adj_end, end); - -if (flags &DRM_MM_CREATE_TOP ) - adj_start = adj_end - size; - -if (alignment) { -u64 rem; - -div64_u64_rem (adj_start, alignment, &rem); -if (rem) { -if (flags &DRM_MM_CREATE_TOP ) - adj_start -= rem; -else - adj_start += alignment - rem; - } - } - -if (adj_start == hole_start) { - hole_node->hole_follows =0 ; -list_del (&hole_node->hole_stack); - } - - node->start = adj_start; - node->size = size; - node->mm = mm; - node->color = color; - node->allocated =1 ; - -list_add (&node->node_list, &hole_node->node_list); - -drm_mm_interval_tree_add_node (hole_node, node); - -DRM_MM_BUG_ON (node->start < start); -DRM_MM_BUG_ON (node->start < adj_start); -DRM_MM_BUG_ON (node->start + node->size > adj_end); -DRM_MM_BUG_ON (node->start + node->size > end); - - node->hole_follows =0 ; -if (__drm_mm_hole_node_start (node) < hole_end) { -list_add (&node->hole_stack, &mm->hole_stack); - node->hole_follows =1 ; - } - -save_stack (node); -} - -/** * drm_mm_insert_node_in_range_generic - ranged search for space and insert @node * @mm: drm_mm to allocate from * @node: preallocate node to insert
@@ -495,9 +393,9 @@ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *nif (!hole_node)return -ENOSPC ; -drm_mm_insert_helper_range (hole_node, node, - size, alignment, color, - start, end, aflags); +drm_mm_insert_helper (hole_node, node, + size, alignment, color, + start, end, aflags);return 0 ; }EXPORT_SYMBOL (drm_mm_insert_node_in_range_generic);
@@ -558,48 +456,6 @@ static int check_free_hole(u64 start, u64 end, u64 size, u64 alignment)return end >= start + size; } -static struct drm_mm_node *drm_mm_search_free_generic (const struct drm_mm *mm, -u64 size, -u64 alignment, -unsigned long color, -enum drm_mm_search_flags flags) -{ -struct drm_mm_node *entry; -struct drm_mm_node *best; -u64 adj_start; -u64 adj_end; -u64 best_size; - -DRM_MM_BUG_ON (mm->scan_active); - - best =NULL ; - best_size = ~0UL ; - -__drm_mm_for_each_hole (entry, mm, adj_start, adj_end, - flags &DRM_MM_SEARCH_BELOW ) { -u64 hole_size = adj_end - adj_start; - -if (mm->color_adjust) { - mm->color_adjust (entry, color, &adj_start, &adj_end); -if (adj_end <= adj_start) -continue ; - } - -if (!check_free_hole (adj_start, adj_end, size, alignment)) -continue ; - -if (!(flags &DRM_MM_SEARCH_BEST )) -return entry; - -if (hole_size < best_size) { - best = entry; - best_size = hole_size; - } - } - -return best; -} - static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, u64 size, u64 alignment,
include/drm/drm_mm.h +56 -34
108 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 38/40] drm: Use drm_mm_insert_node_in_range_generic() for everyone
Quoted 4 lines · Chris Wilson
Remove a superfluous helper as
drm_mm_insert_nodeis equivalent toinsert_node_in_rangewith a range of (0,U64_MAX).Signed-off-by Chris Wilson <[email protected]>
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 39/40 drm: Improve drm_mm search (and fix topdown allocation) with rbtrees
In reply to Chris WilsonThe drm_mm range manager claimed to support top-down insertion, but it was neither searching for the top-most hole that could fit the allocation request nor fitting the request to the hole correctly.
In order to search the range efficiently, we create a secondary index for the holes using either their size or their address. This index allows us to find the smallest hole or the hole at the bottom or top of the range efficiently, whilst keeping the hole stack to rapidly service evictions.
v2: Search for holes both high and low. Rename flags to mode.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 16 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 20 +- drivers/gpu/drm/armada/armada_gem.c | 4 +- drivers/gpu/drm/drm_mm.c | 507 +++++++++++++++------------ drivers/gpu/drm/drm_vma_manager.c | 3 +- drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 8 +- drivers/gpu/drm/i915/i915_gem.c | 10 +- drivers/gpu/drm/i915/i915_gem_evict.c | 9 +- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 5 +- drivers/gpu/drm/i915/i915_gem_gtt.c | 39 +-- drivers/gpu/drm/i915/i915_gem_stolen.c | 6 +- drivers/gpu/drm/msm/msm_gem.c | 3 +- drivers/gpu/drm/msm/msm_gem_vma.c | 3 +- drivers/gpu/drm/selftests/test-drm_mm.c | 97 ++--- drivers/gpu/drm/sis/sis_mm.c | 6 +- drivers/gpu/drm/tegra/gem.c | 4 +- drivers/gpu/drm/ttm/ttm_bo_manager.c | 18 +- drivers/gpu/drm/vc4/vc4_crtc.c | 2 +- drivers/gpu/drm/vc4/vc4_hvs.c | 3 +- drivers/gpu/drm/vc4/vc4_plane.c | 6 +- drivers/gpu/drm/via/via_mm.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 10 +- include/drm/drm_mm.h | 135 +++---- 23 files changed, 442 insertions(+), 476 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +7 -9
@@ -97,8 +97,7 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, {struct amdgpu_gtt_mgr *mgr = man->priv;struct drm_mm_node *node = mem->mm_node; -enum drm_mm_search_flags sflags =DRM_MM_SEARCH_BEST ; -enum drm_mm_allocator_flags aflags =DRM_MM_CREATE_DEFAULT ; +enum drm_mm_insert_mode mode;unsigned long fpfn, lpfn;int r;
@@ -115,15 +114,14 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,else lpfn = man->size; -if (place && place->flags &TTM_PL_FLAG_TOPDOWN ) { - sflags =DRM_MM_SEARCH_BELOW ; - aflags =DRM_MM_CREATE_TOP ; - } + mode =DRM_MM_INSERT_BEST ; +if (place && place->mode &TTM_PL_FLAG_TOPDOWN ) + mode =DRM_MM_INSERT_HIGH ;spin_lock (&mgr->lock); - r =drm_mm_insert_node_in_range_generic (&mgr->mm, node, mem->num_pages, - mem->page_alignment,0 , - fpfn, lpfn, sflags, aflags); + r =drm_mm_insert_node_in_range (&mgr->mm, node, + mem->num_pages, mem->page_alignment,0 , + fpfn, lpfn, mode);spin_unlock (&mgr->lock);if (!r) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +8 -12
@@ -97,8 +97,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,struct amdgpu_vram_mgr *mgr = man->priv;struct drm_mm *mm = &mgr->mm;struct drm_mm_node *nodes; -enum drm_mm_search_flags sflags =DRM_MM_SEARCH_DEFAULT ; -enum drm_mm_allocator_flags aflags =DRM_MM_CREATE_DEFAULT ; +enum drm_mm_insert_mode mode;unsigned long lpfn, num_nodes, pages_per_node, pages_left;unsigned i;int r;
@@ -121,10 +120,9 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,if (!nodes)return -ENOMEM ; -if (place->flags &TTM_PL_FLAG_TOPDOWN ) { - sflags =DRM_MM_SEARCH_BELOW ; - aflags =DRM_MM_CREATE_TOP ; - } + mode =DRM_MM_INSERT_BEST ; +if (place->flags &TTM_PL_FLAG_TOPDOWN ) + mode =DRM_MM_INSERT_HIGH ; pages_left = mem->num_pages;
@@ -135,13 +133,11 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,if (pages == pages_per_node) alignment = pages_per_node; -else - sflags |=DRM_MM_SEARCH_BEST ; - r =drm_mm_insert_node_in_range_generic (mm, &nodes[i], pages, - alignment,0 , - place->fpfn, lpfn, - sflags, aflags); + r =drm_mm_insert_node_in_range (mm, &nodes[i], + pages, alignment,0 , + place->fpfn, lpfn, + mode);if (unlikely (r)) goto error;
drivers/gpu/drm/armada/armada_gem.c +2 -2
@@ -149,8 +149,8 @@ armada_gem_linear_back(struct drm_device *dev, struct armada_gem_object *obj)return -ENOSPC ;mutex_lock (&priv->linear_lock); - ret =drm_mm_insert_node (&priv->linear, node, size, align, -DRM_MM_SEARCH_DEFAULT ); + ret =drm_mm_insert_node_generic (&priv->linear, node, + size, align,0 ,0 );mutex_unlock (&priv->linear_lock);if (ret) {kfree (node);
drivers/gpu/drm/drm_mm.c +283 -224
663 lines not on this page · raw message
drivers/gpu/drm/drm_vma_manager.c +1 -2
@@ -212,8 +212,7 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr, goto out_unlock; } - ret =drm_mm_insert_node (&mgr->vm_addr_space_mm, &node->vm_node, - pages,0 ,DRM_MM_SEARCH_DEFAULT ); + ret =drm_mm_insert_node (&mgr->vm_addr_space_mm, &node->vm_node, pages);if (ret) goto out_unlock;
drivers/gpu/drm/etnaviv/etnaviv_mmu.c +6 -2
@@ -107,6 +107,7 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu, struct drm_mm_node *node, size_t size) {struct etnaviv_vram_mapping *free =NULL ; +enum drm_mm_insert_mode mode =DRM_MM_INSERT_LOW ;int ret;lockdep_assert_held (&mmu->lock);
@@ -118,8 +119,9 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu,bool found; ret =drm_mm_insert_node_in_range (&mmu->mm, node, - size,0 , mmu->last_iova, ~0UL , -DRM_MM_SEARCH_DEFAULT ); + size,0 ,0 , + mmu->last_iova,U64_MAX , + mode);if (ret != -ENOSPC )break ;
@@ -187,6 +189,8 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu,list_del_init (&m->scan_node); } + mode =DRM_MM_INSERT_EVICT ; +/* * We removed enough mappings so that the new allocation will * succeed. Ensure that the MMU will be flushed before the
drivers/gpu/drm/i915/i915_gem.c +4 -6
@@ -69,12 +69,10 @@ insert_mappable_node(struct i915_ggtt *ggtt, struct drm_mm_node *node, u32 size) { memset(node, 0, sizeof(*node)); -return drm_mm_insert_node_in_range_generic (&ggtt->base.mm, node, - size,0 , -I915_COLOR_UNEVICTABLE , -0 , ggtt->mappable_end, -DRM_MM_SEARCH_DEFAULT , -DRM_MM_CREATE_DEFAULT ); +return drm_mm_insert_node_in_range (&ggtt->base.mm, node, + size,0 ,I915_COLOR_UNEVICTABLE , +0 , ggtt->mappable_end, +DRM_MM_INSERT_LOW ); } static void
drivers/gpu/drm/i915/i915_gem_evict.c +7 -2
@@ -109,6 +109,7 @@ i915_gem_evict_something(struct i915_address_space *vm, }, **phase;struct i915_vma *vma, *next;struct drm_mm_node *node; +enum drm_mm_insert_mode mode;int ret;lockdep_assert_held (&vm->i915->drm.struct_mutex);
@@ -127,10 +128,14 @@ i915_gem_evict_something(struct i915_address_space *vm,* On each list, the oldest objects lie at the HEAD with the freshest * object on the TAIL. */ + mode =DRM_MM_INSERT_BEST ; +if (flags &PIN_HIGH ) + mode =DRM_MM_INSERT_HIGH ; +if (flags &PIN_MAPPABLE ) + mode =DRM_MM_INSERT_LOW ;drm_mm_scan_init_with_range (&scan, &vm->mm, min_size, alignment, cache_level, - start, end, - flags &PIN_HIGH ?DRM_MM_CREATE_TOP :0 ); + start, end, mode);/* Retire before we search the active list. Although we have * reasonable accuracy in our retirement lists, we may have
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -3
@@ -436,12 +436,11 @@ static void *reloc_iomap(struct drm_i915_gem_object *obj, PIN_MAPPABLE | PIN_NONBLOCK);if (IS_ERR (vma)) {memset (&cache->node,0 ,sizeof (cache->node)); - ret =drm_mm_insert_node_in_range_generic + ret =drm_mm_insert_node_in_range (&ggtt->base.mm, &cache->node,4096 ,0 ,I915_COLOR_UNEVICTABLE ,0 , ggtt->mappable_end, -DRM_MM_SEARCH_DEFAULT , -DRM_MM_CREATE_DEFAULT ); +DRM_MM_INSERT_LOW );if (ret)/* no inactive aperture space, use cpu reloc */ return NULL ; }else {
drivers/gpu/drm/i915/i915_gem_gtt.c +16 -23
@@ -2734,12 +2734,10 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)return ret;/* Reserve a mappable slot for our lockless error capture */ - ret =drm_mm_insert_node_in_range_generic (&ggtt->base.mm, - &ggtt->error_capture, -4096 ,0 , -I915_COLOR_UNEVICTABLE , -0 , ggtt->mappable_end, -0 ,0 ); + ret =drm_mm_insert_node_in_range (&ggtt->base.mm, &ggtt->error_capture, +4096 ,0 ,I915_COLOR_UNEVICTABLE , +0 , ggtt->mappable_end, +DRM_MM_INSERT_LOW );if (ret)return ret;
@@ -3554,18 +3552,16 @@ int i915_gem_gtt_insert(struct i915_address_space *vm, u64 size, u64 alignment, unsigned long colour, u64 start, u64 end, unsigned int flags) { - u32 search_flag, alloc_flag; + enum drm_mm_insert_mode mode;int err;lockdep_assert_held (&vm->i915->drm.struct_mutex); -if (flags &PIN_HIGH ) { - search_flag =DRM_MM_SEARCH_BELOW ; - alloc_flag =DRM_MM_CREATE_TOP ; - }else { - search_flag =DRM_MM_SEARCH_DEFAULT ; - alloc_flag =DRM_MM_CREATE_DEFAULT ; - } + mode =DRM_MM_INSERT_BEST ; +if (flags &PIN_HIGH ) + mode =DRM_MM_INSERT_HIGH ; +if (flags &PIN_MAPPABLE ) + mode =DRM_MM_INSERT_LOW ;/* We only allocate in PAGE_SIZE/GTT_PAGE_SIZE (4096) chunks, * so we know that we always have a minimum alignment of 4096.
@@ -3577,10 +3573,9 @@ int i915_gem_gtt_insert(struct i915_address_space *vm,if (alignment <=4096 ) alignment =0 ; - err =drm_mm_insert_node_in_range_generic (&vm->mm, node, - size, alignment, colour, - start, end, - search_flag, alloc_flag); + err =drm_mm_insert_node_in_range (&vm->mm, node, + size, alignment, colour, + start, end, mode);if (err != -ENOSPC )return err;
@@ -3589,9 +3584,7 @@ int i915_gem_gtt_insert(struct i915_address_space *vm,if (err)return err; - search_flag =DRM_MM_SEARCH_DEFAULT ; -return drm_mm_insert_node_in_range_generic (&vm->mm, node, - size, alignment, colour, - start, end, - search_flag, alloc_flag); +return drm_mm_insert_node_in_range (&vm->mm, node, + size, alignment, colour, + start, end,DRM_MM_INSERT_EVICT ); }
drivers/gpu/drm/i915/i915_gem_stolen.c +3 -3
@@ -62,9 +62,9 @@ int i915_gem_stolen_insert_node_in_range(struct drm_i915_private *dev_priv, start =4096 ;mutex_lock (&dev_priv->mm.stolen_lock); - ret =drm_mm_insert_node_in_range (&dev_priv->mm.stolen, node, size, - alignment, start, end, -DRM_MM_SEARCH_DEFAULT ); + ret =drm_mm_insert_node_in_range (&dev_priv->mm.stolen, node, + size, alignment,0 , + start, end,DRM_MM_INSERT_BEST );mutex_unlock (&dev_priv->mm.stolen_lock);return ret;
drivers/gpu/drm/msm/msm_gem.c +1 -2
@@ -54,8 +54,7 @@ static struct page **get_pages_vram(struct drm_gem_object *obj,if (!p)return ERR_PTR (-ENOMEM ); - ret =drm_mm_insert_node (&priv->vram.mm, msm_obj->vram_node, - npages,0 ,DRM_MM_SEARCH_DEFAULT ); + ret =drm_mm_insert_node (&priv->vram.mm, msm_obj->vram_node, npages);if (ret) {drm_free_large (p);return ERR_PTR (ret);
drivers/gpu/drm/msm/msm_gem_vma.c +1 -2
@@ -45,8 +45,7 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace,if (WARN_ON (drm_mm_node_allocated (&vma->node)))return 0 ; - ret =drm_mm_insert_node (&aspace->mm, &vma->node, npages, -0 ,DRM_MM_SEARCH_DEFAULT ); + ret =drm_mm_insert_node (&aspace->mm, &vma->node, npages);if (ret)return ret;
drivers/gpu/drm/selftests/test-drm_mm.c +38 -59
232 lines not on this page · raw message
drivers/gpu/drm/sis/sis_mm.c +2 -4
@@ -109,8 +109,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,if (pool ==AGP_TYPE ) { retval =drm_mm_insert_node (&dev_priv->agp_mm, &item->mm_node, - mem->size,0 , -DRM_MM_SEARCH_DEFAULT ); + mem->size); offset = item->mm_node.start; }else {#if defined(CONFIG_FB_SIS ) || defined(CONFIG_FB_SIS_MODULE )
@@ -122,8 +121,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,#else retval =drm_mm_insert_node (&dev_priv->vram_mm, &item->mm_node, - mem->size,0 , -DRM_MM_SEARCH_DEFAULT ); + mem->size); offset = item->mm_node.start;#endif }
drivers/gpu/drm/tegra/gem.c +2 -2
@@ -128,8 +128,8 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)if (!bo->mm)return -ENOMEM ; - err =drm_mm_insert_node_generic (&tegra->mm, bo->mm, bo->gem.size, -PAGE_SIZE ,0 ,0 ,0 ); + err =drm_mm_insert_node_generic (&tegra->mm, + bo->mm, bo->gem.size,PAGE_SIZE ,0 ,0 );if (err <0 ) {dev_err (tegra->drm->dev,"out of I/O virtual memory: %zd\n" , err);
drivers/gpu/drm/ttm/ttm_bo_manager.c +8 -10
@@ -54,9 +54,8 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man, {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;struct drm_mm *mm = &rman->mm; -struct drm_mm_node *node =NULL ; -enum drm_mm_search_flags sflags =DRM_MM_SEARCH_BEST ; -enum drm_mm_allocator_flags aflags =DRM_MM_CREATE_DEFAULT ; +struct drm_mm_node *node; +enum drm_mm_insert_mode mode;unsigned long lpfn;int ret;
@@ -68,16 +67,15 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,if (!node)return -ENOMEM ; -if (place->flags &TTM_PL_FLAG_TOPDOWN ) { - sflags =DRM_MM_SEARCH_BELOW ; - aflags =DRM_MM_CREATE_TOP ; - } + mode =DRM_MM_INSERT_BEST ; +if (place->flags &TTM_PL_FLAG_TOPDOWN ) + mode =DRM_MM_INSERT_HIGH ;spin_lock (&rman->lock); - ret =drm_mm_insert_node_in_range_generic (mm, node, mem->num_pages, + ret =drm_mm_insert_node_in_range (mm, node, + mem->num_pages, mem->page_alignment,0 , - place->fpfn, lpfn, - sflags, aflags); + place->fpfn, lpfn, mode);spin_unlock (&rman->lock);if (unlikely (ret)) {
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
@@ -589,7 +589,7 @@ static int vc4_crtc_atomic_check(struct drm_crtc *crtc,spin_lock_irqsave (&vc4->hvs->mm_lock, flags); ret =drm_mm_insert_node (&vc4->hvs->dlist_mm, &vc4_state->mm, - dlist_count,1 ,0 ); + dlist_count);spin_unlock_irqrestore (&vc4->hvs->mm_lock, flags);if (ret)return ret;
drivers/gpu/drm/vc4/vc4_hvs.c +1 -2
@@ -141,8 +141,7 @@ static int vc4_hvs_upload_linear_kernel(struct vc4_hvs *hvs,int ret, i;u32 __iomem *dst_kernel; - ret =drm_mm_insert_node (&hvs->dlist_mm, space,VC4_KERNEL_DWORDS ,1 , -0 ); + ret =drm_mm_insert_node (&hvs->dlist_mm, space,VC4_KERNEL_DWORDS );if (ret) {DRM_ERROR ("Failed to allocate space for filter kernel: %d\n" , ret);
drivers/gpu/drm/vc4/vc4_plane.c +3 -3
@@ -514,9 +514,9 @@ static int vc4_plane_mode_set(struct drm_plane *plane,if (lbm_size) {if (!vc4_state->lbm.allocated) {spin_lock_irqsave (&vc4->hvs->mm_lock, irqflags); - ret =drm_mm_insert_node (&vc4->hvs->lbm_mm, - &vc4_state->lbm, - lbm_size,32 ,0 ); + ret =drm_mm_insert_node_generic (&vc4->hvs->lbm_mm, + &vc4_state->lbm, + lbm_size,32 ,0 ,0 );spin_unlock_irqrestore (&vc4->hvs->mm_lock, irqflags); }else {WARN_ON_ONCE (lbm_size != vc4_state->lbm.size);
drivers/gpu/drm/via/via_mm.c +2 -2
@@ -140,11 +140,11 @@ int via_mem_alloc(struct drm_device *dev, void *data,if (mem->type ==VIA_MEM_AGP ) retval =drm_mm_insert_node (&dev_priv->agp_mm, &item->mm_node, - tmpSize,0 ,DRM_MM_SEARCH_DEFAULT ); + tmpSize);else retval =drm_mm_insert_node (&dev_priv->vram_mm, &item->mm_node, - tmpSize,0 ,DRM_MM_SEARCH_DEFAULT ); + tmpSize);if (retval) goto fail_alloc;
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +2 -8
@@ -673,16 +673,10 @@ static bool vmw_cmdbuf_try_alloc(struct vmw_cmdbuf_man *man,memset (info->node,0 ,sizeof (*info->node));spin_lock_bh (&man->lock); - ret =drm_mm_insert_node_generic (&man->mm, info->node, info->page_size, -0 ,0 , -DRM_MM_SEARCH_DEFAULT , -DRM_MM_CREATE_DEFAULT ); + ret =drm_mm_insert_node (&man->mm, info->node, info->page_size);if (ret) {vmw_cmdbuf_man_process (man); - ret =drm_mm_insert_node_generic (&man->mm, info->node, - info->page_size,0 ,0 , -DRM_MM_SEARCH_DEFAULT , -DRM_MM_CREATE_DEFAULT ); + ret =drm_mm_insert_node (&man->mm, info->node, info->page_size); }spin_unlock_bh (&man->lock);
include/drm/drm_mm.h +42 -93
233 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 39/40] drm: Improve drm_mm search (and fix topdown allocation) with rbtrees
Quoted 13 lines · Chris Wilson
The
drm_mmrange manager claimed to support top-down insertion, but it was neither searching for the top-most hole that could fit the allocation request nor fitting the request to the hole correctly.In order to search the range efficiently, we create a secondary index for the holes using either their size or their address. This index allows us to find the smallest hole or the hole at the bottom or top of the range efficiently, whilst keeping the hole stack to rapidly service evictions.
v2: Search for holes both high and low. Rename flags to mode.
Signed-off-by Chris Wilson <[email protected]>
<SNIP>
drivers/gpu/drm/drm_mm.c int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node) · line 347
Quoted 8 lines
drivers/gpu/drm/drm_mm.c +8
-0+static struct drm_mm_node *best_hole (struct drm_mm *mm,u64 size) +{ +struct rb_node *best =NULL ; +struct rb_node **link = &mm->holes_size.rb_node; +while (*link) { +struct rb_node *rb = *link; +if (size <=rb_hole_size (rb)) + link = &rb->rb_left, best = rb;
Missed this split.
With that addressed, this is;
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 39/40] drm: Improve drm_mm search (and fix topdown allocation) with rbtrees
Quoted 17 lines · Joonas Lahtinen
Quoted 13 lines · Chris Wilson
The
drm_mmrange manager claimed to support top-down insertion, but it was neither searching for the top-most hole that could fit the allocation request nor fitting the request to the hole correctly.In order to search the range efficiently, we create a secondary index for the holes using either their size or their address. This index allows us to find the smallest hole or the hole at the bottom or top of the range efficiently, whilst keeping the hole stack to rapidly service evictions.
v2: Search for holes both high and low. Rename flags to mode.
Signed-off-by Chris Wilson <[email protected]><SNIP>
Quoted 10 lines
drivers/gpu/drm/drm_mm.c int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node) · line 347
Quoted 8 lines
drivers/gpu/drm/drm_mm.c +8
-0+static struct drm_mm_node *best_hole (struct drm_mm *mm,u64 size) +{ +struct rb_node *best =NULL ; +struct rb_node **link = &mm->holes_size.rb_node; +while (*link) { +struct rb_node *rb = *link; +if (size <=rb_hole_size (rb)) + link = &rb->rb_left, best = rb;Missed this split.
You must own shares in a company selling braces! :-p -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 40/40 drm: kselftest for drm_mm and bottom-up allocation
In reply to Chris WilsonCheck that if we request bottom-up allocation from drm_mm_insert_node() we receive the next available hole from the bottom.
--- drivers/gpu/drm/selftests/drm_mm_selftests.h | 1 + drivers/gpu/drm/selftests/test-drm_mm.c | 102 +++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
drivers/gpu/drm/selftests/drm_mm_selftests.h +1 -0
@@ -17,6 +17,7 @@ selftest(align32, igt_align32) selftest(align64, igt_align64) selftest(evict, igt_evict) selftest(evict_range, igt_evict_range) +selftest(bottomup, igt_bottomup) selftest(topdown, igt_topdown) selftest(color, igt_color)selftest (color_evict, igt_color_evict)
drivers/gpu/drm/selftests/test-drm_mm.c +102 -0
108 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [v2,01/40] drm/i915: Use the MRU stack search after evicting
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [v2,01/40] drm/i915: Use the MRU stack search after evicting
URL : https://patchwork.freedesktop.org/series/16906/
State : success
== Summary ==
Series 16906v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/16906/revisions/1/mbox/
fi-bdw-5557u total:247 pass:233 dwarn:0 dfail:0 fail:0 skip:14 fi-bsw-n3050 total:247 pass:208 dwarn:0 dfail:0 fail:0 skip:39 fi-bxt-j4205 total:247 pass:222 dwarn:0 dfail:0 fail:0 skip:25 fi-byt-j1900 total:247 pass:220 dwarn:0 dfail:0 fail:0 skip:27 fi-byt-n2820 total:247 pass:216 dwarn:0 dfail:0 fail:0 skip:31 fi-hsw-4770 total:247 pass:228 dwarn:0 dfail:0 fail:0 skip:19 fi-hsw-4770r total:247 pass:228 dwarn:0 dfail:0 fail:0 skip:19 fi-ilk-650 total:247 pass:195 dwarn:0 dfail:0 fail:0 skip:52 fi-ivb-3520m total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-ivb-3770 total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-kbl-7500u total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6260u total:247 pass:234 dwarn:0 dfail:0 fail:0 skip:13 fi-skl-6700hq total:247 pass:227 dwarn:0 dfail:0 fail:0 skip:20 fi-skl-6700k total:247 pass:224 dwarn:3 dfail:0 fail:0 skip:20 fi-skl-6770hq total:247 pass:234 dwarn:0 dfail:0 fail:0 skip:13 fi-snb-2520m total:247 pass:216 dwarn:0 dfail:0 fail:0 skip:31 fi-snb-2600 total:247 pass:215 dwarn:0 dfail:0 fail:0 skip:32
428e9f939ad72727abcd02be76fdf41be3672a5b drm-tip: 2016y-12m-16d-08h-25m-46s UTC integration manifest 5bb157c drm: kselftest for drm_mm and bottom-up allocation
4e89e38 drm: Improve drm_mm search (and fix topdown allocation) with rbtrees
25596d7 drm: Use drm_mm_insert_node_in_range_generic() for everyone419b0874 drm: Apply range restriction after color adjustment when allocation
ddaf9d5 drm: Wrap drm_mm_node.hole_follows
d680764 drm: Apply tight eviction scanning to color_adjust
d8a5adf drm: Simplify drm_mm scan-list manipulation
3abacac drm: Optimise power-of-two alignments in drm_mm_scan_add_block()
48ff21d drm: Compute tight evictions for drm_mm_scan
71bad2c drm: Fix application of color vs range restriction when scanning drm_mm 2e4ed5a drm: Unconditionally do the range check in drm_mm_scan_add_block()
64b0df4 drm: Rename prev_node to hole in drm_mm_scan_add_block()
78fe28e drm: Extract struct drm_mm_scan from struct drm_mm
9d2a85a drm: Add asserts to catch overflow in drm_mm_init() and drm_mm_init_scan() 1031757 drm: Simplify drm_mm_clean()
87dd432 drm: Detect overflow in drm_mm_reserve_node()
e797ab0 drm: Fix kerneldoc for drm_mm_scan_remove_block()
0d8045e drm: Promote drm_mm alignment to u64
c93021e drm/i915: Build DRM range manager selftests for CI
20763e9 drm: kselftest for drm_mm and restricted color eviction184bc9575 drm: kselftest for drm_mm and color eviction
cad08ee drm: kselftest for drm_mm and color adjustment
4c17168 drm: kselftest for drm_mm and top-down allocation
c669929 drm: kselftest for drm_mm and range restricted eviction
fed4139 drm: kselftest for drm_mm and eviction
dda6cf3 drm: kselftest for drm_mm and alignment
d735a21 drm: kselftest for drm_mm_insert_node_in_range()
10bbc02 drm: kselftest for drm_mm_replace_node()
04e4898 drm: kselftest for drm_mm_insert_node()
450f1db drm: kselftest for drm_mm_reserve_node()
5ccc47c drm: kselftest for drm_mm_debug()
1d041c9 drm: kselftest for drm_mm_init()
8de9fad drm: Add a simple prime number generator
02bbb5b drm: Add a simple generator of random permutations
75629c2 drm: Add some kselftests for the DRM range manager (struct drm_mm)
ef10a68 drm: Compile time enabling for asserts in drm_mm
0f89700 drm: Constify the drm_mm API
36f3c26 drm: Add drm_mm_for_each_node_safe()
9f0be0f drm/i915: Simplify i915_gtt_color_adjust()
c1d54ce drm/i915: Use the MRU stack search after evicting
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3306/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for series starting with [v2,01/40] drm/i915: Use the MRU stack search after evicting (rev3)
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [v2,01/40] drm/i915: Use the MRU stack search after evicting (rev3)
URL : https://patchwork.freedesktop.org/series/16906/
State : failure
== Summary ==
CC net/ipv4/tcp_cubic.o CC net/ipv4/xfrm4_policy.o LD drivers/net/phy/built-in.o CC net/ipv4/xfrm4_state.o CC net/ipv4/xfrm4_input.o CC net/ipv4/xfrm4_output.o CC net/ipv4/xfrm4_protocol.o CC net/ipv6/exthdrs_offload.o CC net/ipv6/inet6_hashtables.o CC net/ipv6/mcast_snoop.o LD drivers/rtc/built-in.o LD drivers/pci/pcie/pcieportdrv.o LD [M] drivers/net/ethernet/intel/igbvf/igbvf.o LD drivers/acpi/acpica/acpi.o LD kernel/events/built-in.o LD net/netlink/built-in.o LD net/unix/unix_diag.o LD kernel/sched/built-in.o LD drivers/acpi/acpica/built-in.o LD drivers/pci/pcie/aer/aerdriver.o LD kernel/built-in.o LD drivers/pci/pcie/aer/built-in.o LD drivers/usb/gadget/libcomposite.o LD drivers/usb/storage/usb-storage.o LD drivers/pci/pcie/built-in.o LD drivers/acpi/built-in.o LD drivers/usb/storage/built-in.o LD net/key/built-in.o LD drivers/tty/serial/8250/8250.o LD [M] drivers/usb/serial/usbserial.o LD drivers/thermal/thermal_sys.o LD mm/built-in.o LD drivers/thermal/built-in.o LD [M] drivers/misc/mei/mei-me.o LD lib/raid6/raid6_pq.o LD drivers/misc/built-in.o LD lib/raid6/built-in.o LD drivers/spi/built-in.o LD drivers/iommu/built-in.o LD drivers/usb/gadget/udc/udc-core.o LD drivers/usb/gadget/udc/built-in.o LD drivers/usb/gadget/built-in.o
scripts/Makefile.build:544: recipe for target 'drivers/gpu/drm' failed make[2]: *** [drivers/gpu/drm] Error 2 scripts/Makefile.build:544: recipe for target 'drivers/gpu' failed make[1]: *** [drivers/gpu] Error 2
make[1]: *** Waiting for unfinished jobs....
LD net/packet/built-in.o LD drivers/video/fbdev/core/fb.o LD drivers/video/fbdev/core/built-in.o LD [M] sound/pci/hda/snd-hda-codec-generic.o LD drivers/video/fbdev/built-in.o LD [M] drivers/net/ethernet/intel/e1000/e1000.o LD sound/pci/built-in.o LD net/unix/unix.o LD net/unix/built-in.o LD drivers/scsi/scsi_mod.o LD drivers/video/console/built-in.o LD drivers/video/built-in.o LD sound/built-in.o LD [M] drivers/net/ethernet/broadcom/genet/genet.o LD drivers/tty/serial/8250/8250_base.o LD drivers/tty/serial/8250/built-in.o LD drivers/tty/serial/built-in.o LD drivers/pci/built-in.o LD drivers/scsi/sd_mod.o LD drivers/scsi/built-in.o LD [M] drivers/net/ethernet/intel/igb/igb.o LD drivers/md/md-mod.o AR lib/lib.a LD drivers/md/built-in.o EXPORTS lib/lib-ksyms.o CC arch/x86/kernel/cpu/capflags.o LD arch/x86/kernel/cpu/built-in.o LD drivers/usb/core/usbcore.o LD arch/x86/kernel/built-in.o LD drivers/usb/core/built-in.o LD drivers/usb/host/xhci-hcd.o LD arch/x86/built-in.o LD drivers/tty/vt/built-in.o LD net/xfrm/built-in.o LD drivers/tty/built-in.o LD net/ipv6/ipv6.o LD fs/btrfs/btrfs.o LD net/ipv6/built-in.o LD lib/built-in.o LD fs/btrfs/built-in.o LD fs/ext4/ext4.o LD fs/ext4/built-in.o LD drivers/usb/host/built-in.o LD drivers/usb/built-in.o LD fs/built-in.o LD net/ipv4/built-in.o LD [M] drivers/net/ethernet/intel/e1000e/e1000e.o LD net/core/built-in.o LD net/built-in.o LD drivers/net/ethernet/built-in.o LD drivers/net/built-in.o
Makefile:988: recipe for target 'drivers' failed
make: *** [drivers] Error 2
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx