2016-11-01 23:43:03 +07:00
|
|
|
/*
|
|
|
|
* Copyright © 2016 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "i915_drv.h"
|
2019-07-13 02:29:53 +07:00
|
|
|
#include "intel_engine.h"
|
|
|
|
#include "intel_gt.h"
|
|
|
|
#include "intel_reset.h"
|
2016-11-01 23:43:03 +07:00
|
|
|
|
2019-01-25 20:22:28 +07:00
|
|
|
struct hangcheck {
|
|
|
|
u64 acthd;
|
2019-05-01 18:45:28 +07:00
|
|
|
u32 ring;
|
2019-05-08 15:06:25 +07:00
|
|
|
u32 head;
|
2019-01-25 20:22:28 +07:00
|
|
|
enum intel_engine_hangcheck_action action;
|
|
|
|
unsigned long action_timestamp;
|
|
|
|
int deadlock;
|
|
|
|
struct intel_instdone instdone;
|
|
|
|
bool wedged:1;
|
|
|
|
bool stalled:1;
|
|
|
|
};
|
|
|
|
|
2016-11-01 23:43:03 +07:00
|
|
|
static bool instdone_unchanged(u32 current_instdone, u32 *old_instdone)
|
|
|
|
{
|
|
|
|
u32 tmp = current_instdone | *old_instdone;
|
|
|
|
bool unchanged;
|
|
|
|
|
|
|
|
unchanged = tmp == *old_instdone;
|
|
|
|
*old_instdone |= tmp;
|
|
|
|
|
|
|
|
return unchanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool subunits_stuck(struct intel_engine_cs *engine)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = engine->i915;
|
2019-08-23 23:03:05 +07:00
|
|
|
const struct sseu_dev_info *sseu = &RUNTIME_INFO(dev_priv)->sseu;
|
2016-11-01 23:43:03 +07:00
|
|
|
struct intel_instdone instdone;
|
|
|
|
struct intel_instdone *accu_instdone = &engine->hangcheck.instdone;
|
|
|
|
bool stuck;
|
|
|
|
int slice;
|
|
|
|
int subslice;
|
|
|
|
|
|
|
|
intel_engine_get_instdone(engine, &instdone);
|
|
|
|
|
|
|
|
/* There might be unstable subunit states even when
|
|
|
|
* actual head is not moving. Filter out the unstable ones by
|
|
|
|
* accumulating the undone -> done transitions and only
|
|
|
|
* consider those as progress.
|
|
|
|
*/
|
|
|
|
stuck = instdone_unchanged(instdone.instdone,
|
|
|
|
&accu_instdone->instdone);
|
|
|
|
stuck &= instdone_unchanged(instdone.slice_common,
|
|
|
|
&accu_instdone->slice_common);
|
|
|
|
|
2019-08-23 23:03:05 +07:00
|
|
|
for_each_instdone_slice_subslice(dev_priv, sseu, slice, subslice) {
|
2016-11-01 23:43:03 +07:00
|
|
|
stuck &= instdone_unchanged(instdone.sampler[slice][subslice],
|
|
|
|
&accu_instdone->sampler[slice][subslice]);
|
|
|
|
stuck &= instdone_unchanged(instdone.row[slice][subslice],
|
|
|
|
&accu_instdone->row[slice][subslice]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return stuck;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum intel_engine_hangcheck_action
|
|
|
|
head_stuck(struct intel_engine_cs *engine, u64 acthd)
|
|
|
|
{
|
|
|
|
if (acthd != engine->hangcheck.acthd) {
|
|
|
|
|
|
|
|
/* Clear subunit states on head movement */
|
|
|
|
memset(&engine->hangcheck.instdone, 0,
|
|
|
|
sizeof(engine->hangcheck.instdone));
|
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
return ENGINE_ACTIVE_HEAD;
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!subunits_stuck(engine))
|
2016-11-18 20:09:04 +07:00
|
|
|
return ENGINE_ACTIVE_SUBUNITS;
|
2016-11-01 23:43:03 +07:00
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
return ENGINE_DEAD;
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static enum intel_engine_hangcheck_action
|
|
|
|
engine_stuck(struct intel_engine_cs *engine, u64 acthd)
|
|
|
|
{
|
|
|
|
enum intel_engine_hangcheck_action ha;
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
ha = head_stuck(engine, acthd);
|
2016-11-18 20:09:04 +07:00
|
|
|
if (ha != ENGINE_DEAD)
|
2016-11-01 23:43:03 +07:00
|
|
|
return ha;
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
if (IS_GEN(engine->i915, 2))
|
2016-11-18 20:09:04 +07:00
|
|
|
return ENGINE_DEAD;
|
2016-11-01 23:43:03 +07:00
|
|
|
|
|
|
|
/* Is the chip hanging on a WAIT_FOR_EVENT?
|
|
|
|
* If so we can simply poke the RB_WAIT bit
|
|
|
|
* and break the hang. This should work on
|
|
|
|
* all but the second generation chipsets.
|
|
|
|
*/
|
2019-03-26 04:49:40 +07:00
|
|
|
tmp = ENGINE_READ(engine, RING_CTL);
|
2016-11-01 23:43:03 +07:00
|
|
|
if (tmp & RING_WAIT) {
|
2019-07-13 02:29:53 +07:00
|
|
|
intel_gt_handle_error(engine->gt, engine->mask, 0,
|
|
|
|
"stuck wait on %s", engine->name);
|
2019-03-26 04:49:40 +07:00
|
|
|
ENGINE_WRITE(engine, RING_CTL, tmp);
|
2016-11-18 20:09:04 +07:00
|
|
|
return ENGINE_WAIT_KICK;
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
return ENGINE_DEAD;
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
|
|
|
|
2016-11-16 22:20:29 +07:00
|
|
|
static void hangcheck_load_sample(struct intel_engine_cs *engine,
|
2019-01-25 20:22:28 +07:00
|
|
|
struct hangcheck *hc)
|
2016-11-16 22:20:29 +07:00
|
|
|
{
|
|
|
|
hc->acthd = intel_engine_get_active_head(engine);
|
2019-05-01 18:45:28 +07:00
|
|
|
hc->ring = ENGINE_READ(engine, RING_START);
|
2019-05-08 15:06:25 +07:00
|
|
|
hc->head = ENGINE_READ(engine, RING_HEAD);
|
2016-11-16 22:20:29 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hangcheck_store_sample(struct intel_engine_cs *engine,
|
2019-01-25 20:22:28 +07:00
|
|
|
const struct hangcheck *hc)
|
2016-11-16 22:20:29 +07:00
|
|
|
{
|
|
|
|
engine->hangcheck.acthd = hc->acthd;
|
2019-05-01 18:45:28 +07:00
|
|
|
engine->hangcheck.last_ring = hc->ring;
|
2019-05-08 15:06:25 +07:00
|
|
|
engine->hangcheck.last_head = hc->head;
|
2016-11-16 22:20:29 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static enum intel_engine_hangcheck_action
|
|
|
|
hangcheck_get_action(struct intel_engine_cs *engine,
|
2019-01-25 20:22:28 +07:00
|
|
|
const struct hangcheck *hc)
|
2016-11-16 22:20:29 +07:00
|
|
|
{
|
2017-07-21 19:32:23 +07:00
|
|
|
if (intel_engine_is_idle(engine))
|
2016-11-18 20:09:04 +07:00
|
|
|
return ENGINE_IDLE;
|
2016-11-16 22:20:29 +07:00
|
|
|
|
2019-05-01 18:45:28 +07:00
|
|
|
if (engine->hangcheck.last_ring != hc->ring)
|
|
|
|
return ENGINE_ACTIVE_SEQNO;
|
|
|
|
|
2019-05-08 15:06:25 +07:00
|
|
|
if (engine->hangcheck.last_head != hc->head)
|
2019-05-01 18:45:28 +07:00
|
|
|
return ENGINE_ACTIVE_SEQNO;
|
|
|
|
|
2016-11-16 22:20:29 +07:00
|
|
|
return engine_stuck(engine, hc->acthd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hangcheck_accumulate_sample(struct intel_engine_cs *engine,
|
2019-01-25 20:22:28 +07:00
|
|
|
struct hangcheck *hc)
|
2016-11-16 22:20:29 +07:00
|
|
|
{
|
2016-11-18 20:09:04 +07:00
|
|
|
unsigned long timeout = I915_ENGINE_DEAD_TIMEOUT;
|
|
|
|
|
2016-11-16 22:20:29 +07:00
|
|
|
hc->action = hangcheck_get_action(engine, hc);
|
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
/* We always increment the progress
|
|
|
|
* if the engine is busy and still processing
|
|
|
|
* the same request, so that no single request
|
|
|
|
* can run indefinitely (such as a chain of
|
|
|
|
* batches). The only time we do not increment
|
|
|
|
* the hangcheck score on this ring, if this
|
|
|
|
* engine is in a legitimate wait for another
|
|
|
|
* engine. In that case the waiting engine is a
|
|
|
|
* victim and we want to be sure we catch the
|
|
|
|
* right culprit. Then every time we do kick
|
|
|
|
* the ring, make it as a progress as the seqno
|
|
|
|
* advancement might ensure and if not, it
|
|
|
|
* will catch the hanging engine.
|
|
|
|
*/
|
2016-11-16 22:20:29 +07:00
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
switch (hc->action) {
|
|
|
|
case ENGINE_IDLE:
|
|
|
|
case ENGINE_ACTIVE_SEQNO:
|
|
|
|
/* Clear head and subunit states on seqno movement */
|
|
|
|
hc->acthd = 0;
|
2016-11-16 22:20:29 +07:00
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
memset(&engine->hangcheck.instdone, 0,
|
|
|
|
sizeof(engine->hangcheck.instdone));
|
2016-11-16 22:20:29 +07:00
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
/* Intentional fall through */
|
|
|
|
case ENGINE_WAIT_KICK:
|
|
|
|
case ENGINE_WAIT:
|
|
|
|
engine->hangcheck.action_timestamp = jiffies;
|
2016-11-16 22:20:29 +07:00
|
|
|
break;
|
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
case ENGINE_ACTIVE_HEAD:
|
|
|
|
case ENGINE_ACTIVE_SUBUNITS:
|
2017-12-14 19:26:13 +07:00
|
|
|
/*
|
|
|
|
* Seqno stuck with still active engine gets leeway,
|
2016-11-18 20:09:04 +07:00
|
|
|
* in hopes that it is just a long shader.
|
2016-11-16 22:20:29 +07:00
|
|
|
*/
|
2016-11-18 20:09:04 +07:00
|
|
|
timeout = I915_SEQNO_DEAD_TIMEOUT;
|
|
|
|
break;
|
2016-11-16 22:20:29 +07:00
|
|
|
|
2016-11-18 20:09:04 +07:00
|
|
|
case ENGINE_DEAD:
|
2016-11-16 22:20:29 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
MISSING_CASE(hc->action);
|
|
|
|
}
|
2016-11-18 20:09:04 +07:00
|
|
|
|
|
|
|
hc->stalled = time_after(jiffies,
|
|
|
|
engine->hangcheck.action_timestamp + timeout);
|
2018-06-02 17:48:53 +07:00
|
|
|
hc->wedged = time_after(jiffies,
|
|
|
|
engine->hangcheck.action_timestamp +
|
|
|
|
I915_ENGINE_WEDGED_TIMEOUT);
|
2016-11-16 22:20:29 +07:00
|
|
|
}
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
static void hangcheck_declare_hang(struct intel_gt *gt,
|
2019-06-07 15:25:54 +07:00
|
|
|
intel_engine_mask_t hung,
|
|
|
|
intel_engine_mask_t stuck)
|
2016-11-16 22:20:29 +07:00
|
|
|
{
|
|
|
|
struct intel_engine_cs *engine;
|
2019-04-01 23:26:39 +07:00
|
|
|
intel_engine_mask_t tmp;
|
2016-11-16 22:20:29 +07:00
|
|
|
char msg[80];
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* If some rings hung but others were still busy, only
|
|
|
|
* blame the hanging rings in the synopsis.
|
|
|
|
*/
|
|
|
|
if (stuck != hung)
|
|
|
|
hung &= ~stuck;
|
|
|
|
len = scnprintf(msg, sizeof(msg),
|
2018-03-20 17:04:49 +07:00
|
|
|
"%s on ", stuck == hung ? "no progress" : "hang");
|
2019-07-13 02:29:53 +07:00
|
|
|
for_each_engine_masked(engine, gt->i915, hung, tmp)
|
2016-11-16 22:20:29 +07:00
|
|
|
len += scnprintf(msg + len, sizeof(msg) - len,
|
|
|
|
"%s, ", engine->name);
|
|
|
|
msg[len-2] = '\0';
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
return intel_gt_handle_error(gt, hung, I915_ERROR_CAPTURE, "%s", msg);
|
2016-11-16 22:20:29 +07:00
|
|
|
}
|
|
|
|
|
2016-11-01 23:43:03 +07:00
|
|
|
/*
|
|
|
|
* This is called when the chip hasn't reported back with completed
|
|
|
|
* batchbuffers in a long time. We keep track per ring seqno progress and
|
|
|
|
* if there are no progress, hangcheck score for that ring is increased.
|
|
|
|
* Further, acthd is inspected to see if the ring is stuck. On stuck case
|
|
|
|
* we kick the ring. If we see no progress on three subsequent calls
|
|
|
|
* we assume chip is wedged and try to fix it by resetting the chip.
|
|
|
|
*/
|
2019-07-13 02:29:53 +07:00
|
|
|
static void hangcheck_elapsed(struct work_struct *work)
|
2016-11-01 23:43:03 +07:00
|
|
|
{
|
2019-07-13 02:29:53 +07:00
|
|
|
struct intel_gt *gt =
|
|
|
|
container_of(work, typeof(*gt), hangcheck.work.work);
|
2019-06-07 15:25:54 +07:00
|
|
|
intel_engine_mask_t hung = 0, stuck = 0, wedged = 0;
|
2016-11-01 23:43:03 +07:00
|
|
|
struct intel_engine_cs *engine;
|
|
|
|
enum intel_engine_id id;
|
drm/i915: Invert the GEM wakeref hierarchy
In the current scheme, on submitting a request we take a single global
GEM wakeref, which trickles down to wake up all GT power domains. This
is undesirable as we would like to be able to localise our power
management to the available power domains and to remove the global GEM
operations from the heart of the driver. (The intent there is to push
global GEM decisions to the boundary as used by the GEM user interface.)
Now during request construction, each request is responsible via its
logical context to acquire a wakeref on each power domain it intends to
utilize. Currently, each request takes a wakeref on the engine(s) and
the engines themselves take a chipset wakeref. This gives us a
transition on each engine which we can extend if we want to insert more
powermangement control (such as soft rc6). The global GEM operations
that currently require a struct_mutex are reduced to listening to pm
events from the chipset GT wakeref. As we reduce the struct_mutex
requirement, these listeners should evaporate.
Perhaps the biggest immediate change is that this removes the
struct_mutex requirement around GT power management, allowing us greater
flexibility in request construction. Another important knock-on effect,
is that by tracking engine usage, we can insert a switch back to the
kernel context on that engine immediately, avoiding any extra delay or
inserting global synchronisation barriers. This makes tracking when an
engine and its associated contexts are idle much easier -- important for
when we forgo our assumed execution ordering and need idle barriers to
unpin used contexts. In the process, it means we remove a large chunk of
code whose only purpose was to switch back to the kernel context.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190424200717.1686-5-chris@chris-wilson.co.uk
2019-04-25 03:07:17 +07:00
|
|
|
intel_wakeref_t wakeref;
|
2016-11-01 23:43:03 +07:00
|
|
|
|
2017-09-20 02:38:44 +07:00
|
|
|
if (!i915_modparams.enable_hangcheck)
|
2016-11-01 23:43:03 +07:00
|
|
|
return;
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
if (!READ_ONCE(gt->awake))
|
2016-11-01 23:43:03 +07:00
|
|
|
return;
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
if (intel_gt_is_wedged(gt))
|
2016-11-22 21:41:19 +07:00
|
|
|
return;
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
wakeref = intel_runtime_pm_get_if_in_use(>->i915->runtime_pm);
|
drm/i915: Invert the GEM wakeref hierarchy
In the current scheme, on submitting a request we take a single global
GEM wakeref, which trickles down to wake up all GT power domains. This
is undesirable as we would like to be able to localise our power
management to the available power domains and to remove the global GEM
operations from the heart of the driver. (The intent there is to push
global GEM decisions to the boundary as used by the GEM user interface.)
Now during request construction, each request is responsible via its
logical context to acquire a wakeref on each power domain it intends to
utilize. Currently, each request takes a wakeref on the engine(s) and
the engines themselves take a chipset wakeref. This gives us a
transition on each engine which we can extend if we want to insert more
powermangement control (such as soft rc6). The global GEM operations
that currently require a struct_mutex are reduced to listening to pm
events from the chipset GT wakeref. As we reduce the struct_mutex
requirement, these listeners should evaporate.
Perhaps the biggest immediate change is that this removes the
struct_mutex requirement around GT power management, allowing us greater
flexibility in request construction. Another important knock-on effect,
is that by tracking engine usage, we can insert a switch back to the
kernel context on that engine immediately, avoiding any extra delay or
inserting global synchronisation barriers. This makes tracking when an
engine and its associated contexts are idle much easier -- important for
when we forgo our assumed execution ordering and need idle barriers to
unpin used contexts. In the process, it means we remove a large chunk of
code whose only purpose was to switch back to the kernel context.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190424200717.1686-5-chris@chris-wilson.co.uk
2019-04-25 03:07:17 +07:00
|
|
|
if (!wakeref)
|
|
|
|
return;
|
|
|
|
|
2016-11-01 23:43:03 +07:00
|
|
|
/* As enabling the GPU requires fairly extensive mmio access,
|
|
|
|
* periodically arm the mmio checker to see if we are triggering
|
|
|
|
* any invalid access.
|
|
|
|
*/
|
2019-07-13 02:29:53 +07:00
|
|
|
intel_uncore_arm_unclaimed_mmio_detection(gt->uncore);
|
2016-11-01 23:43:03 +07:00
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
for_each_engine(engine, gt->i915, id) {
|
2019-01-25 20:22:28 +07:00
|
|
|
struct hangcheck hc;
|
2016-11-01 23:43:03 +07:00
|
|
|
|
2019-09-26 17:56:43 +07:00
|
|
|
intel_engine_breadcrumbs_irq(engine);
|
2019-01-30 03:52:30 +07:00
|
|
|
|
2017-12-19 20:09:48 +07:00
|
|
|
hangcheck_load_sample(engine, &hc);
|
|
|
|
hangcheck_accumulate_sample(engine, &hc);
|
|
|
|
hangcheck_store_sample(engine, &hc);
|
2016-11-16 22:20:29 +07:00
|
|
|
|
2019-01-25 20:22:28 +07:00
|
|
|
if (hc.stalled) {
|
2019-03-06 01:03:30 +07:00
|
|
|
hung |= engine->mask;
|
2017-12-19 20:09:48 +07:00
|
|
|
if (hc.action != ENGINE_DEAD)
|
2019-03-06 01:03:30 +07:00
|
|
|
stuck |= engine->mask;
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
2018-06-02 17:48:53 +07:00
|
|
|
|
2019-01-25 20:22:28 +07:00
|
|
|
if (hc.wedged)
|
2019-03-06 01:03:30 +07:00
|
|
|
wedged |= engine->mask;
|
2018-06-02 17:48:53 +07:00
|
|
|
}
|
|
|
|
|
2019-01-22 05:20:46 +07:00
|
|
|
if (GEM_SHOW_DEBUG() && (hung | stuck)) {
|
|
|
|
struct drm_printer p = drm_debug_printer("hangcheck");
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
for_each_engine(engine, gt->i915, id) {
|
2019-01-22 05:20:46 +07:00
|
|
|
if (intel_engine_is_idle(engine))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
intel_engine_dump(engine, &p, "%s\n", engine->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-02 17:48:53 +07:00
|
|
|
if (wedged) {
|
2019-07-13 02:29:53 +07:00
|
|
|
dev_err(gt->i915->drm.dev,
|
2018-06-02 17:48:53 +07:00
|
|
|
"GPU recovery timed out,"
|
|
|
|
" cancelling all in-flight rendering.\n");
|
|
|
|
GEM_TRACE_DUMP();
|
2019-07-13 02:29:53 +07:00
|
|
|
intel_gt_set_wedged(gt);
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
|
|
|
|
2016-11-16 22:20:29 +07:00
|
|
|
if (hung)
|
2019-07-13 02:29:53 +07:00
|
|
|
hangcheck_declare_hang(gt, hung, stuck);
|
2016-11-01 23:43:03 +07:00
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
intel_runtime_pm_put(>->i915->runtime_pm, wakeref);
|
drm/i915: Invert the GEM wakeref hierarchy
In the current scheme, on submitting a request we take a single global
GEM wakeref, which trickles down to wake up all GT power domains. This
is undesirable as we would like to be able to localise our power
management to the available power domains and to remove the global GEM
operations from the heart of the driver. (The intent there is to push
global GEM decisions to the boundary as used by the GEM user interface.)
Now during request construction, each request is responsible via its
logical context to acquire a wakeref on each power domain it intends to
utilize. Currently, each request takes a wakeref on the engine(s) and
the engines themselves take a chipset wakeref. This gives us a
transition on each engine which we can extend if we want to insert more
powermangement control (such as soft rc6). The global GEM operations
that currently require a struct_mutex are reduced to listening to pm
events from the chipset GT wakeref. As we reduce the struct_mutex
requirement, these listeners should evaporate.
Perhaps the biggest immediate change is that this removes the
struct_mutex requirement around GT power management, allowing us greater
flexibility in request construction. Another important knock-on effect,
is that by tracking engine usage, we can insert a switch back to the
kernel context on that engine immediately, avoiding any extra delay or
inserting global synchronisation barriers. This makes tracking when an
engine and its associated contexts are idle much easier -- important for
when we forgo our assumed execution ordering and need idle barriers to
unpin used contexts. In the process, it means we remove a large chunk of
code whose only purpose was to switch back to the kernel context.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190424200717.1686-5-chris@chris-wilson.co.uk
2019-04-25 03:07:17 +07:00
|
|
|
|
2016-11-01 23:43:03 +07:00
|
|
|
/* Reset timer in case GPU hangs without another request being added */
|
2019-07-13 02:29:53 +07:00
|
|
|
intel_gt_queue_hangcheck(gt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void intel_gt_queue_hangcheck(struct intel_gt *gt)
|
|
|
|
{
|
|
|
|
unsigned long delay;
|
|
|
|
|
|
|
|
if (unlikely(!i915_modparams.enable_hangcheck))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't continually defer the hangcheck so that it is always run at
|
|
|
|
* least once after work has been scheduled on any ring. Otherwise,
|
|
|
|
* we will ignore a hung ring if a second ring is kept busy.
|
|
|
|
*/
|
|
|
|
|
|
|
|
delay = round_jiffies_up_relative(DRM_I915_HANGCHECK_JIFFIES);
|
|
|
|
queue_delayed_work(system_long_wq, >->hangcheck.work, delay);
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void intel_engine_init_hangcheck(struct intel_engine_cs *engine)
|
|
|
|
{
|
|
|
|
memset(&engine->hangcheck, 0, sizeof(engine->hangcheck));
|
2018-05-03 05:03:12 +07:00
|
|
|
engine->hangcheck.action_timestamp = jiffies;
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
void intel_gt_init_hangcheck(struct intel_gt *gt)
|
2016-11-01 23:43:03 +07:00
|
|
|
{
|
2019-07-13 02:29:53 +07:00
|
|
|
INIT_DELAYED_WORK(>->hangcheck.work, hangcheck_elapsed);
|
2016-11-01 23:43:03 +07:00
|
|
|
}
|
2017-02-14 00:15:58 +07:00
|
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
|
2019-04-25 00:48:39 +07:00
|
|
|
#include "selftest_hangcheck.c"
|
2017-02-14 00:15:58 +07:00
|
|
|
#endif
|