diff mbox

[19/53] drm/i915: Extract pipe control fini & make init outside accesible

Message ID 1402673891-14618-20-git-send-email-oscar.mateo@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

oscar.mateo@intel.com June 13, 2014, 3:37 p.m. UTC
From: Oscar Mateo <oscar.mateo@intel.com>

I plan to reuse these for the new logical ring path.

No functional changes.

Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 31 ++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_ringbuffer.h |  3 +++
 2 files changed, 21 insertions(+), 13 deletions(-)

Comments

Daniel Vetter June 18, 2014, 8:31 p.m. UTC | #1
On Fri, Jun 13, 2014 at 04:37:37PM +0100, oscar.mateo@intel.com wrote:
> From: Oscar Mateo <oscar.mateo@intel.com>
> 
> I plan to reuse these for the new logical ring path.
> 
> No functional changes.
> 
> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>

I don't see the new user of this yet, but imo copy-pasting this around
wouldn't be too harmful.
-Daniel

> ---
>  drivers/gpu/drm/i915/intel_ringbuffer.c | 31 ++++++++++++++++++-------------
>  drivers/gpu/drm/i915/intel_ringbuffer.h |  3 +++
>  2 files changed, 21 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 4a71dd4..254e4c5 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -574,8 +574,21 @@ out:
>  	return ret;
>  }
>  
> -static int
> -init_pipe_control(struct intel_engine_cs *ring)
> +void
> +intel_fini_pipe_control(struct intel_engine_cs *ring)
> +{
> +	if (ring->scratch.obj == NULL)
> +		return;
> +
> +	kunmap(sg_page(ring->scratch.obj->pages->sgl));
> +	i915_gem_object_ggtt_unpin(ring->scratch.obj);
> +
> +	drm_gem_object_unreference(&ring->scratch.obj->base);
> +	ring->scratch.obj = NULL;
> +}
> +
> +int
> +intel_init_pipe_control(struct intel_engine_cs *ring)
>  {
>  	int ret;
>  
> @@ -648,7 +661,7 @@ static int init_render_ring(struct intel_engine_cs *ring)
>  			   _MASKED_BIT_ENABLE(GFX_REPLAY_MODE));
>  
>  	if (INTEL_INFO(dev)->gen >= 5) {
> -		ret = init_pipe_control(ring);
> +		ret = intel_init_pipe_control(ring);
>  		if (ret)
>  			return ret;
>  	}
> @@ -676,16 +689,8 @@ static void render_ring_cleanup(struct intel_engine_cs *ring)
>  {
>  	struct drm_device *dev = ring->dev;
>  
> -	if (ring->scratch.obj == NULL)
> -		return;
> -
> -	if (INTEL_INFO(dev)->gen >= 5) {
> -		kunmap(sg_page(ring->scratch.obj->pages->sgl));
> -		i915_gem_object_ggtt_unpin(ring->scratch.obj);
> -	}
> -
> -	drm_gem_object_unreference(&ring->scratch.obj->base);
> -	ring->scratch.obj = NULL;
> +	if (INTEL_INFO(dev)->gen >= 5)
> +		intel_fini_pipe_control(ring);
>  }
>  
>  static int gen6_signal(struct intel_engine_cs *signaller,
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
> index 599b4ed..42026a1 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.h
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
> @@ -221,6 +221,9 @@ struct  intel_engine_cs {
>  
>  bool intel_ring_initialized(struct intel_engine_cs *ring);
>  
> +void intel_fini_pipe_control(struct intel_engine_cs *ring);
> +int intel_init_pipe_control(struct intel_engine_cs *ring);
> +
>  static inline unsigned
>  intel_ring_flag(struct intel_engine_cs *ring)
>  {
> -- 
> 1.9.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
bradley.d.volkin@intel.com June 19, 2014, 12:04 a.m. UTC | #2
On Fri, Jun 13, 2014 at 08:37:37AM -0700, oscar.mateo@intel.com wrote:
> From: Oscar Mateo <oscar.mateo@intel.com>
> 
> I plan to reuse these for the new logical ring path.
> 
> No functional changes.
> 
> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_ringbuffer.c | 31 ++++++++++++++++++-------------
>  drivers/gpu/drm/i915/intel_ringbuffer.h |  3 +++
>  2 files changed, 21 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index 4a71dd4..254e4c5 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -574,8 +574,21 @@ out:
>  	return ret;
>  }
>  
> -static int
> -init_pipe_control(struct intel_engine_cs *ring)
> +void
> +intel_fini_pipe_control(struct intel_engine_cs *ring)
> +{
> +	if (ring->scratch.obj == NULL)
> +		return;
> +
> +	kunmap(sg_page(ring->scratch.obj->pages->sgl));
> +	i915_gem_object_ggtt_unpin(ring->scratch.obj);
> +
> +	drm_gem_object_unreference(&ring->scratch.obj->base);
> +	ring->scratch.obj = NULL;
> +}
> +
> +int
> +intel_init_pipe_control(struct intel_engine_cs *ring)
>  {
>  	int ret;
>  
> @@ -648,7 +661,7 @@ static int init_render_ring(struct intel_engine_cs *ring)
>  			   _MASKED_BIT_ENABLE(GFX_REPLAY_MODE));
>  
>  	if (INTEL_INFO(dev)->gen >= 5) {
> -		ret = init_pipe_control(ring);
> +		ret = intel_init_pipe_control(ring);
>  		if (ret)
>  			return ret;
>  	}
> @@ -676,16 +689,8 @@ static void render_ring_cleanup(struct intel_engine_cs *ring)
>  {
>  	struct drm_device *dev = ring->dev;
>  
> -	if (ring->scratch.obj == NULL)
> -		return;
> -
> -	if (INTEL_INFO(dev)->gen >= 5) {
> -		kunmap(sg_page(ring->scratch.obj->pages->sgl));
> -		i915_gem_object_ggtt_unpin(ring->scratch.obj);
> -	}
> -
> -	drm_gem_object_unreference(&ring->scratch.obj->base);
> -	ring->scratch.obj = NULL;
> +	if (INTEL_INFO(dev)->gen >= 5)
> +		intel_fini_pipe_control(ring);

It looks like we've changed the behavior such that for the case of
scratch.obj != NULL && gen < 5, we don't unreference scratch.obj.
I don't know if we can ever hit that case though.

Brad

>  }
>  
>  static int gen6_signal(struct intel_engine_cs *signaller,
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
> index 599b4ed..42026a1 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.h
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
> @@ -221,6 +221,9 @@ struct  intel_engine_cs {
>  
>  bool intel_ring_initialized(struct intel_engine_cs *ring);
>  
> +void intel_fini_pipe_control(struct intel_engine_cs *ring);
> +int intel_init_pipe_control(struct intel_engine_cs *ring);
> +
>  static inline unsigned
>  intel_ring_flag(struct intel_engine_cs *ring)
>  {
> -- 
> 1.9.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
oscar.mateo@intel.com June 19, 2014, 10:58 a.m. UTC | #3
> -----Original Message-----
> From: Volkin, Bradley D
> Sent: Thursday, June 19, 2014 1:04 AM
> To: Mateo Lozano, Oscar
> Cc: intel-gfx@lists.freedesktop.org
> Subject: Re: [Intel-gfx] [PATCH 19/53] drm/i915: Extract pipe control fini &
> make init outside accesible
> 
> On Fri, Jun 13, 2014 at 08:37:37AM -0700, oscar.mateo@intel.com wrote:
> > From: Oscar Mateo <oscar.mateo@intel.com>
> >
> > I plan to reuse these for the new logical ring path.
> >
> > No functional changes.
> >
> > Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_ringbuffer.c | 31
> > ++++++++++++++++++-------------
> > drivers/gpu/drm/i915/intel_ringbuffer.h |  3 +++
> >  2 files changed, 21 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c
> > b/drivers/gpu/drm/i915/intel_ringbuffer.c
> > index 4a71dd4..254e4c5 100644
> > --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> > +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> > @@ -574,8 +574,21 @@ out:
> >  	return ret;
> >  }
> >
> > -static int
> > -init_pipe_control(struct intel_engine_cs *ring)
> > +void
> > +intel_fini_pipe_control(struct intel_engine_cs *ring) {
> > +	if (ring->scratch.obj == NULL)
> > +		return;
> > +
> > +	kunmap(sg_page(ring->scratch.obj->pages->sgl));
> > +	i915_gem_object_ggtt_unpin(ring->scratch.obj);
> > +
> > +	drm_gem_object_unreference(&ring->scratch.obj->base);
> > +	ring->scratch.obj = NULL;
> > +}
> > +
> > +int
> > +intel_init_pipe_control(struct intel_engine_cs *ring)
> >  {
> >  	int ret;
> >
> > @@ -648,7 +661,7 @@ static int init_render_ring(struct intel_engine_cs
> *ring)
> >  			   _MASKED_BIT_ENABLE(GFX_REPLAY_MODE));
> >
> >  	if (INTEL_INFO(dev)->gen >= 5) {
> > -		ret = init_pipe_control(ring);
> > +		ret = intel_init_pipe_control(ring);
> >  		if (ret)
> >  			return ret;
> >  	}
> > @@ -676,16 +689,8 @@ static void render_ring_cleanup(struct
> > intel_engine_cs *ring)  {
> >  	struct drm_device *dev = ring->dev;
> >
> > -	if (ring->scratch.obj == NULL)
> > -		return;
> > -
> > -	if (INTEL_INFO(dev)->gen >= 5) {
> > -		kunmap(sg_page(ring->scratch.obj->pages->sgl));
> > -		i915_gem_object_ggtt_unpin(ring->scratch.obj);
> > -	}
> > -
> > -	drm_gem_object_unreference(&ring->scratch.obj->base);
> > -	ring->scratch.obj = NULL;
> > +	if (INTEL_INFO(dev)->gen >= 5)
> > +		intel_fini_pipe_control(ring);
> 
> It looks like we've changed the behavior such that for the case of scratch.obj
> != NULL && gen < 5, we don't unreference scratch.obj.
> I don't know if we can ever hit that case though.

I think you´re right, what was I thinking? :(
Thanks for the heads up!
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 4a71dd4..254e4c5 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -574,8 +574,21 @@  out:
 	return ret;
 }
 
-static int
-init_pipe_control(struct intel_engine_cs *ring)
+void
+intel_fini_pipe_control(struct intel_engine_cs *ring)
+{
+	if (ring->scratch.obj == NULL)
+		return;
+
+	kunmap(sg_page(ring->scratch.obj->pages->sgl));
+	i915_gem_object_ggtt_unpin(ring->scratch.obj);
+
+	drm_gem_object_unreference(&ring->scratch.obj->base);
+	ring->scratch.obj = NULL;
+}
+
+int
+intel_init_pipe_control(struct intel_engine_cs *ring)
 {
 	int ret;
 
@@ -648,7 +661,7 @@  static int init_render_ring(struct intel_engine_cs *ring)
 			   _MASKED_BIT_ENABLE(GFX_REPLAY_MODE));
 
 	if (INTEL_INFO(dev)->gen >= 5) {
-		ret = init_pipe_control(ring);
+		ret = intel_init_pipe_control(ring);
 		if (ret)
 			return ret;
 	}
@@ -676,16 +689,8 @@  static void render_ring_cleanup(struct intel_engine_cs *ring)
 {
 	struct drm_device *dev = ring->dev;
 
-	if (ring->scratch.obj == NULL)
-		return;
-
-	if (INTEL_INFO(dev)->gen >= 5) {
-		kunmap(sg_page(ring->scratch.obj->pages->sgl));
-		i915_gem_object_ggtt_unpin(ring->scratch.obj);
-	}
-
-	drm_gem_object_unreference(&ring->scratch.obj->base);
-	ring->scratch.obj = NULL;
+	if (INTEL_INFO(dev)->gen >= 5)
+		intel_fini_pipe_control(ring);
 }
 
 static int gen6_signal(struct intel_engine_cs *signaller,
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 599b4ed..42026a1 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -221,6 +221,9 @@  struct  intel_engine_cs {
 
 bool intel_ring_initialized(struct intel_engine_cs *ring);
 
+void intel_fini_pipe_control(struct intel_engine_cs *ring);
+int intel_init_pipe_control(struct intel_engine_cs *ring);
+
 static inline unsigned
 intel_ring_flag(struct intel_engine_cs *ring)
 {