From patchwork Tue Dec 8 22:17:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 65824 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB8MHQcG031314 for ; Tue, 8 Dec 2009 22:17:26 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A24C9E8BE; Tue, 8 Dec 2009 14:17:25 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fmsmga102.fm.intel.com (mga10.intel.com [192.55.52.92]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B5AB9E89D for ; Tue, 8 Dec 2009 14:17:23 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 08 Dec 2009 14:12:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.47,364,1257148800"; d="scan'208";a="754070209" Received: from unknown (HELO localhost.localdomain) ([10.255.16.245]) by fmsmga001.fm.intel.com with ESMTP; 08 Dec 2009 14:17:19 -0800 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 8 Dec 2009 22:17:20 +0000 Message-Id: <1260310640-5638-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.6.5.4 Subject: [Intel-gfx] [PATCH] drm/i915: Don't clflush purged objects on unbind X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 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@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 4a400b8..4b0d563 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2028,18 +2028,22 @@ i915_gem_object_unbind(struct drm_gem_object *obj) if (obj_priv->fence_reg != I915_FENCE_REG_NONE) i915_gem_clear_fence_reg(obj); - /* Move the object to the CPU domain to ensure that - * any possible CPU writes while it's not in the GTT - * are flushed when we go to remap it. This will - * also ensure that all pending GPU writes are finished - * before we unbind. - */ - ret = i915_gem_object_set_to_cpu_domain(obj, 1); - if (ret) { - if (ret != -ERESTARTSYS) - DRM_ERROR("set_domain failed: %d\n", ret); - return ret; + if (i915_gem_object_is_purgeable(obj_priv)) { + /* Wait on any GPU rendering and flushing to occur. */ + i915_gem_object_flush_gpu_write_domain(obj); + i915_gem_object_flush_gtt_write_domain(obj); + ret = i915_gem_object_wait_rendering(obj); + } else { + /* Move the object to the CPU domain to ensure that + * any possible CPU writes while it's not in the GTT + * are flushed when we go to remap it. This will + * also ensure that all pending GPU writes are finished + * before we unbind. + */ + ret = i915_gem_object_set_to_cpu_domain(obj, 1); } + if (ret) + return ret; BUG_ON(obj_priv->active);