From patchwork Fri Oct 28 02:14:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9400859 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 1361D60231 for ; Fri, 28 Oct 2016 02:15:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02FCE2A463 for ; Fri, 28 Oct 2016 02:15:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC3302A465; Fri, 28 Oct 2016 02:15:57 +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=ham 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 748082A463 for ; Fri, 28 Oct 2016 02:15:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D7556EB57; Fri, 28 Oct 2016 02:15:01 +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 4DE1D6EB07; Fri, 28 Oct 2016 02:14:45 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id m83so5282091wmc.0; Thu, 27 Oct 2016 19:14:45 -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=fUPxe4/1MU3ESN9ZWIxGU3qNd7xRhKVS4YnXb1qgWuI=; b=kLRS24eM3Kh62BNmGF7BZopFjtDbDKdmIxSJlR386b9PbxvH42KJICctt3A+7LJ5ek ATU5Qe38Osd7PW3tMgiw52QSyFkeOEVDsU/v13767zUdu3RoublniHVCd8RotEJs+2LU 3vHKazB4zzhe/WpbLHrqDrGCeXRTR1AAMFh6Ou31jFgS+AcjpNSnavz4lwLizmTuOjAI 1LHnhvEO1NtnbBqaDwLNEugK0Yoz7/3CXrjSl+0HPLUQ6KeMW+tQYuj7O/faCN4Mx4bO FQpfoNFwB1UFpLtSbAWpb2dztZGqQvKIrbi/XRJBY/v4B/dfwxennIADgJaWd7TijsW4 12Lw== 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=fUPxe4/1MU3ESN9ZWIxGU3qNd7xRhKVS4YnXb1qgWuI=; b=OQjR6fuI9NR7CLLtaill/tw/pwbKeRQyDBV3HdhSoSAhgHBwP98Sj2XwB+Zj3suljt oLeMptPAN5+B1DywNEde+Y27quoyvD7tdIWXd+F7p5OH5m5u8XCpHFn974fFGcSVQ9p2 FOsFzrg1DGKaIH4ekcXsghtjRahRTmnkdAe3SLM2cs0lqpw2qvKMI/uuOxUzuIjNvl+D TdaOAmMBYyhJnzM/oKbmOBtUxVPigUzdg0kTRI6kGUc0pQ5KLwVkq+K+3GAVCeP/0X5Q io7XRJF1yvVXYRRym6ChkVf3jzyfMtJeg1Tj87MbJqHKKIgp7xdXSrJuVm2eTRbt6ZWZ HQzQ== X-Gm-Message-State: ABUngvdMqRh5ExuRsCRcpVS2BpEE0k7sdeLUQ2qg1o8Iz8FoxxS9QwsqOS1QteocZjsHgA== X-Received: by 10.194.236.72 with SMTP id us8mr9342405wjc.211.1477620883892; Thu, 27 Oct 2016 19:14:43 -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 l19sm6362550wmg.5.2016.10.27.19.14.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Oct 2016 19:14:43 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Fri, 28 Oct 2016 03:14:28 +0100 Message-Id: <20161028021430.2177-11-robert@sixbynine.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161028021430.2177-1-robert@sixbynine.org> References: <20161028021430.2177-1-robert@sixbynine.org> Cc: David Airlie , dri-devel@lists.freedesktop.org, Sourab Gupta , Daniel Vetter Subject: [Intel-gfx] [PATCH v8 10/12] 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 Reviewed-by: Matthew Auld --- 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 4e42073..e3c6f51 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -82,6 +82,22 @@ static u32 i915_perf_stream_paranoid = true; #define INVALID_CTX_ID 0xffffffff +/* for sysctl proc_dointvec_minmax of i915_oa_min_timer_exponent */ +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. @@ -1353,21 +1369,14 @@ 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("Minimum OA sampling exponent is 6 without root privileges\n"); + if (value < i915_oa_min_timer_exponent && + !capable(CAP_SYS_ADMIN)) { + DRM_ERROR("Minimum OA sampling exponent (sysctl dev.i915.oa_min_timer_exponent) is %u without root privileges\n", + i915_oa_min_timer_exponent); return -EACCES; } @@ -1475,6 +1484,15 @@ static struct ctl_table oa_table[] = { .extra1 = &zero, .extra2 = &one, }, + { + .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, + }, {} };