public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: tidy up gen8_init_scratch
Date: Wed, 27 Apr 2016 10:39:16 +0300	[thread overview]
Message-ID: <1461742756.3986.6.camel@linux.intel.com> (raw)
In-Reply-To: <1461662839-14690-1-git-send-email-matthew.auld@intel.com>

On ti, 2016-04-26 at 10:27 +0100, Matthew Auld wrote:
> Use goto teardown path and also ensure we reset any struct members which
> would otherwise contain an error encoded pointer, and could be mistaken
> for a valid address.
> 
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>

As this goes through the whole function, good idea to check with git
blame for the function author and CC (in this case Mika, added as CC).

> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 36 +++++++++++++++++++++++++-----------
>  1 file changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 0d666b3..a723b74 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -866,31 +866,31 @@ static void gen8_free_page_tables(struct drm_device *dev,
>  static int gen8_init_scratch(struct i915_address_space *vm)
>  {
>  	struct drm_device *dev = vm->dev;
> +	int ret;
>  
>  	vm->scratch_page = alloc_scratch_page(dev);
> -	if (IS_ERR(vm->scratch_page))
> -		return PTR_ERR(vm->scratch_page);
> +	if (IS_ERR(vm->scratch_page)) {
> +		ret = PTR_ERR(vm->scratch_page);
> +		goto fail_scratch;
> +	}
>  
>  	vm->scratch_pt = alloc_pt(dev);
>  	if (IS_ERR(vm->scratch_pt)) {
> -		free_scratch_page(dev, vm->scratch_page);
> -		return PTR_ERR(vm->scratch_pt);
> +		ret = PTR_ERR(vm->scratch_pt);
> +		goto fail_pt;
>  	}
>  
>  	vm->scratch_pd = alloc_pd(dev);
>  	if (IS_ERR(vm->scratch_pd)) {
> -		free_pt(dev, vm->scratch_pt);
> -		free_scratch_page(dev, vm->scratch_page);
> -		return PTR_ERR(vm->scratch_pd);
> +		ret = PTR_ERR(vm->scratch_pd);
> +		goto fail_pd;
>  	}
>  
>  	if (USES_FULL_48BIT_PPGTT(dev)) {
>  		vm->scratch_pdp = alloc_pdp(dev);
>  		if (IS_ERR(vm->scratch_pdp)) {
> -			free_pd(dev, vm->scratch_pd);
> -			free_pt(dev, vm->scratch_pt);
> -			free_scratch_page(dev, vm->scratch_page);
> -			return PTR_ERR(vm->scratch_pdp);
> +			ret = PTR_ERR(vm->scratch_pdp);
> +			goto fail_pdp;
>  		}
>  	}
>  
> @@ -900,6 +900,20 @@ static int gen8_init_scratch(struct i915_address_space *vm)
>  		gen8_initialize_pdp(vm, vm->scratch_pdp);
>  
>  	return 0;
> +
> +fail_pdp:
> +	vm->scratch_pdp = NULL;

I don't think assigning to NULL is necessary. If this function fails,
it'll lead to driver init failure.

> +	free_pd(dev, vm->scratch_pd);
> +fail_pd:
> +	vm->scratch_pd = NULL;
> +	free_pt(dev, vm->scratch_pt);
> +fail_pt:
> +	vm->scratch_pt = NULL;
> +	free_scratch_page(dev, vm->scratch_page);
> +fail_scratch:
> +	vm->scratch_page = NULL;
> +

Same comment as in the last patch, related to labels, the label should
describe the code under goto section, not the code/situation that jumps
to it.

Regards, Joonas

> +	return ret;
>  }
>  
>  static int gen8_ppgtt_notify_vgt(struct i915_hw_ppgtt *ppgtt, bool create)
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-04-27  7:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26  9:27 [PATCH] drm/i915: tidy up gen8_init_scratch Matthew Auld
2016-04-26 12:30 ` ✗ Fi.CI.BAT: failure for " Patchwork
2016-04-27  7:39 ` Joonas Lahtinen [this message]
2016-04-27 10:15 ` [PATCH] " Dave Gordon
2016-04-27 11:26   ` Mika Kuoppala
  -- strict thread matches above, loose matches on Subject: below --
2016-04-27 12:19 Matthew Auld
2016-04-27 12:30 ` Mika Kuoppala
2016-04-27 13:10   ` Joonas Lahtinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461742756.3986.6.camel@linux.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox