public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	Dave Gordon <david.s.gordon@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 4/5] drm/i915/guc: rework guc_add_workqueue_item()
Date: Tue, 3 May 2016 11:26:34 +0100	[thread overview]
Message-ID: <57287CDA.8010005@linux.intel.com> (raw)
In-Reply-To: <20160429161019.GN30680@nuc-i3427.alporthouse.com>


On 29/04/16 17:10, Chris Wilson wrote:
> On Fri, Apr 29, 2016 at 04:44:24PM +0100, Tvrtko Ursulin wrote:
>>
>> On 27/04/16 19:03, Dave Gordon wrote:
>>> Mostly little optimisations; for instance, if the driver is correctly
>>> following the submission protocol, the "out of space" condition is
>>> impossible, so the previous runtime WARN_ON() is promoted to a
>>> GEM_BUG_ON() for a more dramatic effect in development and less impact
>>> in end-user systems.
>>>
>>> Similarly we can replace other WARN_ON() conditions that don't relate to
>>> the hardware state with either BUILD_BUG_ON() for compile-time-
>>> detectable issues, or GEM_BUG_ON() for logical "can't happen" errors.
>>>
>>> With those changes, we can convert it to void, as suggested by Chris
>>> Wilson, and update the calling code appropriately.
>>>
>>> Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
>>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>>>
>>> ---
>>>   drivers/gpu/drm/i915/i915_guc_submission.c | 69 +++++++++++++++---------------
>>>   drivers/gpu/drm/i915/intel_guc.h           |  2 +-
>>>   drivers/gpu/drm/i915/intel_guc_fwif.h      |  3 +-
>>>   3 files changed, 37 insertions(+), 37 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
>>> index 6626eff..4d2ea84 100644
>>> --- a/drivers/gpu/drm/i915/i915_guc_submission.c
>>> +++ b/drivers/gpu/drm/i915/i915_guc_submission.c
>>> @@ -470,23 +470,28 @@ int i915_guc_wq_check_space(struct drm_i915_gem_request *request)
>>>   	return -EAGAIN;
>>>   }
>>>
>>> -static int guc_add_workqueue_item(struct i915_guc_client *gc,
>>> -				  struct drm_i915_gem_request *rq)
>>> +static void guc_add_workqueue_item(struct i915_guc_client *gc,
>>> +				   struct drm_i915_gem_request *rq)
>>>   {
>>> +	/* wqi_len is in DWords, and does not include the one-word header */
>>> +	const size_t wqi_size = sizeof(struct guc_wq_item);
>>
>> Again, u32 is correct I think.
>>
>>> +	const u32 wqi_len = wqi_size/sizeof(u32) - 1;
>>>   	struct guc_process_desc *desc;
>>>   	struct guc_wq_item *wqi;
>>>   	void *base;
>>> -	u32 tail, wq_len, wq_off, space;
>>> +	u32 space, tail, wq_off, wq_page;
>>>
>>>   	desc = gc->client_base + gc->proc_desc_offset;
>>> +
>>> +	/* Space was checked earlier, in i915_guc_wq_check_space() above */
>>
>> It may be above in the file, but the two do not call one another so
>> I recommend saying exactly who called it.
>>
>>>   	space = CIRC_SPACE(gc->wq_tail, desc->head, gc->wq_size);
>>> -	if (WARN_ON(space < sizeof(struct guc_wq_item)))
>>> -		return -ENOSPC; /* shouldn't happen */
>>> +	GEM_BUG_ON(space < wqi_size);
>>
>> It is impossible to hit this only because of the struct_mutex
>> guarding the whole time window from request creation to submission.
>> If in the future, near or far, that gets fixed, then this will need
>> reworking.
>
> Request submission will still have to serialised by a "ring" mutex,
> from the time we allocate the request to the time we add it to whatever
> submission queue. It should still hold that we can pin all the required
> resources (ringbuffer, context state, vm page tables, workqueues) up
> front and take any errors early and then rely on our preallocation when
> submitting the request.
>
>> I don't have any better ideas though.
>>
>> But a WARN_ON and return would be almost as good. Everything is
>> better than a dead machine one can't ssh into...
>>
>> So I appeal to make this a WARN_ON and return. Nothing bad would
>> happen apart from software thinking GPU has hung.
>
> Hence why not make it a bug? If you can't ssh in because the driver died
> inside GEM, something is very wrong.

I was sure bugs are kernel panics, looks like I've been running with 
panic on oops for too long. :(

GEM_BUG_ON is ok then.

Regards,

Tvrtko


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

  reply	other threads:[~2016-05-03 10:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 18:03 [PATCH v2 1/5] drm/i915/guc: add enable_guc_loading parameter Dave Gordon
2016-04-27 18:03 ` [PATCH v2 2/5] drm/i915/guc: pass request (not client) to i915_guc_{wq_check_space, submit}() Dave Gordon
2016-04-29 15:08   ` Tvrtko Ursulin
2016-05-03 19:22     ` Dave Gordon
2016-05-04  8:33       ` Tvrtko Ursulin
2016-04-27 18:03 ` [PATCH v2 3/5] drm/i915/guc: don't spinwait if the GuC's workqueue is full Dave Gordon
2016-04-29 15:17   ` Tvrtko Ursulin
2016-05-06 17:12     ` Dave Gordon
2016-04-29 15:45   ` Tvrtko Ursulin
2016-05-06 15:17     ` Dave Gordon
2016-05-10 14:44       ` Tvrtko Ursulin
2016-04-27 18:03 ` [PATCH v2 4/5] drm/i915/guc: rework guc_add_workqueue_item() Dave Gordon
2016-04-29 15:44   ` Tvrtko Ursulin
2016-04-29 16:10     ` Chris Wilson
2016-05-03 10:26       ` Tvrtko Ursulin [this message]
2016-05-05 18:38     ` Dave Gordon
2016-05-06  8:55       ` Tvrtko Ursulin
2016-05-06 15:06         ` Dave Gordon
2016-04-27 18:03 ` [PATCH v2 5/5] DO NOT MERGE: change default to using GuC submission if possible Dave Gordon
2016-04-28  6:24 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/5] drm/i915/guc: add enable_guc_loading parameter Patchwork
2016-04-29 15:03 ` [PATCH v2 1/5] " Tvrtko Ursulin
2016-05-06 16:39   ` Dave Gordon
2016-05-10 14:37     ` Tvrtko Ursulin
2016-05-13 14:36       ` Dave Gordon

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=57287CDA.8010005@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=david.s.gordon@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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