From patchwork Thu May 7 14:15:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 6358571 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0369A9F32B for ; Thu, 7 May 2015 14:16:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21C782034E for ; Thu, 7 May 2015 14:16:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 60823203E1 for ; Thu, 7 May 2015 14:16:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DEF186E846; Thu, 7 May 2015 07:16:11 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 878546E834; Thu, 7 May 2015 07:16:10 -0700 (PDT) Received: by wizk4 with SMTP id k4so244583466wiz.1; Thu, 07 May 2015 07:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2yX+VYIW7WLUC3nEjNck2lIfNXOqZt+/uT1W0riT2D4=; b=DaJl6o5gxg12nkLUb/fZNYWPiz5ic/a2pHom4Cvgv8T0VX5HuTN17CVY0uqlqz8V+P SHE2iFTJaR0QlalNXBI2ptfKoJxInv3Mjlxiu8F0GyC0eX/vT7mSfRvUiCv3cdeDuQaH vQO7xkwgkNj18W3tDJwVKMbG+QvjGWuc92igSqrUiifCtA6PU+LCVmgLce5wjjYmhBmb gOP6Awz97bQHnYP3ifo3R1Xi8ZjYWcgS2bdkPM/jki6eMGUnSMo2ON0zmvkV9VUn4xzV xJFiVLaZQh71oem4C7gNSgSlk4rYI0u776faJ0ZWhsXIKyy+gWmiPYCTNEnpc+FGeIr+ +5Tg== X-Received: by 10.180.74.102 with SMTP id s6mr6864080wiv.37.1431008169644; Thu, 07 May 2015 07:16:09 -0700 (PDT) Received: from sixbynine.org (cpc26-heme10-2-0-cust305.9-1.cable.virginm.net. [86.3.57.50]) by mx.google.com with ESMTPSA id l3sm7653378wiv.18.2015.05.07.07.16.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 07:16:08 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Thu, 7 May 2015 15:15:53 +0100 Message-Id: <1431008154-6833-11-git-send-email-robert@sixbynine.org> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1431008154-6833-1-git-send-email-robert@sixbynine.org> References: <1431008154-6833-1-git-send-email-robert@sixbynine.org> Cc: Peter Zijlstra , David Airlie , linux-api@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ingo Molnar , Paul Mackerras , Arnaldo Carvalho de Melo , Daniel Vetter Subject: [Intel-gfx] [RFC PATCH 10/11] drm/i915: report OA buf overrun + report lost status 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 This adds two driver specific PERF_RECORD_DEVICE event types for reporting OA buffer overrun and report lost status bits to userspace. Signed-off-by: Robert Bragg --- drivers/gpu/drm/i915/i915_oa_perf.c | 53 ++++++++++++++++++++++++------------- include/uapi/drm/i915_drm.h | 27 +++++++++++++++++++ 2 files changed, 62 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_oa_perf.c b/drivers/gpu/drm/i915/i915_oa_perf.c index c3e5059..d0dad5d 100644 --- a/drivers/gpu/drm/i915/i915_oa_perf.c +++ b/drivers/gpu/drm/i915/i915_oa_perf.c @@ -159,6 +159,34 @@ static u32 forward_oa_snapshots(struct drm_i915_private *dev_priv, return dev_priv->oa_pmu.oa_buffer.gtt_offset + head; } +static void log_oa_status(struct drm_i915_private *dev_priv, + enum drm_i915_oa_event_type status) +{ + struct { + struct perf_event_header header; + drm_i915_oa_event_header_t i915_oa_header; + } oa_event; + struct perf_output_handle handle; + struct perf_sample_data sample_data; + struct perf_event *event = dev_priv->oa_pmu.exclusive_event; + int ret; + + oa_event.header.size = sizeof(oa_event); + oa_event.header.type = PERF_RECORD_DEVICE; + oa_event.i915_oa_header.type = status; + oa_event.i915_oa_header.__reserved_1 = 0; + + perf_event_header__init_id(&oa_event.header, &sample_data, event); + + ret = perf_output_begin(&handle, event, oa_event.header.size); + if (ret) + return; + + perf_output_put(&handle, oa_event); + perf_event__output_id_sample(event, &handle, &sample_data); + perf_output_end(&handle); +} + static void flush_oa_snapshots(struct drm_i915_private *dev_priv, bool skip_if_flushing) { @@ -189,25 +217,14 @@ static void flush_oa_snapshots(struct drm_i915_private *dev_priv, head = oastatus2 & GEN7_OASTATUS2_HEAD_MASK; tail = oastatus1 & GEN7_OASTATUS1_TAIL_MASK; - if (oastatus1 & (GEN7_OASTATUS1_OABUFFER_OVERFLOW | - GEN7_OASTATUS1_REPORT_LOST)) { + if (unlikely(oastatus1 & (GEN7_OASTATUS1_OABUFFER_OVERFLOW | + GEN7_OASTATUS1_REPORT_LOST))) { - /* XXX: How can we convey report-lost errors to userspace? It - * doesn't look like perf's _REPORT_LOST mechanism is - * appropriate in this case; that's just for cases where we - * run out of space for samples in the perf circular buffer. - * - * Maybe we can claim a special report-id and use that to - * forward status flags? - */ - pr_debug("OA buffer read error: addr = %p, head = %u, offset = %u, tail = %u cnt o'flow = %d, buf o'flow = %d, rpt lost = %d\n", - dev_priv->oa_pmu.oa_buffer.addr, - head, - head - dev_priv->oa_pmu.oa_buffer.gtt_offset, - tail, - oastatus1 & GEN7_OASTATUS1_COUNTER_OVERFLOW ? 1 : 0, - oastatus1 & GEN7_OASTATUS1_OABUFFER_OVERFLOW ? 1 : 0, - oastatus1 & GEN7_OASTATUS1_REPORT_LOST ? 1 : 0); + if (oastatus1 & GEN7_OASTATUS1_OABUFFER_OVERFLOW) + log_oa_status(dev_priv, I915_OA_RECORD_BUFFER_OVERFLOW); + + if (oastatus1 & GEN7_OASTATUS1_REPORT_LOST) + log_oa_status(dev_priv, I915_OA_RECORD_REPORT_LOST); I915_WRITE(GEN7_OASTATUS1, oastatus1 & ~(GEN7_OASTATUS1_OABUFFER_OVERFLOW | diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 7aa1d33..2871922 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -89,6 +89,33 @@ typedef struct _drm_i915_oa_attr { __reserved_1 : 63; } drm_i915_oa_attr_t; +/* Header for PERF_RECORD_DEVICE type events */ +typedef struct _drm_i915_oa_event_header { + __u32 type; + __u32 __reserved_1; +} drm_i915_oa_event_header_t; + +enum drm_i915_oa_event_type { + + /* + * struct { + * struct perf_event_header header; + * drm_i915_oa_event_header_t i915_oa_header; + * }; + */ + I915_OA_RECORD_BUFFER_OVERFLOW = 1, + + /* + * struct { + * struct perf_event_header header; + * drm_i915_oa_event_header_t i915_oa_header; + * }; + */ + I915_OA_RECORD_REPORT_LOST = 2, + + I915_OA_RECORD_MAX, /* non-ABI */ +}; + /* Each region is a minimum of 16k, and there are at most 255 of them. */ #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use