Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240306015819.822128-2-adrian.larumbe@collabora.com

authored by

Adrián Larumbe and committed by
Boris Brezillon
b12f3ea7 57a4e3a9

+56 -44
+10
Documentation/ABI/testing/sysfs-driver-panfrost-profiling
··· 1 + What: /sys/bus/platform/drivers/panfrost/.../profiling 2 + Date: February 2024 3 + KernelVersion: 6.8.0 4 + Contact: Adrian Larumbe <adrian.larumbe@collabora.com> 5 + Description: 6 + Get/set drm fdinfo's engine and cycles profiling status. 7 + Valid values are: 8 + 0: Don't enable fdinfo job profiling sources. 9 + 1: Enable fdinfo job profiling sources, this enables both the GPU's 10 + timestamp and cycle counter registers.
+9
Documentation/gpu/panfrost.rst
··· 38 38 39 39 Possible `drm-engine-` key names are: `fragment`, and `vertex-tiler`. 40 40 `drm-curfreq-` values convey the current operating frequency for that engine. 41 + 42 + Users must bear in mind that engine and cycle sampling are disabled by default, 43 + because of power saving concerns. `fdinfo` users and benchmark applications which 44 + query the fdinfo file must make sure to toggle the job profiling status of the 45 + driver by writing into the appropriate sysfs node:: 46 + 47 + echo <N> > /sys/bus/platform/drivers/panfrost/[a-f0-9]*.gpu/profiling 48 + 49 + Where `N` is either `0` or `1`, depending on the desired enablement status.
-2
drivers/gpu/drm/panfrost/Makefile
··· 12 12 panfrost_perfcnt.o \ 13 13 panfrost_dump.o 14 14 15 - panfrost-$(CONFIG_DEBUG_FS) += panfrost_debugfs.o 16 - 17 15 obj-$(CONFIG_DRM_PANFROST) += panfrost.o
-21
drivers/gpu/drm/panfrost/panfrost_debugfs.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* Copyright 2023 Collabora ltd. */ 3 - /* Copyright 2023 Amazon.com, Inc. or its affiliates. */ 4 - 5 - #include <linux/debugfs.h> 6 - #include <linux/platform_device.h> 7 - #include <drm/drm_debugfs.h> 8 - #include <drm/drm_file.h> 9 - #include <drm/panfrost_drm.h> 10 - 11 - #include "panfrost_device.h" 12 - #include "panfrost_gpu.h" 13 - #include "panfrost_debugfs.h" 14 - 15 - void panfrost_debugfs_init(struct drm_minor *minor) 16 - { 17 - struct drm_device *dev = minor->dev; 18 - struct panfrost_device *pfdev = platform_get_drvdata(to_platform_device(dev->dev)); 19 - 20 - debugfs_create_atomic_t("profile", 0600, minor->debugfs_root, &pfdev->profile_mode); 21 - }
-14
drivers/gpu/drm/panfrost/panfrost_debugfs.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Copyright 2023 Collabora ltd. 4 - * Copyright 2023 Amazon.com, Inc. or its affiliates. 5 - */ 6 - 7 - #ifndef PANFROST_DEBUGFS_H 8 - #define PANFROST_DEBUGFS_H 9 - 10 - #ifdef CONFIG_DEBUG_FS 11 - void panfrost_debugfs_init(struct drm_minor *minor); 12 - #endif 13 - 14 - #endif /* PANFROST_DEBUGFS_H */
+1 -1
drivers/gpu/drm/panfrost/panfrost_device.h
··· 130 130 struct list_head scheduled_jobs; 131 131 132 132 struct panfrost_perfcnt *perfcnt; 133 - atomic_t profile_mode; 133 + bool profile_mode; 134 134 135 135 struct mutex sched_lock; 136 136
+35 -5
drivers/gpu/drm/panfrost/panfrost_drv.c
··· 20 20 #include "panfrost_job.h" 21 21 #include "panfrost_gpu.h" 22 22 #include "panfrost_perfcnt.h" 23 - #include "panfrost_debugfs.h" 24 23 25 24 static bool unstable_ioctls; 26 25 module_param_unsafe(unstable_ioctls, bool, 0600); ··· 599 600 600 601 .gem_create_object = panfrost_gem_create_object, 601 602 .gem_prime_import_sg_table = panfrost_gem_prime_import_sg_table, 602 - 603 - #ifdef CONFIG_DEBUG_FS 604 - .debugfs_init = panfrost_debugfs_init, 605 - #endif 606 603 }; 607 604 608 605 static int panfrost_probe(struct platform_device *pdev) ··· 686 691 687 692 drm_dev_put(ddev); 688 693 } 694 + 695 + static ssize_t profiling_show(struct device *dev, 696 + struct device_attribute *attr, char *buf) 697 + { 698 + struct panfrost_device *pfdev = dev_get_drvdata(dev); 699 + 700 + return sysfs_emit(buf, "%d\n", pfdev->profile_mode); 701 + } 702 + 703 + static ssize_t profiling_store(struct device *dev, 704 + struct device_attribute *attr, 705 + const char *buf, size_t len) 706 + { 707 + struct panfrost_device *pfdev = dev_get_drvdata(dev); 708 + bool value; 709 + int err; 710 + 711 + err = kstrtobool(buf, &value); 712 + if (err) 713 + return err; 714 + 715 + pfdev->profile_mode = value; 716 + 717 + return len; 718 + } 719 + 720 + static DEVICE_ATTR_RW(profiling); 721 + 722 + static struct attribute *panfrost_attrs[] = { 723 + &dev_attr_profiling.attr, 724 + NULL, 725 + }; 726 + 727 + ATTRIBUTE_GROUPS(panfrost); 689 728 690 729 /* 691 730 * The OPP core wants the supply names to be NULL terminated, but we need the ··· 818 789 .name = "panfrost", 819 790 .pm = pm_ptr(&panfrost_pm_ops), 820 791 .of_match_table = dt_match, 792 + .dev_groups = panfrost_groups, 821 793 }, 822 794 }; 823 795 module_platform_driver(panfrost_driver);
+1 -1
drivers/gpu/drm/panfrost/panfrost_job.c
··· 243 243 subslot = panfrost_enqueue_job(pfdev, js, job); 244 244 /* Don't queue the job if a reset is in progress */ 245 245 if (!atomic_read(&pfdev->reset.pending)) { 246 - if (atomic_read(&pfdev->profile_mode)) { 246 + if (pfdev->profile_mode) { 247 247 panfrost_cycle_counter_get(pfdev); 248 248 job->is_profiled = true; 249 249 job->start_time = ktime_get();