diff mbox

[5/9] drm/i915: Make ring buffer size configurable

Message ID 1463473149-5876-6-git-send-email-zhi.a.wang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang, Zhi A May 17, 2016, 8:19 a.m. UTC
This patch introduces an option for configuring ring buffer size during
context creation. If no ring buffer size is specified, the default size
(4 * PAGE_SIZE) will be used.

Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h  | 1 +
 drivers/gpu/drm/i915/intel_lrc.c | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Chris Wilson May 20, 2016, 12:01 p.m. UTC | #1
On Tue, May 17, 2016 at 04:19:05AM -0400, Zhi Wang wrote:
> This patch introduces an option for configuring ring buffer size during
> context creation. If no ring buffer size is specified, the default size
> (4 * PAGE_SIZE) will be used.
> 
> Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h  | 1 +
>  drivers/gpu/drm/i915/intel_lrc.c | 8 ++++++--
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index ea04352..cc83f2d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -883,6 +883,7 @@ struct intel_context {
>  		uint32_t *lrc_reg_state;
>  		bool initialised;
>  	} engine[I915_NUM_ENGINES];
> +	u32 ring_buffer_size;
>  
>  	struct list_head link;
>  };
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index db10c96..d52c806 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -2495,7 +2495,7 @@ static int execlists_context_deferred_alloc(struct intel_context *ctx,
>  					    struct intel_engine_cs *engine)
>  {
>  	struct drm_i915_gem_object *ctx_obj;
> -	uint32_t context_size;
> +	uint32_t context_size, ring_buffer_size;
>  	struct intel_ringbuffer *ringbuf;
>  	int ret;
>  
> @@ -2513,7 +2513,11 @@ static int execlists_context_deferred_alloc(struct intel_context *ctx,
>  		return PTR_ERR(ctx_obj);
>  	}
>  
> -	ringbuf = intel_engine_create_ringbuffer(engine, 4 * PAGE_SIZE);
> +	ring_buffer_size = ctx->ring_buffer_size;
> +	if (!ring_buffer_size)
> +		ring_buffer_size = 4 * PAGE_SIZE;

Just don't let it be zero (during construction).
-Chris
Wang, Zhi A May 20, 2016, 12:20 p.m. UTC | #2
Thanks. Will do. :)

> -----Original Message-----
> From: Chris Wilson [mailto:chris@chris-wilson.co.uk]
> Sent: Friday, May 20, 2016 3:02 PM
> To: Wang, Zhi A <zhi.a.wang@intel.com>
> Cc: intel-gfx@lists.freedesktop.org; tvrtko.ursulin@linux.intel.com;
> joonas.lahtinen@linux.intel.com; Tian, Kevin <kevin.tian@intel.com>; Lv,
> Zhiyuan <zhiyuan.lv@intel.com>
> Subject: Re: [PATCH 5/9] drm/i915: Make ring buffer size configurable
> 
> On Tue, May 17, 2016 at 04:19:05AM -0400, Zhi Wang wrote:
> > This patch introduces an option for configuring ring buffer size
> > during context creation. If no ring buffer size is specified, the
> > default size
> > (4 * PAGE_SIZE) will be used.
> >
> > Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_drv.h  | 1 +
> > drivers/gpu/drm/i915/intel_lrc.c | 8 ++++++--
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h
> > b/drivers/gpu/drm/i915/i915_drv.h index ea04352..cc83f2d 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -883,6 +883,7 @@ struct intel_context {
> >  		uint32_t *lrc_reg_state;
> >  		bool initialised;
> >  	} engine[I915_NUM_ENGINES];
> > +	u32 ring_buffer_size;
> >
> >  	struct list_head link;
> >  };
> > diff --git a/drivers/gpu/drm/i915/intel_lrc.c
> > b/drivers/gpu/drm/i915/intel_lrc.c
> > index db10c96..d52c806 100644
> > --- a/drivers/gpu/drm/i915/intel_lrc.c
> > +++ b/drivers/gpu/drm/i915/intel_lrc.c
> > @@ -2495,7 +2495,7 @@ static int execlists_context_deferred_alloc(struct
> intel_context *ctx,
> >  					    struct intel_engine_cs *engine)  {
> >  	struct drm_i915_gem_object *ctx_obj;
> > -	uint32_t context_size;
> > +	uint32_t context_size, ring_buffer_size;
> >  	struct intel_ringbuffer *ringbuf;
> >  	int ret;
> >
> > @@ -2513,7 +2513,11 @@ static int execlists_context_deferred_alloc(struct
> intel_context *ctx,
> >  		return PTR_ERR(ctx_obj);
> >  	}
> >
> > -	ringbuf = intel_engine_create_ringbuffer(engine, 4 * PAGE_SIZE);
> > +	ring_buffer_size = ctx->ring_buffer_size;
> > +	if (!ring_buffer_size)
> > +		ring_buffer_size = 4 * PAGE_SIZE;
> 
> Just don't let it be zero (during construction).
> -Chris
> 
> --
> Chris Wilson, Intel Open Source Technology Centre
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ea04352..cc83f2d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -883,6 +883,7 @@  struct intel_context {
 		uint32_t *lrc_reg_state;
 		bool initialised;
 	} engine[I915_NUM_ENGINES];
+	u32 ring_buffer_size;
 
 	struct list_head link;
 };
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index db10c96..d52c806 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -2495,7 +2495,7 @@  static int execlists_context_deferred_alloc(struct intel_context *ctx,
 					    struct intel_engine_cs *engine)
 {
 	struct drm_i915_gem_object *ctx_obj;
-	uint32_t context_size;
+	uint32_t context_size, ring_buffer_size;
 	struct intel_ringbuffer *ringbuf;
 	int ret;
 
@@ -2513,7 +2513,11 @@  static int execlists_context_deferred_alloc(struct intel_context *ctx,
 		return PTR_ERR(ctx_obj);
 	}
 
-	ringbuf = intel_engine_create_ringbuffer(engine, 4 * PAGE_SIZE);
+	ring_buffer_size = ctx->ring_buffer_size;
+	if (!ring_buffer_size)
+		ring_buffer_size = 4 * PAGE_SIZE;
+
+	ringbuf = intel_engine_create_ringbuffer(engine, ring_buffer_size);
 	if (IS_ERR(ringbuf)) {
 		ret = PTR_ERR(ringbuf);
 		goto error_deref_obj;