mirror of https://gitee.com/openkylin/linux.git
drm: Compile time enabling for asserts in drm_mm
Use 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). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-4-chris@chris-wilson.co.uk Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-4-chris@chris-wilson.co.uk
This commit is contained in:
parent
2bc98c8651
commit
b3ee963fe4
|
@ -237,7 +237,7 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,
|
||||||
u64 adj_start = hole_start;
|
u64 adj_start = hole_start;
|
||||||
u64 adj_end = hole_end;
|
u64 adj_end = hole_end;
|
||||||
|
|
||||||
BUG_ON(node->allocated);
|
DRM_MM_BUG_ON(node->allocated);
|
||||||
|
|
||||||
if (mm->color_adjust)
|
if (mm->color_adjust)
|
||||||
mm->color_adjust(hole_node, color, &adj_start, &adj_end);
|
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);
|
DRM_MM_BUG_ON(adj_start < hole_start);
|
||||||
BUG_ON(adj_end > hole_end);
|
DRM_MM_BUG_ON(adj_end > hole_end);
|
||||||
|
|
||||||
if (adj_start == hole_start) {
|
if (adj_start == hole_start) {
|
||||||
hole_node->hole_follows = 0;
|
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);
|
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;
|
node->hole_follows = 0;
|
||||||
if (__drm_mm_hole_node_start(node) < hole_end) {
|
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_start = hole_start;
|
||||||
u64 adj_end = hole_end;
|
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)
|
if (adj_start < start)
|
||||||
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);
|
drm_mm_interval_tree_add_node(hole_node, node);
|
||||||
|
|
||||||
BUG_ON(node->start < start);
|
DRM_MM_BUG_ON(node->start < start);
|
||||||
BUG_ON(node->start < adj_start);
|
DRM_MM_BUG_ON(node->start < adj_start);
|
||||||
BUG_ON(node->start + node->size > adj_end);
|
DRM_MM_BUG_ON(node->start + node->size > adj_end);
|
||||||
BUG_ON(node->start + node->size > end);
|
DRM_MM_BUG_ON(node->start + node->size > end);
|
||||||
|
|
||||||
node->hole_follows = 0;
|
node->hole_follows = 0;
|
||||||
if (__drm_mm_hole_node_start(node) < hole_end) {
|
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 *mm = node->mm;
|
||||||
struct drm_mm_node *prev_node;
|
struct drm_mm_node *prev_node;
|
||||||
|
|
||||||
if (WARN_ON(!node->allocated))
|
DRM_MM_BUG_ON(!node->allocated);
|
||||||
return;
|
DRM_MM_BUG_ON(node->scanned_block ||
|
||||||
|
node->scanned_prev_free ||
|
||||||
BUG_ON(node->scanned_block || node->scanned_prev_free
|
node->scanned_next_free);
|
||||||
|| node->scanned_next_free);
|
|
||||||
|
|
||||||
prev_node =
|
prev_node =
|
||||||
list_entry(node->node_list.prev, struct drm_mm_node, node_list);
|
list_entry(node->node_list.prev, struct drm_mm_node, node_list);
|
||||||
|
|
||||||
if (node->hole_follows) {
|
if (node->hole_follows) {
|
||||||
BUG_ON(__drm_mm_hole_node_start(node) ==
|
DRM_MM_BUG_ON(__drm_mm_hole_node_start(node) ==
|
||||||
__drm_mm_hole_node_end(node));
|
__drm_mm_hole_node_end(node));
|
||||||
list_del(&node->hole_stack);
|
list_del(&node->hole_stack);
|
||||||
} else
|
} else
|
||||||
BUG_ON(__drm_mm_hole_node_start(node) !=
|
DRM_MM_BUG_ON(__drm_mm_hole_node_start(node) !=
|
||||||
__drm_mm_hole_node_end(node));
|
__drm_mm_hole_node_end(node));
|
||||||
|
|
||||||
|
|
||||||
if (!prev_node->hole_follows) {
|
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 adj_end;
|
||||||
u64 best_size;
|
u64 best_size;
|
||||||
|
|
||||||
BUG_ON(mm->scanned_blocks);
|
DRM_MM_BUG_ON(mm->scanned_blocks);
|
||||||
|
|
||||||
best = NULL;
|
best = NULL;
|
||||||
best_size = ~0UL;
|
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 adj_end;
|
||||||
u64 best_size;
|
u64 best_size;
|
||||||
|
|
||||||
BUG_ON(mm->scanned_blocks);
|
DRM_MM_BUG_ON(mm->scanned_blocks);
|
||||||
|
|
||||||
best = NULL;
|
best = NULL;
|
||||||
best_size = ~0UL;
|
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)
|
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->node_list, &new->node_list);
|
||||||
list_replace(&old->hole_stack, &new->hole_stack);
|
list_replace(&old->hole_stack, &new->hole_stack);
|
||||||
rb_replace_node(&old->rb, &new->rb, &old->mm->interval_tree);
|
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++;
|
mm->scanned_blocks++;
|
||||||
|
|
||||||
BUG_ON(node->scanned_block);
|
DRM_MM_BUG_ON(node->scanned_block);
|
||||||
node->scanned_block = 1;
|
node->scanned_block = 1;
|
||||||
|
|
||||||
prev_node = list_entry(node->node_list.prev, struct drm_mm_node,
|
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--;
|
mm->scanned_blocks--;
|
||||||
|
|
||||||
BUG_ON(!node->scanned_block);
|
DRM_MM_BUG_ON(!node->scanned_block);
|
||||||
node->scanned_block = 0;
|
node->scanned_block = 0;
|
||||||
|
|
||||||
prev_node = list_entry(node->node_list.prev, struct drm_mm_node,
|
prev_node = list_entry(node->node_list.prev, struct drm_mm_node,
|
||||||
|
|
|
@ -48,6 +48,12 @@
|
||||||
#include <linux/stackdepot.h>
|
#include <linux/stackdepot.h>
|
||||||
#endif
|
#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 {
|
enum drm_mm_search_flags {
|
||||||
DRM_MM_SEARCH_DEFAULT = 0,
|
DRM_MM_SEARCH_DEFAULT = 0,
|
||||||
DRM_MM_SEARCH_BEST = 1 << 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)
|
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);
|
return __drm_mm_hole_node_start(hole_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue