From patchwork Thu Mar 16 06:14:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sourab.gupta@intel.com X-Patchwork-Id: 9627241 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 8968B604A9 for ; Thu, 16 Mar 2017 06:12:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A017285EE for ; Thu, 16 Mar 2017 06:12:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E02D285EF; Thu, 16 Mar 2017 06:12:43 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 222192843D for ; Thu, 16 Mar 2017 06:12:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91C1D6E9F5; Thu, 16 Mar 2017 06:12:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id D13B16E9F5 for ; Thu, 16 Mar 2017 06:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489644760; x=1521180760; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=4Z0exKb9DzpgvoWZews7Oi9nOg2q/EyA+1sB8zUZJ3w=; b=ZvlfBMMLO0S0ohspZ/aOW1K0EjccM6QgAtKD8swzNnFg1+Y9ubNvDMnW qE+Z5PyvpKRD155ZgXauRrW0R7omYg==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2017 23:12:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,170,1486454400"; d="scan'208";a="944881959" Received: from sourab-desktop.iind.intel.com ([10.223.82.140]) by orsmga003.jf.intel.com with ESMTP; 15 Mar 2017 23:12:38 -0700 From: sourab.gupta@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 16 Mar 2017 11:44:12 +0530 Message-Id: <1489644855-25562-6-git-send-email-sourab.gupta@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489644855-25562-1-git-send-email-sourab.gupta@intel.com> References: <1489644855-25562-1-git-send-email-sourab.gupta@intel.com> Cc: Daniel Vetter , Sourab Gupta , Matthew Auld Subject: [Intel-gfx] [PATCH 5/8] drm/i915: Inform userspace about command stream OA buf overflow 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: Sourab Gupta Considering how we don't currently give userspace control over the OA buffer size and always configure a large 16MB buffer, then a buffer overflow does anyway likely indicate that something has gone quite badly wrong. Here we set a status flag to detect overflow and inform userspace of the report_lost condition accordingly. This is in line with the behavior of the periodic OA buffer. Signed-off-by: Sourab Gupta --- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_perf.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index d0f43e9..0f2a552 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2609,6 +2609,8 @@ struct drm_i915_private { struct { struct i915_vma *vma; u8 *vaddr; +#define I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW (1<<0) + u32 status; } command_stream_buf; struct list_head cs_samples; diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index d1d9853..2841d0a 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -478,6 +478,8 @@ static void insert_perf_sample(struct drm_i915_private *dev_priv, else { u32 target_size = sample_size - first->offset; + dev_priv->perf.command_stream_buf.status |= + I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW; release_perf_samples(dev_priv, target_size); sample->offset = 0; } @@ -491,6 +493,8 @@ static void insert_perf_sample(struct drm_i915_private *dev_priv, (first->offset - last->offset - sample_size); + dev_priv->perf.command_stream_buf.status |= + I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW; release_perf_samples(dev_priv, target_size); sample->offset = last->offset + sample_size; } @@ -1577,6 +1581,17 @@ static int oa_rcs_append_reports(struct i915_perf_stream *stream, struct i915_perf_cs_sample *entry, *next; LIST_HEAD(free_list); int ret = 0; + u32 status = dev_priv->perf.command_stream_buf.status; + + if (unlikely(status & I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW)) { + ret = append_oa_status(stream, buf, count, offset, + DRM_I915_PERF_RECORD_OA_BUFFER_LOST); + if (ret) + return ret; + + dev_priv->perf.command_stream_buf.status &= + ~I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW; + } spin_lock(&dev_priv->perf.sample_lock); if (list_empty(&dev_priv->perf.cs_samples)) {