From patchwork Wed Apr 20 14:23:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 8890371 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 B49A59F441 for ; Wed, 20 Apr 2016 14:24:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43241201C0 for ; Wed, 20 Apr 2016 14:24:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5B88E2012B for ; Wed, 20 Apr 2016 14:24:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AAFC6EA0F; Wed, 20 Apr 2016 14:24:40 +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 8BA6A6EA0F; Wed, 20 Apr 2016 14:24:38 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id l6so14215889wml.3; Wed, 20 Apr 2016 07:24:38 -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=o0WchxmHD0FB6iT/Y6un0LGFXQAX2GPEZDhF8rj6ygA=; b=sGePeH00J9tqm3lpguHv0uvL7VUaqMCbzSC253lSjkdppFqQeHmasJPqArsLRK1xgx YXcalyyrofQZhbSKqW2zWw8sGfUr+CBGvFrj/3dsWJ3Hj/a6OYr+NDzrJI/uz38mslcp 2xotFxNQNigYuprgtLMHej7tH/3db43eZODVLg4oLD7LGTs/Dc0nfvcKipViWQurljHt rXoIrWZKEJE2LJW02K3jEdMqg/HRs3bxDgpeV1msleI0I+VAyjMSqjuS2G4qj9lfTzLc sH5ZuE2sWMqtK8WnwLsyJcDdLU5OL0zBZMcYtIz2XWiHPLi9A39AqxjsVInxitLQmYJk Rk2w== 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=o0WchxmHD0FB6iT/Y6un0LGFXQAX2GPEZDhF8rj6ygA=; b=PQB0rtiP2UNToMHG0YZdlb/924AKiRwMpbNS6Aq05Jc8ZZYRZd6vBlCPZep7VhNez3 3BZC+3tBFgoOhng598chNoNpv9+Sxw+veiPL7AQRqDEvKGHiiwFH098Z6IhvT1dGyB6z 3skzjRjNNgSRlLxXJJJni0xKSiZlulJjUvmBsgbwooe7lHvVrgUgAjVoUETLUwa15Li0 IwSX2BlpUumrg1DKapAteSypZPQwRJrd7jsZVABYH4iOrBk7iaAbT0tEK7MDfth6/1dE KRU4ADQhoP7BmoDkIr5mwpbj9aXIgzf5kZeSTDTK4Stj0YHqH+vaW83Tbklt+o9DLyLC bjfQ== X-Gm-Message-State: AOPr4FWFc0Ra7TgoLXPLKNYyA20h/GdJ3Oc/xonp4/vNYu12QLXoFEBncljvS9bj9ceLMA== X-Received: by 10.194.34.39 with SMTP id w7mr9008956wji.19.1461162276843; Wed, 20 Apr 2016 07:24:36 -0700 (PDT) Received: from sixbynine.org (host-78-151-18-103.as13285.net. [78.151.18.103]) by smtp.gmail.com with ESMTPSA id r204sm9915810wmg.20.2016.04.20.07.24.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Apr 2016 07:24:36 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Wed, 20 Apr 2016 15:23:13 +0100 Message-Id: <1461162194-1424-9-git-send-email-robert@sixbynine.org> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1461162194-1424-1-git-send-email-robert@sixbynine.org> References: <1461162194-1424-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 8/9] 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=ham 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 c2ba16a..cc1cd52 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. @@ -1250,21 +1267,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; } @@ -1326,6 +1335,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, + }, {} };