From c9a5def3b225776a62df90f263e69f1eb1a97a39 Mon Sep 17 00:00:00 2001 From: Dhaval Patel Date: Tue, 2 Mar 2021 22:52:25 -0800 Subject: [PATCH] disp: msm: sde: provide rm status through debugfs node Provide rm status through debugfs node. cat /d/dri/0/debug/rm_status. Change-Id: Ic1950b1881f0b57582701a342793aa06adb9da39 Signed-off-by: Dhaval Patel --- msm/sde/sde_kms.c | 1 + msm/sde/sde_rm.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++ msm/sde/sde_rm.h | 6 +++++ 3 files changed, 71 insertions(+) diff --git a/msm/sde/sde_kms.c b/msm/sde/sde_kms.c index 914ab15323..bc9bc1875c 100644 --- a/msm/sde/sde_kms.c +++ b/msm/sde/sde_kms.c @@ -154,6 +154,7 @@ static int _sde_debugfs_init(struct sde_kms *sde_kms) SDE_ERROR("failed to init perf %d\n", rc); return rc; } + sde_rm_debugfs_init(&sde_kms->rm, debugfs_root); if (sde_kms->catalog->qdss_count) debugfs_create_u32("qdss", 0600, debugfs_root, diff --git a/msm/sde/sde_rm.c b/msm/sde/sde_rm.c index 0ddd15402c..a3c7d49003 100644 --- a/msm/sde/sde_rm.c +++ b/msm/sde/sde_rm.c @@ -101,6 +101,22 @@ static const struct sde_rm_topology_def g_top_table_v1[SDE_RM_TOPOLOGY_MAX] = { MSM_DISPLAY_COMPRESSION_DSC }, }; +char sde_hw_blk_str[SDE_HW_BLK_MAX][SDE_HW_BLK_NAME_LEN] = { + "top", + "sspp", + "lm", + "dspp", + "ds", + "ctl", + "cdm", + "pingpong", + "intf", + "wb", + "dsc", + "vdc", + "merge_3d", + "qdss", +}; /** * struct sde_rm_requirements - Reservation requirements parameter bundle @@ -724,6 +740,54 @@ fail: return rc; } +#ifdef CONFIG_DEBUG_FS +static int _sde_rm_status_show(struct seq_file *s, void *data) +{ + struct sde_rm *rm; + struct sde_rm_hw_blk *blk; + u32 type, allocated, unallocated; + + if (!s || !s->private) + return -EINVAL; + + rm = s->private; + for (type = SDE_HW_BLK_LM; type < SDE_HW_BLK_MAX; type++) { + allocated = 0; + unallocated = 0; + list_for_each_entry(blk, &rm->hw_blks[type], list) { + if (!blk->rsvp && !blk->rsvp_nxt) + unallocated++; + else + allocated++; + } + seq_printf(s, "type:%d blk:%s allocated:%d unallocated:%d\n", + type, sde_hw_blk_str[type], allocated, unallocated); + } + + return 0; +} + +static int _sde_rm_debugfs_status_open(struct inode *inode, + struct file *file) +{ + return single_open(file, _sde_rm_status_show, inode->i_private); +} + +void sde_rm_debugfs_init(struct sde_rm *sde_rm, struct dentry *parent) +{ + static const struct file_operations debugfs_rm_status_fops = { + .open = _sde_rm_debugfs_status_open, + .read = seq_read, + }; + + debugfs_create_file("rm_status", 0400, parent, sde_rm, &debugfs_rm_status_fops); +} +#else +void sde_rm_debugfs_init(struct sde_rm *rm, struct dentry *parent) +{ +} +#endif + int sde_rm_init(struct sde_rm *rm, struct sde_mdss_cfg *cat, void __iomem *mmio, diff --git a/msm/sde/sde_rm.h b/msm/sde/sde_rm.h index d0cdf77fdd..46faa545c9 100644 --- a/msm/sde/sde_rm.h +++ b/msm/sde/sde_rm.h @@ -215,6 +215,12 @@ struct sde_rm_hw_request { enum sde_rm_topology_name sde_rm_get_topology_name(struct sde_rm *rm, struct msm_display_topology topology); +/** + * sde_rm_debugfs_init - setup debugfs node for rm module + * @rm: SDE resource manager handle + * @parent: debugfs parent directory node + */ +void sde_rm_debugfs_init(struct sde_rm *rm, struct dentry *parent); /** * sde_rm_init - Read hardware catalog and create reservation tracking objects