diff mbox

[2/6] drm: mm: add drm_mm_node_linked() helper

Message ID 1372703583-9550-3-git-send-email-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Herrmann July 1, 2013, 6:32 p.m. UTC
This helper tests whether a given node is currently linked into a drm_mm
manager. We use the node->mm pointer for that as it is set for all linked
objects.

We also reset node->mm whenever a node is removed. All such access is
currently safe as everyone calls kfree() on the object directly after
removing it. Furthermore, no-one is supposed to access node->mm from
outside drm_mm.c, anyway.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_mm.c | 1 +
 include/drm/drm_mm.h     | 5 +++++
 2 files changed, 6 insertions(+)

Comments

Daniel Vetter July 1, 2013, 7:25 p.m. UTC | #1
On Mon, Jul 01, 2013 at 08:32:59PM +0200, David Herrmann wrote:
> This helper tests whether a given node is currently linked into a drm_mm
> manager. We use the node->mm pointer for that as it is set for all linked
> objects.
> 
> We also reset node->mm whenever a node is removed. All such access is
> currently safe as everyone calls kfree() on the object directly after
> removing it. Furthermore, no-one is supposed to access node->mm from
> outside drm_mm.c, anyway.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_mm.c | 1 +
>  include/drm/drm_mm.h     | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index 7917729..3bd43ce 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -374,6 +374,7 @@ void drm_mm_remove_node(struct drm_mm_node *node)
>  
>  	list_del(&node->node_list);
>  	node->allocated = 0;
> +	node->mm = NULL;
>  }
>  EXPORT_SYMBOL(drm_mm_remove_node);
>  
> diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
> index de92425..d83b966 100644
> --- a/include/drm/drm_mm.h
> +++ b/include/drm/drm_mm.h
> @@ -85,6 +85,11 @@ static inline bool drm_mm_node_allocated(struct drm_mm_node *node)
>  	return node->allocated;
>  }
>  
> +static inline bool drm_mm_node_linked(struct drm_mm_node *node)
> +{
> +	return node->mm;
> +}

I've only checked a few examples, but this seems to duplicate what the
drm_mm_node_allocated right above was meant for. Or do I miss something
here?
-Daniel

> +
>  static inline bool drm_mm_initialized(struct drm_mm *mm)
>  {
>  	return mm->hole_stack.next;
> -- 
> 1.8.3.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 7917729..3bd43ce 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -374,6 +374,7 @@  void drm_mm_remove_node(struct drm_mm_node *node)
 
 	list_del(&node->node_list);
 	node->allocated = 0;
+	node->mm = NULL;
 }
 EXPORT_SYMBOL(drm_mm_remove_node);
 
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index de92425..d83b966 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -85,6 +85,11 @@  static inline bool drm_mm_node_allocated(struct drm_mm_node *node)
 	return node->allocated;
 }
 
+static inline bool drm_mm_node_linked(struct drm_mm_node *node)
+{
+	return node->mm;
+}
+
 static inline bool drm_mm_initialized(struct drm_mm *mm)
 {
 	return mm->hole_stack.next;