diff mbox

[2/2] drm/i915: Add a test that we terminate the trimmed sgtable as expected

Message ID 20161219124346.550-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Dec. 19, 2016, 12:43 p.m. UTC
In commit 0c40ce130e38 ("drm/i915: Trim the object sg table"), we expect
to copy exactly orig_st->nents across and allocate the table thusly.
The copy loop should therefore end with the new_sg being NULL.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Daniel Vetter Dec. 20, 2016, 11:07 a.m. UTC | #1
On Mon, Dec 19, 2016 at 12:43:46PM +0000, Chris Wilson wrote:
> In commit 0c40ce130e38 ("drm/i915: Trim the object sg table"), we expect
> to copy exactly orig_st->nents across and allocate the table thusly.
> The copy loop should therefore end with the new_sg being NULL.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 4e263df2afc3..0a82cce5f731 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2316,6 +2316,7 @@ static void i915_sg_trim(struct sg_table *orig_st)
>  		/* called before being DMA mapped, no need to copy sg->dma_* */
>  		new_sg = sg_next(new_sg);
>  	}
> +	GEM_BUG_ON(new_sg); /* Should walk exactly nents and hit the end */

I wasn't sure this holds up vs. overallocation of sg tables, but the last
entry is marked and that mark seems to survive intact everywhere.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  
>  	sg_free_table(orig_st);
>  
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tvrtko Ursulin Dec. 20, 2016, 11:17 a.m. UTC | #2
On 19/12/2016 12:43, Chris Wilson wrote:
> In commit 0c40ce130e38 ("drm/i915: Trim the object sg table"), we expect
> to copy exactly orig_st->nents across and allocate the table thusly.
> The copy loop should therefore end with the new_sg being NULL.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 4e263df2afc3..0a82cce5f731 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2316,6 +2316,7 @@ static void i915_sg_trim(struct sg_table *orig_st)
>  		/* called before being DMA mapped, no need to copy sg->dma_* */
>  		new_sg = sg_next(new_sg);
>  	}
> +	GEM_BUG_ON(new_sg); /* Should walk exactly nents and hit the end */
>
>  	sg_free_table(orig_st);
>

I was sure I had this in the code back then, hm.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4e263df2afc3..0a82cce5f731 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2316,6 +2316,7 @@  static void i915_sg_trim(struct sg_table *orig_st)
 		/* called before being DMA mapped, no need to copy sg->dma_* */
 		new_sg = sg_next(new_sg);
 	}
+	GEM_BUG_ON(new_sg); /* Should walk exactly nents and hit the end */
 
 	sg_free_table(orig_st);