diff mbox series

drm/i915/blt: fixup block_size rounding

Message ID 20191028163950.9429-1-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/blt: fixup block_size rounding | expand

Commit Message

Matthew Auld Oct. 28, 2019, 4:39 p.m. UTC
There is nothing to say that the obj->base.size is actually a multiple
of the block_size.

Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gem/i915_gem_object_blt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ville Syrjala Oct. 28, 2019, 4:46 p.m. UTC | #1
On Mon, Oct 28, 2019 at 04:39:50PM +0000, Matthew Auld wrote:
> There is nothing to say that the obj->base.size is actually a multiple
> of the block_size.
> 
> Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_object_blt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
> index 516e61e99212..5597f1345a63 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
> @@ -30,7 +30,7 @@ struct i915_vma *intel_emit_vma_fill_blt(struct intel_context *ce,
>  	GEM_BUG_ON(intel_engine_is_virtual(ce->engine));
>  	intel_engine_pm_get(ce->engine);
>  
> -	count = div_u64(vma->size, block_size);
> +	count = DIV64_U64_ROUND_UP(vma->size, block_size);

block_size size look to be u32?

>  	size = (1 + 8 * count) * sizeof(u32);
>  	size = round_up(size, PAGE_SIZE);
>  	pool = intel_engine_get_pool(ce->engine, size);
> @@ -214,7 +214,7 @@ struct i915_vma *intel_emit_vma_copy_blt(struct intel_context *ce,
>  	GEM_BUG_ON(intel_engine_is_virtual(ce->engine));
>  	intel_engine_pm_get(ce->engine);
>  
> -	count = div_u64(dst->size, block_size);
> +	count = DIV64_U64_ROUND_UP(dst->size, block_size);
>  	size = (1 + 11 * count) * sizeof(u32);
>  	size = round_up(size, PAGE_SIZE);
>  	pool = intel_engine_get_pool(ce->engine, size);
> -- 
> 2.20.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson Oct. 28, 2019, 5:33 p.m. UTC | #2
Quoting Ville Syrjälä (2019-10-28 16:46:46)
> On Mon, Oct 28, 2019 at 04:39:50PM +0000, Matthew Auld wrote:
> > There is nothing to say that the obj->base.size is actually a multiple
> > of the block_size.
> > 
> > Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/i915/gem/i915_gem_object_blt.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
> > index 516e61e99212..5597f1345a63 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
> > @@ -30,7 +30,7 @@ struct i915_vma *intel_emit_vma_fill_blt(struct intel_context *ce,
> >       GEM_BUG_ON(intel_engine_is_virtual(ce->engine));
> >       intel_engine_pm_get(ce->engine);
> >  
> > -     count = div_u64(vma->size, block_size);
> > +     count = DIV64_U64_ROUND_UP(vma->size, block_size);
> 
> block_size size look to be u32?

And we can control it to be a pot.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
index 516e61e99212..5597f1345a63 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c
@@ -30,7 +30,7 @@  struct i915_vma *intel_emit_vma_fill_blt(struct intel_context *ce,
 	GEM_BUG_ON(intel_engine_is_virtual(ce->engine));
 	intel_engine_pm_get(ce->engine);
 
-	count = div_u64(vma->size, block_size);
+	count = DIV64_U64_ROUND_UP(vma->size, block_size);
 	size = (1 + 8 * count) * sizeof(u32);
 	size = round_up(size, PAGE_SIZE);
 	pool = intel_engine_get_pool(ce->engine, size);
@@ -214,7 +214,7 @@  struct i915_vma *intel_emit_vma_copy_blt(struct intel_context *ce,
 	GEM_BUG_ON(intel_engine_is_virtual(ce->engine));
 	intel_engine_pm_get(ce->engine);
 
-	count = div_u64(dst->size, block_size);
+	count = DIV64_U64_ROUND_UP(dst->size, block_size);
 	size = (1 + 11 * count) * sizeof(u32);
 	size = round_up(size, PAGE_SIZE);
 	pool = intel_engine_get_pool(ce->engine, size);