From patchwork Fri May 27 19:42:55 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: 9138903 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 F2E766075A for ; Fri, 27 May 2016 19:32:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4AF527CF9 for ; Fri, 27 May 2016 19:32:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D977A28294; Fri, 27 May 2016 19:32:05 +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 57CE427CF9 for ; Fri, 27 May 2016 19:32:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F0D16ED18; Fri, 27 May 2016 19:32:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id C69EC6E0DF for ; Fri, 27 May 2016 19:30:02 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 27 May 2016 12:30:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,375,1459839600"; d="scan'208";a="986117287" Received: from akashgoe-desktop.iind.intel.com ([10.223.82.36]) by orsmga002.jf.intel.com with ESMTP; 27 May 2016 12:30:00 -0700 From: akash.goel@intel.com To: intel-gfx@lists.freedesktop.org Date: Sat, 28 May 2016 01:12:55 +0530 Message-Id: <1464378183-9433-5-git-send-email-akash.goel@intel.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1464378183-9433-1-git-send-email-akash.goel@intel.com> References: <1464378183-9433-1-git-send-email-akash.goel@intel.com> Cc: sourab.gupta@intel.com, Akash Goel Subject: [Intel-gfx] [RFC 04/12] drm/i915: Handle log buffer flush interrupt event from GuC 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: Sagar Arun Kamble GuC ukernel sends an interrupt to Host to flush the log buffer and expects Host to correspondingly update the read pointer information in the state structure, once it has consumed the log buffer contents by copying them to a file or buffer. Even if Host couldn't copy the contents, it can still update the read pointer so that logging state is not disturbed on GuC side. Signed-off-by: Sagar Arun Kamble Signed-off-by: Akash Goel --- drivers/gpu/drm/i915/i915_guc_submission.c | 81 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_irq.c | 19 ++++++- drivers/gpu/drm/i915/intel_guc.h | 1 + 3 files changed, 100 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c index c2f3a67..f7f29f6 100644 --- a/drivers/gpu/drm/i915/i915_guc_submission.c +++ b/drivers/gpu/drm/i915/i915_guc_submission.c @@ -769,6 +769,74 @@ err: return NULL; } +static void guc_move_to_next_buf(struct intel_guc *guc) +{ + return; +} + +static void* guc_get_write_buffer(struct intel_guc *guc) +{ + void *base_addr = NULL; + + return base_addr; +} + +static void guc_read_update_log_buffer(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_guc *guc = &dev_priv->guc; + struct guc_log_buffer_state *log_buffer_state; + struct guc_log_buffer_state *log_buffer_copy_state; + void *page, *data_ptr; + int i; + + if (!guc->log_obj) + return; + + log_buffer_state = page = + kmap_atomic(i915_gem_object_get_page(guc->log_obj, 0)); + + /* Get the pointer to local buffer to store the logs */ + data_ptr = log_buffer_copy_state = guc_get_write_buffer(guc); + if (log_buffer_copy_state) + memcpy(log_buffer_copy_state, log_buffer_state, PAGE_SIZE); + + for (i = 0; i < GUC_MAX_LOG_BUFFER; i++) { + /* Update the read pointer in the shared log buffer */ + log_buffer_state->read_ptr = + log_buffer_state->sampled_write_ptr; + + /* Clear the 'flush to file' flag */ + log_buffer_state->flush_to_file = 0; + log_buffer_state++; + + if (!log_buffer_copy_state) + continue; + + /* The write pointer could have been updated by the GuC firmware, + * after sending the flush interrupt to Host, for consistency + * set the write pointer value to same value of sampled_write_ptr + * in the snapshot buffer. + */ + log_buffer_copy_state->write_ptr = + log_buffer_copy_state->sampled_write_ptr; + + log_buffer_copy_state++; + } + + kunmap_atomic(page); + + /* Now copy the actual logs */ + for (i=1; (i < guc->log_obj->base.size / PAGE_SIZE) && data_ptr; i++) { + data_ptr += PAGE_SIZE; + page = kmap_atomic(i915_gem_object_get_page(guc->log_obj, i)); + memcpy(data_ptr, page, PAGE_SIZE); + kunmap_atomic(page); + } + + guc_move_to_next_buf(guc); +} + static void guc_create_log(struct intel_guc *guc) { struct drm_i915_private *dev_priv = guc_to_i915(guc); @@ -1027,3 +1095,16 @@ int intel_guc_resume(struct drm_device *dev) return host2guc_action(guc, data, ARRAY_SIZE(data)); } + +void i915_guc_capture_logs(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_guc *guc = &dev_priv->guc; + u32 data[1]; + + guc_read_update_log_buffer(dev); + + data[0] = HOST2GUC_ACTION_LOG_BUFFER_FILE_FLUSH_COMPLETE; + if (host2guc_action(guc, data, 1)) + DRM_ERROR("Failed\n"); +} diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index b4294a8..6cea65b 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -1228,6 +1228,7 @@ static void gen8_guc2host_events_work(struct work_struct *work) { struct drm_i915_private *dev_priv = container_of(work, struct drm_i915_private, guc.events_work); + u32 msg; spin_lock_irq(&dev_priv->irq_lock); /* Speed up work cancelation during disabling guc interrupts. */ @@ -1241,7 +1242,23 @@ static void gen8_guc2host_events_work(struct work_struct *work) gen6_enable_pm_irq(dev_priv, GEN8_GUC_TO_HOST_INT_EVENT); spin_unlock_irq(&dev_priv->irq_lock); - /* TODO: Handle the events for which GuC interrupted host */ + /* Determine why GuC interrupted host and process */ + msg = I915_READ(SOFT_SCRATCH(15)); + if (msg & (GUC2HOST_MSG_CRASH_DUMP_POSTED | + GUC2HOST_MSG_FLUSH_LOG_BUFFER)) { + i915_guc_capture_logs(dev_priv->dev); + + /* Clear GuC to Host msg bits that are handled */ + if (msg & GUC2HOST_MSG_FLUSH_LOG_BUFFER) + I915_WRITE(SOFT_SCRATCH(15), + I915_READ(SOFT_SCRATCH(15)) & + ~GUC2HOST_MSG_FLUSH_LOG_BUFFER); + + if (msg & GUC2HOST_MSG_CRASH_DUMP_POSTED) + I915_WRITE(SOFT_SCRATCH(15), + I915_READ(SOFT_SCRATCH(15)) & + ~GUC2HOST_MSG_CRASH_DUMP_POSTED); + } ENABLE_RPM_WAKEREF_ASSERTS(dev_priv); } diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h index e20792d..92d70d8 100644 --- a/drivers/gpu/drm/i915/intel_guc.h +++ b/drivers/gpu/drm/i915/intel_guc.h @@ -167,5 +167,6 @@ int i915_guc_wq_check_space(struct drm_i915_gem_request *rq); int i915_guc_submit(struct drm_i915_gem_request *rq); void i915_guc_submission_disable(struct drm_device *dev); void i915_guc_submission_fini(struct drm_device *dev); +void i915_guc_capture_logs(struct drm_device *dev); #endif