From patchwork Fri Jun 10 13:36:29 2016 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: 9169803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DDA9E60573 for ; Fri, 10 Jun 2016 13:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF35628319 for ; Fri, 10 Jun 2016 13:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C41992835E; Fri, 10 Jun 2016 13:23:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E03628319 for ; Fri, 10 Jun 2016 13:23:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7BA46ED43; Fri, 10 Jun 2016 13:23:50 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 7DC6A6ED3D for ; Fri, 10 Jun 2016 13:23:39 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 10 Jun 2016 06:23:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,449,1459839600"; d="scan'208";a="825507101" Received: from akashgoe-desktop.iind.intel.com ([10.223.82.36]) by orsmga003.jf.intel.com with ESMTP; 10 Jun 2016 06:23:38 -0700 From: akash.goel@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 10 Jun 2016 19:06:29 +0530 Message-Id: <1465565789-30570-12-git-send-email-akash.goel@intel.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1465565789-30570-1-git-send-email-akash.goel@intel.com> References: <1465565789-30570-1-git-send-email-akash.goel@intel.com> Cc: sourab.gupta@intel.com, Akash Goel Subject: [Intel-gfx] [PATCH 11/11] drm/i915: Use uncached(WC) mapping for acessing the GuC log buffer X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Akash Goel Host needs to sample the GuC log buffer on every flush interrupt from GuC. To ensure that we always get the up-to-date data from log buffer, its better to access the buffer through an uncached CPU mapping. Since the data to be read is less than 50 KB, there would not be any performance implications. Signed-off-by: Akash Goel --- drivers/gpu/drm/i915/i915_guc_submission.c | 27 +++++++++++++++++++++------ drivers/gpu/drm/i915/intel_guc.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c index cf72482..3408c4f 100644 --- a/drivers/gpu/drm/i915/i915_guc_submission.c +++ b/drivers/gpu/drm/i915/i915_guc_submission.c @@ -816,8 +816,7 @@ static void guc_read_update_log_buffer(struct drm_device *dev) if (!guc->log_obj) return; - log_buffer_state = src_ptr = - kmap_atomic(i915_gem_object_get_page(guc->log_obj, 0)); + log_buffer_state = src_ptr = guc->log_buf_addr; /* Get the pointer to local buffer to store the logs */ dst_ptr = log_buffer_copy_state = guc_get_write_buffer(guc); @@ -847,14 +846,11 @@ static void guc_read_update_log_buffer(struct drm_device *dev) log_buffer_copy_state++; } - kunmap_atomic(src_ptr); - /* Now copy the actual logs */ for (i=1; (i < guc->log_obj->base.size / PAGE_SIZE) && dst_ptr; i++) { dst_ptr += PAGE_SIZE; - src_ptr = kmap_atomic(i915_gem_object_get_page(guc->log_obj, i)); + src_ptr += PAGE_SIZE; memcpy(dst_ptr, src_ptr, PAGE_SIZE); - kunmap_atomic(src_ptr); } } @@ -983,6 +979,7 @@ static void guc_create_log(struct intel_guc *guc) struct drm_i915_gem_object *obj; unsigned long offset; uint32_t size, flags; + void *vaddr; if (i915.guc_log_level > GUC_LOG_VERBOSITY_MAX) i915.guc_log_level = GUC_LOG_VERBOSITY_MAX; @@ -1003,6 +1000,21 @@ static void guc_create_log(struct intel_guc *guc) } guc->log_obj = obj; + + /* Create a WC (Uncached for read) mapping so that we can + * directly get the data (up-to-date) from system memory. + */ + vaddr = i915_gem_object_pin_map(obj, true); + if (IS_ERR(vaddr)) { + DRM_DEBUG_DRIVER("Couldn't map log buffer pages(%ld)\n", + PTR_ERR(vaddr)); + i915.guc_log_level = -1; + gem_release_guc_obj(dev_priv->guc.log_obj); + guc->log_obj = NULL; + return; + } + + guc->log_buf_addr = vaddr; } /* each allocated unit is a page */ @@ -1176,6 +1188,9 @@ void i915_guc_submission_fini(struct drm_device *dev) gem_release_guc_obj(dev_priv->guc.ads_obj); guc->ads_obj = NULL; + if (guc->log_obj) + i915_gem_object_unpin_map(guc->log_obj); + guc->log_buf_addr = NULL; gem_release_guc_obj(dev_priv->guc.log_obj); guc->log_obj = NULL; guc_logging_fini(guc); diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h index 6f4828b..d6146e4 100644 --- a/drivers/gpu/drm/i915/intel_guc.h +++ b/drivers/gpu/drm/i915/intel_guc.h @@ -125,6 +125,7 @@ struct intel_guc { struct intel_guc_fw guc_fw; uint32_t log_flags; struct drm_i915_gem_object *log_obj; + void *log_buf_addr; struct rchan *log_relay_chan; /* * work, interrupts_enabled are protected by dev_priv->irq_lock