Commit b4a0b32d authored by Chris Wilson's avatar Chris Wilson

drm/i915: Flush the idle-worker for debugfs/i915_drop_caches

After being requested to idle the GPU, flush the idle worker to drop the
residual active state, and any internal object caches.

v2: By popular demand, introduce DROP_IDLE for fine-grained control from
userspace, though it should be used as part of a
	DROP_ACTIVE | DROP_RETIRE | DROP_IDLE | DROP_FREED
sequence.
v3: Convert to BIT() to sell it to Joonas.

References: https://bugs.freedesktop.org/show_bug.cgi?id=102655Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171018121621.10824-1-chris@chris-wilson.co.ukReviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
parent 31d1d3c8
...@@ -4179,18 +4179,20 @@ DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops, ...@@ -4179,18 +4179,20 @@ DEFINE_SIMPLE_ATTRIBUTE(i915_ring_test_irq_fops,
i915_ring_test_irq_get, i915_ring_test_irq_set, i915_ring_test_irq_get, i915_ring_test_irq_set,
"0x%08llx\n"); "0x%08llx\n");
#define DROP_UNBOUND 0x1 #define DROP_UNBOUND BIT(0)
#define DROP_BOUND 0x2 #define DROP_BOUND BIT(1)
#define DROP_RETIRE 0x4 #define DROP_RETIRE BIT(2)
#define DROP_ACTIVE 0x8 #define DROP_ACTIVE BIT(3)
#define DROP_FREED 0x10 #define DROP_FREED BIT(4)
#define DROP_SHRINK_ALL 0x20 #define DROP_SHRINK_ALL BIT(5)
#define DROP_IDLE BIT(6)
#define DROP_ALL (DROP_UNBOUND | \ #define DROP_ALL (DROP_UNBOUND | \
DROP_BOUND | \ DROP_BOUND | \
DROP_RETIRE | \ DROP_RETIRE | \
DROP_ACTIVE | \ DROP_ACTIVE | \
DROP_FREED | \ DROP_FREED | \
DROP_SHRINK_ALL) DROP_SHRINK_ALL |\
DROP_IDLE)
static int static int
i915_drop_caches_get(void *data, u64 *val) i915_drop_caches_get(void *data, u64 *val)
{ {
...@@ -4206,7 +4208,8 @@ i915_drop_caches_set(void *data, u64 val) ...@@ -4206,7 +4208,8 @@ i915_drop_caches_set(void *data, u64 val)
struct drm_device *dev = &dev_priv->drm; struct drm_device *dev = &dev_priv->drm;
int ret = 0; int ret = 0;
DRM_DEBUG("Dropping caches: 0x%08llx\n", val); DRM_DEBUG("Dropping caches: 0x%08llx [0x%08llx]\n",
val, val & DROP_ALL);
/* No need to check and wait for gpu resets, only libdrm auto-restarts /* No need to check and wait for gpu resets, only libdrm auto-restarts
* on ioctls on -EAGAIN. */ * on ioctls on -EAGAIN. */
...@@ -4237,6 +4240,9 @@ i915_drop_caches_set(void *data, u64 val) ...@@ -4237,6 +4240,9 @@ i915_drop_caches_set(void *data, u64 val)
i915_gem_shrink_all(dev_priv); i915_gem_shrink_all(dev_priv);
fs_reclaim_release(GFP_KERNEL); fs_reclaim_release(GFP_KERNEL);
if (val & DROP_IDLE)
drain_delayed_work(&dev_priv->gt.idle_work);
if (val & DROP_FREED) { if (val & DROP_FREED) {
synchronize_rcu(); synchronize_rcu();
i915_gem_drain_freed_objects(dev_priv); i915_gem_drain_freed_objects(dev_priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment