From patchwork Thu Aug 18 22:42:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9288717 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 B258B607FF for ; Thu, 18 Aug 2016 22:43:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7A3C292AB for ; Thu, 18 Aug 2016 22:43:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C978292BE; Thu, 18 Aug 2016 22:43:10 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 5F14A292AB for ; Thu, 18 Aug 2016 22:43:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 159446EB5D; Thu, 18 Aug 2016 22:43:09 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 196466EB50; Thu, 18 Aug 2016 22:42:56 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id q128so1323507wma.1; Thu, 18 Aug 2016 15:42:56 -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=Re0to4s5iE5STxo2OYpBwSybgxzkQmIrMdltlTmPsrA=; b=kd1AgI4oEzMW/GEz1VMYz9kauH2anwEhIkUtAkke5qahjjq73g863ZoyYGRoiMsDEK mTQ6JrxHSnNJlLVzYkRaBiN7JHtmKpUoi8f6IfQJiCz7g9GfOqltMEWMJdmxwTRqLUDD Ng2EbFO0TWqkbni7nGMl0NtrGXk3xtQAUoF3vQFYQ6NTui6dcl5aqYnEC18GD1yZGt1v t+sOlCN9i86T7Fn8CUDkyNcIofcwDJgyUQz2ZK1uQD0y9CxNHm8t+yxo2H2YT9imJK+1 qrHZQnov2MdbuOWZkiuO/mY3p58pApKJu/tbXrC/3IEFCysIPj02WnIUDFpCIIzVKDk+ UVgA== 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=Re0to4s5iE5STxo2OYpBwSybgxzkQmIrMdltlTmPsrA=; b=Ppw6hTT1UHrsdOpNUTVjGQnfzsDAQ7vw/bGXqS6/7psthrxsXq/I2O9MU2nQf3+Y5R q0lVbXzxlQNaZxt7lTg25FEr3CwkLy7O+Xk6Br9J7kEi32v3b+9ZHfhC1u88cNnvGF8j Ifnc2bjIkFHlh+BtQCUQDCeX6ZYu1V9eRbdRJK1qPr33fuqnilfs706b6yp3tOmBM7RV pQuAMTbFULuAvYT7tlPAxIRg7roaY6D+Jc2aQNK1XjYpSBekSrL5OREGiGUpEAfpj8Tq obSa1TMAqyGxaXtVAUlK+ch46JhP/I3OAxt/YL+L1gJQR2/dAZmlCWROQNNGgF/SXGb8 9W4A== X-Gm-Message-State: AEkoouvHYXHZeJePMIjqLwHx47Yi37WjuCPQPqhT8DUuf+VQPk2id0K6NeqQ1885L2wEJg== X-Received: by 10.28.221.212 with SMTP id u203mr1263819wmg.118.1471560174130; Thu, 18 Aug 2016 15:42:54 -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 i80sm1566597wmf.11.2016.08.18.15.42.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Aug 2016 15:42:53 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Thu, 18 Aug 2016 23:42:39 +0100 Message-Id: <20160818224241.2315-10-robert@sixbynine.org> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160818224241.2315-1-robert@sixbynine.org> References: <20160818224241.2315-1-robert@sixbynine.org> Cc: David Airlie , dri-devel@lists.freedesktop.org, Sourab Gupta , Daniel Vetter Subject: [Intel-gfx] [PATCH v4 09/11] 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-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 ac1f600..3d0ba09 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -74,6 +74,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. @@ -1303,21 +1320,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; } @@ -1415,6 +1424,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, + }, {} };