drm/panfrost: Replace fdinfo's profiling debugfs knob
Subsystems (4)
Adrián Larumbe
maintainerv3 cover drm/panfrost: Replace fdinfo's profiling debugfs knob
This is v3 of the patch already discussed in [2] and [1]
Changelog:
v3:
- Replaced manual kobj initialisation with a device attribute
- Handle user input with kstrtobool instead of treating it as an uint v2:
- Turned the profile mode atomic variable into a boolean
- Rewrote the sysfs file's uAPI documentation to make it more generic
- Improved the casting of the profiling variable inside the Panfrost device structure
[2]https://lore.kernel.org/dri-devel/[email protected]/ [1]https://lore.kernel.org/dri-devel/[email protected]/
Adrián Larumbe (1):
drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
.../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
base-commit: e635b7eb7062b464bbd9795308b1a80eac0b01f5
Signature · 1 line
2.43.0
Adrián Larumbe
maintainerPATCH v3 1/1 drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
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.
--- .../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
Documentation/ABI/testing/sysfs-driver-panfrost-profiling new file +10 -0
@@ -0,0 +1,10 @@ +What: /sys/bus/platform/drivers/panfrost/.../profiling +Date: February 2024 +KernelVersion: 6.8.0 +Contact: Adrian Larumbe <[email protected]> +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.
Documentation/gpu/panfrost.rst +9 -0
@@ -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 <N> > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profiling + +Where `N` is either `0` or `1`, depending on the desired enablement status.
drivers/gpu/drm/panfrost/Makefile +0 -2
@@ -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
drivers/gpu/drm/panfrost/panfrost_debugfs.c deleted +0 -21
@@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright 2023 Collabora ltd. */ -/* Copyright 2023 Amazon.com, Inc. or its affiliates. */ - -#include <linux/debugfs.h> -#include <linux/platform_device.h> -#include <drm/drm_debugfs.h> -#include <drm/drm_file.h> -#include <drm/panfrost_drm.h> - -#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); -}
drivers/gpu/drm/panfrost/panfrost_debugfs.h deleted +0 -14
@@ -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 */
drivers/gpu/drm/panfrost/panfrost_device.h +1 -1
@@ -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;
drivers/gpu/drm/panfrost/panfrost_drv.c +36 -5
65 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_job.c +1 -1
@@ -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 ();
Signature · 1 line
2.43.0
Re: [PATCH v3 1/1] drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
Quoted 45 lines · Adrián Larumbe
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 <[email protected]>--- .../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-profilingdelete mode 100644drivers/gpu/drm/panfrost/panfrost_debugfs.cdelete mode 100644drivers/gpu/drm/panfrost/panfrost_debugfs.hDocumentation/ABI/testing/sysfs-driver-panfrost-profiling new file +10
-0@@ -0,0 +1,10 @@ +What: /sys/bus/platform/drivers/panfrost/.../profiling +Date: February 2024 +KernelVersion: 6.8.0 +Contact: Adrian Larumbe <[email protected]> +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.Documentation/gpu/panfrost.rst +0
-0
Documentation/gpu/panfrost.rst the currently possible format options: · line 47
Quoted 10 lines
Documentation/gpu/panfrost.rst +7
-0@@ -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 <N> > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profiling
A late thought - how it would work to not output the inactive fdinfo keys when this knob is not enabled?
Generic userspace like gputop already handles that and wouldn't show the stat. Which may be more user friendly than showing stats permanently at zero. It may be moot once you add the auto-toggle to gputop (or so) but perhaps worth considering.
Regards,
Tvrtko
Quoted 159 lines
Documentation/gpu/panfrost.rst +2
-0+ +Where `N` is either `0` or `1`, depending on the desired enablement status.drivers/gpu/drm/panfrost/Makefile +0
-2@@ -12,6 +12,4 @@ panfrost-y := \ panfrost_perfcnt.o \ panfrost_dump.o -panfrost-$(CONFIG_DEBUG_FS) += panfrost_debugfs.o - obj-$(CONFIG_DRM_PANFROST) += panfrost.odrivers/gpu/drm/panfrost/panfrost_debugfs.c deleted +0
-21@@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright 2023 Collabora ltd. */ -/* Copyright 2023 Amazon.com, Inc. or its affiliates. */ - -#include <linux/debugfs.h> -#include <linux/platform_device.h> -#include <drm/drm_debugfs.h> -#include <drm/drm_file.h> -#include <drm/panfrost_drm.h> - -#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); -}drivers/gpu/drm/panfrost/panfrost_debugfs.h deleted +0
-14@@ -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 */ drivers/gpu/drm/panfrost/panfrost_device.h +1
-1@@ -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;drivers/gpu/drm/panfrost/panfrost_drv.c +36
-5@@ -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);drivers/gpu/drm/panfrost/panfrost_job.c +1
-1@@ -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 ();
Boris Brezillon
maintainerRe: [PATCH v3 1/1] drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
Quoted 60 lines · On Wed, 6 Mar 2024 08:33:47 +0000 Tvrtko Ursulin <[email protected]> wrote:
Quoted 45 lines · Adrián Larumbe
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 <[email protected]>--- .../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-profilingdelete mode 100644drivers/gpu/drm/panfrost/panfrost_debugfs.cdelete mode 100644drivers/gpu/drm/panfrost/panfrost_debugfs.hDocumentation/ABI/testing/sysfs-driver-panfrost-profiling new file +10
-0@@ -0,0 +1,10 @@ +What: /sys/bus/platform/drivers/panfrost/.../profiling +Date: February 2024 +KernelVersion: 6.8.0 +Contact: Adrian Larumbe <[email protected]> +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.Documentation/gpu/panfrost.rst +0
-0Documentation/gpu/panfrost.rst the currently possible format options: · line 47
Quoted 10 lines
Documentation/gpu/panfrost.rst +7
-0@@ -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 <N> > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profilingA late thought - how it would work to not output the inactive fdinfo keys when this knob is not enabled?
Quoted 4 lines
Generic userspace like gputop already handles that and wouldn't show the stat. Which may be more user friendly than showing stats permanently at zero. It may be moot once you add the auto-toggle to gputop (or so) but perhaps worth considering.
I agree with Tvrtko, if the line being printed in fdinfo relies on some sysfs knob to be valid, we'd rather not print the information in that case, instead of printing zero.
Adrián Larumbe
maintainerRe: [PATCH v3 1/1] drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
Quoted 63 lines · Boris Brezillon
Quoted 60 lines · On Wed, 6 Mar 2024 08:33:47 +0000 Tvrtko Ursulin <[email protected]> wrote:
Quoted 45 lines · Adrián Larumbe
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 <[email protected]>--- .../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-profilingdelete mode 100644drivers/gpu/drm/panfrost/panfrost_debugfs.cdelete mode 100644drivers/gpu/drm/panfrost/panfrost_debugfs.hDocumentation/ABI/testing/sysfs-driver-panfrost-profiling new file +10
-0@@ -0,0 +1,10 @@ +What: /sys/bus/platform/drivers/panfrost/.../profiling +Date: February 2024 +KernelVersion: 6.8.0 +Contact: Adrian Larumbe <[email protected]> +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.Documentation/gpu/panfrost.rst +0
-0Documentation/gpu/panfrost.rst the currently possible format options: · line 47
Quoted 10 lines
Documentation/gpu/panfrost.rst +7
-0@@ -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 <N> > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profilingA late thought - how it would work to not output the inactive fdinfo keys when this knob is not enabled?
Quoted 8 lines
Quoted 4 lines
Generic userspace like gputop already handles that and wouldn't show the stat. Which may be more user friendly than showing stats permanently at zero. It may be moot once you add the auto-toggle to gputop (or so) but perhaps worth considering.
I agree with Tvrtko, if the line being printed in fdinfo relies on some sysfs knob to be valid, we'd rather not print the information in that case, instead of printing zero.
Me too. I'll go first change both gputop and nvtop to make sure they use the new sysfs knob for Panfrost, and then submit a new patch that handles printing of the drm-cycles-* and drm-engine-* stats depending on the profiling knob state.
Re: [PATCH v3 1/1] drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
In reply to Adrián LarumbeQuoted 9 lines · On Wed, 6 Mar 2024 01:56:36 +0000 Adrián Larumbe…
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 <[email protected]>
Quoted 205 lines
--- .../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.hDocumentation/ABI/testing/sysfs-driver-panfrost-profiling new file +10
-0@@ -0,0 +1,10 @@ +What: /sys/bus/platform/drivers/panfrost/.../profiling +Date: February 2024 +KernelVersion: 6.8.0 +Contact: Adrian Larumbe <[email protected]> +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.Documentation/gpu/panfrost.rst +9
-0@@ -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 <N> > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profiling + +Where `N` is either `0` or `1`, depending on the desired enablement status.drivers/gpu/drm/panfrost/Makefile +0
-2@@ -12,6 +12,4 @@ panfrost-y := \ panfrost_perfcnt.o \ panfrost_dump.o -panfrost-$(CONFIG_DEBUG_FS) += panfrost_debugfs.o - obj-$(CONFIG_DRM_PANFROST) += panfrost.odrivers/gpu/drm/panfrost/panfrost_debugfs.c deleted +0
-21@@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright 2023 Collabora ltd. */ -/* Copyright 2023 Amazon.com, Inc. or its affiliates. */ - -#include <linux/debugfs.h> -#include <linux/platform_device.h> -#include <drm/drm_debugfs.h> -#include <drm/drm_file.h> -#include <drm/panfrost_drm.h> - -#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); -}drivers/gpu/drm/panfrost/panfrost_debugfs.h deleted +0
-14@@ -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 */ drivers/gpu/drm/panfrost/panfrost_device.h +1
-1@@ -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;drivers/gpu/drm/panfrost/panfrost_drv.c +36
-5@@ -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);drivers/gpu/drm/panfrost/panfrost_job.c +1
-1@@ -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 ();
Re: [PATCH v3 1/1] drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
In reply to Adrián LarumbeQuoted 9 lines · Adrián Larumbe
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 <[email protected]>
Quoted 205 lines
--- .../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.hDocumentation/ABI/testing/sysfs-driver-panfrost-profiling new file +10
-0@@ -0,0 +1,10 @@ +What: /sys/bus/platform/drivers/panfrost/.../profiling +Date: February 2024 +KernelVersion: 6.8.0 +Contact: Adrian Larumbe <[email protected]> +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.Documentation/gpu/panfrost.rst +9
-0@@ -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 <N> > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profiling + +Where `N` is either `0` or `1`, depending on the desired enablement status.drivers/gpu/drm/panfrost/Makefile +0
-2@@ -12,6 +12,4 @@ panfrost-y := \ panfrost_perfcnt.o \ panfrost_dump.o -panfrost-$(CONFIG_DEBUG_FS) += panfrost_debugfs.o - obj-$(CONFIG_DRM_PANFROST) += panfrost.odrivers/gpu/drm/panfrost/panfrost_debugfs.c deleted +0
-21@@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright 2023 Collabora ltd. */ -/* Copyright 2023 Amazon.com, Inc. or its affiliates. */ - -#include <linux/debugfs.h> -#include <linux/platform_device.h> -#include <drm/drm_debugfs.h> -#include <drm/drm_file.h> -#include <drm/panfrost_drm.h> - -#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); -}drivers/gpu/drm/panfrost/panfrost_debugfs.h deleted +0
-14@@ -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 */ drivers/gpu/drm/panfrost/panfrost_device.h +1
-1@@ -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;drivers/gpu/drm/panfrost/panfrost_drv.c +36
-5@@ -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);drivers/gpu/drm/panfrost/panfrost_job.c +1
-1@@ -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 ();
Boris Brezillon
maintainerRe: [PATCH v3 1/1] drm/panfrost: Replace fdinfo's profiling debugfs knob with sysfs
In reply to Adrián Larumbedrivers/gpu/drm/panfrost/panfrost_drv.c static void panfrost_remove(struct platform_device *pdev) · line 698
Quoted 10 lines · On Wed, 6 Mar 2024 01:56:36 +0000 Adrián Larumbe…
drivers/gpu/drm/panfrost/panfrost_drv.c +9
-0+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); +} + +
Dropped the extra blank and queued the patch to drm-misc-next.
Quoted 16 lines
drivers/gpu/drm/panfrost/panfrost_drv.c +16
-0+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; +}