All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Jackie Li <yaodong.li@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v9 5/7] drm/i915/guc: Add HuC firmware size related restriction for Gen9 and CNL A0
Date: Fri, 09 Feb 2018 11:57:06 +0200	[thread overview]
Message-ID: <151817022598.4964.4248009261854573810@jlahtine-desk.ger.corp.intel.com> (raw)
In-Reply-To: <1518131035-24108-5-git-send-email-yaodong.li@intel.com>

Quoting Jackie Li (2018-02-09 01:03:53)
> On CNL A0 and Gen9, there's a hardware restriction that requires the
> available GuC WOPCM size to be larger than or equal to HuC firmware size.
> 
> This patch adds new verfication code to ensure the available GuC WOPCM size
> to be larger than or equal to HuC firmware size on both Gen9 and CNL A0.
> 
> v6:
>  - Extended HuC FW size check against GuC WOPCM size to all
>    Gen9 and CNL A0 platforms
> 
> v7:
>  - Fixed patch format issues
> 
> v8:
>  - Renamed variables and functions to avoid ambiguity (Joonas)
>  - Updated commit message and comments to be more comprehensive (Sagar)
> 
> v9:
>  - Moved code that is not related to restriction check into a separate
>    patch and updated the commit message accordingly (Sagar/Michal)
>  - Avoided to call uc_get_fw_size for better layer isolation (Michal)
> 
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Sagar Arun Kamble <sagar.a.kamble@intel.com>
> Cc: John Spotswood <john.a.spotswood@intel.com>
> Cc: Jeff McGee <jeff.mcgee@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Reviewed-by: Sagar Arun Kamble <sagar.a.kamble@intel.com> (v8)
> Signed-off-by: Jackie Li <yaodong.li@intel.com>

<SNIP>

> -static inline int gen9_guc_wopcm_size_check(struct intel_guc_wopcm *guc_wopcm)
> +static inline int guc_wopcm_check_huc_fw_size(struct intel_guc_wopcm *guc_wopcm,
> +                                             u32 huc_fw_size)

You can abbreviate here as there are local funcs, "check_huc_fw_fits" is
enough.

> +{
> +       /*
> +        * On Gen9 & CNL A0, hardware requires the total available GuC WOPCM
> +        * size to be larger than or equal to HuC firmware size. Otherwise,
> +        * firmware uploading would fail.
> +        */
> +       if (unlikely(guc_wopcm->size - GUC_WOPCM_RESERVED < huc_fw_size))
> +               return -E2BIG;

Again, it is overkill to try to educate branch predictor when this is
called once during boot, just do the check without unlikely() wrapping
:)

> +
> +       return 0;
> +}
> +
> +static inline int gen9_guc_wopcm_size_check(struct intel_guc_wopcm *guc_wopcm,
> +                                           u32 huc_fw_size)

Abbreviate to gen9_check_dword_gap or something, don't bring the huc_fw_size
here.

>  {
>         u32 guc_wopcm_start;
>         u32 delta;
> @@ -58,16 +73,19 @@ static inline int gen9_guc_wopcm_size_check(struct intel_guc_wopcm *guc_wopcm)
>         if (unlikely(delta < sizeof(u32)))
>                 return -E2BIG;
>  
> -       return 0;
> +       return guc_wopcm_check_huc_fw_size(guc_wopcm, huc_fw_size);
>  }
>  
> -static inline int guc_wopcm_size_check(struct intel_guc *guc)
> +static inline int guc_wopcm_size_check(struct intel_guc *guc, u32 huc_fw_size)
>  {
>         struct drm_i915_private *i915 = guc_to_i915(guc);
>         struct intel_guc_wopcm *guc_wopcm = &guc->wopcm;
	int err = 0;

>  
>         if (IS_GEN9(i915))
> -               return gen9_guc_wopcm_size_check(guc_wopcm);
> +               return gen9_guc_wopcm_size_check(guc_wopcm, huc_fw_size);
	if (..)
		err = gen9_check_dword_gap(guc_wopcm);
	if (err)
		goto err;
> +
> +       if (IS_CNL_REVID(i915, CNL_REVID_A0, CNL_REVID_A0))
> +               return guc_wopcm_check_huc_fw_size(guc_wopcm, huc_fw_size);
>  

	if (IS_GEN9(i915) || IS_CNL_REVID(...))
		err = check_huc_fw_fit(...)
out:
	return err;

This will better isolate the "two bugs", and huc_fw_size only goes to one
of the checks, which makes the picture clearer.

>         return 0;
>  }
> @@ -131,7 +149,7 @@ int intel_guc_wopcm_init(struct intel_guc_wopcm *guc_wopcm, u32 guc_fw_size,
>         guc->wopcm.top = top;
>  
>         /* Check platform specific restrictions */
> -       err = guc_wopcm_size_check(guc);
> +       err = guc_wopcm_size_check(guc, huc_fw_size);

s/guc_wopcm_size_check/size_checks/ as we're doing multiple (that's
the only information the comment carries). Then drop the comment.

Regards, Joonas
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-02-09  9:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08 23:03 [PATCH v9 1/7] drm/i915/guc: Move GuC WOPCM related code into separate files Jackie Li
2018-02-08 23:03 ` [PATCH v9 2/7] drm/i915/guc: Rename guc_ggtt_offset to intel_guc_ggtt_offset Jackie Li
2018-02-09  8:01   ` Joonas Lahtinen
2018-02-08 23:03 ` [PATCH v9 3/7] drm/i915/guc: Implement dynamic GuC WOPCM offset and size Jackie Li
2018-02-09  9:31   ` Joonas Lahtinen
2018-02-09 17:24   ` Michal Wajdeczko
2018-02-09 19:32     ` Yaodong Li
2018-02-08 23:03 ` [PATCH v9 4/7] drm/i915/guc: Add support to return CNL specific reserved GuC WOPCM size Jackie Li
2018-02-09  9:37   ` Joonas Lahtinen
2018-02-08 23:03 ` [PATCH v9 5/7] drm/i915/guc: Add HuC firmware size related restriction for Gen9 and CNL A0 Jackie Li
2018-02-09  9:57   ` Joonas Lahtinen [this message]
2018-02-08 23:03 ` [PATCH v9 6/7] drm/i915/guc: Check the locking status of GuC WOPCM registers Jackie Li
2018-02-08 23:31   ` Chris Wilson
2018-02-09  5:05     ` Yaodong Li
2018-02-09 10:47   ` Joonas Lahtinen
2018-02-11  0:36     ` Yaodong Li
2018-02-09 19:42   ` Michal Wajdeczko
2018-02-09 22:12     ` Yaodong Li
2018-02-08 23:03 ` [PATCH v9 7/7] HAX Enable GuC Submission for CI Jackie Li
2018-02-08 23:29 ` ✗ Fi.CI.BAT: failure for series starting with [v9,1/7] drm/i915/guc: Move GuC WOPCM related code into separate files Patchwork
2018-02-09 16:46 ` [PATCH v9 1/7] " Michal Wajdeczko
2018-02-09 19:38   ` Yaodong Li
2018-02-09 20:59     ` Michel Thierry

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=151817022598.4964.4248009261854573810@jlahtine-desk.ger.corp.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=yaodong.li@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.