[5/9] drm/i915: Remove unneeded check on execlist ringbuf alloc

Submitted by Rodrigo Vivi on April 15, 2015, 11:52 p.m.

Details

Message ID 1429141956-2338-6-git-send-email-rodrigo.vivi@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Rodrigo Vivi April 15, 2015, 11:52 p.m.
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>

We just allocated the intel_ringbuffer with kzalloc. There
is no chance of the ringbuf->obj being other than NULL
so remove the redudant check.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/i915/intel_lrc.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 4373754..dcfd975 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1879,25 +1879,22 @@  int intel_lr_context_deferred_create(struct intel_context *ctx,
 	ringbuf->last_retired_head = -1;
 	intel_ring_update_space(ringbuf);
 
-	if (ringbuf->obj == NULL) {
-		ret = intel_alloc_ringbuffer_obj(dev, ringbuf);
+	ret = intel_alloc_ringbuffer_obj(dev, ringbuf);
+	if (ret) {
+		DRM_DEBUG_DRIVER(
+			"Failed to allocate ringbuffer obj %s: %d\n",
+			ring->name, ret);
+		goto error_free_rbuf;
+	}
+
+	if (is_global_default_ctx) {
+		ret = intel_pin_and_map_ringbuffer_obj(dev, ringbuf);
 		if (ret) {
-			DRM_DEBUG_DRIVER(
-				"Failed to allocate ringbuffer obj %s: %d\n",
+			DRM_ERROR(
+				"Failed to pin and map ringbuffer %s: %d\n",
 				ring->name, ret);
-			goto error_free_rbuf;
+			goto error_destroy_rbuf;
 		}
-
-		if (is_global_default_ctx) {
-			ret = intel_pin_and_map_ringbuffer_obj(dev, ringbuf);
-			if (ret) {
-				DRM_ERROR(
-					"Failed to pin and map ringbuffer %s: %d\n",
-					ring->name, ret);
-				goto error_destroy_rbuf;
-			}
-		}
-
 	}
 
 	ret = populate_lr_context(ctx, ctx_obj, ring, ringbuf);

Comments

On Wed, 2015-04-15 at 16:52 -0700, Rodrigo Vivi wrote:
> From: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> 

> We just allocated the intel_ringbuffer with kzalloc. There

> is no chance of the ringbuf->obj being other than NULL

> so remove the redudant check.

> 

> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>

> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---

>  drivers/gpu/drm/i915/intel_lrc.c | 29 +++++++++++++----------------

>  1 file changed, 13 insertions(+), 16 deletions(-)

> 

> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c

> index 4373754..dcfd975 100644

> --- a/drivers/gpu/drm/i915/intel_lrc.c

> +++ b/drivers/gpu/drm/i915/intel_lrc.c

> @@ -1879,25 +1879,22 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,

>  	ringbuf->last_retired_head = -1;

>  	intel_ring_update_space(ringbuf);

>  

> -	if (ringbuf->obj == NULL) {

I was going to suggest a warn here at least...
> -		ret = intel_alloc_ringbuffer_obj(dev, ringbuf);

> +	ret = intel_alloc_ringbuffer_obj(dev, ringbuf);

> +	if (ret) {

> +		DRM_DEBUG_DRIVER(

> +			"Failed to allocate ringbuffer obj %s: %d\n",

> +			ring->name, ret);

but it will probably end op here so nevermind...

> +		goto error_free_rbuf;

> +	}

> +

> +	if (is_global_default_ctx) {

> +		ret = intel_pin_and_map_ringbuffer_obj(dev, ringbuf);

>  		if (ret) {

> -			DRM_DEBUG_DRIVER(

> -				"Failed to allocate ringbuffer obj %s: %d\n",

> +			DRM_ERROR(

> +				"Failed to pin and map ringbuffer %s: %d\n",

>  				ring->name, ret);

> -			goto error_free_rbuf;

> +			goto error_destroy_rbuf;

>  		}

> -

> -		if (is_global_default_ctx) {

> -			ret = intel_pin_and_map_ringbuffer_obj(dev, ringbuf);

> -			if (ret) {

> -				DRM_ERROR(

> -					"Failed to pin and map ringbuffer %s: %d\n",

> -					ring->name, ret);

> -				goto error_destroy_rbuf;

> -			}

> -		}

> -

>  	}

>  

>  	ret = populate_lr_context(ctx, ctx_obj, ring, ringbuf);


Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>