Skip to content

Commit 6643b38

Browse files
committed
Merge tag 'drm-intel-fixes-2022-09-29' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes
- Restrict forced preemption to the active context (Chris) - Restrict perf_limit_reasons to the supported platforms - gen11+ (Ashutosh) Signed-off-by: Dave Airlie <[email protected]> From: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 91462af + 7738be9 commit 6643b38

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

drivers/gpu/drm/i915/gt/intel_engine_types.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ struct intel_engine_execlists {
165165
*/
166166
struct timer_list preempt;
167167

168+
/**
169+
* @preempt_target: active request at the time of the preemption request
170+
*
171+
* We force a preemption to occur if the pending contexts have not
172+
* been promoted to active upon receipt of the CS ack event within
173+
* the timeout. This timeout maybe chosen based on the target,
174+
* using a very short timeout if the context is no longer schedulable.
175+
* That short timeout may not be applicable to other contexts, so
176+
* if a context switch should happen within before the preemption
177+
* timeout, we may shoot early at an innocent context. To prevent this,
178+
* we record which context was active at the time of the preemption
179+
* request and only reset that context upon the timeout.
180+
*/
181+
const struct i915_request *preempt_target;
182+
168183
/**
169184
* @ccid: identifier for contexts submitted to this engine
170185
*/

drivers/gpu/drm/i915/gt/intel_execlists_submission.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,9 @@ static unsigned long active_preempt_timeout(struct intel_engine_cs *engine,
12411241
if (!rq)
12421242
return 0;
12431243

1244+
/* Only allow ourselves to force reset the currently active context */
1245+
engine->execlists.preempt_target = rq;
1246+
12441247
/* Force a fast reset for terminated contexts (ignoring sysfs!) */
12451248
if (unlikely(intel_context_is_banned(rq->context) || bad_request(rq)))
12461249
return INTEL_CONTEXT_BANNED_PREEMPT_TIMEOUT_MS;
@@ -2427,8 +2430,24 @@ static void execlists_submission_tasklet(struct tasklet_struct *t)
24272430
GEM_BUG_ON(inactive - post > ARRAY_SIZE(post));
24282431

24292432
if (unlikely(preempt_timeout(engine))) {
2433+
const struct i915_request *rq = *engine->execlists.active;
2434+
2435+
/*
2436+
* If after the preempt-timeout expired, we are still on the
2437+
* same active request/context as before we initiated the
2438+
* preemption, reset the engine.
2439+
*
2440+
* However, if we have processed a CS event to switch contexts,
2441+
* but not yet processed the CS event for the pending
2442+
* preemption, reset the timer allowing the new context to
2443+
* gracefully exit.
2444+
*/
24302445
cancel_timer(&engine->execlists.preempt);
2431-
engine->execlists.error_interrupt |= ERROR_PREEMPT;
2446+
if (rq == engine->execlists.preempt_target)
2447+
engine->execlists.error_interrupt |= ERROR_PREEMPT;
2448+
else
2449+
set_timer_ms(&engine->execlists.preempt,
2450+
active_preempt_timeout(engine, rq));
24322451
}
24332452

24342453
if (unlikely(READ_ONCE(engine->execlists.error_interrupt))) {

drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,7 @@ static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_ratl, RATL_MASK);
545545
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_thermalert, VR_THERMALERT_MASK);
546546
static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_vr_tdc, VR_TDC_MASK);
547547

548-
static const struct attribute *freq_attrs[] = {
549-
&dev_attr_punit_req_freq_mhz.attr,
548+
static const struct attribute *throttle_reason_attrs[] = {
550549
&attr_throttle_reason_status.attr,
551550
&attr_throttle_reason_pl1.attr,
552551
&attr_throttle_reason_pl2.attr,
@@ -763,12 +762,20 @@ void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj)
763762
if (!is_object_gt(kobj))
764763
return;
765764

766-
ret = sysfs_create_files(kobj, freq_attrs);
765+
ret = sysfs_create_file(kobj, &dev_attr_punit_req_freq_mhz.attr);
767766
if (ret)
768767
drm_warn(&gt->i915->drm,
769-
"failed to create gt%u throttle sysfs files (%pe)",
768+
"failed to create gt%u punit_req_freq_mhz sysfs (%pe)",
770769
gt->info.id, ERR_PTR(ret));
771770

771+
if (GRAPHICS_VER(gt->i915) >= 11) {
772+
ret = sysfs_create_files(kobj, throttle_reason_attrs);
773+
if (ret)
774+
drm_warn(&gt->i915->drm,
775+
"failed to create gt%u throttle sysfs files (%pe)",
776+
gt->info.id, ERR_PTR(ret));
777+
}
778+
772779
if (HAS_MEDIA_RATIO_MODE(gt->i915) && intel_uc_uses_guc_slpc(&gt->uc)) {
773780
ret = sysfs_create_files(kobj, media_perf_power_attrs);
774781
if (ret)

0 commit comments

Comments
 (0)