public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: Declare that create drm_mm nodes with size 0 is illegal
Date: Thu, 4 Aug 2016 10:14:26 +0200	[thread overview]
Message-ID: <20160804081426.GS6232@phenom.ffwll.local> (raw)
In-Reply-To: <1470248788-30873-1-git-send-email-chris@chris-wilson.co.uk>

On Wed, Aug 03, 2016 at 07:26:28PM +0100, Chris Wilson wrote:
> At a higher level, all objects are created with definite size i.e. 0 is
> illegal. In forthcoming patches, this assumption is dependent upon in
> the drm_mm range manager, i.e. trying to create a drm_mm node with size
> 0 will have undefined behaviour. Add a couple of WARNs upon creating the
> drm_mm node to prevent later bugs.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Queued all up for -misc, will push out once -rc1 hits.
-Daniel

> ---
>  drivers/gpu/drm/drm_mm.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index cb39f45d6a16..e8c15795386d 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -185,6 +185,9 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)
>  
>  	BUG_ON(node == NULL);
>  
> +	if (WARN_ON(node->size == 0))
> +		return -EINVAL;
> +
>  	end = node->start + node->size;
>  
>  	/* Find the relevant hole to add our node to */
> @@ -239,6 +242,9 @@ int drm_mm_insert_node_generic(struct drm_mm *mm, struct drm_mm_node *node,
>  {
>  	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)
> @@ -340,6 +346,9 @@ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *n
>  {
>  	struct drm_mm_node *hole_node;
>  
> +	if (WARN_ON(size == 0))
> +		return -EINVAL;
> +
>  	hole_node = drm_mm_search_free_in_range_generic(mm,
>  							size, alignment, color,
>  							start, end, sflags);
> -- 
> 2.8.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-08-04  8:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03 15:04 [PATCH 1/3] drm: Track drm_mm nodes with an interval tree Chris Wilson
2016-08-03 15:04 ` [PATCH 2/3] drm: Convert drm_vma_manager to embedded interval-tree in drm_mm Chris Wilson
2016-08-03 17:45   ` David Herrmann
2016-08-03 15:04 ` [PATCH 3/3] drm: Skip initialising the drm_mm_node->hole_stack Chris Wilson
2016-08-03 17:49   ` David Herrmann
2016-08-03 15:29 ` ✗ Ro.CI.BAT: failure for series starting with [1/3] drm: Track drm_mm nodes with an interval tree Patchwork
2016-08-03 17:55 ` [PATCH 1/3] " David Herrmann
2016-08-03 18:26   ` [PATCH] drm: Declare that create drm_mm nodes with size 0 is illegal Chris Wilson
2016-08-04  8:13     ` David Herrmann
2016-08-04  8:14     ` Daniel Vetter [this message]
2016-08-03 20:33 ` ✗ Fi.CI.BAT: failure for series starting with drm: Declare that create drm_mm nodes with size 0 is illegal (rev2) Patchwork
2016-08-04  5:20 ` ✗ Ro.CI.BAT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160804081426.GS6232@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox