Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1321759imm; Fri, 28 Sep 2018 16:23:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV63odEhJGr8QyDejJrwyNm5kTTwvvxripH24Dlmo9+x6pyXaJscI5FZCU6wKl8IsOJJEeawq X-Received: by 2002:a63:f5a:: with SMTP id 26-v6mr731683pgp.100.1538177004410; Fri, 28 Sep 2018 16:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538177004; cv=none; d=google.com; s=arc-20160816; b=gLCCOGLwYdsjHQZK2ti9iRaWp0kdOmSvc3NgERJ+ZbQNSNEW6px3STb3jmCd3YuAvV AoJ+1B5aj7hLP3ReavAf5VTi3LN6645NXUq3IpRUIyHcJVtzmgXOYd/4UZXPKYfVuJBx fmGuqq4QUAsUYAiANLDTMfNcifP8ZPB9FSrYRPIpGVWqIeZqJsy74mjUufez1S408XrS vc1DHiGn6qHj9MFpZQxEuxXugcw7Kzdi0CwMPQUtyOd5bl7DRLAUM1zQq/UlBxgxogrp xtwiJnFxW/LGlkzbd22rIGWgceKsqMDe+j5hsNSP+2kF/HkCbzNqQWEuRx+avzU/GOXU ECtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=rXzsUAvVrHpx4Znsl7NCBpyaySRepOV3RHFBmm3tNbw=; b=iWcEBaAayVzhsuxwjUtxZKvh37J0WuqC8wJ3H9BpgDtVBvdgiKBPiUdk9J4Bo2Wrre yGXiE4NNrssSMqJEs2tvnskqM2lHb+CBDbOucq61UuQAS+I8PdtZUiKUFTzvG2slr7Ei 8at61w3cIl6d5vUbsTCotO5MIetv4P0j0s5EiqQgtgcrwNfJgD4R/AwIY/3iOOLX7gzd 12pasUNLXZN62fyicskba13s1Mh5LTVmbAuCwQFn0U2ik8/l9ABCi0RWa+M08CyilS3p SiObvip4FN5Ldj8omQUc2eWk+1Jr5bJ4iaU5PqSNMyP/AzimDPfrj8Qe5OvY7BmjgG3F /O+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d40-v6si5673917pla.217.2018.09.28.16.23.09; Fri, 28 Sep 2018 16:23:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727635AbeI2Frd (ORCPT + 99 others); Sat, 29 Sep 2018 01:47:33 -0400 Received: from anholt.net ([50.246.234.109]:45454 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbeI2Frc (ORCPT ); Sat, 29 Sep 2018 01:47:32 -0400 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 1D73210A1AF0; Fri, 28 Sep 2018 16:21:31 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id oap7_UIFLlNK; Fri, 28 Sep 2018 16:21:28 -0700 (PDT) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id EB10110A0414; Fri, 28 Sep 2018 16:21:27 -0700 (PDT) Received: by eliezer.anholt.net (Postfix, from userid 1000) id E4BB52FE1B3F; Fri, 28 Sep 2018 16:21:26 -0700 (PDT) From: Eric Anholt To: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, boris.brezillon@bootlin.com, Eric Anholt Subject: [PATCH 2/4] drm/v3d: Add a little debugfs entry for measuring the core clock. Date: Fri, 28 Sep 2018 16:21:24 -0700 Message-Id: <20180928232126.4332-2-eric@anholt.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180928232126.4332-1-eric@anholt.net> References: <20180928232126.4332-1-eric@anholt.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds just enough performance counter support to measure the clock. We don't have linux kernel drivers for the clock driving the HW, and this was useful for determining that the V3D HW is running on a slow clock, not that the driver was slow. Signed-off-by: Eric Anholt --- drivers/gpu/drm/v3d/v3d_debugfs.c | 35 +++++++++++++++++++++++++++++++ drivers/gpu/drm/v3d/v3d_regs.h | 30 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/drivers/gpu/drm/v3d/v3d_debugfs.c b/drivers/gpu/drm/v3d/v3d_debugfs.c index 4db62c545748..d48008adb085 100644 --- a/drivers/gpu/drm/v3d/v3d_debugfs.c +++ b/drivers/gpu/drm/v3d/v3d_debugfs.c @@ -176,9 +176,44 @@ static int v3d_debugfs_bo_stats(struct seq_file *m, void *unused) return 0; } +static int v3d_measure_clock(struct seq_file *m, void *unused) +{ + struct drm_info_node *node = (struct drm_info_node *)m->private; + struct drm_device *dev = node->minor->dev; + struct v3d_dev *v3d = to_v3d_dev(dev); + uint32_t cycles; + int core = 0; + int measure_ms = 1000; + + if (v3d->ver >= 40) { + V3D_CORE_WRITE(core, V3D_V4_PCTR_0_SRC_0_3, + V3D_SET_FIELD(V3D_PCTR_CYCLE_COUNT, + V3D_PCTR_S0)); + V3D_CORE_WRITE(core, V3D_V4_PCTR_0_CLR, 1); + V3D_CORE_WRITE(core, V3D_V4_PCTR_0_EN, 1); + } else { + V3D_CORE_WRITE(core, V3D_V3_PCTR_0_PCTRS0, + V3D_PCTR_CYCLE_COUNT); + V3D_CORE_WRITE(core, V3D_V3_PCTR_0_CLR, 1); + V3D_CORE_WRITE(core, V3D_V3_PCTR_0_EN, + V3D_V3_PCTR_0_EN_ENABLE | + 1); + } + msleep(measure_ms); + cycles = V3D_CORE_READ(core, V3D_PCTR_0_PCTR0); + + seq_printf(m, "cycles: %d (%d.%d Mhz)\n", + cycles, + cycles / (measure_ms * 1000), + (cycles / (measure_ms * 100)) % 10); + + return 0; +} + static const struct drm_info_list v3d_debugfs_list[] = { {"v3d_ident", v3d_v3d_debugfs_ident, 0}, {"v3d_regs", v3d_v3d_debugfs_regs, 0}, + {"measure_clock", v3d_measure_clock, 0}, {"bo_stats", v3d_debugfs_bo_stats, 0}, }; diff --git a/drivers/gpu/drm/v3d/v3d_regs.h b/drivers/gpu/drm/v3d/v3d_regs.h index 854046565989..c3a5e4e44f73 100644 --- a/drivers/gpu/drm/v3d/v3d_regs.h +++ b/drivers/gpu/drm/v3d/v3d_regs.h @@ -267,6 +267,36 @@ # define V3D_PTB_BXCF_RWORDERDISA BIT(1) # define V3D_PTB_BXCF_CLIPDISA BIT(0) +#define V3D_V3_PCTR_0_EN 0x00674 +#define V3D_V3_PCTR_0_EN_ENABLE BIT(31) +#define V3D_V4_PCTR_0_EN 0x00650 +/* When a bit is set, resets the counter to 0. */ +#define V3D_V3_PCTR_0_CLR 0x00670 +#define V3D_V4_PCTR_0_CLR 0x00654 +#define V3D_PCTR_0_OVERFLOW 0x00658 + +#define V3D_V3_PCTR_0_PCTRS0 0x00684 +#define V3D_V3_PCTR_0_PCTRS15 0x00660 +#define V3D_V3_PCTR_0_PCTRSX(x) (V3D_V3_PCTR_0_PCTRS0 + \ + 4 * (x)) +/* Each src reg muxes four counters each. */ +#define V3D_V4_PCTR_0_SRC_0_3 0x00660 +#define V3D_V4_PCTR_0_SRC_28_31 0x0067c +# define V3D_PCTR_S0_MASK V3D_MASK(6, 0) +# define V3D_PCTR_S0_SHIFT 0 +# define V3D_PCTR_S1_MASK V3D_MASK(14, 8) +# define V3D_PCTR_S1_SHIFT 8 +# define V3D_PCTR_S2_MASK V3D_MASK(22, 16) +# define V3D_PCTR_S2_SHIFT 16 +# define V3D_PCTR_S3_MASK V3D_MASK(30, 24) +# define V3D_PCTR_S3_SHIFT 24 +# define V3D_PCTR_CYCLE_COUNT 32 + +/* Output values of the counters. */ +#define V3D_PCTR_0_PCTR0 0x00680 +#define V3D_PCTR_0_PCTR31 0x006fc +#define V3D_PCTR_0_PCTRX(x) (V3D_PCTR_0_PCTR0 + \ + 4 * (x)) #define V3D_GMP_STATUS 0x00800 # define V3D_GMP_STATUS_GMPRST BIT(31) # define V3D_GMP_STATUS_WR_COUNT_MASK V3D_MASK(30, 24) -- 2.18.0