From patchwork Thu May 27 20:38:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alyssa Rosenzweig X-Patchwork-Id: 12285313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12A69C47089 for ; Thu, 27 May 2021 20:38:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B8790613E3 for ; Thu, 27 May 2021 20:38:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8790613E3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3045F6F4C3; Thu, 27 May 2021 20:38:24 +0000 (UTC) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9137C6F4C2 for ; Thu, 27 May 2021 20:38:22 +0000 (UTC) Received: from localhost.localdomain (unknown [IPv6:2600:8800:8c09:5500::19dc]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: alyssa) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 1E6DD1F43DF3; Thu, 27 May 2021 21:38:19 +0100 (BST) From: alyssa.rosenzweig@collabora.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 0/4] drm/panfrost: Plumb cycle counters to userspace Date: Thu, 27 May 2021 16:38:00 -0400 Message-Id: <20210527203804.12914-1-alyssa.rosenzweig@collabora.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tomeu.vizoso@collabora.com, airlied@linux.ie, steven.price@arm.com, Alyssa Rosenzweig Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Alyssa Rosenzweig Mali has hardware cycle counters (and GPU timestamps) available for profiling. These are exposed in various ways: - Kernel: As CYCLE_COUNT and TIMESTAMP registers - Job chain: As WRITE_VALUE descriptors - Shader (Midgard): As LD_SPECIAL selectors - Shader (Bifrost): As the LD_GCLK.u64 instruction These form building blocks for profiling features, for example the ARB_shader_clock extension which accesses the counters from an application's shader. The counters consume power, so it is recommended to disable the counters when not in use. To do so, we follow the strategy from mali_kbase: add a counter requirement to the job, start the counters only when required, and stop them as quickly as possible. The new UABI will be used in Mesa. An implementation of ARB_shader_clock using this UABI is available as a pending upstream merge request [1]. The implementation passes the relevant piglit test, validating both the kernel and mesa. The main outstanding questing is the proper name. Performance monitoring ("PERMON") is the name used by kbase, but it's jargon-y and risks confusion with performance counters, an orthogonal mechanism. Cycle count is more descriptive and matches the actual hardware name, but obscures that the same mechanism is required for GPU timestamps. This bit of bikeshedding aside, I'm pleased with the patches. [1] https://gitlab.freedesktop.org/mesa/mesa/merge_requests/11051 Alyssa Rosenzweig (4): drm/panfrost: Add cycle counter job requirement drm/panfrost: Add CYCLE_COUNT_START/STOP commands drm/panfrost: Add permon acquire/release helpers drm/panfrost: Handle PANFROST_JD_REQ_PERMON drivers/gpu/drm/panfrost/panfrost_device.h | 3 +++ drivers/gpu/drm/panfrost/panfrost_drv.c | 10 +++++++--- drivers/gpu/drm/panfrost/panfrost_gpu.c | 20 ++++++++++++++++++++ drivers/gpu/drm/panfrost/panfrost_gpu.h | 3 +++ drivers/gpu/drm/panfrost/panfrost_job.c | 6 ++++++ drivers/gpu/drm/panfrost/panfrost_regs.h | 2 ++ include/uapi/drm/panfrost_drm.h | 3 ++- 7 files changed, 43 insertions(+), 4 deletions(-)