Skip to content

Commit cb56cd6

Browse files
sarah-walker-imgtecmripard
authored andcommitted
drm/imagination: Add firmware trace to debugfs
Firmware trace is exposed at /sys/debug/dri/<dev_nr>/pvr_fw/trace_0. Trace is enabled via the group mask at /sys/debug/dri/<dev_nr>/pvr_params/fw_trace_mask. Changes since v8: - Corrected license identifiers Changes since v3: - Use drm_dev_{enter,exit} Co-developed-by: Matt Coster <matt.coster@imgtec.com> Signed-off-by: Matt Coster <matt.coster@imgtec.com> Signed-off-by: Sarah Walker <sarah.walker@imgtec.com> Signed-off-by: Donald Robson <donald.robson@imgtec.com> Link: https://lore.kernel.org/r/009cf9fee347fa96c8a665dc368fc54a5ffceff0.1700668843.git.donald.robson@imgtec.com Signed-off-by: Maxime Ripard <mripard@kernel.org>
1 parent 6b17baa commit cb56cd6

9 files changed

Lines changed: 723 additions & 0 deletions

File tree

drivers/gpu/drm/imagination/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ powervr-y := \
2020
pvr_hwrt.o \
2121
pvr_job.o \
2222
pvr_mmu.o \
23+
pvr_params.o \
2324
pvr_power.o \
2425
pvr_queue.o \
2526
pvr_stream.o \
@@ -28,4 +29,7 @@ powervr-y := \
2829
pvr_vm.o \
2930
pvr_vm_mips.o
3031

32+
powervr-$(CONFIG_DEBUG_FS) += \
33+
pvr_debugfs.o
34+
3135
obj-$(CONFIG_DRM_POWERVR) += powervr.o
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: GPL-2.0-only OR MIT
2+
/* Copyright (c) 2023 Imagination Technologies Ltd. */
3+
4+
#include "pvr_debugfs.h"
5+
6+
#include "pvr_device.h"
7+
#include "pvr_fw_trace.h"
8+
#include "pvr_params.h"
9+
10+
#include <linux/dcache.h>
11+
#include <linux/debugfs.h>
12+
#include <linux/err.h>
13+
#include <linux/kernel.h>
14+
#include <linux/types.h>
15+
16+
#include <drm/drm_device.h>
17+
#include <drm/drm_file.h>
18+
#include <drm/drm_print.h>
19+
20+
static const struct pvr_debugfs_entry pvr_debugfs_entries[] = {
21+
{"pvr_params", pvr_params_debugfs_init},
22+
{"pvr_fw", pvr_fw_trace_debugfs_init},
23+
};
24+
25+
void
26+
pvr_debugfs_init(struct drm_minor *minor)
27+
{
28+
struct drm_device *drm_dev = minor->dev;
29+
struct pvr_device *pvr_dev = to_pvr_device(drm_dev);
30+
struct dentry *root = minor->debugfs_root;
31+
size_t i;
32+
33+
for (i = 0; i < ARRAY_SIZE(pvr_debugfs_entries); ++i) {
34+
const struct pvr_debugfs_entry *entry = &pvr_debugfs_entries[i];
35+
struct dentry *dir;
36+
37+
dir = debugfs_create_dir(entry->name, root);
38+
if (IS_ERR(dir)) {
39+
drm_warn(drm_dev,
40+
"failed to create debugfs dir '%s' (err=%d)",
41+
entry->name, (int)PTR_ERR(dir));
42+
continue;
43+
}
44+
45+
entry->init(pvr_dev, dir);
46+
}
47+
}
48+
49+
/*
50+
* Since all entries are created under &drm_minor->debugfs_root, there's no
51+
* need for a pvr_debugfs_fini() as DRM will clean up everything under its root
52+
* automatically.
53+
*/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2+
/* Copyright (c) 2023 Imagination Technologies Ltd. */
3+
4+
#ifndef PVR_DEBUGFS_H
5+
#define PVR_DEBUGFS_H
6+
7+
/* Forward declaration from <drm/drm_drv.h>. */
8+
struct drm_minor;
9+
10+
#if defined(CONFIG_DEBUG_FS)
11+
/* Forward declaration from "pvr_device.h". */
12+
struct pvr_device;
13+
14+
/* Forward declaration from <linux/dcache.h>. */
15+
struct dentry;
16+
17+
struct pvr_debugfs_entry {
18+
const char *name;
19+
void (*init)(struct pvr_device *pvr_dev, struct dentry *dir);
20+
};
21+
22+
void pvr_debugfs_init(struct drm_minor *minor);
23+
#else /* defined(CONFIG_DEBUG_FS) */
24+
#include <linux/compiler_attributes.h>
25+
26+
static __always_inline void pvr_debugfs_init(struct drm_minor *minor) {}
27+
#endif /* defined(CONFIG_DEBUG_FS) */
28+
29+
#endif /* PVR_DEBUGFS_H */

drivers/gpu/drm/imagination/pvr_device.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "pvr_device_info.h"
66

77
#include "pvr_fw.h"
8+
#include "pvr_params.h"
89
#include "pvr_power.h"
910
#include "pvr_queue.h"
1011
#include "pvr_rogue_cr_defs.h"
@@ -495,6 +496,14 @@ pvr_device_init(struct pvr_device *pvr_dev)
495496
struct device *dev = drm_dev->dev;
496497
int err;
497498

499+
/*
500+
* Setup device parameters. We do this first in case other steps
501+
* depend on them.
502+
*/
503+
err = pvr_device_params_init(&pvr_dev->params);
504+
if (err)
505+
return err;
506+
498507
/* Enable and initialize clocks required for the device to operate. */
499508
err = pvr_device_clk_init(pvr_dev);
500509
if (err)

drivers/gpu/drm/imagination/pvr_device.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "pvr_ccb.h"
88
#include "pvr_device_info.h"
99
#include "pvr_fw.h"
10+
#include "pvr_params.h"
1011
#include "pvr_rogue_fwif_stream.h"
1112
#include "pvr_stream.h"
1213

@@ -148,6 +149,15 @@ struct pvr_device {
148149
/** @fw_dev: Firmware related data. */
149150
struct pvr_fw_device fw_dev;
150151

152+
/**
153+
* @params: Device-specific parameters.
154+
*
155+
* The values of these parameters are initialized from the
156+
* defaults specified as module parameters. They may be
157+
* modified at runtime via debugfs (if enabled).
158+
*/
159+
struct pvr_device_params params;
160+
151161
/** @stream_musthave_quirks: Bit array of "must-have" quirks for stream commands. */
152162
u32 stream_musthave_quirks[PVR_STREAM_TYPE_MAX][PVR_STREAM_EXTHDR_TYPE_MAX];
153163

drivers/gpu/drm/imagination/pvr_drv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright (c) 2023 Imagination Technologies Ltd. */
33

44
#include "pvr_context.h"
5+
#include "pvr_debugfs.h"
56
#include "pvr_device.h"
67
#include "pvr_drv.h"
78
#include "pvr_free_list.h"
@@ -1377,6 +1378,9 @@ static struct drm_driver pvr_drm_driver = {
13771378
.ioctls = pvr_drm_driver_ioctls,
13781379
.num_ioctls = ARRAY_SIZE(pvr_drm_driver_ioctls),
13791380
.fops = &pvr_drm_driver_fops,
1381+
#if defined(CONFIG_DEBUG_FS)
1382+
.debugfs_init = pvr_debugfs_init,
1383+
#endif
13801384

13811385
.name = PVR_DRIVER_NAME,
13821386
.desc = PVR_DRIVER_DESC,

0 commit comments

Comments
 (0)