Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp1103626lqs; Wed, 6 Mar 2024 06:31:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIFl37dqt4YeWMQrpm5+BQLUsBlzkdIfe0QGzeo9JU/iTOfTqkd5UHk6QlnoQToliWEb6K+flZv/1epOGMXA1pGk0fqHTcg/4K+3Hkww== X-Google-Smtp-Source: AGHT+IGMU7xsdFQ81PO/xvqJtAEHFkQzK7/kiiOyJ27jF3fM4UG5VXiq2cOr01JsWEPR7Z6d0t2X X-Received: by 2002:a17:903:228a:b0:1db:9ff1:b59b with SMTP id b10-20020a170903228a00b001db9ff1b59bmr6836841plh.23.1709735510005; Wed, 06 Mar 2024 06:31:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709735509; cv=pass; d=google.com; s=arc-20160816; b=dvskTf81GFpQ/NccD1OmLE+OavDkNudQ0tdZ+G920qxzGkqdddSL1+IDIH1n/u+wua Pzv/aLIDO959xrMVkiM5zN63oW29OmDjzC1FP2cxKl2DIpcGmdUL1RC/EGm2mAUhEzG5 p8gF9iyGTQywntqMFQC8QR1XOzcrCfBc/iWjF3+EwTA3cmp7kLCgQLfPPtXZKa36TnMg je5uR8fYdCXoDSWyaoMhV7ZT4GLJYG916n7K387JoGhYnBcnTazCz/veA7i9k+nP14uT Fk4lBVBI/TfBV0I1Ujgj8HOOa0fw2DT+tHubuqPhZcHmWKRB2HRR42QIM7bxFsoqrrsQ eVww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=sxcwRihwWklCMMXh7zO5152Z5/QMR0peMOvukJQSbJM=; fh=RLzFKhvw5CPqZg5HZ24QQxVKpNWYeOPgtj92NvTlUjw=; b=Zz0b8WTxUPCUgrq85tp64vdt6MM4pZWgBATdMA9NCWaelyE22zXPEH8PcaZ88V7QtD qwC1xrEA7wLN/f40OcOqbKriqrr8aaqYR5XSLxNTRZF2QByfFvZ6YG4sLU+LTSS1jIEi FjljmdMRzVex7EGg9nwBjdJ19AUvKwU3WfZoP9/gvCdQPXW46ByTgLKZSNaPd6W8o4uG +/wbN2PnJRtColsgu3owKZirv3X47oTFnslW7lGw1MAMfHPRGjFicVUZG4LDWaxcvGg4 LPiEf2cKLPA/QYsSbVb9hhYUgxSVaobBGfH7vvv/f+WCHeDKD6siflkeFlaGwPVVU0/W KdIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-94055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94055-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i9-20020a17090332c900b001d9fcd34721si12360772plr.119.2024.03.06.06.31.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:31:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-94055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94055-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A2A492824B5 for ; Wed, 6 Mar 2024 14:31:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F530132464; Wed, 6 Mar 2024 14:31:42 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 152A8131745; Wed, 6 Mar 2024 14:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709735501; cv=none; b=fTfDrAMKREGq2UpS77fkKC75yBp0hX1WaTzYc2x3cVpvpjGHuBVgWjLL0qw/DobIGRWL42LPh1XaeEKHUClXKO3S/w2rjD00ahL7gljLZHs2xvgwav1O65L1OP+XM0wb6/u5KIUzG8/ZDeUfIb1w599u7Ykm7MZJYxb/JFayvcc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709735501; c=relaxed/simple; bh=dbnHiZjb/P6UjDEKf3yalHtdTeFWkOkyikyrXGzM5Ro=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aWHf0b8uL7v9lxyOs88qc7PkfHWGEBVu6URZeGS4uACVehu1XhjqugKv5ph1nsUQ7eJ0y6x16ENBCOMy8DYYnMOWm3PXHiQyQuicGjauDP9pWVWM4EHRheHKv9unOw2gIqKzo9AgmA6B5Cz6ZD3/sn2A4a6B66C3bzU3VeICiOg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 340CB1FB; Wed, 6 Mar 2024 06:32:15 -0800 (PST) Received: from [10.57.11.156] (unknown [10.57.11.156]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2F5A23F762; Wed, 6 Mar 2024 06:31:35 -0800 (PST) Message-ID: <61095f51-3d74-48e9-96b4-75da4645331e@arm.com> Date: Wed, 6 Mar 2024 14:31:47 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/1] drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs To: =?UTF-8?Q?Adri=C3=A1n_Larumbe?= , boris.brezillon@collabora.com, robh@kernel.org, airlied@gmail.com, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, corbet@lwn.net Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org References: <20240306015819.822128-1-adrian.larumbe@collabora.com> <20240306015819.822128-2-adrian.larumbe@collabora.com> Content-Language: en-GB From: Steven Price In-Reply-To: <20240306015819.822128-2-adrian.larumbe@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 06/03/2024 01:56, Adrián Larumbe wrote: > Debugfs isn't always available in production builds that try to squeeze > every single byte out of the kernel image, but we still need a way to > toggle the timestamp and cycle counter registers so that jobs can be > profiled for fdinfo's drm engine and cycle calculations. > > Drop the debugfs knob and replace it with a sysfs file that accomplishes > the same functionality, and document its ABI in a separate file. > > Signed-off-by: Adrián Larumbe Reviewed-by: Steven Price > --- > .../testing/sysfs-driver-panfrost-profiling | 10 +++++ > Documentation/gpu/panfrost.rst | 9 ++++ > 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 | 2 +- > drivers/gpu/drm/panfrost/panfrost_drv.c | 41 ++++++++++++++++--- > drivers/gpu/drm/panfrost/panfrost_job.c | 2 +- > 8 files changed, 57 insertions(+), 44 deletions(-) > create mode 100644 Documentation/ABI/testing/sysfs-driver-panfrost-profiling > delete mode 100644 drivers/gpu/drm/panfrost/panfrost_debugfs.c > delete mode 100644 drivers/gpu/drm/panfrost/panfrost_debugfs.h > > diff --git a/Documentation/ABI/testing/sysfs-driver-panfrost-profiling b/Documentation/ABI/testing/sysfs-driver-panfrost-profiling > new file mode 100644 > index 000000000000..1d8bb0978920 > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-driver-panfrost-profiling > @@ -0,0 +1,10 @@ > +What: /sys/bus/platform/drivers/panfrost/.../profiling > +Date: February 2024 > +KernelVersion: 6.8.0 > +Contact: Adrian Larumbe > +Description: > + Get/set drm fdinfo's engine and cycles profiling status. > + Valid values are: > + 0: Don't enable fdinfo job profiling sources. > + 1: Enable fdinfo job profiling sources, this enables both the GPU's > + timestamp and cycle counter registers. > \ No newline at end of file > diff --git a/Documentation/gpu/panfrost.rst b/Documentation/gpu/panfrost.rst > index b80e41f4b2c5..51ba375fd80d 100644 > --- a/Documentation/gpu/panfrost.rst > +++ b/Documentation/gpu/panfrost.rst > @@ -38,3 +38,12 @@ the currently possible format options: > > Possible `drm-engine-` key names are: `fragment`, and `vertex-tiler`. > `drm-curfreq-` values convey the current operating frequency for that engine. > + > +Users must bear in mind that engine and cycle sampling are disabled by default, > +because of power saving concerns. `fdinfo` users and benchmark applications which > +query the fdinfo file must make sure to toggle the job profiling status of the > +driver by writing into the appropriate sysfs node:: > + > + echo > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profiling > + > +Where `N` is either `0` or `1`, depending on the desired enablement status. > 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..cffcb0ac7c11 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_device.h > +++ b/drivers/gpu/drm/panfrost/panfrost_device.h > @@ -130,7 +130,7 @@ struct panfrost_device { > struct list_head scheduled_jobs; > > struct panfrost_perfcnt *perfcnt; > - atomic_t profile_mode; > + bool 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..9696702800a4 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) > @@ -692,6 +687,41 @@ static void panfrost_remove(struct platform_device *pdev) > drm_dev_put(ddev); > } > > +static ssize_t profiling_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct panfrost_device *pfdev = dev_get_drvdata(dev); > + > + return sysfs_emit(buf, "%d\n", pfdev->profile_mode); > +} > + > + > +static ssize_t profiling_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t len) > +{ > + struct panfrost_device *pfdev = dev_get_drvdata(dev); > + bool value; > + int err; > + > + err = kstrtobool(buf, &value); > + if (err) > + return err; > + > + pfdev->profile_mode = value; > + > + return len; > +} > + > +static DEVICE_ATTR_RW(profiling); > + > +static struct attribute *panfrost_attrs[] = { > + &dev_attr_profiling.attr, > + NULL, > +}; > + > +ATTRIBUTE_GROUPS(panfrost); > + > /* > * The OPP core wants the supply names to be NULL terminated, but we need the > * correct num_supplies value for regulator core. Hence, we NULL terminate here > @@ -789,6 +819,7 @@ static struct platform_driver panfrost_driver = { > .name = "panfrost", > .pm = pm_ptr(&panfrost_pm_ops), > .of_match_table = dt_match, > + .dev_groups = panfrost_groups, > }, > }; > module_platform_driver(panfrost_driver); > diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c > index 0c2dbf6ef2a5..a61ef0af9a4e 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_job.c > +++ b/drivers/gpu/drm/panfrost/panfrost_job.c > @@ -243,7 +243,7 @@ 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)) { > + if (pfdev->profile_mode) { > panfrost_cycle_counter_get(pfdev); > job->is_profiled = true; > job->start_time = ktime_get();