All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 04/10] drm/i915/dmc: extract function to parse css header
Date: Thu, 23 May 2019 10:45:00 -0700	[thread overview]
Message-ID: <20190523174500.GS4441@intel.com> (raw)
In-Reply-To: <20190523082420.10352-4-lucas.demarchi@intel.com>

On Thu, May 23, 2019 at 01:24:14AM -0700, Lucas De Marchi wrote:
> Let's start splitting the parse function, making all of them return the
> number of bytes parsed - different versions of the firmware header may
> require different sizes for the structures.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---

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

>  drivers/gpu/drm/i915/intel_csr.c | 49 +++++++++++++++++++-------------
>  1 file changed, 30 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
> index b9651fbe4c25..7e53bf576892 100644
> --- a/drivers/gpu/drm/i915/intel_csr.c
> +++ b/drivers/gpu/drm/i915/intel_csr.c
> @@ -332,29 +332,16 @@ static u32 find_dmc_fw_offset(const struct intel_fw_info *fw_info,
>  	return dmc_offset;
>  }
>  
> -static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,
> -			 const struct firmware *fw)
> +/* Return number of bytes parsed or 0 on error */
> +static u32 parse_csr_fw_css(struct intel_csr *csr,
> +			    struct intel_css_header *css_header)
>  {
> -	struct intel_css_header *css_header;
> -	struct intel_package_header *package_header;
> -	struct intel_dmc_header *dmc_header;
> -	struct intel_csr *csr = &dev_priv->csr;
> -	const struct stepping_info *si = intel_get_stepping_info(dev_priv);
> -	u32 dmc_offset, num_entries, max_entries, readcount = 0, nbytes;
> -	u32 i;
> -	u32 *dmc_payload;
> -
> -	if (!fw)
> -		return NULL;
> -
> -	/* Extract CSS Header information*/
> -	css_header = (struct intel_css_header *)fw->data;
>  	if (sizeof(struct intel_css_header) !=
>  	    (css_header->header_len * 4)) {
>  		DRM_ERROR("DMC firmware has wrong CSS header length "
>  			  "(%u bytes)\n",
>  			  (css_header->header_len * 4));
> -		return NULL;
> +		return 0;
>  	}
>  
>  	if (csr->required_version &&
> @@ -365,12 +352,36 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,
>  			 CSR_VERSION_MINOR(css_header->version),
>  			 CSR_VERSION_MAJOR(csr->required_version),
>  			 CSR_VERSION_MINOR(csr->required_version));
> -		return NULL;
> +		return 0;
>  	}
>  
>  	csr->version = css_header->version;
>  
> -	readcount += sizeof(struct intel_css_header);
> +	return sizeof(struct intel_css_header);
> +}
> +
> +static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,
> +			 const struct firmware *fw)
> +{
> +	struct intel_css_header *css_header;
> +	struct intel_package_header *package_header;
> +	struct intel_dmc_header *dmc_header;
> +	struct intel_csr *csr = &dev_priv->csr;
> +	const struct stepping_info *si = intel_get_stepping_info(dev_priv);
> +	u32 dmc_offset, num_entries, max_entries, readcount = 0, nbytes;
> +	u32 i, r;
> +	u32 *dmc_payload;
> +
> +	if (!fw)
> +		return NULL;
> +
> +	/* Extract CSS Header information*/
> +	css_header = (struct intel_css_header *)fw->data;
> +	r = parse_csr_fw_css(csr, css_header);
> +	if (!r)
> +		return NULL;
> +
> +	readcount += r;
>  
>  	/* Extract Package Header information*/
>  	package_header = (struct intel_package_header *)
> -- 
> 2.21.0
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-05-23 17:44 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  8:24 [PATCH 01/10] drm/i915/dmc: use kernel types Lucas De Marchi
2019-05-23  8:24 ` [PATCH 02/10] drm/i915/dmc: extract fw_info and table walk from intel_package_header Lucas De Marchi
2019-05-23 17:36   ` Rodrigo Vivi
2019-05-23 17:45   ` Srivatsa, Anusha
2019-05-23  8:24 ` [PATCH 03/10] drm/i915/dmc: add support for package_header with version 2 Lucas De Marchi
2019-05-23 17:43   ` Rodrigo Vivi
2019-05-23 17:55     ` Lucas De Marchi
2019-05-23 17:49   ` Srivatsa, Anusha
2019-05-23  8:24 ` [PATCH 04/10] drm/i915/dmc: extract function to parse css header Lucas De Marchi
2019-05-23 17:45   ` Rodrigo Vivi [this message]
2019-05-23 17:51   ` Srivatsa, Anusha
2019-05-23  8:24 ` [PATCH 05/10] drm/i915/dmc: extract function to parse package_header Lucas De Marchi
2019-05-23 18:03   ` Srivatsa, Anusha
2019-05-23  8:24 ` [PATCH 06/10] drm/i915/dmc: extract function to parse dmc_header Lucas De Marchi
2019-05-23 18:22   ` Srivatsa, Anusha
2019-05-23  8:24 ` [PATCH 07/10] drm/i915/dmc: add support to load dmc_header version 3 Lucas De Marchi
2019-05-23 18:26   ` Srivatsa, Anusha
2019-05-23 18:57   ` Rodrigo Vivi
2019-05-23 19:25     ` Lucas De Marchi
2019-05-23 23:27       ` Rodrigo Vivi
2019-05-23  8:24 ` [PATCH 08/10] drm/i915/dmc: remove redundant return in parse_csr_fw() Lucas De Marchi
2019-05-23 18:28   ` Srivatsa, Anusha
2019-05-23  8:24 ` [PATCH 09/10] drm/i915/dmc: protect against reading random memory Lucas De Marchi
2019-05-23 18:58   ` Rodrigo Vivi
2019-05-23 19:41     ` Lucas De Marchi
2019-05-23  8:24 ` [PATCH 10/10] drm/i915/dmc: protect against loading wrong firmware Lucas De Marchi
2019-05-23 19:00   ` Rodrigo Vivi
2019-05-23 16:13 ` ✓ Fi.CI.BAT: success for series starting with [01/10] drm/i915/dmc: use kernel types Patchwork
2019-05-23 17:32 ` [PATCH 01/10] " Srivatsa, Anusha
2019-05-23 17:34 ` Rodrigo Vivi
2019-05-24 23:56 ` ✓ Fi.CI.IGT: success for series starting with [01/10] " Patchwork

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=20190523174500.GS4441@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lucas.demarchi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.