From patchwork Wed Feb 3 18:39:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 8206981 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 DA7D59F4DD for ; Wed, 3 Feb 2016 18:39:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA13820320 for ; Wed, 3 Feb 2016 18:39:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DBD5A20266 for ; Wed, 3 Feb 2016 18:39:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A28706E7F3; Wed, 3 Feb 2016 10:39:28 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 122906E7F5; Wed, 3 Feb 2016 10:39:27 -0800 (PST) Received: by mail-wm0-f67.google.com with SMTP id r129so8658206wmr.0; Wed, 03 Feb 2016 10:39:27 -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=ibyCfNphFZrnnZHlcR98W1j0WYweYj9hr3leF+K8iB3jj1G+wg1dJ5qRtZYnhBa3Uj wSmaDhXlb4kYuGJA2Zwbh084tpHBKWKJWbyY2a7swzmT99wZJyI2UCUyw+Eluh/5XOV+ ivz/SxMuopp5tOeCZpV3oMMT4WUgqQq2kiZo56O+lr7wJMQXAn03r6we6N15gRtW1/5H aMX8py85YOtwogQxeGT4SVBbgJhdF2adhR2zwfw1OEyr7c7qiRzrcSMdZwy4rO0DtXZa uwsToZZ+EOVt28Ns39l1bSeINHR76pQGi/aNur5Kh89fk9WzkMcmQoFnEfXQE5T43W3r bazA== 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=WVuuk7a0kRKcRK1KeslOPn9sCbUavKEetfd61MiW3a0U6YsyF2BZRj0rJAtJJy0PIp Ah6kwCz+TKfptJ2Xi9HaqX0DQlVBqmEZYznwfxIBQ38ft2UgC/Oqlh/NT4j/dRxFYw9U cqqtevqLGINLXI/+xL8GKlh3flYo7ET0H8d5J1zlhoPkbaFixfs5LOWiAkd4TMCaD3a8 rHe41ddeTqj/IJ/+kfCYOZlnKjajud/pKZy/7WF0yG9X8N6XrUNC7RL97AHTMrfjXs5j E4tAK+/Et9B5eXcDF19jpENOa5dnhxz4jIDdDrktRyk2zvDyyRGLt/1BJticflHMXJfh y3UA== X-Gm-Message-State: AG10YORNYVmPSFKhmBDkolqiMhk+7VT+h+49s/ICJkwpIZIEPTesw5OOJMh6TX4QQ938Wg== X-Received: by 10.28.48.19 with SMTP id w19mr18677182wmw.18.1454524765343; Wed, 03 Feb 2016 10:39:25 -0800 (PST) Received: from sixbynine.org ([83.217.123.106]) by smtp.gmail.com with ESMTPSA id u130sm22622740wmg.15.2016.02.03.10.39.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2016 10:39:24 -0800 (PST) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Wed, 3 Feb 2016 18:39:12 +0000 Message-Id: <1454524753-13218-8-git-send-email-robert@sixbynine.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454524753-13218-1-git-send-email-robert@sixbynine.org> References: <1454524753-13218-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, + }, {} };