From patchwork Fri Sep 29 12:35:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9977937 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 617336034B for ; Fri, 29 Sep 2017 12:35:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59B0629858 for ; Fri, 29 Sep 2017 12:35:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4ED0E2985B; Fri, 29 Sep 2017 12:35:21 +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 06A9529858 for ; Fri, 29 Sep 2017 12:35:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1DD46EB85; Fri, 29 Sep 2017 12:35:20 +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 2AB8F6EB85 for ; Fri, 29 Sep 2017 12:35:17 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id u138so2977524wmu.4 for ; Fri, 29 Sep 2017 05:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Jo6cjeAptgNgr75f7sYz7k7IvIoBKmFBd27ww99R+D0=; b=AmLmyk4KaRikJRLC0kGeuZdW4UTxUfbDcvRTqgbXq00JLnnnCc4xzj6+TbVI2nklWl Ly3w/LuC8D6UbpwSptvIRHJuVMcDXyyfGlx6/xjHJSuu5MAM3FThhbT/6sU80eoXUv/o z3iTYLWhtbL+CTUgQ50RDzb3LFmsVsYFQXqWYGLGJFgIovR9AYndZ5Y6BQJxBGb6j7NT Ttsywyb5EPXH+JbZ6pQCqz2R6r4d8VvT5AGv6HYC6G+QvfoFF2TMvKzBPX4H8G2dzowy wKYXw/9Jl/9n5DtOUZsfnrp70A1bWxWkoXH5s+GCE6Y9weXT/65UGxvcxZ98zmrEORS3 Yhww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Jo6cjeAptgNgr75f7sYz7k7IvIoBKmFBd27ww99R+D0=; b=uJ4krFtprhxIC7sqM/ZfigqzD/picMgMJvv6pplu59ApAFCjWyqqTAkC4Uv7moWGVw 9YPlx97AiCXf2sF66KJ7vKE3fGWp9J06lXFK2DxVB4VDT2aGj6DVgPK2HCwPXdeEvzbZ 9RHV+pKQnJWm4uZcHwWVCDtMD56RE6I5lnqk/SnVZphO3+JRExKcqcW2lUZwtbsUme6z g2QHEBjk82MDzhhrpdYP9YhzJ7W6qbEu0eopu8UGl2pKoV6exc5ZNaMqLnbXnZPjRN4W p9BuaD4ZtJAp0naGZkSGqW4l5mx3dR7N9MbbT+yt4IO03JJh+R3tdpY1CHUcVqnCdfhy 0I8Q== X-Gm-Message-State: AMCzsaXX1aHrIELo2Pl517U5x/pL5fQi92OxwdVKhodLbDZF1Gw4T2pa FD1TyF3XqBCS23mEOprzuPUrJ+Bz X-Google-Smtp-Source: AOwi7QClMvgn35oUBerNDK+Mi6v9Auv5ugTrJI74OL0BiSLMYAUCyC+jiXP5GfQ48B61LWO4/BZa4A== X-Received: by 10.28.186.135 with SMTP id k129mr4360394wmf.100.1506688515540; Fri, 29 Sep 2017 05:35:15 -0700 (PDT) Received: from t460p.intel ([95.146.151.158]) by smtp.gmail.com with ESMTPSA id j73sm8196637wmf.15.2017.09.29.05.35.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 05:35:15 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2017 13:35:00 +0100 Message-Id: <20170929123500.3186-11-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170929123500.3186-1-tvrtko.ursulin@linux.intel.com> References: <20170929123500.3186-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH 10/10] drm/i915/pmu: Add RC6 residency metrics 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 From: Tvrtko Ursulin For clients like intel-gpu-overlay it is easier to read the counters via the perf API than having to parse sysfs. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_pmu.c | 31 +++++++++++++++++++++++++++++++ include/uapi/drm/i915_drm.h | 6 +++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index 4c37c8b3cc54..32b6c3c170e9 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c @@ -360,6 +360,15 @@ static int i915_pmu_event_init(struct perf_event *event) break; case I915_PMU_INTERRUPTS: break; + case I915_PMU_RC6_RESIDENCY: + if (!HAS_RC6(i915)) + ret = -ENODEV; + break; + case I915_PMU_RC6p_RESIDENCY: + case I915_PMU_RC6pp_RESIDENCY: + if (!HAS_RC6p(i915)) + ret = -ENODEV; + break; default: ret = -ENOENT; break; @@ -412,6 +421,24 @@ static u64 __i915_pmu_event_read(struct perf_event *event) case I915_PMU_INTERRUPTS: val = count_interrupts(i915); break; + case I915_PMU_RC6_RESIDENCY: + intel_runtime_pm_get(i915); + val = intel_rc6_residency_ns(i915, + IS_VALLEYVIEW(i915) ? + VLV_GT_RENDER_RC6 : + GEN6_GT_GFX_RC6); + intel_runtime_pm_put(i915); + break; + case I915_PMU_RC6p_RESIDENCY: + intel_runtime_pm_get(i915); + val = intel_rc6_residency_ns(i915, GEN6_GT_GFX_RC6p); + intel_runtime_pm_put(i915); + break; + case I915_PMU_RC6pp_RESIDENCY: + intel_runtime_pm_get(i915); + val = intel_rc6_residency_ns(i915, GEN6_GT_GFX_RC6pp); + intel_runtime_pm_put(i915); + break; } } @@ -666,6 +693,10 @@ static struct attribute *i915_pmu_events_attrs[] = { I915_EVENT_ATTR(interrupts, I915_PMU_INTERRUPTS), + I915_EVENT(rc6-residency, I915_PMU_RC6_RESIDENCY, "ns"), + I915_EVENT(rc6p-residency, I915_PMU_RC6p_RESIDENCY, "ns"), + I915_EVENT(rc6pp-residency, I915_PMU_RC6pp_RESIDENCY, "ns"), + NULL, }; diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 22b3e5e5bef8..e6f8e0a5bd63 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -134,7 +134,11 @@ enum drm_i915_pmu_engine_sample { #define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2) -#define I915_PMU_LAST I915_PMU_INTERRUPTS +#define I915_PMU_RC6_RESIDENCY __I915_PMU_OTHER(3) +#define I915_PMU_RC6p_RESIDENCY __I915_PMU_OTHER(4) +#define I915_PMU_RC6pp_RESIDENCY __I915_PMU_OTHER(5) + +#define I915_PMU_LAST I915_PMU_RC6pp_RESIDENCY /* Each region is a minimum of 16k, and there are at most 255 of them. */