From patchwork Mon Jan 13 10:54:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: akash.goel@intel.com X-Patchwork-Id: 3474451 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A72839F169 for ; Mon, 13 Jan 2014 10:52:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4551200FE for ; Mon, 13 Jan 2014 10:52:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D70AE20034 for ; Mon, 13 Jan 2014 10:52:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2FEB106ECB; Mon, 13 Jan 2014 02:52:19 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 91CF7106ECB for ; Mon, 13 Jan 2014 02:52:17 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 13 Jan 2014 02:52:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,652,1384329600"; d="scan'208";a="465767617" Received: from akashgoe-desktop.iind.intel.com ([10.223.82.34]) by orsmga002.jf.intel.com with ESMTP; 13 Jan 2014 02:52:15 -0800 From: akash.goel@intel.com To: intel-gfx@lists.freedesktop.org Date: Mon, 13 Jan 2014 16:24:05 +0530 Message-Id: <1389610445-12010-1-git-send-email-akash.goel@intel.com> X-Mailer: git-send-email 1.8.5.2 Cc: Akash Goel Subject: [Intel-gfx] [PATCH 7/7] drm/i915/vlv: Use Blitter Engine to clear out contents of Stolen frame buffers 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@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Akash Goel On VLV, to clear out the contents of Frame buffers allocated from stolen area, Blitter engine is being used, to avoid the waste of CPU cycles in doing a sw based memset. v2: Removed macros used to construct the dwords of color fill command of blittter engine. Corrected handling of stride parameter for Linear objects (Daniel) Signed-off-by: Akash Goel --- drivers/gpu/drm/i915/i915_gem_stolen.c | 89 ++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index ad01cd2b..91c7cdc 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -364,7 +364,86 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size) return NULL; } -static void i915_memset_stolen_obj(struct drm_i915_gem_object *obj) +static int i915_add_clear_obj_cmd(struct drm_i915_gem_object *obj) +{ + struct drm_i915_private *dev_priv = obj->base.dev->dev_private; + struct intel_ring_buffer *ring = &dev_priv->ring[BCS]; + u32 offset = i915_gem_obj_ggtt_offset(obj); + int ret; + + ret = intel_ring_begin(ring, 6); + if (ret) + return ret; + + intel_ring_emit(ring, (0x2 << 29) | (0x40 << 22) | + XY_SRC_COPY_BLT_WRITE_ALPHA | + XY_SRC_COPY_BLT_WRITE_RGB | + 0x3); + intel_ring_emit(ring, BLT_DEPTH_32 | (0xF0 << 16) | 4096); + intel_ring_emit(ring, + (DIV_ROUND_UP(obj->base.size, 4096) << 16) | 4096); + intel_ring_emit(ring, offset); + intel_ring_emit(ring, 0); + intel_ring_emit(ring, MI_NOOP); + intel_ring_advance(ring); + + return 0; +} + +static int i915_memset_stolen_obj_hw(struct drm_i915_gem_object *obj) +{ + struct drm_i915_private *dev_priv = obj->base.dev->dev_private; + struct intel_ring_buffer *ring = &dev_priv->ring[BCS]; + unsigned alignment = 0; + bool map_and_fenceable = true; + bool nonblocking = false; + u32 seqno; + int ret; + + /* Pre-Gen6, blitter engine is not on a separate ring */ + if (!(INTEL_INFO(obj->base.dev)->gen >= 6)) + return 1; + + ret = i915_gem_obj_ggtt_pin(obj, alignment, map_and_fenceable, + nonblocking); + if (ret) { + DRM_ERROR("Mapping of User FB to GTT failed\n"); + return ret; + } + + /* Adding commands to the blitter ring to + * clear out the contents of the buffer object + */ + ret = i915_add_clear_obj_cmd(obj); + if (ret) { + DRM_ERROR("couldn't add commands in blitter ring\n"); + i915_gem_object_ggtt_unpin(obj); + return ret; + } + + seqno = intel_ring_get_seqno(ring); + + /* Object now in render domain */ + obj->base.read_domains = I915_GEM_DOMAIN_RENDER; + obj->base.write_domain = I915_GEM_DOMAIN_RENDER; + + i915_vma_move_to_active(i915_gem_obj_to_ggtt(obj), ring); + + obj->dirty = 1; + obj->last_write_seqno = seqno; + + /* Unconditionally force add_request to emit a full flush. */ + ring->gpu_caches_dirty = true; + + /* Add a breadcrumb for the completion of the clear request */ + (void)i915_add_request(ring, NULL); + + i915_gem_object_ggtt_unpin(obj); + + return 0; +} + +static void i915_memset_stolen_obj_sw(struct drm_i915_gem_object *obj) { int ret; char __iomem *base; @@ -483,9 +562,13 @@ i915_gem_object_move_to_stolen(struct drm_i915_gem_object *obj) obj->cache_level = HAS_LLC(dev) ? I915_CACHE_LLC : I915_CACHE_NONE; /* Zero-out the contents of the stolen object, otherwise we observe - * corruptions in the display. + * corruptions in the display. First try using the blitter engine + * to clear the buffer contents */ - i915_memset_stolen_obj(obj); + ret = i915_memset_stolen_obj_hw(obj); + /* fallback to Sw based memset if Hw memset fails */ + if (ret) + i915_memset_stolen_obj_sw(obj); return; cleanup: