From patchwork Tue Feb 2 21:30:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 8195951 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 90B089FE6C for ; Tue, 2 Feb 2016 21:31:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABEC120320 for ; Tue, 2 Feb 2016 21:31:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A75F0202EB for ; Tue, 2 Feb 2016 21:31:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0FA8B72098; Tue, 2 Feb 2016 13:31:10 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 75D3872093; Tue, 2 Feb 2016 13:31:08 -0800 (PST) Received: by mail-wm0-f68.google.com with SMTP id l66so4301169wml.2; Tue, 02 Feb 2016 13:31:08 -0800 (PST) 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=IQYotzpi99JzIsWYBGenQtG22jbTjh7YbnT01qA7dxM=; b=TioNzagfluVHARKPqYMbeySTFiD8/iB1It7i5ZB0qvxvRdvkVfmL+c3tiSwB8HQWD4 Zo1Ez9agANOPki74V39drW/aP582nDl394LyWhvW1V4F6yRnKF7b6MtFNjC7iiqm93on deosal7DCOHMxAn9R+JPV6IZWDS/9Rmkdpyo/FA3ZRXEjiv0cS9L/Dexn5wMtfrHaT0a ByMY2sYS+0IGX3PPDIOOm1ftM+WYBmMwCRh+RsvBu0yUFNeA+XjbQf00si2loKptrAiL Rwm/X6xg2cdmzitak0pXzTGnIiBYL4dwWQ/JocUppPBE7HNtdoLkCfl3DoA3Ix235Ljz r+8w== 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=IQYotzpi99JzIsWYBGenQtG22jbTjh7YbnT01qA7dxM=; b=RMemOkTOGjlg1Fho3dSCe2joQbz+MBN+OKTa9CZctm+cRI6reEQ8DcP6U9d4SGLiiP yoKp71tS81BWoRsBlvxrmkYK+OEu76cVwDXp1Fuxru5OVKQ9EeGxs1ymgXvPZMBhu8Jb mPqcEK0o+yqJEW1LnG2SbHZR3ZkeoqyqWQWVZAckMezvn6Up+z3uFHaGraRLWArEB0J3 W7n/tgsdALTyPjENsYI6DJ4U1GG6Zb5SjimJv9TT0Zx0paZsyN7jxtLUTQcS8bD9yOxU 45fxZI4qMATebxL4chAPHlWGvhROYNm32gy1ajjswifVx9a6BKzJ48t3i6X86C7RPNlU VJUg== X-Gm-Message-State: AG10YOTQC1IU2bQ9oz+vpeVHb4WAtZqicWZkwZlHpA6u81CN8rgjVGIHWIMEiS9P4HDU/A== X-Received: by 10.28.216.134 with SMTP id p128mr18836756wmg.59.1454448667277; Tue, 02 Feb 2016 13:31:07 -0800 (PST) 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 cb2sm3314731wjc.16.2016.02.02.13.31.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Feb 2016 13:31:06 -0800 (PST) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Tue, 2 Feb 2016 21:30:54 +0000 Message-Id: <1454448655-11178-8-git-send-email-robert@sixbynine.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454448655-11178-1-git-send-email-robert@sixbynine.org> References: <1454448655-11178-1-git-send-email-robert@sixbynine.org> Cc: David Airlie , dri-devel@lists.freedesktop.org, Sourab Gupta , Daniel Vetter Subject: [Intel-gfx] [PATCH 7/8] 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=-4.5 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 | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 7c27d93..ca4860b 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -41,6 +41,23 @@ static u32 i915_perf_stream_paranoid = true; #define OA_EXPONENT_MAX 0x3f +/* 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; + static struct i915_oa_format hsw_oa_formats[I915_OA_FORMAT_MAX] = { [I915_OA_FORMAT_A13] = { 0, 64 }, [I915_OA_FORMAT_A29] = { 1, 128 }, @@ -1098,20 +1115,12 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv, if (value > OA_EXPONENT_MAX) 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)) { + if (value < i915_oa_min_timer_exponent && + !capable(CAP_SYS_ADMIN)) { DRM_ERROR("Sampling period too high without root privileges\n"); return -EACCES; } @@ -1174,6 +1183,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, + }, {} };