Skip to content

Commit

Permalink
drm/msm/debugfs: Add display/kms state snapshot
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
robclark committed Dec 16, 2021
1 parent 5987121 commit c176055
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions drivers/gpu/drm/msm/msm_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
#include "msm_gpu.h"
#include "msm_kms.h"
#include "msm_debugfs.h"
#include "disp/msm_disp_snapshot.h"

/*
* GPU Snapshot:
*/

struct msm_gpu_show_priv {
struct msm_gpu_state *state;
Expand Down Expand Up @@ -109,6 +114,73 @@ static const struct file_operations msm_gpu_fops = {
.release = msm_gpu_release,
};

/*
* Display Snapshot:
*/

static int msm_kms_show(struct seq_file *m, void *arg)
{
struct drm_printer p = drm_seq_file_printer(m);
struct msm_disp_state *state = m->private;

msm_disp_state_print(state, &p);

return 0;
}

static int msm_kms_release(struct inode *inode, struct file *file)
{
struct seq_file *m = file->private_data;
struct msm_disp_state *state = m->private;

msm_disp_state_free(state);

return single_release(inode, file);
}

static int msm_kms_open(struct inode *inode, struct file *file)
{
struct drm_device *dev = inode->i_private;
struct msm_drm_private *priv = dev->dev_private;
struct msm_disp_state *state;
int ret;

if (!priv->kms)
return -ENODEV;

ret = mutex_lock_interruptible(&priv->kms->dump_mutex);
if (ret)
return ret;

state = msm_disp_snapshot_state_sync(priv->kms);

mutex_unlock(&priv->kms->dump_mutex);

if (IS_ERR(state)) {
return PTR_ERR(state);
}

ret = single_open(file, msm_kms_show, state);
if (ret) {
msm_disp_state_free(state);
return ret;
}

return 0;
}

static const struct file_operations msm_kms_fops = {
.owner = THIS_MODULE,
.open = msm_kms_open,
.read = seq_read,
.llseek = seq_lseek,
.release = msm_kms_release,
};

/*
* Other debugfs:
*/

static unsigned long last_shrink_freed;

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

debugfs_create_file("kms", S_IRUSR, minor->debugfs_root,
dev, &msm_kms_fops);

debugfs_create_u32("hangcheck_period_ms", 0600, minor->debugfs_root,
&priv->hangcheck_period);

Expand Down

0 comments on commit c176055

Please sign in to comment.