From patchwork Wed Feb 14 12:14:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Larumbe?= X-Patchwork-Id: 200936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1167585dyb; Wed, 14 Feb 2024 04:15:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXWtHruSvg8qbvxxz9gfSQxzI8bRnrgFngvDISatbsjrxtzuJ3dYtgK7KXgu8Hms895Oc8BCkx5bTEA6aJYk/F0aoDu0A== X-Google-Smtp-Source: AGHT+IGYJ5kHhAQzcLt52SvnrA6Pu65gXSnmLoZHEUAip4TKP9+ZSAI/a71WAwg+sZ++2DcfnJc1 X-Received: by 2002:a05:6402:1254:b0:562:1819:bbc4 with SMTP id l20-20020a056402125400b005621819bbc4mr1907906edw.6.1707912934213; Wed, 14 Feb 2024 04:15:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707912934; cv=pass; d=google.com; s=arc-20160816; b=A2XKsWMhN2KPxOsl3wcL1fp2pckHoMxf/Qb3AyaK4KqFCsyUlS59IZiPoOziS75FyW E4ppZTmxnCvxIh1F3ZbCRw9ImOBQ971boWXQQcmzPGYJMUv2dZyCcgs2zeWDzLFKjPZa 1e9rZACs+MMERdmIzoqZ1L6ODkTjPFrcALKHdG7Fpw6tMbN5zsDdekPxAtQqxFpYZ6RV 0yC/1RhE8gFYsTezo4oCXiWk/4WwwhyxKLb8ESmdEwRAR9kVIlrMo596P6IESKGqwdau MVbOeBTLJbkM9vOu4nrnH+Vvnn04oOD2eGNG5ZioK+e9g3l7pSx5HgZmqbRaz4oxxMaa OzuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WcmixLWl9HeI0NAI6uWA5Sz73i2EPrsvRweXD7G6B80=; fh=Uu0bbYixEagdNT7csv5bJXqFMgqbbsyrwsjfY3Q+3+M=; b=m0vFLYg3TtYNP8NlI850teqhEFw/vjcEO749F2jkZD+gAa1vHoZ0pDtX3nfxrrDTFj bFLLJvde+QRL+g2NYN8D2Qa9T2bv2gxZUgV8LFc8kzaYysQ95xwuwRF1mAV9u1wPbTOn WCyNFPSgaKe06EjVyjJTG4NYD3tPCZ6LTNpT/jl6uOAloOZVy6RP2NCUfugusEMmmjic yWsBViHdcZoJ76SXSse0MJl929C7jnU9kjRhzTN8uhi5ZcLWOcnf+eOydKM3kMIkgUTQ dj8uqmatMhBR3xo/mfDwFyimLXqK4xk/krWoR+nfuOyNmszkb5nhXzPuMUAXRxm3sjmN AsAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=41HykHli; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-65180-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65180-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=2; AJvYcCW6YZMjfF1AcR1lDL81q85Ue5V9aqqfY5s+fg9wyoWzb13TzSINqFo3Tz0fRJbTdO6oTjYAowgVKc/oonXOqZxG7dJJTA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ee17-20020a056402291100b00563912227fdsi45990edb.452.2024.02.14.04.15.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 04:15:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65180-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=41HykHli; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-65180-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65180-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A0B8F1F25370 for ; Wed, 14 Feb 2024 12:15:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D544E1BDCE; Wed, 14 Feb 2024 12:15:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="41HykHli" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08F1E1B813 for ; Wed, 14 Feb 2024 12:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707912904; cv=none; b=hFqub/HIokZFHFrGDK3kMLxa2TDZed7rrvw01EzWd0jXLmPT69BR9I7zrUT5Y/ITpaxW1oDk+fPrMpMCtxpL2dHrJp3EN6LxgMUPu5I9ZSoI36V5OnsItMdgAh9xYF5zuNICnEaI3VcBY3YkYrr2p0qagsbMF15xFwzavwFwONk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707912904; c=relaxed/simple; bh=a9LrVHonu2XB3YYQb5kFdwq7EY9F5HNdPDXVenpHkh4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s1vhRYiTXmQUTTGh6rdOo7ytiUlIjNsx8OIc7QAow1oo2GOpWfxDqxklVLsLTub992kWoLrkRHdRUIww7xfPgCOthvtyDjiQr29TJTlvyYJDxfJlohbG7772IC2hnILlpl1bPXkSgwHSYzYa9AOoGWfOyNBXyngwi8OXhU/dhm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=41HykHli; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1707912901; bh=a9LrVHonu2XB3YYQb5kFdwq7EY9F5HNdPDXVenpHkh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=41HykHliSAXpFUgAys8pjHgemH2RaB+j1D9U3+itBqGNSls4fBavEJaVK51Lt2L7B Y+QAFVZVgLCxg59MCs4ga+esKiRDwX1D/WawTLP/e38G8IQXNkBrWVRJA7nviWF2uN Ua6H0bwgXWcfMoPPq6IfDYe3jXyr/f1G9EEbvOUxEi1pzWUf7ZY2Ups+1ba+CE/tma sf+EBU+uWikHQDtxxVO3jy1N1/iLlLdH44na4532GaMuQ6xkRj7o6/orHEZLIl4mR6 w0s1OTUMeiimlTexs856TToWa06qTaNzdiiX7Ug7S+lfkcqmHQpvnFoy/RuGQQRYC0 8u/Ey845oTf2Q== Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: alarumbe) by madrid.collaboradmins.com (Postfix) with ESMTPSA id B600A37813DF; Wed, 14 Feb 2024 12:15:00 +0000 (UTC) From: =?utf-8?q?Adri=C3=A1n_Larumbe?= To: Boris Brezillon , Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: =?utf-8?q?Adri=C3=A1n_Larumbe?= , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 1/1] drm/panfrost: Always record job cycle and timestamp information Date: Wed, 14 Feb 2024 12:14:27 +0000 Message-ID: <20240214121435.3813983-2-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214121435.3813983-1-adrian.larumbe@collabora.com> References: <20240214121435.3813983-1-adrian.larumbe@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790876512646632069 X-GMAIL-MSGID: 1790876512646632069 Some users of Panfrost expressed interest in being able to gather fdinfo stats for running jobs, on production builds with no built-in debugfs support. Sysfs was first considered, but eventually it was realised timestamp and cycle counting don't incur in additional power consumption when the GPU is running and there are inflight jobs, so there's no reason to let user space toggle profiling. Remove the profiling debugfs knob altogether so that cycle and timestamp counting is always enabled for inflight jobs. Signed-off-by: Adrián Larumbe --- drivers/gpu/drm/panfrost/Makefile | 2 -- drivers/gpu/drm/panfrost/panfrost_debugfs.c | 21 ------------------ drivers/gpu/drm/panfrost/panfrost_debugfs.h | 14 ------------ drivers/gpu/drm/panfrost/panfrost_device.h | 1 - drivers/gpu/drm/panfrost/panfrost_drv.c | 5 ----- drivers/gpu/drm/panfrost/panfrost_job.c | 24 ++++++++------------- drivers/gpu/drm/panfrost/panfrost_job.h | 1 - 7 files changed, 9 insertions(+), 59 deletions(-) delete mode 100644 drivers/gpu/drm/panfrost/panfrost_debugfs.c delete mode 100644 drivers/gpu/drm/panfrost/panfrost_debugfs.h diff --git a/drivers/gpu/drm/panfrost/Makefile b/drivers/gpu/drm/panfrost/Makefile index 2c01c1e7523e..7da2b3f02ed9 100644 --- a/drivers/gpu/drm/panfrost/Makefile +++ b/drivers/gpu/drm/panfrost/Makefile @@ -12,6 +12,4 @@ panfrost-y := \ panfrost_perfcnt.o \ panfrost_dump.o -panfrost-$(CONFIG_DEBUG_FS) += panfrost_debugfs.o - obj-$(CONFIG_DRM_PANFROST) += panfrost.o diff --git a/drivers/gpu/drm/panfrost/panfrost_debugfs.c b/drivers/gpu/drm/panfrost/panfrost_debugfs.c deleted file mode 100644 index 72d4286a6bf7..000000000000 --- a/drivers/gpu/drm/panfrost/panfrost_debugfs.c +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright 2023 Collabora ltd. */ -/* Copyright 2023 Amazon.com, Inc. or its affiliates. */ - -#include -#include -#include -#include -#include - -#include "panfrost_device.h" -#include "panfrost_gpu.h" -#include "panfrost_debugfs.h" - -void panfrost_debugfs_init(struct drm_minor *minor) -{ - struct drm_device *dev = minor->dev; - struct panfrost_device *pfdev = platform_get_drvdata(to_platform_device(dev->dev)); - - debugfs_create_atomic_t("profile", 0600, minor->debugfs_root, &pfdev->profile_mode); -} diff --git a/drivers/gpu/drm/panfrost/panfrost_debugfs.h b/drivers/gpu/drm/panfrost/panfrost_debugfs.h deleted file mode 100644 index c5af5f35877f..000000000000 --- a/drivers/gpu/drm/panfrost/panfrost_debugfs.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright 2023 Collabora ltd. - * Copyright 2023 Amazon.com, Inc. or its affiliates. - */ - -#ifndef PANFROST_DEBUGFS_H -#define PANFROST_DEBUGFS_H - -#ifdef CONFIG_DEBUG_FS -void panfrost_debugfs_init(struct drm_minor *minor); -#endif - -#endif /* PANFROST_DEBUGFS_H */ diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index 62f7e3527385..cd6bbcb2bea4 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -130,7 +130,6 @@ struct panfrost_device { struct list_head scheduled_jobs; struct panfrost_perfcnt *perfcnt; - atomic_t profile_mode; struct mutex sched_lock; diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index a926d71e8131..e31fd4d62bbe 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -20,7 +20,6 @@ #include "panfrost_job.h" #include "panfrost_gpu.h" #include "panfrost_perfcnt.h" -#include "panfrost_debugfs.h" static bool unstable_ioctls; module_param_unsafe(unstable_ioctls, bool, 0600); @@ -600,10 +599,6 @@ static const struct drm_driver panfrost_drm_driver = { .gem_create_object = panfrost_gem_create_object, .gem_prime_import_sg_table = panfrost_gem_prime_import_sg_table, - -#ifdef CONFIG_DEBUG_FS - .debugfs_init = panfrost_debugfs_init, -#endif }; static int panfrost_probe(struct platform_device *pdev) diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index 0c2dbf6ef2a5..745b16a77edd 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -159,13 +159,11 @@ panfrost_dequeue_job(struct panfrost_device *pfdev, int slot) struct panfrost_job *job = pfdev->jobs[slot][0]; WARN_ON(!job); - if (job->is_profiled) { - if (job->engine_usage) { - job->engine_usage->elapsed_ns[slot] += - ktime_to_ns(ktime_sub(ktime_get(), job->start_time)); - job->engine_usage->cycles[slot] += - panfrost_cycle_counter_read(pfdev) - job->start_cycles; - } + if (job->engine_usage) { + job->engine_usage->elapsed_ns[slot] += + ktime_to_ns(ktime_sub(ktime_get(), job->start_time)); + job->engine_usage->cycles[slot] += + panfrost_cycle_counter_read(pfdev) - job->start_cycles; panfrost_cycle_counter_put(job->pfdev); } @@ -243,12 +241,9 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) subslot = panfrost_enqueue_job(pfdev, js, job); /* Don't queue the job if a reset is in progress */ if (!atomic_read(&pfdev->reset.pending)) { - if (atomic_read(&pfdev->profile_mode)) { - panfrost_cycle_counter_get(pfdev); - job->is_profiled = true; - job->start_time = ktime_get(); - job->start_cycles = panfrost_cycle_counter_read(pfdev); - } + panfrost_cycle_counter_get(pfdev); + job->start_time = ktime_get(); + job->start_cycles = panfrost_cycle_counter_read(pfdev); job_write(pfdev, JS_COMMAND_NEXT(js), JS_COMMAND_START); dev_dbg(pfdev->dev, @@ -693,8 +688,7 @@ panfrost_reset(struct panfrost_device *pfdev, spin_lock(&pfdev->js->job_lock); for (i = 0; i < NUM_JOB_SLOTS; i++) { for (j = 0; j < ARRAY_SIZE(pfdev->jobs[0]) && pfdev->jobs[i][j]; j++) { - if (pfdev->jobs[i][j]->is_profiled) - panfrost_cycle_counter_put(pfdev->jobs[i][j]->pfdev); + panfrost_cycle_counter_put(pfdev->jobs[i][j]->pfdev); pm_runtime_put_noidle(pfdev->dev); panfrost_devfreq_record_idle(&pfdev->pfdevfreq); } diff --git a/drivers/gpu/drm/panfrost/panfrost_job.h b/drivers/gpu/drm/panfrost/panfrost_job.h index ec581b97852b..022c83ede368 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.h +++ b/drivers/gpu/drm/panfrost/panfrost_job.h @@ -34,7 +34,6 @@ struct panfrost_job { struct dma_fence *render_done_fence; struct panfrost_engine_usage *engine_usage; - bool is_profiled; ktime_t start_time; u64 start_cycles; };