From patchwork Thu Sep 7 10:06:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sagar.a.kamble@intel.com X-Patchwork-Id: 9941975 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 00033602CC for ; Thu, 7 Sep 2017 10:03:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F40A28600 for ; Thu, 7 Sep 2017 10:03:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0423528608; Thu, 7 Sep 2017 10:03:06 +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]) (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 B452D28600 for ; Thu, 7 Sep 2017 10:03:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 059016E8D2; Thu, 7 Sep 2017 10:03:05 +0000 (UTC) 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 ESMTPS id 9EEF26E8D2 for ; Thu, 7 Sep 2017 10:03:03 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2017 03:03:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,357,1500966000"; d="scan'208";a="126439729" Received: from sakamble-desktop.iind.intel.com ([10.223.26.118]) by orsmga004.jf.intel.com with ESMTP; 07 Sep 2017 03:03:02 -0700 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Sep 2017 15:36:06 +0530 Message-Id: <1504778774-18117-7-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1504778774-18117-1-git-send-email-sagar.a.kamble@intel.com> References: <1504778774-18117-1-git-send-email-sagar.a.kamble@intel.com> Cc: Sourab Gupta Subject: [Intel-gfx] [PATCH 06/14] 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 Signed-off-by: Sagar Arun Kamble --- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_perf.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index cd0920d..db2505f 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2120,6 +2120,8 @@ struct i915_perf_stream { struct { struct i915_vma *vma; u8 *vaddr; +#define I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW (1<<0) + u32 status; } cs_buffer; struct list_head cs_samples; diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 0b1aa78..7664c5b 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -613,8 +613,11 @@ static void i915_perf_stream_patch_request(struct i915_perf_stream *stream, while (sample_id < MAX_REQUEST_SAMPLE_ID) { spin_lock_irqsave(&stream->samples_lock, flags); - if (list_empty(&stream->free_samples)) + if (list_empty(&stream->free_samples)) { + stream->cs_buffer.status |= + I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW; release_perf_sample(stream); + } sample = list_first_entry_or_null(&stream->free_samples, struct i915_perf_cs_sample, link); WARN_ON(sample == NULL); @@ -1572,6 +1575,17 @@ static int append_cs_buffer_samples(struct i915_perf_stream *stream, LIST_HEAD(free_list); int ret = 0; unsigned long flags; + u32 status = stream->cs_buffer.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; + + stream->cs_buffer.status &= + ~I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW; + } spin_lock_irqsave(&stream->samples_lock, flags); if (list_empty(&stream->cs_samples)) {