brintos

brintos / linux-shallow public Read only

0
0
Text · 1.6 KiB · d610e35 Raw
67 lines · c
1// SPDX-License-Identifier: MIT2/*3 * Copyright © 2023 Igalia S.L.4 */5 6#include <linux/sched/clock.h>7#include <linux/sysfs.h>8 9#include "v3d_drv.h"10 11static ssize_t12gpu_stats_show(struct device *dev, struct device_attribute *attr, char *buf)13{14	struct drm_device *drm = dev_get_drvdata(dev);15	struct v3d_dev *v3d = to_v3d_dev(drm);16	enum v3d_queue queue;17	u64 timestamp = local_clock();18	ssize_t len = 0;19 20	len += sysfs_emit(buf, "queue\ttimestamp\tjobs\truntime\n");21 22	for (queue = 0; queue < V3D_MAX_QUEUES; queue++) {23		struct v3d_stats *stats = &v3d->queue[queue].stats;24		u64 active_runtime, jobs_completed;25 26		v3d_get_stats(stats, timestamp, &active_runtime, &jobs_completed);27 28		/* Each line will display the queue name, timestamp, the number29		 * of jobs sent to that queue and the runtime, as can be seem here:30		 *31		 * queue	timestamp	jobs	runtime32		 * bin		239043069420	22620	1743816405633		 * render	239043069420	22619	2728481416134		 * tfu		239043069420	8763	39459256635		 * csd		239043069420	3168	1078790553036		 * cache_clean	239043069420	6127	23737594037		 */38		len += sysfs_emit_at(buf, len, "%s\t%llu\t%llu\t%llu\n",39				     v3d_queue_to_string(queue),40				     timestamp, jobs_completed, active_runtime);41	}42 43	return len;44}45static DEVICE_ATTR_RO(gpu_stats);46 47static struct attribute *v3d_sysfs_entries[] = {48	&dev_attr_gpu_stats.attr,49	NULL,50};51 52static struct attribute_group v3d_sysfs_attr_group = {53	.attrs = v3d_sysfs_entries,54};55 56int57v3d_sysfs_init(struct device *dev)58{59	return sysfs_create_group(&dev->kobj, &v3d_sysfs_attr_group);60}61 62void63v3d_sysfs_destroy(struct device *dev)64{65	return sysfs_remove_group(&dev->kobj, &v3d_sysfs_attr_group);66}67