>-----Original Message----- >From: De Marchi, Lucas >Sent: Thursday, May 23, 2019 1:24 AM >To: intel-gfx@xxxxxxxxxxxxxxxxxxxxx >Cc: Jani Nikula <jani.nikula@xxxxxxxxxxxxxxx>; Srivatsa, Anusha ><anusha.srivatsa@xxxxxxxxx>; Vivi, Rodrigo <rodrigo.vivi@xxxxxxxxx>; De >Marchi, Lucas <lucas.demarchi@xxxxxxxxx> >Subject: [PATCH 04/10] drm/i915/dmc: extract function to parse css header > >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@xxxxxxxxx> Looks good. Reviewed-by: Anusha Srivatsa <anusha.srivatsa@xxxxxxxxx> >--- > 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@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx