From patchwork Thu Feb 7 10:27:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 2109921 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id E60F0DFB7B for ; Thu, 7 Feb 2013 10:28:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D7DCAE6209 for ; Thu, 7 Feb 2013 02:28:42 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (smtp.fireflyinternet.com [109.228.6.236]) by gabe.freedesktop.org (Postfix) with ESMTP id 181CDE5E06 for ; Thu, 7 Feb 2013 02:28:33 -0800 (PST) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.73.22; Received: from arrandale.alporthouse.com (unverified [78.156.73.22]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 128751435-1500050 for multiple; Thu, 07 Feb 2013 10:28:27 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Feb 2013 10:27:47 +0000 Message-Id: <1360232867-26613-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.7.10.4 X-Originating-IP: 78.156.73.22 Subject: [Intel-gfx] [PATCH] drm/i915: After hibernation, discard the unbound list X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org The unbound list is an optimisation to track objects that have been evicted from the GTT but remain untouched by the CPU. After hibernation, all memory is in the CPU domain (having been restored from a disk image) and so we need to restore the domain tracking upon the objects. However, for the unbound list we can simply discard those objects and lazily wait for them to be reused. v2: Perform the unbound discard explicitly during thawing after hibernation. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_drv.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 9069e71..f5ccb3d 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -592,6 +592,30 @@ static int __i915_drm_thaw(struct drm_device *dev) return error; } +static void i915_gem_discard_unbound(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + struct drm_i915_gem_object *obj, *next; + + /* After hibernation all memory is in the CPU domain and so we need + * to restore our domain tracking. However, the unbound list is + * merely an optimisation to track memory that has been evicted from + * the GTT but remains in the GTT domain. After hibernation, that + * is no longer the case and we can trim the unbound list. + */ + list_for_each_entry_safe(obj, next, + &dev_priv->mm.unbound_list, gtt_list) { + obj->base.read_domains = I915_GEM_DOMAIN_CPU; + obj->base.write_domain = I915_GEM_DOMAIN_CPU; + if (i915_gem_object_put_pages(obj)) { + /* Abandon hope all ye who enter here */ + obj->base.read_domains = I915_GEM_DOMAIN_GTT; + obj->base.write_domain = I915_GEM_DOMAIN_GTT; + /* Will be clflushed during restore_gtt_mappings */ + } + } +} + static int i915_drm_thaw(struct drm_device *dev) { int error = 0; @@ -600,6 +624,7 @@ static int i915_drm_thaw(struct drm_device *dev) if (drm_core_check_feature(dev, DRIVER_MODESET)) { mutex_lock(&dev->struct_mutex); + i915_gem_discard_unbound(dev); i915_gem_restore_gtt_mappings(dev); mutex_unlock(&dev->struct_mutex); }