Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4864319imm; Tue, 9 Oct 2018 06:27:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV61RgJ9MdHpCUTFiP1sLXslrZaysleXuguGoAC3REH0EzeY/oogG1JE3EB4K5Bdt7NTOH2+D X-Received: by 2002:a62:8dcd:: with SMTP id p74-v6mr30789651pfk.217.1539091666421; Tue, 09 Oct 2018 06:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091666; cv=none; d=google.com; s=arc-20160816; b=gR+dmNB1beW4XaRnYsHzx0L07h7TXs7aBS1NuMxUPIDrCchF2up1E79+Gb8fkkumMH kv4p3Y3pUuHuWqTF0YYPydbummrwgR2nNGuTEhAqEiZZGiyR8OZ9LzVSAzBVUOtvwBgi wgYu43YV2EZAzIPw+3WrF1vgR5HJt7VC/evf95xN+HBHxA/NUF5FLy/4wdAVXYQ3z5+q Oz0APof9m5YHZvuJn1w4rJ1XpGNyXp1JomcWT9+nK28W8yLy2hKvoEwz4ngoAaDVri6O aALLjgitIkeP3H1am1XR/pWa62K2GOvb3PyHMC3CP4Gt4hRxdqhjvoE3vquKfF/T/MDq BWow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=IV9PpQh7JfKN6YeoXNxU0UAb+1uFZdW0R1Bxh9PFU3g=; b=VCUFQJxHDWkj02UqnWkEyux6MjYSp/95zxI8ykVOx+L5SOLRCwB/lOYl57z3i0uQ9B YLM/N65Pg6EZSBVYE1pOnCIPtxmuqeoRuQzzHqiOSVZNqsKpP5GTDTTOt0G0rvouw+WO BPdrzzyESUzyjX3muZNNpDA2PjH4eJG32EU/KiRDeiBG6Ob7SVKx6rDQBYv07aYBBarj 2HYYJntwWUM+zsVq44SVd2MjVckWMdeEDQJlfN3u2/PWR58DrlVnlv6jRs0UTM2BX5u5 afFJk1SXFry/uEKHKoVGHyjtCyu1Ii+ZkTYbu4k+J/zgnPABS+GtzQNcC40x9cIIz+ij dBNQ== 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 p17-v6si20770438pgk.58.2018.10.09.06.27.31; Tue, 09 Oct 2018 06:27:46 -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 S1728020AbeJIUnk (ORCPT + 99 others); Tue, 9 Oct 2018 16:43:40 -0400 Received: from mail.bootlin.com ([62.4.15.54]:51035 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbeJIUnj (ORCPT ); Tue, 9 Oct 2018 16:43:39 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id D02A1207C3; Tue, 9 Oct 2018 15:26:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-28-153.w90-88.abo.wanadoo.fr [90.88.148.153]) by mail.bootlin.com (Postfix) with ESMTPSA id 95F1820712; Tue, 9 Oct 2018 15:26:40 +0200 (CEST) Date: Tue, 9 Oct 2018 15:26:40 +0200 From: Boris Brezillon To: Eric Anholt Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] drm/v3d: Add a little debugfs entry for measuring the core clock. Message-ID: <20181009152640.791c709d@bbrezillon> In-Reply-To: <20180928232126.4332-2-eric@anholt.net> References: <20180928232126.4332-1-eric@anholt.net> <20180928232126.4332-2-eric@anholt.net> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 Sep 2018 16:21:24 -0700 Eric Anholt wrote: > 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 Reviewed-by: Boris Brezillon > --- > 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)