mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:38:03 +00:00
f11b0417ee
The drm-stats fdinfo tags made available to user space are drm-engine, drm-cycles, drm-max-freq and drm-curfreq, one per job slot. This deviates from standard practice in other DRM drivers, where a single set of key:value pairs is provided for the whole render engine. However, Panfrost has separate queues for fragment and vertex/tiler jobs, so a decision was made to calculate bus cycles and workload times separately. Maximum operating frequency is calculated at devfreq initialisation time. Current frequency is made available to user space because nvtop uses it when performing engine usage calculations. It is important to bear in mind that both GPU cycle and kernel time numbers provided are at best rough estimations, and always reported in excess from the actual figure because of two reasons: - Excess time because of the delay between the end of a job processing, the subsequent job IRQ and the actual time of the sample. - Time spent in the engine queue waiting for the GPU to pick up the next job. To avoid race conditions during enablement/disabling, a reference counting mechanism was introduced, and a job flag that tells us whether a given job increased the refcount. This is necessary, because user space can toggle cycle counting through a debugfs file, and a given job might have been in flight by the time cycle counting was disabled. The main goal of the debugfs cycle counter knob is letting tools like nvtop or IGT's gputop switch it at any time, to avoid power waste in case no engine usage measuring is necessary. Also add a documentation file explaining the possible values for fdinfo's engine keystrings and Panfrost-specific drm-curfreq-<keystr> pairs. 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> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230929181616.2769345-3-adrian.larumbe@collabora.com
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright 2019 Collabora ltd. */
|
|
|
|
#ifndef __PANFROST_DEVFREQ_H__
|
|
#define __PANFROST_DEVFREQ_H__
|
|
|
|
#include <linux/devfreq.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/ktime.h>
|
|
|
|
struct devfreq;
|
|
struct thermal_cooling_device;
|
|
|
|
struct panfrost_device;
|
|
|
|
struct panfrost_devfreq {
|
|
struct devfreq *devfreq;
|
|
struct thermal_cooling_device *cooling;
|
|
struct devfreq_simple_ondemand_data gov_data;
|
|
bool opp_of_table_added;
|
|
|
|
unsigned long current_frequency;
|
|
unsigned long fast_rate;
|
|
|
|
ktime_t busy_time;
|
|
ktime_t idle_time;
|
|
ktime_t time_last_update;
|
|
int busy_count;
|
|
/*
|
|
* Protect busy_time, idle_time, time_last_update and busy_count
|
|
* because these can be updated concurrently between multiple jobs.
|
|
*/
|
|
spinlock_t lock;
|
|
};
|
|
|
|
int panfrost_devfreq_init(struct panfrost_device *pfdev);
|
|
void panfrost_devfreq_fini(struct panfrost_device *pfdev);
|
|
|
|
void panfrost_devfreq_resume(struct panfrost_device *pfdev);
|
|
void panfrost_devfreq_suspend(struct panfrost_device *pfdev);
|
|
|
|
void panfrost_devfreq_record_busy(struct panfrost_devfreq *devfreq);
|
|
void panfrost_devfreq_record_idle(struct panfrost_devfreq *devfreq);
|
|
|
|
#endif /* __PANFROST_DEVFREQ_H__ */
|