Skip to content

Commit 97804a1

Browse files
committed
drm/etnaviv: export client GPU usage statistics via fdinfo
This exposes a accumulated GPU active time per client via the fdinfo infrastructure. Signed-off-by: Lucas Stach <[email protected]> Reviewed-by: Philipp Zabel <[email protected]>
1 parent d306788 commit 97804a1

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

drivers/gpu/drm/etnaviv/etnaviv_drv.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "etnaviv_gem.h"
2323
#include "etnaviv_mmu.h"
2424
#include "etnaviv_perfmon.h"
25+
#include "common.xml.h"
2526

2627
/*
2728
* DRM operations:
@@ -475,7 +476,47 @@ static const struct drm_ioctl_desc etnaviv_ioctls[] = {
475476
ETNA_IOCTL(PM_QUERY_SIG, pm_query_sig, DRM_RENDER_ALLOW),
476477
};
477478

478-
DEFINE_DRM_GEM_FOPS(fops);
479+
static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
480+
{
481+
struct drm_file *file = f->private_data;
482+
struct drm_device *dev = file->minor->dev;
483+
struct etnaviv_drm_private *priv = dev->dev_private;
484+
struct etnaviv_file_private *ctx = file->driver_priv;
485+
486+
/*
487+
* For a description of the text output format used here, see
488+
* Documentation/gpu/drm-usage-stats.rst.
489+
*/
490+
seq_printf(m, "drm-driver:\t%s\n", dev->driver->name);
491+
seq_printf(m, "drm-client-id:\t%u\n", ctx->id);
492+
493+
for (int i = 0; i < ETNA_MAX_PIPES; i++) {
494+
struct etnaviv_gpu *gpu = priv->gpu[i];
495+
char engine[10] = "UNK";
496+
int cur = 0;
497+
498+
if (!gpu)
499+
continue;
500+
501+
if (gpu->identity.features & chipFeatures_PIPE_2D)
502+
cur = snprintf(engine, sizeof(engine), "2D");
503+
if (gpu->identity.features & chipFeatures_PIPE_3D)
504+
cur = snprintf(engine + cur, sizeof(engine) - cur,
505+
"%s3D", cur ? "/" : "");
506+
if (gpu->identity.nn_core_count > 0)
507+
cur = snprintf(engine + cur, sizeof(engine) - cur,
508+
"%sNN", cur ? "/" : "");
509+
510+
seq_printf(m, "drm-engine-%s:\t%llu ns\n", engine,
511+
ctx->sched_entity[i].elapsed_ns);
512+
}
513+
}
514+
515+
static const struct file_operations fops = {
516+
.owner = THIS_MODULE,
517+
DRM_GEM_FOPS,
518+
.show_fdinfo = etnaviv_fop_show_fdinfo,
519+
};
479520

480521
static const struct drm_driver etnaviv_drm_driver = {
481522
.driver_features = DRIVER_GEM | DRIVER_RENDER,

0 commit comments

Comments
 (0)