diff mbox

aubdump: Don't bail if a GEM handle of 0 is passed into execbuf

Message ID 1490399101-6549-1-git-send-email-jason.ekstrand@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jason Ekstrand March 24, 2017, 11:45 p.m. UTC
A gem handle of 0 can be used to check for whether or not 48-bit
addressing is available.  This keeps aubdump from failing on you if
you try to do the check.
---
 tools/aubdump.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Rafael Antognolli April 14, 2017, 6:34 p.m. UTC | #1
Patch is
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>

On Fri, Mar 24, 2017 at 04:45:01PM -0700, Jason Ekstrand wrote:
> A gem handle of 0 can be used to check for whether or not 48-bit
> addressing is available.  This keeps aubdump from failing on you if
> you try to do the check.
> ---
>  tools/aubdump.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/aubdump.c b/tools/aubdump.c
> index 8a89b8c..3aca7eb 100644
> --- a/tools/aubdump.c
> +++ b/tools/aubdump.c
> @@ -131,7 +131,6 @@ get_bo(uint32_t handle)
>  
>  	fail_if(handle >= MAX_BO_COUNT, "bo handle too large\n");
>  	bo = &bos[handle];
> -	fail_if(bo->size == 0, "invalid bo handle (%d) in execbuf\n", handle);
>  
>  	return bo;
>  }
> @@ -442,7 +441,7 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
>  			offset = align_u32(offset + bo->size + 4095, 4096);
>  		}
>  
> -		if (bo->map == NULL)
> +		if (bo->map == NULL && bo->size > 0)
>  			bo->map = gem_mmap(fd, obj->handle, 0, bo->size);
>  		fail_if(bo->map == MAP_FAILED, "intel_aubdump: bo mmap failed\n");
>  	}
> @@ -583,7 +582,7 @@ maybe_init(void)
>  	}
>  	fclose(config);
>  
> -	bos = malloc(MAX_BO_COUNT * sizeof(bos[0]));
> +	bos = calloc(MAX_BO_COUNT, sizeof(bos[0]));
>  	fail_if(bos == NULL, "intel_aubdump: out of memory\n");
>  }
>  
> -- 
> 2.5.0.400.gff86faf
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jason Ekstrand April 14, 2017, 7:35 p.m. UTC | #2
On Fri, Apr 14, 2017 at 11:34 AM, Rafael Antognolli <
rafael.antognolli@intel.com> wrote:

> Patch is
> Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
>

Thanks!  Pushed.


> On Fri, Mar 24, 2017 at 04:45:01PM -0700, Jason Ekstrand wrote:
> > A gem handle of 0 can be used to check for whether or not 48-bit
> > addressing is available.  This keeps aubdump from failing on you if
> > you try to do the check.
> > ---
> >  tools/aubdump.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/aubdump.c b/tools/aubdump.c
> > index 8a89b8c..3aca7eb 100644
> > --- a/tools/aubdump.c
> > +++ b/tools/aubdump.c
> > @@ -131,7 +131,6 @@ get_bo(uint32_t handle)
> >
> >       fail_if(handle >= MAX_BO_COUNT, "bo handle too large\n");
> >       bo = &bos[handle];
> > -     fail_if(bo->size == 0, "invalid bo handle (%d) in execbuf\n",
> handle);
> >
> >       return bo;
> >  }
> > @@ -442,7 +441,7 @@ dump_execbuffer2(int fd, struct
> drm_i915_gem_execbuffer2 *execbuffer2)
> >                       offset = align_u32(offset + bo->size + 4095, 4096);
> >               }
> >
> > -             if (bo->map == NULL)
> > +             if (bo->map == NULL && bo->size > 0)
> >                       bo->map = gem_mmap(fd, obj->handle, 0, bo->size);
> >               fail_if(bo->map == MAP_FAILED, "intel_aubdump: bo mmap
> failed\n");
> >       }
> > @@ -583,7 +582,7 @@ maybe_init(void)
> >       }
> >       fclose(config);
> >
> > -     bos = malloc(MAX_BO_COUNT * sizeof(bos[0]));
> > +     bos = calloc(MAX_BO_COUNT, sizeof(bos[0]));
> >       fail_if(bos == NULL, "intel_aubdump: out of memory\n");
> >  }
> >
> > --
> > 2.5.0.400.gff86faf
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
diff mbox

Patch

diff --git a/tools/aubdump.c b/tools/aubdump.c
index 8a89b8c..3aca7eb 100644
--- a/tools/aubdump.c
+++ b/tools/aubdump.c
@@ -131,7 +131,6 @@  get_bo(uint32_t handle)
 
 	fail_if(handle >= MAX_BO_COUNT, "bo handle too large\n");
 	bo = &bos[handle];
-	fail_if(bo->size == 0, "invalid bo handle (%d) in execbuf\n", handle);
 
 	return bo;
 }
@@ -442,7 +441,7 @@  dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
 			offset = align_u32(offset + bo->size + 4095, 4096);
 		}
 
-		if (bo->map == NULL)
+		if (bo->map == NULL && bo->size > 0)
 			bo->map = gem_mmap(fd, obj->handle, 0, bo->size);
 		fail_if(bo->map == MAP_FAILED, "intel_aubdump: bo mmap failed\n");
 	}
@@ -583,7 +582,7 @@  maybe_init(void)
 	}
 	fclose(config);
 
-	bos = malloc(MAX_BO_COUNT * sizeof(bos[0]));
+	bos = calloc(MAX_BO_COUNT, sizeof(bos[0]));
 	fail_if(bos == NULL, "intel_aubdump: out of memory\n");
 }