mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 05:48:40 +00:00
drm: Use drm_mm_nodes() as shorthand for the list of nodes under struct drm_mm
Fairly commonly we want to inspect the node list on the struct drm_mm,
which is buried within an embedded node. Bring it to the surface with a
bit of syntatic sugar.
Note this was intended to be split from commit ad579002c8
("drm: Add
drm_mm_for_each_node_safe()") before being applied, but my timing sucks.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-3-chris@chris-wilson.co.uk
This commit is contained in:
parent
0bfd4a01a6
commit
2bc98c8651
2 changed files with 19 additions and 7 deletions
|
@ -138,7 +138,7 @@ static void show_leaks(struct drm_mm *mm)
|
|||
if (!buf)
|
||||
return;
|
||||
|
||||
list_for_each_entry(node, __drm_mm_nodes(mm), node_list) {
|
||||
list_for_each_entry(node, drm_mm_nodes(mm), node_list) {
|
||||
struct stack_trace trace = {
|
||||
.entries = entries,
|
||||
.max_entries = STACKDEPTH
|
||||
|
@ -320,7 +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(__drm_mm_nodes(mm), 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);
|
||||
|
@ -883,7 +883,7 @@ EXPORT_SYMBOL(drm_mm_scan_remove_block);
|
|||
*/
|
||||
bool drm_mm_clean(const struct drm_mm *mm)
|
||||
{
|
||||
const struct list_head *head = __drm_mm_nodes(mm);
|
||||
const struct list_head *head = drm_mm_nodes(mm);
|
||||
|
||||
return (head->next->next == head);
|
||||
}
|
||||
|
@ -929,7 +929,7 @@ EXPORT_SYMBOL(drm_mm_init);
|
|||
*/
|
||||
void drm_mm_takedown(struct drm_mm *mm)
|
||||
{
|
||||
if (WARN(!list_empty(__drm_mm_nodes(mm)),
|
||||
if (WARN(!list_empty(drm_mm_nodes(mm)),
|
||||
"Memory manager not clean during takedown.\n"))
|
||||
show_leaks(mm);
|
||||
|
||||
|
|
|
@ -180,7 +180,19 @@ static inline u64 drm_mm_hole_node_end(const 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_nodes - list of nodes under the drm_mm range manager
|
||||
* @mm: the struct drm_mm range manger
|
||||
*
|
||||
* As the drm_mm range manager hides its node_list deep with its
|
||||
* structure, extracting it looks painful and repetitive. This is
|
||||
* not expected to be used outside of the drm_mm_for_each_node()
|
||||
* macros and similar internal functions.
|
||||
*
|
||||
* Returns:
|
||||
* The node list, may be empty.
|
||||
*/
|
||||
#define drm_mm_nodes(mm) (&(mm)->head_node.node_list)
|
||||
|
||||
/**
|
||||
* drm_mm_for_each_node - iterator to walk over all allocated nodes
|
||||
|
@ -191,7 +203,7 @@ static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
|
|||
* with list_for_each, so not save against removal of elements.
|
||||
*/
|
||||
#define drm_mm_for_each_node(entry, mm) \
|
||||
list_for_each_entry(entry, __drm_mm_nodes(mm), node_list)
|
||||
list_for_each_entry(entry, drm_mm_nodes(mm), node_list)
|
||||
|
||||
/**
|
||||
* drm_mm_for_each_node_safe - iterator to walk over all allocated nodes
|
||||
|
@ -203,7 +215,7 @@ static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
|
|||
* 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)
|
||||
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); \
|
||||
|
|
Loading…
Reference in a new issue