From patchwork Fri Apr 29 18:21:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 8984731 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35792BF29F for ; Fri, 29 Apr 2016 18:23:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47AB7201ED for ; Fri, 29 Apr 2016 18:23:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4CBB7201CE for ; Fri, 29 Apr 2016 18:23:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3A736EFF4; Fri, 29 Apr 2016 18:23:08 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4310D6EFE1; Fri, 29 Apr 2016 18:22:16 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id w143so6754055wmw.3; Fri, 29 Apr 2016 11:22:16 -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=YLFDbxBnzAxo6OGt5lywB62ihljFDZTHptoW/wNIM+8=; b=B4kMwFUX6EDdehD0YHgkqX5ubKEKa3QhurbhHivGFiphyKyaa1HJUM2ZCYqa8YXZYF JqR40ASolo3K7I/9pFc3pWYckvrbpkArQSd8pFe6HPhoxnwdnVIl4ORU60N1M8ZvbRzF WVC+dqNLj0u6WT/v9raEZn/6JjrIiHq6s+2O9n/uk1T0Zk/MHuu5Xk/HnEjLR6zWuHbF 2NhuOion4kd+X0TxDLNfXo+SGdWO5h8A8u2uYTwO1o5S5ArBjNMDOaDFXkClKGHBqzEY gm2Xn8HhxvASNXXDhbKdsn5weYKatAj1Sa6Py3syjk0L8Y71Ou4cgr9fFksQNTlNiOTR oOWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=YLFDbxBnzAxo6OGt5lywB62ihljFDZTHptoW/wNIM+8=; b=iZkv3gVZicKxrdrJPXpPP/cywLpbprsanicX4LtGLkYxELQMu6dAiMIfwmYJe5vfgR 9FI5BR4ZbnCukNOH++5UA9wOyj8IvuRG2Uki9DoMgNR1FYlPwJiYtwlEybo6qCTt/p/a 4CVi5c4oPAkq+z6vW/xR8SZ5zm4FNEwdCyMHrUelIFKx0/97LQcMbfx96FeTtfuypdjM N1SwH/qOr2kd1mWZBdiTO/6tX5W/edUOWy0cKrjENYgEynWFkU14KTr5rC8lB+vXMXob nYsobSx3fyjgkp7ByaPnPalMIEgH8fpT0m1pJzU3NCmOlR3ZrgXUOzJpE/mdNep6/BXO RFxQ== X-Gm-Message-State: AOPr4FXL2r0RyrsOkm8a+jBavpfXM0HZEA6PsgiAPsZa86Jwq8pvkQps07ypef5h65ZWMw== X-Received: by 10.28.31.73 with SMTP id f70mr6011818wmf.77.1461954134011; Fri, 29 Apr 2016 11:22:14 -0700 (PDT) Received: from sixbynine.org (cpc26-heme10-2-0-cust305.9-1.cable.virginm.net. [86.3.57.50]) by smtp.gmail.com with ESMTPSA id i1sm8558078wjd.38.2016.04.29.11.22.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Apr 2016 11:22:13 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Fri, 29 Apr 2016 19:21:44 +0100 Message-Id: <1461954105-5940-10-git-send-email-robert@sixbynine.org> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1461954105-5940-1-git-send-email-robert@sixbynine.org> References: <1461954105-5940-1-git-send-email-robert@sixbynine.org> Cc: David Airlie , dri-devel@lists.freedesktop.org, Sourab Gupta , Deepak S , Daniel Vetter Subject: [Intel-gfx] [PATCH v2 09/10] drm/i915: add oa_event_min_timer_exponent sysctl 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=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 The minimal sampling period is now configurable via a dev.i915.oa_min_timer_exponent sysctl parameter. Following the precedent set by perf, the default is the minimum that won't (on its own) exceed the default kernel.perf_event_max_sample_rate default of 100000 samples/s. Signed-off-by: Robert Bragg --- drivers/gpu/drm/i915/i915_perf.c | 42 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 3789378..045ffe8 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -71,6 +71,23 @@ static u32 i915_perf_stream_paranoid = true; */ #define OA_EXPONENT_MAX 31 +/* for sysctl proc_dointvec_minmax of i915_oa_min_timer_exponent */ +static int zero; +static int oa_exponent_max = OA_EXPONENT_MAX; + +/* Theoretically we can program the OA unit to sample every 160ns but don't + * allow that by default unless root... + * + * The period is derived from the exponent as: + * + * period = 80ns * 2^(exponent + 1) + * + * Referring to perf's kernel.perf_event_max_sample_rate for a precedent + * (100000 by default); with an OA exponent of 6 we get a period of 10.240 + * microseconds - just under 100000Hz + */ +static u32 i915_oa_min_timer_exponent = 6; + /* XXX: beware if future OA HW adds new report formats that the current * code assumes all reports have a power-of-two size and ~(size - 1) can * be used as a mask to align the OA tail pointer. @@ -1229,21 +1246,13 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv, return -EINVAL; } - /* NB: The exponent represents a period as follows: - * - * 80ns * 2^(period_exponent + 1) - * - * Theoretically we can program the OA unit to sample + /* Theoretically we can program the OA unit to sample * every 160ns but don't allow that by default unless * root. - * - * Referring to perf's - * kernel.perf_event_max_sample_rate for a precedent - * (100000 by default); with an OA exponent of 6 we get - * a period of 10.240 microseconds -just under 100000Hz */ - if (value < 6 && !capable(CAP_SYS_ADMIN)) { - DRM_ERROR("Sampling period too high without root privileges\n"); + if (value < i915_oa_min_timer_exponent && + !capable(CAP_SYS_ADMIN)) { + DRM_ERROR("OA timer exponent too low without root privileges\n"); return -EACCES; } @@ -1305,6 +1314,15 @@ static struct ctl_table oa_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, + { + .procname = "oa_min_timer_exponent", + .data = &i915_oa_min_timer_exponent, + .maxlen = sizeof(i915_oa_min_timer_exponent), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &oa_exponent_max, + }, {} };