All of lore.kernel.org
 help / color / mirror / Atom feed
* [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms
@ 2019-05-27 11:10 Chris Wilson
  2019-05-27 11:22 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5) Patchwork
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Chris Wilson @ 2019-05-27 11:10 UTC (permalink / raw)
  To: intel-gfx

Do not allow runtime pm autosuspend to remove userspace GGTT mmaps too
quickly. For example, igt sets the autosuspend delay to 0, and so we
immediately attempt to perform runtime suspend upon releasing the
wakeref. Unfortunately, that involves tearing down GGTT mmaps as they
require an active device.

Override the autosuspend for GGTT mmaps, by keeping the wakeref around
for 250ms after populating the PTE for a fresh mmap.

v2: Prefer refcount_t for its under/overflow error detection
v3: Flush the user runtime autosuspend prior to system system.

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/Kconfig.profile | 14 +++++++
 drivers/gpu/drm/i915/i915_drv.h      |  3 ++
 drivers/gpu/drm/i915/i915_gem.c      |  7 ++++
 drivers/gpu/drm/i915/i915_gem_pm.c   |  1 +
 drivers/gpu/drm/i915/intel_wakeref.c | 62 ++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_wakeref.h | 31 ++++++++++++++
 6 files changed, 118 insertions(+)

diff --git a/drivers/gpu/drm/i915/Kconfig.profile b/drivers/gpu/drm/i915/Kconfig.profile
index 0e5db98da8f3..4fd1ea639d0f 100644
--- a/drivers/gpu/drm/i915/Kconfig.profile
+++ b/drivers/gpu/drm/i915/Kconfig.profile
@@ -1,3 +1,17 @@
+config DRM_I915_USERFAULT_AUTOSUSPEND
+	int "Runtime autosuspend delay for userspace GGTT mmaps (ms)"
+	default 250 # milliseconds
+	help
+	  On runtime suspend, as we suspend the device, we have to revoke
+	  userspace GGTT mmaps and force userspace to take a pagefault on
+	  their next access. The revocation and subsequent recreation of
+	  the GGTT mmap can be very slow and so we impose a small hysteris
+	  that complements the runtime-pm autosuspend and provides a lower
+	  floor on the autosuspend delay.
+
+	  May be 0 to disable the extra delay and solely use the device level
+	  runtime pm autosuspend delay tunable.
+
 config DRM_I915_SPIN_REQUEST
 	int
 	default 5 # microseconds
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a2664ea1395b..e7452d6b663f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -874,6 +874,9 @@ struct i915_gem_mm {
 	 */
 	struct list_head userfault_list;
 
+	/* Manual runtime pm autosuspend delay for user GGTT mmaps */
+	struct intel_wakeref_auto userfault_wakeref;
+
 	/**
 	 * List of objects which are pending destruction.
 	 */
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index d3b7dac527dc..902162c04d35 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1834,6 +1834,9 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 	assert_rpm_wakelock_held(dev_priv);
 	if (!i915_vma_set_userfault(vma) && !obj->userfault_count++)
 		list_add(&obj->userfault_link, &dev_priv->mm.userfault_list);
+	if (CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND)
+		intel_wakeref_auto(&dev_priv->mm.userfault_wakeref,
+				   msecs_to_jiffies_timeout(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND));
 	GEM_BUG_ON(!obj->userfault_count);
 
 	i915_vma_set_ggtt_write(vma);
@@ -4671,6 +4674,8 @@ void i915_gem_fini(struct drm_i915_private *dev_priv)
 {
 	GEM_BUG_ON(dev_priv->gt.awake);
 
+	intel_wakeref_auto_fini(&dev_priv->mm.userfault_wakeref);
+
 	i915_gem_suspend_late(dev_priv);
 	intel_disable_gt_powersave(dev_priv);
 
@@ -4746,7 +4751,9 @@ static void i915_gem_init__mm(struct drm_i915_private *i915)
 	INIT_LIST_HEAD(&i915->mm.unbound_list);
 	INIT_LIST_HEAD(&i915->mm.bound_list);
 	INIT_LIST_HEAD(&i915->mm.fence_list);
+
 	INIT_LIST_HEAD(&i915->mm.userfault_list);
+	intel_wakeref_auto_init(&i915->mm.userfault_wakeref, i915);
 
 	INIT_WORK(&i915->mm.free_work, __i915_gem_free_work);
 }
diff --git a/drivers/gpu/drm/i915/i915_gem_pm.c b/drivers/gpu/drm/i915/i915_gem_pm.c
index fa9c2ebd966a..c0ad19605297 100644
--- a/drivers/gpu/drm/i915/i915_gem_pm.c
+++ b/drivers/gpu/drm/i915/i915_gem_pm.c
@@ -126,6 +126,7 @@ void i915_gem_suspend(struct drm_i915_private *i915)
 {
 	GEM_TRACE("\n");
 
+	intel_wakeref_auto(&i915->mm.userfault_wakeref, 0);
 	flush_workqueue(i915->wq);
 
 	mutex_lock(&i915->drm.struct_mutex);
diff --git a/drivers/gpu/drm/i915/intel_wakeref.c b/drivers/gpu/drm/i915/intel_wakeref.c
index 91196d9612bb..84b49056e677 100644
--- a/drivers/gpu/drm/i915/intel_wakeref.c
+++ b/drivers/gpu/drm/i915/intel_wakeref.c
@@ -73,3 +73,65 @@ void __intel_wakeref_init(struct intel_wakeref *wf, struct lock_class_key *key)
 	atomic_set(&wf->count, 0);
 	wf->wakeref = 0;
 }
+
+static void wakeref_auto_timeout(struct timer_list *t)
+{
+	struct intel_wakeref_auto *wf = from_timer(wf, t, timer);
+	intel_wakeref_t wakeref;
+	unsigned long flags;
+
+	if (!refcount_dec_and_lock_irqsave(&wf->count, &wf->lock, &flags))
+		return;
+
+	wakeref = fetch_and_zero(&wf->wakeref);
+	spin_unlock_irqrestore(&wf->lock, flags);
+
+	intel_runtime_pm_put(wf->i915, wakeref);
+}
+
+void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
+			     struct drm_i915_private *i915)
+{
+	spin_lock_init(&wf->lock);
+	timer_setup(&wf->timer, wakeref_auto_timeout, 0);
+	refcount_set(&wf->count, 0);
+	wf->wakeref = 0;
+	wf->i915 = i915;
+}
+
+void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout)
+{
+	unsigned long flags;
+
+	if (!timeout && del_timer_sync(&wf->timer)) {
+		wakeref_auto_timeout(&wf->timer);
+		return;
+	}
+
+	/* Our mission is that we only extend an already active wakeref */
+	assert_rpm_wakelock_held(wf->i915);
+
+	if (!refcount_inc_not_zero(&wf->count)) {
+		spin_lock_irqsave(&wf->lock, flags);
+		if (!refcount_read(&wf->count)) {
+			GEM_BUG_ON(wf->wakeref);
+			wf->wakeref = intel_runtime_pm_get_if_in_use(wf->i915);
+		}
+		refcount_inc(&wf->count);
+		spin_unlock_irqrestore(&wf->lock, flags);
+	}
+
+	/*
+	 * If we extend a pending timer, we will only get a single timer
+	 * callback and so need to cancel the local inc by running the
+	 * elided callback to keep the wf->count balanced.
+	 */
+	if (mod_timer(&wf->timer, jiffies + timeout))
+		wakeref_auto_timeout(&wf->timer);
+}
+
+void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf)
+{
+	intel_wakeref_auto(wf, 0);
+	GEM_BUG_ON(wf->wakeref);
+}
diff --git a/drivers/gpu/drm/i915/intel_wakeref.h b/drivers/gpu/drm/i915/intel_wakeref.h
index db742291211c..8a5f85c000ce 100644
--- a/drivers/gpu/drm/i915/intel_wakeref.h
+++ b/drivers/gpu/drm/i915/intel_wakeref.h
@@ -9,7 +9,9 @@
 
 #include <linux/atomic.h>
 #include <linux/mutex.h>
+#include <linux/refcount.h>
 #include <linux/stackdepot.h>
+#include <linux/timer.h>
 
 struct drm_i915_private;
 
@@ -130,4 +132,33 @@ intel_wakeref_active(struct intel_wakeref *wf)
 	return READ_ONCE(wf->wakeref);
 }
 
+struct intel_wakeref_auto {
+	struct drm_i915_private *i915;
+	struct timer_list timer;
+	intel_wakeref_t wakeref;
+	spinlock_t lock;
+	refcount_t count;
+};
+
+/**
+ * intel_wakeref_auto: Delay the runtime-pm autosuspend
+ * @wf: the wakeref
+ * @timeout: relative timeout in jiffies
+ *
+ * The runtime-pm core uses a suspend delay after the last wakeref
+ * is released before triggering runtime suspend of the device. That
+ * delay is configurable via sysfs with little regard to the device
+ * characteristics. Instead, we want to tune the autosuspend based on our
+ * HW knowledge. intel_wakeref_auto() delays the sleep by the supplied
+ * timeout.
+ *
+ * Pass @timeout = 0 to cancel a previous autosuspend by executing the
+ * suspend immediately.
+ */
+void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout);
+
+void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
+			     struct drm_i915_private *i915);
+void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf);
+
 #endif /* INTEL_WAKEREF_H */
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5)
  2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
@ 2019-05-27 11:22 ` Patchwork
  2019-05-27 11:23 ` ✗ Fi.CI.SPARSE: " Patchwork
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2019-05-27 11:22 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5)
URL   : https://patchwork.freedesktop.org/series/61047/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
6e1b0f65e952 drm/i915: Keep user GGTT alive for a minimum of 250ms
-:195: CHECK:UNCOMMENTED_DEFINITION: spinlock_t definition without comment
#195: FILE: drivers/gpu/drm/i915/intel_wakeref.h:139:
+	spinlock_t lock;

total: 0 errors, 0 warnings, 1 checks, 166 lines checked

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* ✗ Fi.CI.SPARSE: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5)
  2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
  2019-05-27 11:22 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5) Patchwork
@ 2019-05-27 11:23 ` Patchwork
  2019-05-27 11:47 ` ✗ Fi.CI.BAT: failure " Patchwork
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2019-05-27 11:23 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5)
URL   : https://patchwork.freedesktop.org/series/61047/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.5.2
Commit: drm/i915: Keep user GGTT alive for a minimum of 250ms
+
+drivers/gpu/drm/i915/i915_utils.h:220:16: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/intel_wakeref.c:86:19: warning: context imbalance in 'wakeref_auto_timeout' - unexpected unlock
+Error in reading or end of file.

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* ✗ Fi.CI.BAT: failure for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5)
  2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
  2019-05-27 11:22 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5) Patchwork
  2019-05-27 11:23 ` ✗ Fi.CI.SPARSE: " Patchwork
@ 2019-05-27 11:47 ` Patchwork
  2019-05-27 11:51 ` [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2019-05-27 11:47 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5)
URL   : https://patchwork.freedesktop.org/series/61047/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6147 -> Patchwork_13105
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_13105 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_13105, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_13105:

### IGT changes ###

#### Possible regressions ####

  * igt@i915_module_load@reload:
    - fi-kbl-r:           [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-kbl-r/igt@i915_module_load@reload.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-r/igt@i915_module_load@reload.html
    - fi-whl-u:           [PASS][3] -> [INCOMPLETE][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-whl-u/igt@i915_module_load@reload.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-whl-u/igt@i915_module_load@reload.html
    - fi-skl-iommu:       [PASS][5] -> [INCOMPLETE][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-iommu/igt@i915_module_load@reload.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-iommu/igt@i915_module_load@reload.html
    - fi-hsw-4770r:       [PASS][7] -> [INCOMPLETE][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-hsw-4770r/igt@i915_module_load@reload.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-hsw-4770r/igt@i915_module_load@reload.html
    - fi-skl-6700k2:      [PASS][9] -> [INCOMPLETE][10]
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-6700k2/igt@i915_module_load@reload.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-6700k2/igt@i915_module_load@reload.html
    - fi-bsw-kefka:       [PASS][11] -> [INCOMPLETE][12]
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-bsw-kefka/igt@i915_module_load@reload.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bsw-kefka/igt@i915_module_load@reload.html
    - fi-bdw-5557u:       [PASS][13] -> [INCOMPLETE][14]
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-bdw-5557u/igt@i915_module_load@reload.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bdw-5557u/igt@i915_module_load@reload.html
    - fi-skl-guc:         [PASS][15] -> [INCOMPLETE][16]
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-guc/igt@i915_module_load@reload.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-guc/igt@i915_module_load@reload.html
    - fi-kbl-guc:         [PASS][17] -> [INCOMPLETE][18]
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-kbl-guc/igt@i915_module_load@reload.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-guc/igt@i915_module_load@reload.html
    - fi-cfl-8109u:       [PASS][19] -> [INCOMPLETE][20]
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-cfl-8109u/igt@i915_module_load@reload.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cfl-8109u/igt@i915_module_load@reload.html
    - fi-kbl-7500u:       [PASS][21] -> [INCOMPLETE][22]
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-kbl-7500u/igt@i915_module_load@reload.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-7500u/igt@i915_module_load@reload.html
    - fi-cfl-8700k:       [PASS][23] -> [INCOMPLETE][24]
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-cfl-8700k/igt@i915_module_load@reload.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cfl-8700k/igt@i915_module_load@reload.html
    - fi-snb-2520m:       [PASS][25] -> [INCOMPLETE][26]
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-snb-2520m/igt@i915_module_load@reload.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-snb-2520m/igt@i915_module_load@reload.html
    - fi-hsw-4770:        [PASS][27] -> [INCOMPLETE][28]
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-hsw-4770/igt@i915_module_load@reload.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-hsw-4770/igt@i915_module_load@reload.html
    - fi-cfl-guc:         [PASS][29] -> [INCOMPLETE][30]
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-cfl-guc/igt@i915_module_load@reload.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cfl-guc/igt@i915_module_load@reload.html
    - fi-skl-6770hq:      [PASS][31] -> [INCOMPLETE][32]
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-6770hq/igt@i915_module_load@reload.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-6770hq/igt@i915_module_load@reload.html
    - fi-bsw-n3050:       NOTRUN -> [INCOMPLETE][33]
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bsw-n3050/igt@i915_module_load@reload.html
    - fi-ilk-650:         [PASS][34] -> [INCOMPLETE][35]
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-ilk-650/igt@i915_module_load@reload.html
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-ilk-650/igt@i915_module_load@reload.html
    - fi-ivb-3770:        [PASS][36] -> [INCOMPLETE][37]
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-ivb-3770/igt@i915_module_load@reload.html
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-ivb-3770/igt@i915_module_load@reload.html
    - fi-skl-lmem:        [PASS][38] -> [INCOMPLETE][39]
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-lmem/igt@i915_module_load@reload.html
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-lmem/igt@i915_module_load@reload.html
    - fi-hsw-peppy:       [PASS][40] -> [INCOMPLETE][41]
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-hsw-peppy/igt@i915_module_load@reload.html
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-hsw-peppy/igt@i915_module_load@reload.html
    - fi-skl-6260u:       [PASS][42] -> [INCOMPLETE][43]
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-6260u/igt@i915_module_load@reload.html
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-6260u/igt@i915_module_load@reload.html
    - fi-kbl-7567u:       [PASS][44] -> [INCOMPLETE][45]
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-kbl-7567u/igt@i915_module_load@reload.html
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-7567u/igt@i915_module_load@reload.html
    - fi-kbl-x1275:       [PASS][46] -> [INCOMPLETE][47]
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-kbl-x1275/igt@i915_module_load@reload.html
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-x1275/igt@i915_module_load@reload.html
    - fi-gdg-551:         [PASS][48] -> [INCOMPLETE][49]
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-gdg-551/igt@i915_module_load@reload.html
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-gdg-551/igt@i915_module_load@reload.html

  * igt@i915_module_load@reload-no-display:
    - fi-bwr-2160:        [PASS][50] -> [INCOMPLETE][51]
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-bwr-2160/igt@i915_module_load@reload-no-display.html
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bwr-2160/igt@i915_module_load@reload-no-display.html

  * igt@runner@aborted:
    - fi-ilk-650:         NOTRUN -> [FAIL][52]
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-ilk-650/igt@runner@aborted.html
    - fi-pnv-d510:        NOTRUN -> [FAIL][53]
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-pnv-d510/igt@runner@aborted.html
    - fi-bdw-gvtdvm:      NOTRUN -> [FAIL][54]
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bdw-gvtdvm/igt@runner@aborted.html
    - fi-cfl-8109u:       NOTRUN -> [FAIL][55]
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cfl-8109u/igt@runner@aborted.html
    - fi-hsw-peppy:       NOTRUN -> [FAIL][56]
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-hsw-peppy/igt@runner@aborted.html
    - fi-icl-u2:          NOTRUN -> [FAIL][57]
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-icl-u2/igt@runner@aborted.html
    - fi-gdg-551:         NOTRUN -> [FAIL][58]
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-gdg-551/igt@runner@aborted.html
    - fi-snb-2520m:       NOTRUN -> [FAIL][59]
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-snb-2520m/igt@runner@aborted.html
    - fi-hsw-4770:        NOTRUN -> [FAIL][60]
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-hsw-4770/igt@runner@aborted.html
    - fi-kbl-7500u:       NOTRUN -> [FAIL][61]
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-7500u/igt@runner@aborted.html
    - fi-bxt-j4205:       NOTRUN -> [FAIL][62]
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bxt-j4205/igt@runner@aborted.html
    - fi-whl-u:           NOTRUN -> [FAIL][63]
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-whl-u/igt@runner@aborted.html
    - fi-cml-u2:          NOTRUN -> [FAIL][64]
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cml-u2/igt@runner@aborted.html
    - fi-icl-u3:          NOTRUN -> [FAIL][65]
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-icl-u3/igt@runner@aborted.html
    - fi-ivb-3770:        NOTRUN -> [FAIL][66]
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-ivb-3770/igt@runner@aborted.html
    - fi-bxt-dsi:         NOTRUN -> [FAIL][67]
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bxt-dsi/igt@runner@aborted.html
    - fi-byt-j1900:       NOTRUN -> [FAIL][68]
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-byt-j1900/igt@runner@aborted.html
    - fi-icl-y:           NOTRUN -> [FAIL][69]
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-icl-y/igt@runner@aborted.html
    - fi-kbl-7567u:       NOTRUN -> [FAIL][70]
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-7567u/igt@runner@aborted.html
    - fi-bsw-n3050:       NOTRUN -> [FAIL][71]
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bsw-n3050/igt@runner@aborted.html
    - fi-blb-e6850:       NOTRUN -> [FAIL][72]
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-blb-e6850/igt@runner@aborted.html
    - fi-kbl-x1275:       NOTRUN -> [FAIL][73]
   [73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-x1275/igt@runner@aborted.html
    - fi-bsw-kefka:       NOTRUN -> [FAIL][74]
   [74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bsw-kefka/igt@runner@aborted.html
    - fi-cfl-8700k:       NOTRUN -> [FAIL][75]
   [75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cfl-8700k/igt@runner@aborted.html
    - fi-hsw-4770r:       NOTRUN -> [FAIL][76]
   [76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-hsw-4770r/igt@runner@aborted.html
    - fi-kbl-8809g:       NOTRUN -> [FAIL][77]
   [77]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-8809g/igt@runner@aborted.html
    - fi-kbl-r:           NOTRUN -> [FAIL][78]
   [78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-r/igt@runner@aborted.html
    - fi-bdw-5557u:       NOTRUN -> [FAIL][79]
   [79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bdw-5557u/igt@runner@aborted.html
    - fi-byt-n2820:       NOTRUN -> [FAIL][80]
   [80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-byt-n2820/igt@runner@aborted.html
    - fi-snb-2600:        NOTRUN -> [FAIL][81]
   [81]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-snb-2600/igt@runner@aborted.html
    - fi-elk-e7500:       NOTRUN -> [FAIL][82]
   [82]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-elk-e7500/igt@runner@aborted.html

  
Known issues
------------

  Here are the changes found in Patchwork_13105 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_create@basic-files:
    - fi-cml-u:           [PASS][83] -> [INCOMPLETE][84] ([fdo#110566])
   [83]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-cml-u/igt@gem_ctx_create@basic-files.html
   [84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cml-u/igt@gem_ctx_create@basic-files.html

  * igt@i915_module_load@reload:
    - fi-kbl-8809g:       [PASS][85] -> [INCOMPLETE][86] ([fdo#103665])
   [85]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-kbl-8809g/igt@i915_module_load@reload.html
   [86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-8809g/igt@i915_module_load@reload.html
    - fi-byt-j1900:       [PASS][87] -> [INCOMPLETE][88] ([fdo#102657])
   [87]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-byt-j1900/igt@i915_module_load@reload.html
   [88]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-byt-j1900/igt@i915_module_load@reload.html
    - fi-skl-6600u:       [PASS][89] -> [INCOMPLETE][90] ([fdo#104108])
   [89]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-6600u/igt@i915_module_load@reload.html
   [90]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-6600u/igt@i915_module_load@reload.html
    - fi-elk-e7500:       [PASS][91] -> [INCOMPLETE][92] ([fdo#103989])
   [91]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-elk-e7500/igt@i915_module_load@reload.html
   [92]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-elk-e7500/igt@i915_module_load@reload.html
    - fi-glk-dsi:         [PASS][93] -> [INCOMPLETE][94] ([fdo#103359] / [k.org#198133])
   [93]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-glk-dsi/igt@i915_module_load@reload.html
   [94]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-glk-dsi/igt@i915_module_load@reload.html
    - fi-bdw-gvtdvm:      [PASS][95] -> [INCOMPLETE][96] ([fdo#105600])
   [95]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-bdw-gvtdvm/igt@i915_module_load@reload.html
   [96]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bdw-gvtdvm/igt@i915_module_load@reload.html
    - fi-cml-u2:          [PASS][97] -> [INCOMPLETE][98] ([fdo#110566])
   [97]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-cml-u2/igt@i915_module_load@reload.html
   [98]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cml-u2/igt@i915_module_load@reload.html
    - fi-bxt-dsi:         [PASS][99] -> [INCOMPLETE][100] ([fdo#103927])
   [99]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-bxt-dsi/igt@i915_module_load@reload.html
   [100]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bxt-dsi/igt@i915_module_load@reload.html
    - fi-skl-gvtdvm:      [PASS][101] -> [INCOMPLETE][102] ([fdo#105600])
   [101]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-gvtdvm/igt@i915_module_load@reload.html
   [102]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-gvtdvm/igt@i915_module_load@reload.html
    - fi-bxt-j4205:       [PASS][103] -> [INCOMPLETE][104] ([fdo#103927])
   [103]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-bxt-j4205/igt@i915_module_load@reload.html
   [104]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-bxt-j4205/igt@i915_module_load@reload.html
    - fi-byt-n2820:       [PASS][105] -> [INCOMPLETE][106] ([fdo#102657])
   [105]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-byt-n2820/igt@i915_module_load@reload.html
   [106]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-byt-n2820/igt@i915_module_load@reload.html
    - fi-icl-u3:          [PASS][107] -> [INCOMPLETE][108] ([fdo#107713])
   [107]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-icl-u3/igt@i915_module_load@reload.html
   [108]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-icl-u3/igt@i915_module_load@reload.html
    - fi-snb-2600:        [PASS][109] -> [INCOMPLETE][110] ([fdo#105411])
   [109]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-snb-2600/igt@i915_module_load@reload.html
   [110]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-snb-2600/igt@i915_module_load@reload.html
    - fi-icl-y:           [PASS][111] -> [INCOMPLETE][112] ([fdo#107713])
   [111]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-icl-y/igt@i915_module_load@reload.html
   [112]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-icl-y/igt@i915_module_load@reload.html

  * igt@kms_chamelium@dp-crc-fast:
    - fi-cml-u2:          [PASS][113] -> [FAIL][114] ([fdo#110627])
   [113]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-cml-u2/igt@kms_chamelium@dp-crc-fast.html
   [114]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-cml-u2/igt@kms_chamelium@dp-crc-fast.html

  
#### Possible fixes ####

  * igt@gem_exec_suspend@basic-s3:
    - fi-blb-e6850:       [INCOMPLETE][115] ([fdo#107718]) -> [PASS][116]
   [115]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html
   [116]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html

  * igt@kms_busy@basic-flip-a:
    - fi-kbl-7567u:       [SKIP][117] ([fdo#109271] / [fdo#109278]) -> [PASS][118] +2 similar issues
   [117]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-kbl-7567u/igt@kms_busy@basic-flip-a.html
   [118]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-kbl-7567u/igt@kms_busy@basic-flip-a.html

  * igt@kms_busy@basic-flip-c:
    - fi-icl-u3:          [DMESG-WARN][119] ([fdo#107724]) -> [PASS][120] +1 similar issue
   [119]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-icl-u3/igt@kms_busy@basic-flip-c.html
   [120]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-icl-u3/igt@kms_busy@basic-flip-c.html

  
#### Warnings ####

  * igt@i915_module_load@reload:
    - fi-icl-u2:          [DMESG-WARN][121] ([fdo#110595]) -> [INCOMPLETE][122] ([fdo#107713])
   [121]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-icl-u2/igt@i915_module_load@reload.html
   [122]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-icl-u2/igt@i915_module_load@reload.html

  * igt@runner@aborted:
    - fi-skl-iommu:       [FAIL][123] ([fdo#104108] / [fdo#108602]) -> [FAIL][124] ([fdo#104108])
   [123]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6147/fi-skl-iommu/igt@runner@aborted.html
   [124]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/fi-skl-iommu/igt@runner@aborted.html

  
  [fdo#102657]: https://bugs.freedesktop.org/show_bug.cgi?id=102657
  [fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
  [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#103989]: https://bugs.freedesktop.org/show_bug.cgi?id=103989
  [fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
  [fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
  [fdo#105600]: https://bugs.freedesktop.org/show_bug.cgi?id=105600
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13105/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms
  2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
                   ` (2 preceding siblings ...)
  2019-05-27 11:47 ` ✗ Fi.CI.BAT: failure " Patchwork
@ 2019-05-27 11:51 ` Chris Wilson
  2019-05-28  9:24   ` Maarten Lankhorst
  2019-05-27 13:13 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6) Patchwork
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Chris Wilson @ 2019-05-27 11:51 UTC (permalink / raw)
  To: intel-gfx

Do not allow runtime pm autosuspend to remove userspace GGTT mmaps too
quickly. For example, igt sets the autosuspend delay to 0, and so we
immediately attempt to perform runtime suspend upon releasing the
wakeref. Unfortunately, that involves tearing down GGTT mmaps as they
require an active device.

Override the autosuspend for GGTT mmaps, by keeping the wakeref around
for 250ms after populating the PTE for a fresh mmap.

v2: Prefer refcount_t for its under/overflow error detection
v3: Flush the user runtime autosuspend prior to system system.

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/Kconfig.profile | 14 +++++++
 drivers/gpu/drm/i915/i915_drv.h      |  3 ++
 drivers/gpu/drm/i915/i915_gem.c      |  7 ++++
 drivers/gpu/drm/i915/i915_gem_pm.c   |  1 +
 drivers/gpu/drm/i915/intel_wakeref.c | 63 ++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_wakeref.h | 31 ++++++++++++++
 6 files changed, 119 insertions(+)

diff --git a/drivers/gpu/drm/i915/Kconfig.profile b/drivers/gpu/drm/i915/Kconfig.profile
index 0e5db98da8f3..4fd1ea639d0f 100644
--- a/drivers/gpu/drm/i915/Kconfig.profile
+++ b/drivers/gpu/drm/i915/Kconfig.profile
@@ -1,3 +1,17 @@
+config DRM_I915_USERFAULT_AUTOSUSPEND
+	int "Runtime autosuspend delay for userspace GGTT mmaps (ms)"
+	default 250 # milliseconds
+	help
+	  On runtime suspend, as we suspend the device, we have to revoke
+	  userspace GGTT mmaps and force userspace to take a pagefault on
+	  their next access. The revocation and subsequent recreation of
+	  the GGTT mmap can be very slow and so we impose a small hysteris
+	  that complements the runtime-pm autosuspend and provides a lower
+	  floor on the autosuspend delay.
+
+	  May be 0 to disable the extra delay and solely use the device level
+	  runtime pm autosuspend delay tunable.
+
 config DRM_I915_SPIN_REQUEST
 	int
 	default 5 # microseconds
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a2664ea1395b..e7452d6b663f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -874,6 +874,9 @@ struct i915_gem_mm {
 	 */
 	struct list_head userfault_list;
 
+	/* Manual runtime pm autosuspend delay for user GGTT mmaps */
+	struct intel_wakeref_auto userfault_wakeref;
+
 	/**
 	 * List of objects which are pending destruction.
 	 */
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index d3b7dac527dc..902162c04d35 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1834,6 +1834,9 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 	assert_rpm_wakelock_held(dev_priv);
 	if (!i915_vma_set_userfault(vma) && !obj->userfault_count++)
 		list_add(&obj->userfault_link, &dev_priv->mm.userfault_list);
+	if (CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND)
+		intel_wakeref_auto(&dev_priv->mm.userfault_wakeref,
+				   msecs_to_jiffies_timeout(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND));
 	GEM_BUG_ON(!obj->userfault_count);
 
 	i915_vma_set_ggtt_write(vma);
@@ -4671,6 +4674,8 @@ void i915_gem_fini(struct drm_i915_private *dev_priv)
 {
 	GEM_BUG_ON(dev_priv->gt.awake);
 
+	intel_wakeref_auto_fini(&dev_priv->mm.userfault_wakeref);
+
 	i915_gem_suspend_late(dev_priv);
 	intel_disable_gt_powersave(dev_priv);
 
@@ -4746,7 +4751,9 @@ static void i915_gem_init__mm(struct drm_i915_private *i915)
 	INIT_LIST_HEAD(&i915->mm.unbound_list);
 	INIT_LIST_HEAD(&i915->mm.bound_list);
 	INIT_LIST_HEAD(&i915->mm.fence_list);
+
 	INIT_LIST_HEAD(&i915->mm.userfault_list);
+	intel_wakeref_auto_init(&i915->mm.userfault_wakeref, i915);
 
 	INIT_WORK(&i915->mm.free_work, __i915_gem_free_work);
 }
diff --git a/drivers/gpu/drm/i915/i915_gem_pm.c b/drivers/gpu/drm/i915/i915_gem_pm.c
index fa9c2ebd966a..c0ad19605297 100644
--- a/drivers/gpu/drm/i915/i915_gem_pm.c
+++ b/drivers/gpu/drm/i915/i915_gem_pm.c
@@ -126,6 +126,7 @@ void i915_gem_suspend(struct drm_i915_private *i915)
 {
 	GEM_TRACE("\n");
 
+	intel_wakeref_auto(&i915->mm.userfault_wakeref, 0);
 	flush_workqueue(i915->wq);
 
 	mutex_lock(&i915->drm.struct_mutex);
diff --git a/drivers/gpu/drm/i915/intel_wakeref.c b/drivers/gpu/drm/i915/intel_wakeref.c
index 91196d9612bb..c2dda5a375f0 100644
--- a/drivers/gpu/drm/i915/intel_wakeref.c
+++ b/drivers/gpu/drm/i915/intel_wakeref.c
@@ -73,3 +73,66 @@ void __intel_wakeref_init(struct intel_wakeref *wf, struct lock_class_key *key)
 	atomic_set(&wf->count, 0);
 	wf->wakeref = 0;
 }
+
+static void wakeref_auto_timeout(struct timer_list *t)
+{
+	struct intel_wakeref_auto *wf = from_timer(wf, t, timer);
+	intel_wakeref_t wakeref;
+	unsigned long flags;
+
+	if (!refcount_dec_and_lock_irqsave(&wf->count, &wf->lock, &flags))
+		return;
+
+	wakeref = fetch_and_zero(&wf->wakeref);
+	spin_unlock_irqrestore(&wf->lock, flags);
+
+	intel_runtime_pm_put(wf->i915, wakeref);
+}
+
+void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
+			     struct drm_i915_private *i915)
+{
+	spin_lock_init(&wf->lock);
+	timer_setup(&wf->timer, wakeref_auto_timeout, 0);
+	refcount_set(&wf->count, 0);
+	wf->wakeref = 0;
+	wf->i915 = i915;
+}
+
+void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout)
+{
+	unsigned long flags;
+
+	if (!timeout) {
+		if (del_timer_sync(&wf->timer))
+			wakeref_auto_timeout(&wf->timer);
+		return;
+	}
+
+	/* Our mission is that we only extend an already active wakeref */
+	assert_rpm_wakelock_held(wf->i915);
+
+	if (!refcount_inc_not_zero(&wf->count)) {
+		spin_lock_irqsave(&wf->lock, flags);
+		if (!refcount_read(&wf->count)) {
+			GEM_BUG_ON(wf->wakeref);
+			wf->wakeref = intel_runtime_pm_get_if_in_use(wf->i915);
+		}
+		refcount_inc(&wf->count);
+		spin_unlock_irqrestore(&wf->lock, flags);
+	}
+
+	/*
+	 * If we extend a pending timer, we will only get a single timer
+	 * callback and so need to cancel the local inc by running the
+	 * elided callback to keep the wf->count balanced.
+	 */
+	if (mod_timer(&wf->timer, jiffies + timeout))
+		wakeref_auto_timeout(&wf->timer);
+}
+
+void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf)
+{
+	intel_wakeref_auto(wf, 0);
+	GEM_BUG_ON(wf->wakeref);
+}
diff --git a/drivers/gpu/drm/i915/intel_wakeref.h b/drivers/gpu/drm/i915/intel_wakeref.h
index db742291211c..8a5f85c000ce 100644
--- a/drivers/gpu/drm/i915/intel_wakeref.h
+++ b/drivers/gpu/drm/i915/intel_wakeref.h
@@ -9,7 +9,9 @@
 
 #include <linux/atomic.h>
 #include <linux/mutex.h>
+#include <linux/refcount.h>
 #include <linux/stackdepot.h>
+#include <linux/timer.h>
 
 struct drm_i915_private;
 
@@ -130,4 +132,33 @@ intel_wakeref_active(struct intel_wakeref *wf)
 	return READ_ONCE(wf->wakeref);
 }
 
+struct intel_wakeref_auto {
+	struct drm_i915_private *i915;
+	struct timer_list timer;
+	intel_wakeref_t wakeref;
+	spinlock_t lock;
+	refcount_t count;
+};
+
+/**
+ * intel_wakeref_auto: Delay the runtime-pm autosuspend
+ * @wf: the wakeref
+ * @timeout: relative timeout in jiffies
+ *
+ * The runtime-pm core uses a suspend delay after the last wakeref
+ * is released before triggering runtime suspend of the device. That
+ * delay is configurable via sysfs with little regard to the device
+ * characteristics. Instead, we want to tune the autosuspend based on our
+ * HW knowledge. intel_wakeref_auto() delays the sleep by the supplied
+ * timeout.
+ *
+ * Pass @timeout = 0 to cancel a previous autosuspend by executing the
+ * suspend immediately.
+ */
+void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout);
+
+void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
+			     struct drm_i915_private *i915);
+void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf);
+
 #endif /* INTEL_WAKEREF_H */
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6)
  2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
                   ` (3 preceding siblings ...)
  2019-05-27 11:51 ` [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
@ 2019-05-27 13:13 ` Patchwork
  2019-05-27 13:14 ` ✗ Fi.CI.SPARSE: " Patchwork
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2019-05-27 13:13 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6)
URL   : https://patchwork.freedesktop.org/series/61047/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
fbf134649c9d drm/i915: Keep user GGTT alive for a minimum of 250ms
-:196: CHECK:UNCOMMENTED_DEFINITION: spinlock_t definition without comment
#196: FILE: drivers/gpu/drm/i915/intel_wakeref.h:139:
+	spinlock_t lock;

total: 0 errors, 0 warnings, 1 checks, 167 lines checked

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* ✗ Fi.CI.SPARSE: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6)
  2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
                   ` (4 preceding siblings ...)
  2019-05-27 13:13 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6) Patchwork
@ 2019-05-27 13:14 ` Patchwork
  2019-05-27 13:50 ` ✓ Fi.CI.BAT: success " Patchwork
  2019-05-28  1:36 ` ✓ Fi.CI.IGT: " Patchwork
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2019-05-27 13:14 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6)
URL   : https://patchwork.freedesktop.org/series/61047/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.5.2
Commit: drm/i915: Keep user GGTT alive for a minimum of 250ms
+
+drivers/gpu/drm/i915/i915_utils.h:220:16: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/intel_wakeref.c:86:19: warning: context imbalance in 'wakeref_auto_timeout' - unexpected unlock
+Error in reading or end of file.

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6)
  2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
                   ` (5 preceding siblings ...)
  2019-05-27 13:14 ` ✗ Fi.CI.SPARSE: " Patchwork
@ 2019-05-27 13:50 ` Patchwork
  2019-05-28  1:36 ` ✓ Fi.CI.IGT: " Patchwork
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2019-05-27 13:50 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6)
URL   : https://patchwork.freedesktop.org/series/61047/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6148 -> Patchwork_13106
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/

Known issues
------------

  Here are the changes found in Patchwork_13106 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@core_auth@basic-auth:
    - fi-icl-u3:          [PASS][1] -> [DMESG-WARN][2] ([fdo#107724])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/fi-icl-u3/igt@core_auth@basic-auth.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/fi-icl-u3/igt@core_auth@basic-auth.html

  * igt@gem_exec_fence@basic-busy-default:
    - fi-icl-y:           [PASS][3] -> [INCOMPLETE][4] ([fdo#107713])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/fi-icl-y/igt@gem_exec_fence@basic-busy-default.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/fi-icl-y/igt@gem_exec_fence@basic-busy-default.html

  * igt@kms_cursor_legacy@basic-flip-after-cursor-varying-size:
    - fi-pnv-d510:        [PASS][5] -> [FAIL][6] ([fdo#106081])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/fi-pnv-d510/igt@kms_cursor_legacy@basic-flip-after-cursor-varying-size.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/fi-pnv-d510/igt@kms_cursor_legacy@basic-flip-after-cursor-varying-size.html

  
#### Possible fixes ####

  * igt@gem_tiled_pread_basic:
    - fi-icl-u3:          [DMESG-WARN][7] ([fdo#107724]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/fi-icl-u3/igt@gem_tiled_pread_basic.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/fi-icl-u3/igt@gem_tiled_pread_basic.html

  * igt@i915_selftest@live_hangcheck:
    - fi-skl-iommu:       [INCOMPLETE][9] ([fdo#108602] / [fdo#108744]) -> [PASS][10]
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html

  
#### Warnings ####

  * igt@kms_flip@basic-flip-vs-modeset:
    - fi-icl-u3:          [DMESG-FAIL][11] ([fdo#110718]) -> [DMESG-WARN][12] ([fdo#110718])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/fi-icl-u3/igt@kms_flip@basic-flip-vs-modeset.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/fi-icl-u3/igt@kms_flip@basic-flip-vs-modeset.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#106081]: https://bugs.freedesktop.org/show_bug.cgi?id=106081
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108602
  [fdo#108744]: https://bugs.freedesktop.org/show_bug.cgi?id=108744
  [fdo#110718]: https://bugs.freedesktop.org/show_bug.cgi?id=110718


Participating hosts (52 -> 45)
------------------------------

  Additional (1): fi-gdg-551 
  Missing    (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-apl-guc fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * Linux: CI_DRM_6148 -> Patchwork_13106

  CI_DRM_6148: 91e4739d3a58b7a95a43788bad6cd68887934595 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5017: 2892adce93fb8eea3d764dc0f766a202d9dcef37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_13106: fbf134649c9df2620e89d6f658e317ccd7528c9b @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

fbf134649c9d drm/i915: Keep user GGTT alive for a minimum of 250ms

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* ✓ Fi.CI.IGT: success for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6)
  2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
                   ` (6 preceding siblings ...)
  2019-05-27 13:50 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-05-28  1:36 ` Patchwork
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2019-05-28  1:36 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6)
URL   : https://patchwork.freedesktop.org/series/61047/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6148_full -> Patchwork_13106_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Known issues
------------

  Here are the changes found in Patchwork_13106_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_mmap_gtt@forked-big-copy:
    - shard-iclb:         [PASS][1] -> [INCOMPLETE][2] ([fdo#107713] / [fdo#109100])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-iclb6/igt@gem_mmap_gtt@forked-big-copy.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-iclb1/igt@gem_mmap_gtt@forked-big-copy.html

  * igt@gem_softpin@noreloc-s3:
    - shard-snb:          [PASS][3] -> [DMESG-WARN][4] ([fdo#102365])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-snb2/igt@gem_softpin@noreloc-s3.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-snb7/igt@gem_softpin@noreloc-s3.html

  * igt@gem_tiled_swapping@non-threaded:
    - shard-iclb:         [PASS][5] -> [FAIL][6] ([fdo#108686])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-iclb4/igt@gem_tiled_swapping@non-threaded.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-iclb2/igt@gem_tiled_swapping@non-threaded.html
    - shard-glk:          [PASS][7] -> [DMESG-WARN][8] ([fdo#108686])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-glk7/igt@gem_tiled_swapping@non-threaded.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-glk2/igt@gem_tiled_swapping@non-threaded.html

  * igt@i915_suspend@fence-restore-untiled:
    - shard-apl:          [PASS][9] -> [DMESG-WARN][10] ([fdo#108566]) +4 similar issues
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-apl8/igt@i915_suspend@fence-restore-untiled.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-apl7/igt@i915_suspend@fence-restore-untiled.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
    - shard-kbl:          [PASS][11] -> [DMESG-WARN][12] ([fdo#108566]) +3 similar issues
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-kbl6/igt@kms_cursor_crc@pipe-a-cursor-suspend.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-kbl1/igt@kms_cursor_crc@pipe-a-cursor-suspend.html

  * igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-cpu:
    - shard-glk:          [PASS][13] -> [INCOMPLETE][14] ([fdo#103359] / [k.org#198133])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-glk7/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-cpu.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-glk2/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-cpu.html

  * igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-gtt:
    - shard-snb:          [PASS][15] -> [SKIP][16] ([fdo#109271])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-snb5/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-gtt.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-snb6/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-gtt.html

  * igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-shrfb-draw-mmap-wc:
    - shard-hsw:          [PASS][17] -> [SKIP][18] ([fdo#109271]) +23 similar issues
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-hsw7/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-shrfb-draw-mmap-wc.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-hsw1/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-shrfb-draw-mmap-wc.html

  * igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-indfb-draw-blt:
    - shard-iclb:         [PASS][19] -> [FAIL][20] ([fdo#103167]) +4 similar issues
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-iclb5/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-indfb-draw-blt.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-iclb7/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-indfb-draw-blt.html

  * igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min:
    - shard-skl:          [PASS][21] -> [FAIL][22] ([fdo#108145])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-skl1/igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-skl1/igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min.html

  * igt@kms_psr@psr2_primary_mmap_gtt:
    - shard-iclb:         [PASS][23] -> [SKIP][24] ([fdo#109441])
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-iclb2/igt@kms_psr@psr2_primary_mmap_gtt.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-iclb3/igt@kms_psr@psr2_primary_mmap_gtt.html

  
#### Possible fixes ####

  * igt@gem_workarounds@suspend-resume:
    - shard-apl:          [DMESG-WARN][25] ([fdo#108566]) -> [PASS][26] +8 similar issues
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-apl6/igt@gem_workarounds@suspend-resume.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-apl6/igt@gem_workarounds@suspend-resume.html

  * igt@i915_suspend@fence-restore-untiled:
    - shard-kbl:          [DMESG-WARN][27] ([fdo#108566]) -> [PASS][28] +2 similar issues
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-kbl1/igt@i915_suspend@fence-restore-untiled.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-kbl4/igt@i915_suspend@fence-restore-untiled.html

  * igt@kms_cursor_crc@pipe-b-cursor-64x64-sliding:
    - shard-iclb:         [INCOMPLETE][29] ([fdo#107713]) -> [PASS][30]
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-iclb7/igt@kms_cursor_crc@pipe-b-cursor-64x64-sliding.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-iclb6/igt@kms_cursor_crc@pipe-b-cursor-64x64-sliding.html

  * igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic:
    - shard-hsw:          [SKIP][31] ([fdo#109271]) -> [PASS][32] +7 similar issues
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-hsw1/igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-hsw7/igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic.html

  * igt@kms_frontbuffer_tracking@fbc-stridechange:
    - shard-iclb:         [FAIL][33] ([fdo#103167]) -> [PASS][34] +3 similar issues
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-iclb1/igt@kms_frontbuffer_tracking@fbc-stridechange.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-iclb5/igt@kms_frontbuffer_tracking@fbc-stridechange.html

  * igt@kms_plane_lowres@pipe-a-tiling-x:
    - shard-iclb:         [FAIL][35] ([fdo#103166]) -> [PASS][36]
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-iclb5/igt@kms_plane_lowres@pipe-a-tiling-x.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-iclb1/igt@kms_plane_lowres@pipe-a-tiling-x.html

  * igt@kms_psr@psr2_suspend:
    - shard-iclb:         [SKIP][37] ([fdo#109441]) -> [PASS][38]
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6148/shard-iclb5/igt@kms_psr@psr2_suspend.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13106/shard-iclb2/igt@kms_psr@psr2_suspend.html

  
  [fdo#102365]: https://bugs.freedesktop.org/show_bug.cgi?id=102365
  [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#108686]: https://bugs.freedesktop.org/show_bug.cgi?id=108686
  [fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133


Participating hosts (10 -> 10)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * Linux: CI_DRM_6148 -> Patchwork_13106

  CI_DRM_6148: 91e4739d3a58b7a95a43788bad6cd68887934595 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5017: 2892adce93fb8eea3d764dc0f766a202d9dcef37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_13106: fbf134649c9df2620e89d6f658e317ccd7528c9b @ 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_13106/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms
  2019-05-27 11:51 ` [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
@ 2019-05-28  9:24   ` Maarten Lankhorst
  2019-05-28  9:27     ` Chris Wilson
  0 siblings, 1 reply; 12+ messages in thread
From: Maarten Lankhorst @ 2019-05-28  9:24 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Op 27-05-2019 om 13:51 schreef Chris Wilson:
> Do not allow runtime pm autosuspend to remove userspace GGTT mmaps too
> quickly. For example, igt sets the autosuspend delay to 0, and so we
> immediately attempt to perform runtime suspend upon releasing the
> wakeref. Unfortunately, that involves tearing down GGTT mmaps as they
> require an active device.
>
> Override the autosuspend for GGTT mmaps, by keeping the wakeref around
> for 250ms after populating the PTE for a fresh mmap.
>
> v2: Prefer refcount_t for its under/overflow error detection
> v3: Flush the user runtime autosuspend prior to system system.
>
> 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>

Can't this extra delay be added to the kernel core? Feels like we're just duplicating autosuspend behavior here..


> ---
>  drivers/gpu/drm/i915/Kconfig.profile | 14 +++++++
>  drivers/gpu/drm/i915/i915_drv.h      |  3 ++
>  drivers/gpu/drm/i915/i915_gem.c      |  7 ++++
>  drivers/gpu/drm/i915/i915_gem_pm.c   |  1 +
>  drivers/gpu/drm/i915/intel_wakeref.c | 63 ++++++++++++++++++++++++++++
>  drivers/gpu/drm/i915/intel_wakeref.h | 31 ++++++++++++++
>  6 files changed, 119 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/Kconfig.profile b/drivers/gpu/drm/i915/Kconfig.profile
> index 0e5db98da8f3..4fd1ea639d0f 100644
> --- a/drivers/gpu/drm/i915/Kconfig.profile
> +++ b/drivers/gpu/drm/i915/Kconfig.profile
> @@ -1,3 +1,17 @@
> +config DRM_I915_USERFAULT_AUTOSUSPEND
> +	int "Runtime autosuspend delay for userspace GGTT mmaps (ms)"
> +	default 250 # milliseconds
> +	help
> +	  On runtime suspend, as we suspend the device, we have to revoke
> +	  userspace GGTT mmaps and force userspace to take a pagefault on
> +	  their next access. The revocation and subsequent recreation of
> +	  the GGTT mmap can be very slow and so we impose a small hysteris
> +	  that complements the runtime-pm autosuspend and provides a lower
> +	  floor on the autosuspend delay.
> +
> +	  May be 0 to disable the extra delay and solely use the device level
> +	  runtime pm autosuspend delay tunable.
> +
>  config DRM_I915_SPIN_REQUEST
>  	int
>  	default 5 # microseconds
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index a2664ea1395b..e7452d6b663f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -874,6 +874,9 @@ struct i915_gem_mm {
>  	 */
>  	struct list_head userfault_list;
>  
> +	/* Manual runtime pm autosuspend delay for user GGTT mmaps */
> +	struct intel_wakeref_auto userfault_wakeref;
> +
>  	/**
>  	 * List of objects which are pending destruction.
>  	 */
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index d3b7dac527dc..902162c04d35 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1834,6 +1834,9 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
>  	assert_rpm_wakelock_held(dev_priv);
>  	if (!i915_vma_set_userfault(vma) && !obj->userfault_count++)
>  		list_add(&obj->userfault_link, &dev_priv->mm.userfault_list);
> +	if (CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND)
> +		intel_wakeref_auto(&dev_priv->mm.userfault_wakeref,
> +				   msecs_to_jiffies_timeout(CONFIG_DRM_I915_USERFAULT_AUTOSUSPEND));
>  	GEM_BUG_ON(!obj->userfault_count);
>  
>  	i915_vma_set_ggtt_write(vma);
> @@ -4671,6 +4674,8 @@ void i915_gem_fini(struct drm_i915_private *dev_priv)
>  {
>  	GEM_BUG_ON(dev_priv->gt.awake);
>  
> +	intel_wakeref_auto_fini(&dev_priv->mm.userfault_wakeref);
> +
>  	i915_gem_suspend_late(dev_priv);
>  	intel_disable_gt_powersave(dev_priv);
>  
> @@ -4746,7 +4751,9 @@ static void i915_gem_init__mm(struct drm_i915_private *i915)
>  	INIT_LIST_HEAD(&i915->mm.unbound_list);
>  	INIT_LIST_HEAD(&i915->mm.bound_list);
>  	INIT_LIST_HEAD(&i915->mm.fence_list);
> +
>  	INIT_LIST_HEAD(&i915->mm.userfault_list);
> +	intel_wakeref_auto_init(&i915->mm.userfault_wakeref, i915);
>  
>  	INIT_WORK(&i915->mm.free_work, __i915_gem_free_work);
>  }
> diff --git a/drivers/gpu/drm/i915/i915_gem_pm.c b/drivers/gpu/drm/i915/i915_gem_pm.c
> index fa9c2ebd966a..c0ad19605297 100644
> --- a/drivers/gpu/drm/i915/i915_gem_pm.c
> +++ b/drivers/gpu/drm/i915/i915_gem_pm.c
> @@ -126,6 +126,7 @@ void i915_gem_suspend(struct drm_i915_private *i915)
>  {
>  	GEM_TRACE("\n");
>  
> +	intel_wakeref_auto(&i915->mm.userfault_wakeref, 0);
>  	flush_workqueue(i915->wq);
>  
>  	mutex_lock(&i915->drm.struct_mutex);
> diff --git a/drivers/gpu/drm/i915/intel_wakeref.c b/drivers/gpu/drm/i915/intel_wakeref.c
> index 91196d9612bb..c2dda5a375f0 100644
> --- a/drivers/gpu/drm/i915/intel_wakeref.c
> +++ b/drivers/gpu/drm/i915/intel_wakeref.c
> @@ -73,3 +73,66 @@ void __intel_wakeref_init(struct intel_wakeref *wf, struct lock_class_key *key)
>  	atomic_set(&wf->count, 0);
>  	wf->wakeref = 0;
>  }
> +
> +static void wakeref_auto_timeout(struct timer_list *t)
> +{
> +	struct intel_wakeref_auto *wf = from_timer(wf, t, timer);
> +	intel_wakeref_t wakeref;
> +	unsigned long flags;
> +
> +	if (!refcount_dec_and_lock_irqsave(&wf->count, &wf->lock, &flags))
> +		return;
> +
> +	wakeref = fetch_and_zero(&wf->wakeref);
> +	spin_unlock_irqrestore(&wf->lock, flags);
> +
> +	intel_runtime_pm_put(wf->i915, wakeref);
> +}
> +
> +void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
> +			     struct drm_i915_private *i915)
> +{
> +	spin_lock_init(&wf->lock);
> +	timer_setup(&wf->timer, wakeref_auto_timeout, 0);
> +	refcount_set(&wf->count, 0);
> +	wf->wakeref = 0;
> +	wf->i915 = i915;
> +}
> +
> +void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout)
> +{
> +	unsigned long flags;
> +
> +	if (!timeout) {
> +		if (del_timer_sync(&wf->timer))
> +			wakeref_auto_timeout(&wf->timer);
> +		return;
> +	}
> +
> +	/* Our mission is that we only extend an already active wakeref */
> +	assert_rpm_wakelock_held(wf->i915);
> +
> +	if (!refcount_inc_not_zero(&wf->count)) {
> +		spin_lock_irqsave(&wf->lock, flags);
> +		if (!refcount_read(&wf->count)) {
> +			GEM_BUG_ON(wf->wakeref);
> +			wf->wakeref = intel_runtime_pm_get_if_in_use(wf->i915);
> +		}
> +		refcount_inc(&wf->count);
> +		spin_unlock_irqrestore(&wf->lock, flags);
> +	}
> +
> +	/*
> +	 * If we extend a pending timer, we will only get a single timer
> +	 * callback and so need to cancel the local inc by running the
> +	 * elided callback to keep the wf->count balanced.
> +	 */
> +	if (mod_timer(&wf->timer, jiffies + timeout))
> +		wakeref_auto_timeout(&wf->timer);
> +}
> +
> +void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf)
> +{
> +	intel_wakeref_auto(wf, 0);
> +	GEM_BUG_ON(wf->wakeref);
> +}
> diff --git a/drivers/gpu/drm/i915/intel_wakeref.h b/drivers/gpu/drm/i915/intel_wakeref.h
> index db742291211c..8a5f85c000ce 100644
> --- a/drivers/gpu/drm/i915/intel_wakeref.h
> +++ b/drivers/gpu/drm/i915/intel_wakeref.h
> @@ -9,7 +9,9 @@
>  
>  #include <linux/atomic.h>
>  #include <linux/mutex.h>
> +#include <linux/refcount.h>
>  #include <linux/stackdepot.h>
> +#include <linux/timer.h>
>  
>  struct drm_i915_private;
>  
> @@ -130,4 +132,33 @@ intel_wakeref_active(struct intel_wakeref *wf)
>  	return READ_ONCE(wf->wakeref);
>  }
>  
> +struct intel_wakeref_auto {
> +	struct drm_i915_private *i915;
> +	struct timer_list timer;
> +	intel_wakeref_t wakeref;
> +	spinlock_t lock;
> +	refcount_t count;
> +};
> +
> +/**
> + * intel_wakeref_auto: Delay the runtime-pm autosuspend
> + * @wf: the wakeref
> + * @timeout: relative timeout in jiffies
> + *
> + * The runtime-pm core uses a suspend delay after the last wakeref
> + * is released before triggering runtime suspend of the device. That
> + * delay is configurable via sysfs with little regard to the device
> + * characteristics. Instead, we want to tune the autosuspend based on our
> + * HW knowledge. intel_wakeref_auto() delays the sleep by the supplied
> + * timeout.
> + *
> + * Pass @timeout = 0 to cancel a previous autosuspend by executing the
> + * suspend immediately.
> + */
> +void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout);
> +
> +void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
> +			     struct drm_i915_private *i915);
> +void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf);
> +
>  #endif /* INTEL_WAKEREF_H */


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms
  2019-05-28  9:24   ` Maarten Lankhorst
@ 2019-05-28  9:27     ` Chris Wilson
  2019-05-28 10:11       ` Maarten Lankhorst
  0 siblings, 1 reply; 12+ messages in thread
From: Chris Wilson @ 2019-05-28  9:27 UTC (permalink / raw)
  To: Maarten Lankhorst, intel-gfx

Quoting Maarten Lankhorst (2019-05-28 10:24:40)
> Op 27-05-2019 om 13:51 schreef Chris Wilson:
> > Do not allow runtime pm autosuspend to remove userspace GGTT mmaps too
> > quickly. For example, igt sets the autosuspend delay to 0, and so we
> > immediately attempt to perform runtime suspend upon releasing the
> > wakeref. Unfortunately, that involves tearing down GGTT mmaps as they
> > require an active device.
> >
> > Override the autosuspend for GGTT mmaps, by keeping the wakeref around
> > for 250ms after populating the PTE for a fresh mmap.
> >
> > v2: Prefer refcount_t for its under/overflow error detection
> > v3: Flush the user runtime autosuspend prior to system system.
> >
> > 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>
> 
> Can't this extra delay be added to the kernel core? Feels like we're just duplicating autosuspend behavior here..

Yes. In the end, we would need to adjust the device pm to clamp the user
sysfs value. But really, we want different floors for different
operations as we would expect different wakeup latencies / penalties.
E.g. reaping GTT mmaps is expensive, but if none are in use...
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms
  2019-05-28  9:27     ` Chris Wilson
@ 2019-05-28 10:11       ` Maarten Lankhorst
  0 siblings, 0 replies; 12+ messages in thread
From: Maarten Lankhorst @ 2019-05-28 10:11 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Op 28-05-2019 om 11:27 schreef Chris Wilson:
> Quoting Maarten Lankhorst (2019-05-28 10:24:40)
>> Op 27-05-2019 om 13:51 schreef Chris Wilson:
>>> Do not allow runtime pm autosuspend to remove userspace GGTT mmaps too
>>> quickly. For example, igt sets the autosuspend delay to 0, and so we
>>> immediately attempt to perform runtime suspend upon releasing the
>>> wakeref. Unfortunately, that involves tearing down GGTT mmaps as they
>>> require an active device.
>>>
>>> Override the autosuspend for GGTT mmaps, by keeping the wakeref around
>>> for 250ms after populating the PTE for a fresh mmap.
>>>
>>> v2: Prefer refcount_t for its under/overflow error detection
>>> v3: Flush the user runtime autosuspend prior to system system.
>>>
>>> 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>
>> Can't this extra delay be added to the kernel core? Feels like we're just duplicating autosuspend behavior here..
> Yes. In the end, we would need to adjust the device pm to clamp the user
> sysfs value. But really, we want different floors for different
> operations as we would expect different wakeup latencies / penalties.
> E.g. reaping GTT mmaps is expensive, but if none are in use...
> -Chris

Seems a bit like the PM QoS management then, but for autosuspend.

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-05-28 10:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27 11:10 [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
2019-05-27 11:22 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev5) Patchwork
2019-05-27 11:23 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-05-27 11:47 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-05-27 11:51 ` [CI] drm/i915: Keep user GGTT alive for a minimum of 250ms Chris Wilson
2019-05-28  9:24   ` Maarten Lankhorst
2019-05-28  9:27     ` Chris Wilson
2019-05-28 10:11       ` Maarten Lankhorst
2019-05-27 13:13 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Keep user GGTT alive for a minimum of 250ms (rev6) Patchwork
2019-05-27 13:14 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-05-27 13:50 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-28  1:36 ` ✓ Fi.CI.IGT: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.