* [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt
@ 2018-06-27 20:13 Chris Wilson
2018-06-27 20:13 ` [PATCH 2/4] drm/i915: Only trigger missed-seqno checking next to boundary Chris Wilson
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: Chris Wilson @ 2018-06-27 20:13 UTC (permalink / raw)
To: intel-gfx
By taking advantage of the RCU protection of the task struct, we can find
the appropriate signaler under the spinlock and then release the spinlock
before waking the task and signaling the fence.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
drivers/gpu/drm/i915/i915_irq.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 46aaef5c1851..56a080bc4498 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1145,21 +1145,23 @@ static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv)
static void notify_ring(struct intel_engine_cs *engine)
{
+ const u32 seqno = intel_engine_get_seqno(engine);
struct i915_request *rq = NULL;
+ struct task_struct *tsk = NULL;
struct intel_wait *wait;
- if (!engine->breadcrumbs.irq_armed)
+ if (unlikely(!engine->breadcrumbs.irq_armed))
return;
atomic_inc(&engine->irq_count);
- set_bit(ENGINE_IRQ_BREADCRUMB, &engine->irq_posted);
+
+ rcu_read_lock();
spin_lock(&engine->breadcrumbs.irq_lock);
wait = engine->breadcrumbs.irq_wait;
if (wait) {
- bool wakeup = engine->irq_seqno_barrier;
-
- /* We use a callback from the dma-fence to submit
+ /*
+ * We use a callback from the dma-fence to submit
* requests after waiting on our own requests. To
* ensure minimum delay in queuing the next request to
* hardware, signal the fence now rather than wait for
@@ -1170,19 +1172,22 @@ static void notify_ring(struct intel_engine_cs *engine)
* and to handle coalescing of multiple seqno updates
* and many waiters.
*/
- if (i915_seqno_passed(intel_engine_get_seqno(engine),
- wait->seqno)) {
+ if (i915_seqno_passed(seqno, wait->seqno)) {
struct i915_request *waiter = wait->request;
- wakeup = true;
if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
&waiter->fence.flags) &&
intel_wait_check_request(wait, waiter))
rq = i915_request_get(waiter);
- }
- if (wakeup)
- wake_up_process(wait->tsk);
+ tsk = wait->tsk;
+ } else {
+ if (engine->irq_seqno_barrier) {
+ set_bit(ENGINE_IRQ_BREADCRUMB,
+ &engine->irq_posted);
+ tsk = wait->tsk;
+ }
+ }
} else {
if (engine->breadcrumbs.irq_armed)
__intel_engine_disarm_breadcrumbs(engine);
@@ -1195,6 +1200,11 @@ static void notify_ring(struct intel_engine_cs *engine)
i915_request_put(rq);
}
+ if (tsk && tsk->state & TASK_NORMAL)
+ wake_up_process(tsk);
+
+ rcu_read_unlock();
+
trace_intel_engine_notify(engine, wait);
}
--
2.18.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] drm/i915: Only trigger missed-seqno checking next to boundary
2018-06-27 20:13 [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Chris Wilson
@ 2018-06-27 20:13 ` Chris Wilson
2018-06-28 8:06 ` Mika Kuoppala
2018-06-27 20:13 ` [PATCH 3/4] drm/i915: Move the irq_counter inside the spinlock Chris Wilson
` (4 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Chris Wilson @ 2018-06-27 20:13 UTC (permalink / raw)
To: intel-gfx
If we have more interrupts pending (because we know there are more
breadcrumb signals before the completion), then we do not need to
trigger an irq_seqno_barrier or even wakeup the task on this interrupt
as there will be another. To allow some margin of error (we are trying
to work around incoherent seqno after all), we wakeup the breadcrumb
before the target as well as on the target.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
drivers/gpu/drm/i915/i915_irq.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 56a080bc4498..55aba89adfb1 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1182,7 +1182,8 @@ static void notify_ring(struct intel_engine_cs *engine)
tsk = wait->tsk;
} else {
- if (engine->irq_seqno_barrier) {
+ if (engine->irq_seqno_barrier &&
+ i915_seqno_passed(seqno, wait->seqno - 1)) {
set_bit(ENGINE_IRQ_BREADCRUMB,
&engine->irq_posted);
tsk = wait->tsk;
--
2.18.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] drm/i915: Move the irq_counter inside the spinlock
2018-06-27 20:13 [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Chris Wilson
2018-06-27 20:13 ` [PATCH 2/4] drm/i915: Only trigger missed-seqno checking next to boundary Chris Wilson
@ 2018-06-27 20:13 ` Chris Wilson
2018-06-27 20:13 ` [PATCH 4/4] drm/i915: Only signal from interrupt when requested Chris Wilson
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Chris Wilson @ 2018-06-27 20:13 UTC (permalink / raw)
To: intel-gfx
Rather than have multiple locked instructions inside the notify_ring()
irq handler, move them inside the spinlock and reduce their intrinsic
locking.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
drivers/gpu/drm/i915/i915_irq.c | 4 ++--
drivers/gpu/drm/i915/i915_request.c | 4 ++--
drivers/gpu/drm/i915/intel_breadcrumbs.c | 11 +++++++----
drivers/gpu/drm/i915/intel_ringbuffer.h | 2 +-
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 55aba89adfb1..6adeaac48ea9 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1153,8 +1153,6 @@ static void notify_ring(struct intel_engine_cs *engine)
if (unlikely(!engine->breadcrumbs.irq_armed))
return;
- atomic_inc(&engine->irq_count);
-
rcu_read_lock();
spin_lock(&engine->breadcrumbs.irq_lock);
@@ -1189,6 +1187,8 @@ static void notify_ring(struct intel_engine_cs *engine)
tsk = wait->tsk;
}
}
+
+ engine->breadcrumbs.irq_count++;
} else {
if (engine->breadcrumbs.irq_armed)
__intel_engine_disarm_breadcrumbs(engine);
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index e1dbb544046f..39b296878ba2 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -1196,7 +1196,7 @@ static bool __i915_spin_request(const struct i915_request *rq,
* takes to sleep on a request, on the order of a microsecond.
*/
- irq = atomic_read(&engine->irq_count);
+ irq = READ_ONCE(engine->breadcrumbs.irq_count);
timeout_us += local_clock_us(&cpu);
do {
if (i915_seqno_passed(intel_engine_get_seqno(engine), seqno))
@@ -1208,7 +1208,7 @@ static bool __i915_spin_request(const struct i915_request *rq,
* assume we won't see one in the near future but require
* the engine->seqno_barrier() to fixup coherency.
*/
- if (atomic_read(&engine->irq_count) != irq)
+ if (READ_ONCE(engine->breadcrumbs.irq_count) != irq)
break;
if (signal_pending_state(state, current))
diff --git a/drivers/gpu/drm/i915/intel_breadcrumbs.c b/drivers/gpu/drm/i915/intel_breadcrumbs.c
index 86a987b8ac66..1db6ba7d926e 100644
--- a/drivers/gpu/drm/i915/intel_breadcrumbs.c
+++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c
@@ -98,12 +98,14 @@ static void intel_breadcrumbs_hangcheck(struct timer_list *t)
struct intel_engine_cs *engine =
from_timer(engine, t, breadcrumbs.hangcheck);
struct intel_breadcrumbs *b = &engine->breadcrumbs;
+ unsigned int irq_count;
if (!b->irq_armed)
return;
- if (b->hangcheck_interrupts != atomic_read(&engine->irq_count)) {
- b->hangcheck_interrupts = atomic_read(&engine->irq_count);
+ irq_count = READ_ONCE(b->irq_count);
+ if (b->hangcheck_interrupts != irq_count) {
+ b->hangcheck_interrupts = irq_count;
mod_timer(&b->hangcheck, wait_timeout());
return;
}
@@ -272,13 +274,14 @@ static bool use_fake_irq(const struct intel_breadcrumbs *b)
if (!test_bit(engine->id, &engine->i915->gpu_error.missed_irq_rings))
return false;
- /* Only start with the heavy weight fake irq timer if we have not
+ /*
+ * Only start with the heavy weight fake irq timer if we have not
* seen any interrupts since enabling it the first time. If the
* interrupts are still arriving, it means we made a mistake in our
* engine->seqno_barrier(), a timing error that should be transient
* and unlikely to reoccur.
*/
- return atomic_read(&engine->irq_count) == b->hangcheck_interrupts;
+ return READ_ONCE(b->irq_count) == b->hangcheck_interrupts;
}
static void enable_fake_irq(struct intel_breadcrumbs *b)
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index a0bc7a8222b4..44ac90ec540c 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -345,7 +345,6 @@ struct intel_engine_cs {
struct drm_i915_gem_object *default_state;
void *pinned_default_state;
- atomic_t irq_count;
unsigned long irq_posted;
#define ENGINE_IRQ_BREADCRUMB 0
#define ENGINE_IRQ_EXECLIST 1
@@ -380,6 +379,7 @@ struct intel_engine_cs {
unsigned int hangcheck_interrupts;
unsigned int irq_enabled;
+ unsigned int irq_count;
bool irq_armed : 1;
I915_SELFTEST_DECLARE(bool mock : 1);
--
2.18.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] drm/i915: Only signal from interrupt when requested
2018-06-27 20:13 [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Chris Wilson
2018-06-27 20:13 ` [PATCH 2/4] drm/i915: Only trigger missed-seqno checking next to boundary Chris Wilson
2018-06-27 20:13 ` [PATCH 3/4] drm/i915: Move the irq_counter inside the spinlock Chris Wilson
@ 2018-06-27 20:13 ` Chris Wilson
2018-06-27 21:14 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Patchwork
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Chris Wilson @ 2018-06-27 20:13 UTC (permalink / raw)
To: intel-gfx
Avoid calling dma_fence_signal() from inside the interrupt if we haven't
enabled signaling on the request.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
drivers/gpu/drm/i915/i915_irq.c | 8 ++++++--
drivers/gpu/drm/i915/i915_request.c | 2 +-
drivers/gpu/drm/i915/intel_ringbuffer.h | 5 ++---
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 6adeaac48ea9..1eba2c3895fc 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1173,7 +1173,8 @@ static void notify_ring(struct intel_engine_cs *engine)
if (i915_seqno_passed(seqno, wait->seqno)) {
struct i915_request *waiter = wait->request;
- if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
+ if (waiter &&
+ !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
&waiter->fence.flags) &&
intel_wait_check_request(wait, waiter))
rq = i915_request_get(waiter);
@@ -1196,8 +1197,11 @@ static void notify_ring(struct intel_engine_cs *engine)
spin_unlock(&engine->breadcrumbs.irq_lock);
if (rq) {
- dma_fence_signal(&rq->fence);
+ spin_lock(&rq->lock);
+ dma_fence_signal_locked(&rq->fence);
GEM_BUG_ON(!i915_request_completed(rq));
+ spin_unlock(&rq->lock);
+
i915_request_put(rq);
}
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index 39b296878ba2..a2f7e9358450 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -1285,7 +1285,7 @@ long i915_request_wait(struct i915_request *rq,
if (flags & I915_WAIT_LOCKED)
add_wait_queue(errq, &reset);
- intel_wait_init(&wait, rq);
+ intel_wait_init(&wait);
restart:
do {
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 44ac90ec540c..78f01a35823a 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -928,11 +928,10 @@ static inline u32 intel_hws_preempt_done_address(struct intel_engine_cs *engine)
/* intel_breadcrumbs.c -- user interrupt bottom-half for waiters */
int intel_engine_init_breadcrumbs(struct intel_engine_cs *engine);
-static inline void intel_wait_init(struct intel_wait *wait,
- struct i915_request *rq)
+static inline void intel_wait_init(struct intel_wait *wait)
{
wait->tsk = current;
- wait->request = rq;
+ wait->request = NULL;
}
static inline void intel_wait_init_for_seqno(struct intel_wait *wait, u32 seqno)
--
2.18.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 9+ messages in thread
* ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt
2018-06-27 20:13 [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Chris Wilson
` (2 preceding siblings ...)
2018-06-27 20:13 ` [PATCH 4/4] drm/i915: Only signal from interrupt when requested Chris Wilson
@ 2018-06-27 21:14 ` Patchwork
2018-06-28 2:22 ` ✓ Fi.CI.IGT: " Patchwork
2018-06-28 8:04 ` [PATCH 1/4] " Mika Kuoppala
5 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2018-06-27 21:14 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: series starting with [1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt
URL : https://patchwork.freedesktop.org/series/45527/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4391 -> Patchwork_9454 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/45527/revisions/1/mbox/
== Known issues ==
Here are the changes found in Patchwork_9454 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
fi-snb-2520m: PASS -> INCOMPLETE (fdo#103713)
==== Possible fixes ====
igt@gem_ctx_create@basic-files:
fi-glk-dsi: DMESG-WARN (fdo#106954) -> PASS
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#106954 https://bugs.freedesktop.org/show_bug.cgi?id=106954
== Participating hosts (44 -> 40) ==
Additional (1): fi-byt-j1900
Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u
== Build changes ==
* Linux: CI_DRM_4391 -> Patchwork_9454
CI_DRM_4391: 9134bde2e681ec232f4d8bec56aa3700177630fe @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4530: 0e98bf69f146eb72fe3a7c3b19a049b5786f0ca3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9454: 4788e34a2edeb12c5bb8d598a60ec225d6302413 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
4788e34a2ede drm/i915: Only signal from interrupt when requested
02f0fc1f0fcb drm/i915: Move the irq_counter inside the spinlock
e209cc72ebfc drm/i915: Only trigger missed-seqno checking next to boundary
1f5a0a938f95 drm/i915: Reduce spinlock hold time during notify_ring() interrupt
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9454/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
* ✓ Fi.CI.IGT: success for series starting with [1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt
2018-06-27 20:13 [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Chris Wilson
` (3 preceding siblings ...)
2018-06-27 21:14 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Patchwork
@ 2018-06-28 2:22 ` Patchwork
2018-06-28 8:04 ` [PATCH 1/4] " Mika Kuoppala
5 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2018-06-28 2:22 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: series starting with [1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt
URL : https://patchwork.freedesktop.org/series/45527/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4391_full -> Patchwork_9454_full =
== Summary - WARNING ==
Minor unknown changes coming with Patchwork_9454_full need to be verified
manually.
If you think the reported changes have nothing to do with the changes
introduced in Patchwork_9454_full, please notify your bug team to allow them
to document this new failure mode, which will reduce false positives in CI.
== Possible new issues ==
Here are the unknown changes that may have been introduced in Patchwork_9454_full:
=== IGT changes ===
==== Possible regressions ====
igt@drv_selftest@mock_scatterlist:
{shard-glk9}: NOTRUN -> DMESG-WARN
igt@testdisplay:
{shard-glk9}: NOTRUN -> INCOMPLETE +1
==== Warnings ====
igt@gem_linear_blits@interruptible:
shard-apl: SKIP -> PASS
igt@gem_mocs_settings@mocs-rc6-blt:
shard-kbl: PASS -> SKIP
== Known issues ==
Here are the changes found in Patchwork_9454_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@gem_exec_schedule@pi-ringfull-vebox:
{shard-glk9}: NOTRUN -> FAIL (fdo#103158)
igt@kms_flip_tiling@flip-to-y-tiled:
shard-glk: PASS -> FAIL (fdo#104724)
igt@kms_flip_tiling@flip-x-tiled:
shard-glk: NOTRUN -> FAIL (fdo#103822, fdo#104724)
==== Possible fixes ====
igt@kms_flip_tiling@flip-y-tiled:
shard-glk: FAIL (fdo#103822, fdo#104724) -> PASS
igt@kms_setmode@basic:
shard-apl: FAIL (fdo#99912) -> PASS
shard-kbl: FAIL (fdo#99912) -> PASS
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (6 -> 6) ==
No changes in participating hosts
== Build changes ==
* Linux: CI_DRM_4391 -> Patchwork_9454
CI_DRM_4391: 9134bde2e681ec232f4d8bec56aa3700177630fe @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4530: 0e98bf69f146eb72fe3a7c3b19a049b5786f0ca3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9454: 4788e34a2edeb12c5bb8d598a60ec225d6302413 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9454/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt
2018-06-27 20:13 [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Chris Wilson
` (4 preceding siblings ...)
2018-06-28 2:22 ` ✓ Fi.CI.IGT: " Patchwork
@ 2018-06-28 8:04 ` Mika Kuoppala
5 siblings, 0 replies; 9+ messages in thread
From: Mika Kuoppala @ 2018-06-28 8:04 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
Chris Wilson <chris@chris-wilson.co.uk> writes:
> By taking advantage of the RCU protection of the task struct, we can find
> the appropriate signaler under the spinlock and then release the spinlock
> before waking the task and signaling the fence.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_irq.c | 32 +++++++++++++++++++++-----------
> 1 file changed, 21 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 46aaef5c1851..56a080bc4498 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -1145,21 +1145,23 @@ static void ironlake_rps_change_irq_handler(struct drm_i915_private *dev_priv)
>
> static void notify_ring(struct intel_engine_cs *engine)
> {
> + const u32 seqno = intel_engine_get_seqno(engine);
> struct i915_request *rq = NULL;
> + struct task_struct *tsk = NULL;
> struct intel_wait *wait;
>
> - if (!engine->breadcrumbs.irq_armed)
> + if (unlikely(!engine->breadcrumbs.irq_armed))
> return;
>
> atomic_inc(&engine->irq_count);
> - set_bit(ENGINE_IRQ_BREADCRUMB, &engine->irq_posted);
> +
> + rcu_read_lock();
>
> spin_lock(&engine->breadcrumbs.irq_lock);
> wait = engine->breadcrumbs.irq_wait;
> if (wait) {
> - bool wakeup = engine->irq_seqno_barrier;
> -
> - /* We use a callback from the dma-fence to submit
> + /*
> + * We use a callback from the dma-fence to submit
> * requests after waiting on our own requests. To
> * ensure minimum delay in queuing the next request to
> * hardware, signal the fence now rather than wait for
> @@ -1170,19 +1172,22 @@ static void notify_ring(struct intel_engine_cs *engine)
> * and to handle coalescing of multiple seqno updates
> * and many waiters.
> */
> - if (i915_seqno_passed(intel_engine_get_seqno(engine),
> - wait->seqno)) {
> + if (i915_seqno_passed(seqno, wait->seqno)) {
> struct i915_request *waiter = wait->request;
>
> - wakeup = true;
> if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
> &waiter->fence.flags) &&
> intel_wait_check_request(wait, waiter))
> rq = i915_request_get(waiter);
> - }
>
> - if (wakeup)
> - wake_up_process(wait->tsk);
> + tsk = wait->tsk;
> + } else {
> + if (engine->irq_seqno_barrier) {
> + set_bit(ENGINE_IRQ_BREADCRUMB,
> + &engine->irq_posted);
> + tsk = wait->tsk;
> + }
> + }
> } else {
> if (engine->breadcrumbs.irq_armed)
> __intel_engine_disarm_breadcrumbs(engine);
> @@ -1195,6 +1200,11 @@ static void notify_ring(struct intel_engine_cs *engine)
> i915_request_put(rq);
> }
>
> + if (tsk && tsk->state & TASK_NORMAL)
> + wake_up_process(tsk);
> +
> + rcu_read_unlock();
> +
> trace_intel_engine_notify(engine, wait);
> }
>
> --
> 2.18.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/4] drm/i915: Only trigger missed-seqno checking next to boundary
2018-06-27 20:13 ` [PATCH 2/4] drm/i915: Only trigger missed-seqno checking next to boundary Chris Wilson
@ 2018-06-28 8:06 ` Mika Kuoppala
2018-06-28 20:06 ` Chris Wilson
0 siblings, 1 reply; 9+ messages in thread
From: Mika Kuoppala @ 2018-06-28 8:06 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
Chris Wilson <chris@chris-wilson.co.uk> writes:
> If we have more interrupts pending (because we know there are more
> breadcrumb signals before the completion), then we do not need to
> trigger an irq_seqno_barrier or even wakeup the task on this interrupt
> as there will be another. To allow some margin of error (we are trying
> to work around incoherent seqno after all), we wakeup the breadcrumb
> before the target as well as on the target.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Thanks for splitting this out.
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_irq.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 56a080bc4498..55aba89adfb1 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -1182,7 +1182,8 @@ static void notify_ring(struct intel_engine_cs *engine)
>
> tsk = wait->tsk;
> } else {
> - if (engine->irq_seqno_barrier) {
> + if (engine->irq_seqno_barrier &&
> + i915_seqno_passed(seqno, wait->seqno - 1)) {
> set_bit(ENGINE_IRQ_BREADCRUMB,
> &engine->irq_posted);
> tsk = wait->tsk;
> --
> 2.18.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/4] drm/i915: Only trigger missed-seqno checking next to boundary
2018-06-28 8:06 ` Mika Kuoppala
@ 2018-06-28 20:06 ` Chris Wilson
0 siblings, 0 replies; 9+ messages in thread
From: Chris Wilson @ 2018-06-28 20:06 UTC (permalink / raw)
To: Mika Kuoppala, intel-gfx
Quoting Mika Kuoppala (2018-06-28 09:06:37)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
>
> > If we have more interrupts pending (because we know there are more
> > breadcrumb signals before the completion), then we do not need to
> > trigger an irq_seqno_barrier or even wakeup the task on this interrupt
> > as there will be another. To allow some margin of error (we are trying
> > to work around incoherent seqno after all), we wakeup the breadcrumb
> > before the target as well as on the target.
> >
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
>
> Thanks for splitting this out.
>
> Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
And applied, thanks for the review.
Fingers crossed as always when touching interrupt handling.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-06-28 20:06 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-27 20:13 [PATCH 1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Chris Wilson
2018-06-27 20:13 ` [PATCH 2/4] drm/i915: Only trigger missed-seqno checking next to boundary Chris Wilson
2018-06-28 8:06 ` Mika Kuoppala
2018-06-28 20:06 ` Chris Wilson
2018-06-27 20:13 ` [PATCH 3/4] drm/i915: Move the irq_counter inside the spinlock Chris Wilson
2018-06-27 20:13 ` [PATCH 4/4] drm/i915: Only signal from interrupt when requested Chris Wilson
2018-06-27 21:14 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: Reduce spinlock hold time during notify_ring() interrupt Patchwork
2018-06-28 2:22 ` ✓ Fi.CI.IGT: " Patchwork
2018-06-28 8:04 ` [PATCH 1/4] " Mika Kuoppala
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).