Skip to content

Commit c176055

Browse files
committed
drm/msm/debugfs: Add display/kms state snapshot
Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
1 parent 5987121 commit c176055

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

drivers/gpu/drm/msm/msm_debugfs.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
#include "msm_gpu.h"
1616
#include "msm_kms.h"
1717
#include "msm_debugfs.h"
18+
#include "disp/msm_disp_snapshot.h"
19+
20+
/*
21+
* GPU Snapshot:
22+
*/
1823

1924
struct msm_gpu_show_priv {
2025
struct msm_gpu_state *state;
@@ -109,6 +114,73 @@ static const struct file_operations msm_gpu_fops = {
109114
.release = msm_gpu_release,
110115
};
111116

117+
/*
118+
* Display Snapshot:
119+
*/
120+
121+
static int msm_kms_show(struct seq_file *m, void *arg)
122+
{
123+
struct drm_printer p = drm_seq_file_printer(m);
124+
struct msm_disp_state *state = m->private;
125+
126+
msm_disp_state_print(state, &p);
127+
128+
return 0;
129+
}
130+
131+
static int msm_kms_release(struct inode *inode, struct file *file)
132+
{
133+
struct seq_file *m = file->private_data;
134+
struct msm_disp_state *state = m->private;
135+
136+
msm_disp_state_free(state);
137+
138+
return single_release(inode, file);
139+
}
140+
141+
static int msm_kms_open(struct inode *inode, struct file *file)
142+
{
143+
struct drm_device *dev = inode->i_private;
144+
struct msm_drm_private *priv = dev->dev_private;
145+
struct msm_disp_state *state;
146+
int ret;
147+
148+
if (!priv->kms)
149+
return -ENODEV;
150+
151+
ret = mutex_lock_interruptible(&priv->kms->dump_mutex);
152+
if (ret)
153+
return ret;
154+
155+
state = msm_disp_snapshot_state_sync(priv->kms);
156+
157+
mutex_unlock(&priv->kms->dump_mutex);
158+
159+
if (IS_ERR(state)) {
160+
return PTR_ERR(state);
161+
}
162+
163+
ret = single_open(file, msm_kms_show, state);
164+
if (ret) {
165+
msm_disp_state_free(state);
166+
return ret;
167+
}
168+
169+
return 0;
170+
}
171+
172+
static const struct file_operations msm_kms_fops = {
173+
.owner = THIS_MODULE,
174+
.open = msm_kms_open,
175+
.read = seq_read,
176+
.llseek = seq_lseek,
177+
.release = msm_kms_release,
178+
};
179+
180+
/*
181+
* Other debugfs:
182+
*/
183+
112184
static unsigned long last_shrink_freed;
113185

114186
static int
@@ -239,6 +311,9 @@ void msm_debugfs_init(struct drm_minor *minor)
239311
debugfs_create_file("gpu", S_IRUSR, minor->debugfs_root,
240312
dev, &msm_gpu_fops);
241313

314+
debugfs_create_file("kms", S_IRUSR, minor->debugfs_root,
315+
dev, &msm_kms_fops);
316+
242317
debugfs_create_u32("hangcheck_period_ms", 0600, minor->debugfs_root,
243318
&priv->hangcheck_period);
244319

0 commit comments

Comments
 (0)