Commit 74e5a9ac authored by Chris Wilson's avatar Chris Wilson

drm/i915/gt: Mark up intel_rps.active for racy reads

We read the current state of intel_rps.active outside of the lock, so
mark up the racy access.

[  525.037073] BUG: KCSAN: data-race in intel_rps_boost [i915] / intel_rps_park [i915]
[  525.037091]
[  525.037103] write to 0xffff8881f145efa1 of 1 bytes by task 192 on cpu 2:
[  525.037331]  intel_rps_park+0x72/0x230 [i915]
[  525.037552]  __gt_park+0x61/0xa0 [i915]
[  525.037771]  ____intel_wakeref_put_last+0x42/0x90 [i915]
[  525.037991]  __intel_wakeref_put_work+0xd3/0xf0 [i915]
[  525.038008]  process_one_work+0x3b1/0x690
[  525.038022]  worker_thread+0x80/0x670
[  525.038037]  kthread+0x19a/0x1e0
[  525.038051]  ret_from_fork+0x1f/0x30
[  525.038062]
[  525.038074] read to 0xffff8881f145efa1 of 1 bytes by task 733 on cpu 3:
[  525.038304]  intel_rps_boost+0x67/0x1f0 [i915]
[  525.038535]  i915_request_wait+0x562/0x5d0 [i915]
[  525.038764]  i915_gem_object_wait_fence+0x81/0xa0 [i915]
[  525.038994]  i915_gem_object_wait_reservation+0x489/0x520 [i915]
[  525.039224]  i915_gem_wait_ioctl+0x167/0x2b0 [i915]
[  525.039241]  drm_ioctl_kernel+0xe4/0x120
[  525.039255]  drm_ioctl+0x297/0x4c7
[  525.039269]  ksys_ioctl+0x89/0xb0
[  525.039282]  __x64_sys_ioctl+0x42/0x60
[  525.039296]  do_syscall_64+0x6e/0x2c0
[  525.039311]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200309113623.24208-1-chris@chris-wilson.co.uk
parent dbe748cd
...@@ -644,7 +644,7 @@ void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive) ...@@ -644,7 +644,7 @@ void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive)
{ {
mutex_lock(&rps->power.mutex); mutex_lock(&rps->power.mutex);
if (interactive) { if (interactive) {
if (!rps->power.interactive++ && rps->active) if (!rps->power.interactive++ && READ_ONCE(rps->active))
rps_set_power(rps, HIGH_POWER); rps_set_power(rps, HIGH_POWER);
} else { } else {
GEM_BUG_ON(!rps->power.interactive); GEM_BUG_ON(!rps->power.interactive);
...@@ -721,11 +721,14 @@ void intel_rps_unpark(struct intel_rps *rps) ...@@ -721,11 +721,14 @@ void intel_rps_unpark(struct intel_rps *rps)
* performance, jump directly to RPe as our starting frequency. * performance, jump directly to RPe as our starting frequency.
*/ */
mutex_lock(&rps->lock); mutex_lock(&rps->lock);
rps->active = true;
WRITE_ONCE(rps->active, true);
freq = max(rps->cur_freq, rps->efficient_freq), freq = max(rps->cur_freq, rps->efficient_freq),
freq = clamp(freq, rps->min_freq_softlimit, rps->max_freq_softlimit); freq = clamp(freq, rps->min_freq_softlimit, rps->max_freq_softlimit);
intel_rps_set(rps, freq); intel_rps_set(rps, freq);
rps->last_adj = 0; rps->last_adj = 0;
mutex_unlock(&rps->lock); mutex_unlock(&rps->lock);
if (INTEL_GEN(rps_to_i915(rps)) >= 6) if (INTEL_GEN(rps_to_i915(rps)) >= 6)
...@@ -745,7 +748,7 @@ void intel_rps_park(struct intel_rps *rps) ...@@ -745,7 +748,7 @@ void intel_rps_park(struct intel_rps *rps)
if (INTEL_GEN(i915) >= 6) if (INTEL_GEN(i915) >= 6)
rps_disable_interrupts(rps); rps_disable_interrupts(rps);
rps->active = false; WRITE_ONCE(rps->active, false);
if (rps->last_freq <= rps->idle_freq) if (rps->last_freq <= rps->idle_freq)
return; return;
...@@ -772,7 +775,7 @@ void intel_rps_boost(struct i915_request *rq) ...@@ -772,7 +775,7 @@ void intel_rps_boost(struct i915_request *rq)
struct intel_rps *rps = &rq->engine->gt->rps; struct intel_rps *rps = &rq->engine->gt->rps;
unsigned long flags; unsigned long flags;
if (i915_request_signaled(rq) || !rps->active) if (i915_request_signaled(rq) || !READ_ONCE(rps->active))
return; return;
/* Serializes with i915_request_retire() */ /* Serializes with i915_request_retire() */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment