From: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/i915/uc: Move FW size sanity check back to fetch
Date: Wed, 14 Aug 2019 13:06:31 -0700 [thread overview]
Message-ID: <c9a49ecc-da4a-4405-b955-c080d930fcd8@intel.com> (raw)
In-Reply-To: <20190814113821.28700-2-michal.wajdeczko@intel.com>
On 8/14/19 4:38 AM, Michal Wajdeczko wrote:
> From: Michał Winiarski <michal.winiarski@intel.com>
>
> While we need to know WOPCM size to do this sanity check, it has more to
> do with FW than with WOPCM. Let's move the check to fetch phase, it's
> not like WOPCM is going to grow in the meantime.
>
> v2: rebased
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jackie Li <yaodong.li@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
> drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 11 +++++++++++
> drivers/gpu/drm/i915/intel_wopcm.c | 14 ++------------
> 2 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
> index d056e1f4bd6d..98cb0eff143f 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
> @@ -265,6 +265,7 @@ int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw, struct drm_i915_private *i915)
> size_t size;
> int err;
>
> + GEM_BUG_ON(!i915->wopcm.size);
> GEM_BUG_ON(!intel_uc_fw_supported(uc_fw));
>
> err = i915_inject_load_error(i915, -ENXIO);
> @@ -324,6 +325,16 @@ int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw, struct drm_i915_private *i915)
> goto fail;
> }
>
> + /* Sanity check whether this fw is not larger than whole WOPCM memory */
> + size = sizeof(struct uc_css_header) + uc_fw->ucode_size;
We could add a __intel_uc_fw_get_upload_size() that skips the
is_available() check and use that here. With our without this:
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Daniele
> + if (unlikely(size >= i915->wopcm.size)) {
> + dev_warn(dev, "%s firmware %s: invalid size: %zu > %zu\n",
> + intel_uc_fw_type_repr(uc_fw->type), uc_fw->path,
> + size, (size_t)i915->wopcm.size);
> + err = -E2BIG;
> + goto fail;
> + }
> +
> /* Get version numbers from the CSS header */
> switch (uc_fw->type) {
> case INTEL_UC_FW_TYPE_GUC:
> diff --git a/drivers/gpu/drm/i915/intel_wopcm.c b/drivers/gpu/drm/i915/intel_wopcm.c
> index e5bc7b8a433e..295978356eef 100644
> --- a/drivers/gpu/drm/i915/intel_wopcm.c
> +++ b/drivers/gpu/drm/i915/intel_wopcm.c
> @@ -197,6 +197,8 @@ void intel_wopcm_init(struct intel_wopcm *wopcm)
> GEM_BUG_ON(!wopcm->size);
> GEM_BUG_ON(wopcm->guc.base);
> GEM_BUG_ON(wopcm->guc.size);
> + GEM_BUG_ON(guc_fw_size >= wopcm->size);
> + GEM_BUG_ON(huc_fw_size >= wopcm->size);
>
> if (i915_inject_probe_failure(i915))
> return;
> @@ -209,18 +211,6 @@ void intel_wopcm_init(struct intel_wopcm *wopcm)
> goto check;
> }
>
> - if (guc_fw_size >= wopcm->size) {
> - DRM_ERROR("GuC FW (%uKiB) is too big to fit in WOPCM.",
> - guc_fw_size / 1024);
> - return;
> - }
> -
> - if (huc_fw_size >= wopcm->size) {
> - DRM_ERROR("HuC FW (%uKiB) is too big to fit in WOPCM.",
> - huc_fw_size / 1024);
> - return;
> - }
> -
> guc_wopcm_base = ALIGN(huc_fw_size + WOPCM_RESERVED_SIZE,
> GUC_WOPCM_OFFSET_ALIGNMENT);
> if ((guc_wopcm_base + ctx_rsvd) >= wopcm->size) {
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-08-14 20:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-14 11:38 [PATCH 1/2] drm/i915/wopcm: Try to use already locked WOPCM layout Michal Wajdeczko
2019-08-14 11:38 ` [PATCH 2/2] drm/i915/uc: Move FW size sanity check back to fetch Michal Wajdeczko
2019-08-14 20:06 ` Daniele Ceraolo Spurio [this message]
2019-08-14 13:21 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/wopcm: Try to use already locked WOPCM layout Patchwork
2019-08-14 19:51 ` [PATCH 1/2] " Daniele Ceraolo Spurio
2019-08-14 20:10 ` Daniele Ceraolo Spurio
2019-08-14 20:49 ` Michal Wajdeczko
2019-08-14 21:32 ` Daniele Ceraolo Spurio
2019-08-15 3:51 ` ✓ Fi.CI.IGT: success for series starting with [1/2] " 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=c9a49ecc-da4a-4405-b955-c080d930fcd8@intel.com \
--to=daniele.ceraolospurio@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=michal.wajdeczko@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