From: Oscar Mateo <oscar.mateo@intel.com>
To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Intel graphics driver community testing & development
<intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v2] drm/i915: Sanitize GuC client initialization
Date: Thu, 16 Feb 2017 02:50:06 -0800 [thread overview]
Message-ID: <88dc1f33-d15e-6492-2b09-9a6cd27a9336@intel.com> (raw)
In-Reply-To: <1487080386-16022-1-git-send-email-joonas.lahtinen@linux.intel.com>
On 02/14/2017 05:53 AM, Joonas Lahtinen wrote:
> Started adding proper teardown to guc_client_alloc, ended up removing
> quite a few dead ends where errors communicating with the GuC were
> silently ignored. There also seemed to be quite a few erronous
> teardown actions performed in case of an error (ordering wrong).
>
> v2:
> - Increase function symmetry/proximity (Michal/Daniele)
> - Fix __reserve_doorbell accounting for high priority (Daniele)
> - Call __update_doorbell_desc! (Daniele)
> - Isolate __guc_{,de}allocate_doorbell (Michal/Daniele)
>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> Cc: Oscar Mateo <oscar.mateo@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 4 +-
> drivers/gpu/drm/i915/i915_guc_submission.c | 371 ++++++++++++++++-------------
> drivers/gpu/drm/i915/intel_guc_fwif.h | 4 +-
> drivers/gpu/drm/i915/intel_uc.h | 11 +-
> 4 files changed, 215 insertions(+), 175 deletions(-)
<SNIP>
>
> /*
> * Since the doorbell only requires a single cacheline, we can save
> @@ -753,27 +781,35 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
> guc_proc_desc_init(guc, client);
> guc_ctx_desc_init(guc, client);
> - /* For runtime client allocation we need to enable the doorbell. Not
> - * required yet for the static execbuf_client as this special kernel
> - * client is enabled from i915_guc_submission_enable().
> - *
> - * guc_update_doorbell_id(guc, client, db_id);
> - */
> + /* For runtime client allocation we need to enable the doorbell. */
> + ret = __update_doorbell_desc(client, client->doorbell_id);
> + if (ret)
> + goto err_vaddr;
> +
> + ret = __create_doorbell(client);
> + if (ret)
> + goto err_db;
At this point, client->doorbell_id is still invalid (__reserve_doorbell
is not called until later from guc_init_doorbell_hw), so the
__create_doorbell fails (and from there, the whole thing falls over: see
my next comment below). CI.BAT didn't catch it because GuC is disabled
by default.
> DRM_DEBUG_DRIVER("new priority %u client %p for engine(s) 0x%x: ctx_index %u\n",
> - priority, client, client->engines, client->ctx_index);
> - DRM_DEBUG_DRIVER("doorbell id %u, cacheline offset 0x%x\n",
> - client->doorbell_id, client->doorbell_offset);
> + priority, client, client->engines, client->ctx_index);
> + DRM_DEBUG_DRIVER("doorbell id %u, cacheline offset 0x%lx\n",
> + client->doorbell_id, client->doorbell_offset);
>
> return client;
> +err_db:
> + __update_doorbell_desc(client, GUC_DOORBELL_INVALID);
> +err_vaddr:
> + i915_gem_object_unpin_map(client->vma->obj);
> +err_vma:
> + i915_vma_unpin_and_release(&client->vma);
> +err_id:
> + ida_simple_remove(&guc->ctx_ids, client->ctx_index);
> +err_client:
> + kfree(client);
>
> -err:
> - guc_client_free(dev_priv, client);
> - return NULL;
> + return ERR_PTR(ret);
> }
>
I know you are leaving i915_guc_submission_init to me, but this patch
should as a minimum check the return code from guc_client_alloc,
otherwise we might end up with an invalid guc->execbuf_client without
noticing.
Something like this should suffice, and I can take it from there:
@@ -939,7 +939,7 @@ int i915_guc_submission_init(struct drm_i915_private
*dev_priv)
INTEL_INFO(dev_priv)->ring_mask,
GUC_CTX_PRIORITY_KMD_NORMAL,
dev_priv->kernel_context);
- if (!guc->execbuf_client) {
+ if (IS_ERR(guc->execbuf_client)) {
DRM_ERROR("Failed to create GuC client for execbuf!\n");
goto err;
}
@@ -1016,10 +1016,8 @@ void i915_guc_submission_fini(struct
drm_i915_private *dev_priv)
struct i915_guc_client *client;
client = fetch_and_zero(&guc->execbuf_client);
- if (!client)
- return;
-
- guc_client_free(client);
+ if (client && !IS_ERR(client))
+ guc_client_free(client);
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
prev parent reply other threads:[~2017-02-16 18:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 13:53 [PATCH v2] drm/i915: Sanitize GuC client initialization Joonas Lahtinen
2017-02-14 17:52 ` ✓ Fi.CI.BAT: success for drm/i915: Sanitize GuC client initialization (rev2) Patchwork
2017-02-16 2:28 ` [PATCH v2] drm/i915: Sanitize GuC client initialization Daniele Ceraolo Spurio
2017-02-16 7:44 ` Chris Wilson
2017-02-16 16:22 ` Daniele Ceraolo Spurio
2017-02-21 15:38 ` Joonas Lahtinen
2017-02-22 11:44 ` Joonas Lahtinen
2017-02-16 10:50 ` Oscar Mateo [this message]
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=88dc1f33-d15e-6492-2b09-9a6cd27a9336@intel.com \
--to=oscar.mateo@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=joonas.lahtinen@linux.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