drm/i915: Try harder to finish the idle-worker
Subsystems (2)
PATCH 1/2 drm/i915: Try harder to finish the idle-worker
If a worker requeues itself, it may switch to a different kworker pool, which flush_work() considers as complete. To be strict, we then need to keep flushing the work until it is no longer pending.
References: https://bugs.freedesktop.org/show_bug.cgi?id=102456
--- drivers/gpu/drm/i915/i915_debugfs.c | 3 +-- drivers/gpu/drm/i915/i915_gem.c | 3 +-- drivers/gpu/drm/i915/i915_utils.h | 13 +++++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -2
@@ -4202,8 +4202,7 @@ fault_irq_set(struct drm_i915_private *i915,mutex_unlock (&i915->drm.struct_mutex);/* Flush idle worker to disarm irq */ -while (flush_delayed_work (&i915->gt.idle_work)) - ; +drain_delayed_work (&i915->gt.idle_work);return 0 ;
drivers/gpu/drm/i915/i915_gem.c +1 -2
@@ -4582,8 +4582,7 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv)/* As the idle_work is rearming if it detects a race, play safe and * repeat the flush until it is definitely idle. */ -while (flush_delayed_work (&dev_priv->gt.idle_work)) - ; +drain_delayed_work (&dev_priv->gt.idle_work);/* Assert that we sucessfully flushed all the work and * reset the GPU back to its idle, low power state.
drivers/gpu/drm/i915/i915_utils.h +13 -0
@@ -119,4 +119,17 @@ static inline void __list_del_many(struct list_head *head, WRITE_ONCE(head->next, first); } +/* +* Wait until the work is finally complete, even if it tries to postpone +* by requeueing itself. Note, that if the worker never cancels itself, +* we will spin forever. +*/ +static inline void drain_delayed_work (struct delayed_work *dw) +{ +do { +while (flush_delayed_work (dw)) + ; + }while (delayed_work_pending (dw)); +} +#endif /* !__I915_UTILS_H */
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915: Keep the device awake whilst in the GTT domain
Since runtime suspend is very harsh on GTT mmappings (they all get zapped on suspend) keep the device awake while the buffer remains in the GTT domain. However, userspace can control the domain and although there is a soft contract that writes must be flushed (for e.g. flushing scanouts and fbc), we are intentionally lax with respect to read domains, allowing them to persist for as long as is feasible.
We acquire a wakeref when using the buffer in the GEM domain so that all subsequent operations on that object are fast, trying to avoid suspending while the GTT is still in active use by userspace. To ensure that the device can eventually suspend, we install a timer and expire the GTT wakeref. So in effect we have just a fancy pm autosuspend that tries to estimate the cost of restoring actively used GTT mmapping.
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 + drivers/gpu/drm/i915/i915_drv.h | 12 +++ drivers/gpu/drm/i915/i915_gem.c | 116 +++++++++++++++++++---- drivers/gpu/drm/i915/i915_gem_object.h | 5 + drivers/gpu/drm/i915/i915_gem_shrinker.c | 4 +- drivers/gpu/drm/i915/selftests/i915_gem_object.c | 2 +- 6 files changed, 122 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -0
@@ -2809,6 +2809,8 @@ static int i915_runtime_pm_status(struct seq_file *m, void *unused)if (!HAS_RUNTIME_PM (dev_priv))seq_puts (m,"Runtime power management not supported\n" ); +seq_printf (m,"GTT wakeref count: %d\n" , +atomic_read (&dev_priv->mm.gtt_wakeref.count));seq_printf (m,"GPU idle: %s\n" ,yesno (!dev_priv->gt.awake));seq_printf (m,"IRQs disabled: %s\n" ,yesno (!intel_irqs_enabled (dev_priv)));
drivers/gpu/drm/i915/i915_drv.h +12 -0
@@ -1479,6 +1479,18 @@ struct i915_gem_mm {*/ struct list_head userfault_list; +/* List of all objects in gtt domain, holding a wakeref. +* The list is reaped periodically, and protected by its own mutex. +* Entries on this list do not carry a reference. +*/ +struct { +struct mutex lock; +struct list_head list; +atomic_t count;/* -1 == no timeout scheduled */ + +struct delayed_work work; + } gtt_wakeref; +/** * List of objects which are pending destruction. */
drivers/gpu/drm/i915/i915_gem.c +99 -17
230 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_object.h +5 -0
@@ -177,6 +177,8 @@ struct drm_i915_gem_object {struct mutex lock;/* protects this cache */ } get_page; +struct list_head gtt_wakeref_link; +/** * Advice: are the backing pages purgeable? */
@@ -421,5 +423,8 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj, unsigned int cache_level);void i915_gem_object_flush_if_display (struct drm_i915_gem_object *obj); +void i915_gem_object_flush_write_domain (struct drm_i915_gem_object *obj, +unsigned int flush_domains); +#endif
drivers/gpu/drm/i915/i915_gem_shrinker.c +3 -1
@@ -127,8 +127,10 @@ static bool can_release_pages(struct drm_i915_gem_object *obj)static bool unsafe_drop_pages (struct drm_i915_gem_object *obj) { -if (i915_gem_object_unbind (obj) ==0 ) +if (i915_gem_object_unbind (obj) ==0 ) { +i915_gem_object_flush_write_domain (obj, ~I915_GEM_DOMAIN_CPU );__i915_gem_object_put_pages (obj,I915_MM_SHRINKER ); + }return !READ_ONCE (obj->mm.pages); }
drivers/gpu/drm/i915/selftests/i915_gem_object.c +1 -1
@@ -266,7 +266,7 @@ static int check_partial_mapping(struct drm_i915_gem_object *obj,if (offset >= obj->base.size)continue ; -flush_write_domain (obj, ~I915_GEM_DOMAIN_CPU ); +i915_gem_object_flush_write_domain (obj, ~I915_GEM_DOMAIN_CPU ); p =i915_gem_object_get_page (obj, offset >>PAGE_SHIFT ); cpu =kmap (p) +offset_in_page (offset);
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Try harder to finish the idle-worker
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915: Try harder to finish the idle-worker
URL : https://patchwork.freedesktop.org/series/29708/
State : success
== Summary ==
Series 29708v1 series starting with [1/2] drm/i915: Try harder to finish the idle-worker
https://patchwork.freedesktop.org/api/1.0/series/29708/revisions/1/mbox/
fi-bdw-5557u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:461s fi-bdw-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:440s fi-blb-e6850 total:288 pass:224 dwarn:1 dfail:0 fail:0 skip:63 time:360s fi-bsw-n3050 total:288 pass:243 dwarn:0 dfail:0 fail:0 skip:45 time:553s fi-bwr-2160 total:288 pass:184 dwarn:0 dfail:0 fail:0 skip:104 time:254s fi-bxt-j4205 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:531s fi-byt-j1900 total:288 pass:254 dwarn:1 dfail:0 fail:0 skip:33 time:528s fi-byt-n2820 total:288 pass:250 dwarn:1 dfail:0 fail:0 skip:37 time:520s fi-elk-e7500 total:288 pass:230 dwarn:0 dfail:0 fail:0 skip:58 time:437s fi-glk-2a total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:617s fi-hsw-4770 total:288 pass:263 dwarn:0 dfail:0 fail:0 skip:25 time:449s fi-hsw-4770r total:288 pass:263 dwarn:0 dfail:0 fail:0 skip:25 time:436s fi-ilk-650 total:288 pass:229 dwarn:0 dfail:0 fail:0 skip:59 time:430s fi-ivb-3520m total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:505s fi-ivb-3770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:474s fi-kbl-7500u total:288 pass:264 dwarn:1 dfail:0 fail:0 skip:23 time:517s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:599s fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:597s fi-pnv-d510 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:524s fi-skl-6260u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:485s fi-skl-6700k total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:535s fi-skl-6770hq total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:498s fi-skl-gvtdvm total:288 pass:266 dwarn:0 dfail:0 fail:0 skip:22 time:445s fi-skl-x1585l total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:493s fi-snb-2520m total:288 pass:251 dwarn:0 dfail:0 fail:0 skip:37 time:555s fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:2 skip:38 time:399s
8b962a9a16b3a4e3cc2a56cba82ee9c0dc0941b5 drm-tip: 2017y-09m-01d-13h-56m-06s UTC integration manifest 68df61716a18 drm/i915: Keep the device awake whilst in the GTT domain3b1d04f05670 drm/i915: Try harder to finish the idle-worker
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5567/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for series starting with [1/2] drm/i915: Try harder to finish the idle-worker
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915: Try harder to finish the idle-worker
URL : https://patchwork.freedesktop.org/series/29708/
State : success
== Summary ==
Test kms_setmode:
Subgroup basic:
pass -> FAIL (shard-hsw) fdo#99912
Test kms_sysfs_edid_timing:
pass -> WARN (shard-hsw) fdo#100047
Test perf:
Subgroup blocking:
fail -> PASS (shard-hsw) fdo#102252fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
shard-hsw total:2263 pass:1231 dwarn:0 dfail:0 fail:15 skip:1015 time:9602s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5567/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx