Commit 3d688410 authored by Jordan Crouse's avatar Jordan Crouse Committed by Rob Clark

drm/msm/dpu: Cleanup the debugfs functions

Do some debugfs cleanups from across the DPU driver. The DRM
destroy functions will do a recursive delete on the entire
debugfs node so there is no need to store dentry pointers for
the debugfs files that are persistent for the life of the
driver. This also means that the destroy functions can go
away too.

Also, use standard API functions where applicable instead of
using hand written code.

v3: No changes
v2: Add more code; most of the dpu debugfs files should be
addressed now.
Reviewed-by: default avatarSean Paul <sean@poorly.run>
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent 8fe62a63
...@@ -319,10 +319,8 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v) ...@@ -319,10 +319,8 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v)
unsigned long irq_flags; unsigned long irq_flags;
int i, irq_count, enable_count, cb_count; int i, irq_count, enable_count, cb_count;
if (!irq_obj || !irq_obj->enable_counts || !irq_obj->irq_cb_tbl) { if (WARN_ON(!irq_obj->enable_counts || !irq_obj->irq_cb_tbl))
DPU_ERROR("invalid parameters\n");
return 0; return 0;
}
for (i = 0; i < irq_obj->total_irqs; i++) { for (i = 0; i < irq_obj->total_irqs; i++) {
spin_lock_irqsave(&irq_obj->cb_lock, irq_flags); spin_lock_irqsave(&irq_obj->cb_lock, irq_flags);
...@@ -343,31 +341,11 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v) ...@@ -343,31 +341,11 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v)
DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_debugfs_core_irq); DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_debugfs_core_irq);
int dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms, void dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms,
struct dentry *parent)
{
dpu_kms->irq_obj.debugfs_file = debugfs_create_file("core_irq", 0600,
parent, &dpu_kms->irq_obj,
&dpu_debugfs_core_irq_fops);
return 0;
}
void dpu_debugfs_core_irq_destroy(struct dpu_kms *dpu_kms)
{
debugfs_remove(dpu_kms->irq_obj.debugfs_file);
dpu_kms->irq_obj.debugfs_file = NULL;
}
#else
int dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms,
struct dentry *parent) struct dentry *parent)
{ {
return 0; debugfs_create_file("core_irq", 0600, parent, &dpu_kms->irq_obj,
} &dpu_debugfs_core_irq_fops);
void dpu_debugfs_core_irq_destroy(struct dpu_kms *dpu_kms)
{
} }
#endif #endif
......
...@@ -132,15 +132,8 @@ int dpu_core_irq_unregister_callback( ...@@ -132,15 +132,8 @@ int dpu_core_irq_unregister_callback(
* dpu_debugfs_core_irq_init - register core irq debugfs * dpu_debugfs_core_irq_init - register core irq debugfs
* @dpu_kms: pointer to kms * @dpu_kms: pointer to kms
* @parent: debugfs directory root * @parent: debugfs directory root
* @Return: 0 on success
*/ */
int dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms, void dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms,
struct dentry *parent); struct dentry *parent);
/**
* dpu_debugfs_core_irq_destroy - deregister core irq debugfs
* @dpu_kms: pointer to kms
*/
void dpu_debugfs_core_irq_destroy(struct dpu_kms *dpu_kms);
#endif /* __DPU_CORE_IRQ_H__ */ #endif /* __DPU_CORE_IRQ_H__ */
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#include "dpu_crtc.h" #include "dpu_crtc.h"
#include "dpu_core_perf.h" #include "dpu_core_perf.h"
#define DPU_PERF_MODE_STRING_SIZE 128
/** /**
* enum dpu_perf_mode - performance tuning mode * enum dpu_perf_mode - performance tuning mode
* @DPU_PERF_MODE_NORMAL: performance controlled by user mode client * @DPU_PERF_MODE_NORMAL: performance controlled by user mode client
...@@ -451,24 +449,14 @@ static ssize_t _dpu_core_perf_mode_write(struct file *file, ...@@ -451,24 +449,14 @@ static ssize_t _dpu_core_perf_mode_write(struct file *file,
struct dpu_core_perf *perf = file->private_data; struct dpu_core_perf *perf = file->private_data;
struct dpu_perf_cfg *cfg = &perf->catalog->perf; struct dpu_perf_cfg *cfg = &perf->catalog->perf;
u32 perf_mode = 0; u32 perf_mode = 0;
char buf[10]; int ret;
if (!perf)
return -ENODEV;
if (count >= sizeof(buf))
return -EFAULT;
if (copy_from_user(buf, user_buf, count))
return -EFAULT;
buf[count] = 0; /* end of string */
if (kstrtouint(buf, 0, &perf_mode)) ret = kstrtouint_from_user(user_buf, count, 0, &perf_mode);
return -EFAULT; if (ret)
return ret;
if (perf_mode >= DPU_PERF_MODE_MAX) if (perf_mode >= DPU_PERF_MODE_MAX)
return -EFAULT; return -EINVAL;
if (perf_mode == DPU_PERF_MODE_FIXED) { if (perf_mode == DPU_PERF_MODE_FIXED) {
DRM_INFO("fix performance mode\n"); DRM_INFO("fix performance mode\n");
...@@ -493,29 +481,16 @@ static ssize_t _dpu_core_perf_mode_read(struct file *file, ...@@ -493,29 +481,16 @@ static ssize_t _dpu_core_perf_mode_read(struct file *file,
char __user *buff, size_t count, loff_t *ppos) char __user *buff, size_t count, loff_t *ppos)
{ {
struct dpu_core_perf *perf = file->private_data; struct dpu_core_perf *perf = file->private_data;
int len = 0; int len;
char buf[DPU_PERF_MODE_STRING_SIZE] = {'\0'}; char buf[128];
if (!perf) len = scnprintf(buf, sizeof(buf),
return -ENODEV;
if (*ppos)
return 0; /* the end */
len = snprintf(buf, sizeof(buf),
"mode %d min_mdp_clk %llu min_bus_vote %llu\n", "mode %d min_mdp_clk %llu min_bus_vote %llu\n",
perf->perf_tune.mode, perf->perf_tune.mode,
perf->perf_tune.min_core_clk, perf->perf_tune.min_core_clk,
perf->perf_tune.min_bus_vote); perf->perf_tune.min_bus_vote);
if (len < 0 || len >= sizeof(buf))
return 0;
if ((count < sizeof(buf)) || copy_to_user(buff, buf, len))
return -EFAULT;
*ppos += len; /* increase offset */ return simple_read_from_buffer(buff, count, ppos, buf, len);
return len;
} }
static const struct file_operations dpu_core_perf_mode_fops = { static const struct file_operations dpu_core_perf_mode_fops = {
...@@ -524,70 +499,43 @@ static const struct file_operations dpu_core_perf_mode_fops = { ...@@ -524,70 +499,43 @@ static const struct file_operations dpu_core_perf_mode_fops = {
.write = _dpu_core_perf_mode_write, .write = _dpu_core_perf_mode_write,
}; };
static void dpu_core_perf_debugfs_destroy(struct dpu_core_perf *perf) int dpu_core_perf_debugfs_init(struct dpu_kms *dpu_kms, struct dentry *parent)
{
debugfs_remove_recursive(perf->debugfs_root);
perf->debugfs_root = NULL;
}
int dpu_core_perf_debugfs_init(struct dpu_core_perf *perf,
struct dentry *parent)
{ {
struct dpu_core_perf *perf = &dpu_kms->perf;
struct dpu_mdss_cfg *catalog = perf->catalog; struct dpu_mdss_cfg *catalog = perf->catalog;
struct msm_drm_private *priv; struct dentry *entry;
struct dpu_kms *dpu_kms;
priv = perf->dev->dev_private;
if (!priv || !priv->kms) {
DPU_ERROR("invalid KMS reference\n");
return -EINVAL;
}
dpu_kms = to_dpu_kms(priv->kms);
perf->debugfs_root = debugfs_create_dir("core_perf", parent); entry = debugfs_create_dir("core_perf", parent);
if (!perf->debugfs_root) { if (IS_ERR_OR_NULL(entry))
DPU_ERROR("failed to create core perf debugfs\n");
return -EINVAL; return -EINVAL;
}
debugfs_create_u64("max_core_clk_rate", 0600, perf->debugfs_root, debugfs_create_u64("max_core_clk_rate", 0600, entry,
&perf->max_core_clk_rate); &perf->max_core_clk_rate);
debugfs_create_u64("core_clk_rate", 0600, perf->debugfs_root, debugfs_create_u64("core_clk_rate", 0600, entry,
&perf->core_clk_rate); &perf->core_clk_rate);
debugfs_create_u32("enable_bw_release", 0600, perf->debugfs_root, debugfs_create_u32("enable_bw_release", 0600, entry,
(u32 *)&perf->enable_bw_release); (u32 *)&perf->enable_bw_release);
debugfs_create_u32("threshold_low", 0600, perf->debugfs_root, debugfs_create_u32("threshold_low", 0600, entry,
(u32 *)&catalog->perf.max_bw_low); (u32 *)&catalog->perf.max_bw_low);
debugfs_create_u32("threshold_high", 0600, perf->debugfs_root, debugfs_create_u32("threshold_high", 0600, entry,
(u32 *)&catalog->perf.max_bw_high); (u32 *)&catalog->perf.max_bw_high);
debugfs_create_u32("min_core_ib", 0600, perf->debugfs_root, debugfs_create_u32("min_core_ib", 0600, entry,
(u32 *)&catalog->perf.min_core_ib); (u32 *)&catalog->perf.min_core_ib);
debugfs_create_u32("min_llcc_ib", 0600, perf->debugfs_root, debugfs_create_u32("min_llcc_ib", 0600, entry,
(u32 *)&catalog->perf.min_llcc_ib); (u32 *)&catalog->perf.min_llcc_ib);
debugfs_create_u32("min_dram_ib", 0600, perf->debugfs_root, debugfs_create_u32("min_dram_ib", 0600, entry,
(u32 *)&catalog->perf.min_dram_ib); (u32 *)&catalog->perf.min_dram_ib);
debugfs_create_file("perf_mode", 0600, perf->debugfs_root, debugfs_create_file("perf_mode", 0600, entry,
(u32 *)perf, &dpu_core_perf_mode_fops); (u32 *)perf, &dpu_core_perf_mode_fops);
debugfs_create_u64("fix_core_clk_rate", 0600, perf->debugfs_root, debugfs_create_u64("fix_core_clk_rate", 0600, entry,
&perf->fix_core_clk_rate); &perf->fix_core_clk_rate);
debugfs_create_u64("fix_core_ib_vote", 0600, perf->debugfs_root, debugfs_create_u64("fix_core_ib_vote", 0600, entry,
&perf->fix_core_ib_vote); &perf->fix_core_ib_vote);
debugfs_create_u64("fix_core_ab_vote", 0600, perf->debugfs_root, debugfs_create_u64("fix_core_ab_vote", 0600, entry,
&perf->fix_core_ab_vote); &perf->fix_core_ab_vote);
return 0; return 0;
} }
#else
static void dpu_core_perf_debugfs_destroy(struct dpu_core_perf *perf)
{
}
int dpu_core_perf_debugfs_init(struct dpu_core_perf *perf,
struct dentry *parent)
{
return 0;
}
#endif #endif
void dpu_core_perf_destroy(struct dpu_core_perf *perf) void dpu_core_perf_destroy(struct dpu_core_perf *perf)
...@@ -597,7 +545,6 @@ void dpu_core_perf_destroy(struct dpu_core_perf *perf) ...@@ -597,7 +545,6 @@ void dpu_core_perf_destroy(struct dpu_core_perf *perf)
return; return;
} }
dpu_core_perf_debugfs_destroy(perf);
perf->max_core_clk_rate = 0; perf->max_core_clk_rate = 0;
perf->core_clk = NULL; perf->core_clk = NULL;
perf->catalog = NULL; perf->catalog = NULL;
......
...@@ -130,12 +130,13 @@ int dpu_core_perf_init(struct dpu_core_perf *perf, ...@@ -130,12 +130,13 @@ int dpu_core_perf_init(struct dpu_core_perf *perf,
struct dpu_mdss_cfg *catalog, struct dpu_mdss_cfg *catalog,
struct dss_clk *core_clk); struct dss_clk *core_clk);
struct dpu_kms;
/** /**
* dpu_core_perf_debugfs_init - initialize debugfs for core performance context * dpu_core_perf_debugfs_init - initialize debugfs for core performance context
* @perf: Pointer to core performance context * @dpu_kms: Pointer to the dpu_kms struct
* @debugfs_parent: Pointer to parent debugfs * @debugfs_parent: Pointer to parent debugfs
*/ */
int dpu_core_perf_debugfs_init(struct dpu_core_perf *perf, int dpu_core_perf_debugfs_init(struct dpu_kms *dpu_kms, struct dentry *parent);
struct dentry *parent);
#endif /* _DPU_CORE_PERF_H_ */ #endif /* _DPU_CORE_PERF_H_ */
...@@ -1186,9 +1186,6 @@ static int _dpu_debugfs_status_show(struct seq_file *s, void *data) ...@@ -1186,9 +1186,6 @@ static int _dpu_debugfs_status_show(struct seq_file *s, void *data)
int i, out_width; int i, out_width;
if (!s || !s->private)
return -EINVAL;
dpu_crtc = s->private; dpu_crtc = s->private;
crtc = &dpu_crtc->base; crtc = &dpu_crtc->base;
...@@ -1328,8 +1325,7 @@ DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_crtc_debugfs_state); ...@@ -1328,8 +1325,7 @@ DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_crtc_debugfs_state);
static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc) static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc)
{ {
struct dpu_crtc *dpu_crtc; struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
struct dpu_kms *dpu_kms;
static const struct file_operations debugfs_status_fops = { static const struct file_operations debugfs_status_fops = {
.open = _dpu_debugfs_status_open, .open = _dpu_debugfs_status_open,
...@@ -1338,12 +1334,6 @@ static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc) ...@@ -1338,12 +1334,6 @@ static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc)
.release = single_release, .release = single_release,
}; };
if (!crtc)
return -EINVAL;
dpu_crtc = to_dpu_crtc(crtc);
dpu_kms = _dpu_crtc_get_kms(crtc);
dpu_crtc->debugfs_root = debugfs_create_dir(dpu_crtc->name, dpu_crtc->debugfs_root = debugfs_create_dir(dpu_crtc->name,
crtc->dev->primary->debugfs_root); crtc->dev->primary->debugfs_root);
if (!dpu_crtc->debugfs_root) if (!dpu_crtc->debugfs_root)
...@@ -1360,25 +1350,11 @@ static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc) ...@@ -1360,25 +1350,11 @@ static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc)
return 0; return 0;
} }
static void _dpu_crtc_destroy_debugfs(struct drm_crtc *crtc)
{
struct dpu_crtc *dpu_crtc;
if (!crtc)
return;
dpu_crtc = to_dpu_crtc(crtc);
debugfs_remove_recursive(dpu_crtc->debugfs_root);
}
#else #else
static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc) static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc)
{ {
return 0; return 0;
} }
static void _dpu_crtc_destroy_debugfs(struct drm_crtc *crtc)
{
}
#endif /* CONFIG_DEBUG_FS */ #endif /* CONFIG_DEBUG_FS */
static int dpu_crtc_late_register(struct drm_crtc *crtc) static int dpu_crtc_late_register(struct drm_crtc *crtc)
...@@ -1388,7 +1364,9 @@ static int dpu_crtc_late_register(struct drm_crtc *crtc) ...@@ -1388,7 +1364,9 @@ static int dpu_crtc_late_register(struct drm_crtc *crtc)
static void dpu_crtc_early_unregister(struct drm_crtc *crtc) static void dpu_crtc_early_unregister(struct drm_crtc *crtc)
{ {
_dpu_crtc_destroy_debugfs(crtc); struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
debugfs_remove_recursive(dpu_crtc->debugfs_root);
} }
static const struct drm_crtc_funcs dpu_crtc_funcs = { static const struct drm_crtc_funcs dpu_crtc_funcs = {
......
...@@ -1863,14 +1863,9 @@ void dpu_encoder_prepare_commit(struct drm_encoder *drm_enc) ...@@ -1863,14 +1863,9 @@ void dpu_encoder_prepare_commit(struct drm_encoder *drm_enc)
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
static int _dpu_encoder_status_show(struct seq_file *s, void *data) static int _dpu_encoder_status_show(struct seq_file *s, void *data)
{ {
struct dpu_encoder_virt *dpu_enc; struct dpu_encoder_virt *dpu_enc = s->private;
int i; int i;
if (!s || !s->private)
return -EINVAL;
dpu_enc = s->private;
mutex_lock(&dpu_enc->enc_lock); mutex_lock(&dpu_enc->enc_lock);
for (i = 0; i < dpu_enc->num_phys_encs; i++) { for (i = 0; i < dpu_enc->num_phys_encs; i++) {
struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
...@@ -1908,7 +1903,7 @@ static int _dpu_encoder_debugfs_status_open(struct inode *inode, ...@@ -1908,7 +1903,7 @@ static int _dpu_encoder_debugfs_status_open(struct inode *inode,
static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc) static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc)
{ {
struct dpu_encoder_virt *dpu_enc; struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc);
struct msm_drm_private *priv; struct msm_drm_private *priv;
struct dpu_kms *dpu_kms; struct dpu_kms *dpu_kms;
int i; int i;
...@@ -1922,12 +1917,11 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc) ...@@ -1922,12 +1917,11 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc)
char name[DPU_NAME_SIZE]; char name[DPU_NAME_SIZE];
if (!drm_enc || !drm_enc->dev || !drm_enc->dev->dev_private) { if (!drm_enc->dev || !drm_enc->dev->dev_private) {
DPU_ERROR("invalid encoder or kms\n"); DPU_ERROR("invalid encoder or kms\n");
return -EINVAL; return -EINVAL;
} }
dpu_enc = to_dpu_encoder_virt(drm_enc);
priv = drm_enc->dev->dev_private; priv = drm_enc->dev->dev_private;
dpu_kms = to_dpu_kms(priv->kms); dpu_kms = to_dpu_kms(priv->kms);
...@@ -1952,26 +1946,11 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc) ...@@ -1952,26 +1946,11 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc)
return 0; return 0;
} }
static void _dpu_encoder_destroy_debugfs(struct drm_encoder *drm_enc)
{
struct dpu_encoder_virt *dpu_enc;
if (!drm_enc)
return;
dpu_enc = to_dpu_encoder_virt(drm_enc);
debugfs_remove_recursive(dpu_enc->debugfs_root);
}
#else #else
static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc) static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc)
{ {
return 0; return 0;
} }
static void _dpu_encoder_destroy_debugfs(struct drm_encoder *drm_enc)
{
}
#endif #endif
static int dpu_encoder_late_register(struct drm_encoder *encoder) static int dpu_encoder_late_register(struct drm_encoder *encoder)
...@@ -1981,7 +1960,9 @@ static int dpu_encoder_late_register(struct drm_encoder *encoder) ...@@ -1981,7 +1960,9 @@ static int dpu_encoder_late_register(struct drm_encoder *encoder)
static void dpu_encoder_early_unregister(struct drm_encoder *encoder) static void dpu_encoder_early_unregister(struct drm_encoder *encoder)
{ {
_dpu_encoder_destroy_debugfs(encoder); struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(encoder);
debugfs_remove_recursive(dpu_enc->debugfs_root);
} }
static int dpu_encoder_virt_add_phys_encs( static int dpu_encoder_virt_add_phys_encs(
......
...@@ -81,7 +81,7 @@ static int _dpu_danger_signal_status(struct seq_file *s, ...@@ -81,7 +81,7 @@ static int _dpu_danger_signal_status(struct seq_file *s,
struct dpu_danger_safe_status status; struct dpu_danger_safe_status status;
int i; int i;
if (!kms || !kms->dev || !kms->dev->dev_private || !kms->hw_mdp) { if (!kms->dev || !kms->dev->dev_private || !kms->hw_mdp) {
DPU_ERROR("invalid arg(s)\n"); DPU_ERROR("invalid arg(s)\n");
return 0; return 0;
} }
...@@ -138,46 +138,29 @@ static int dpu_debugfs_safe_stats_show(struct seq_file *s, void *v) ...@@ -138,46 +138,29 @@ static int dpu_debugfs_safe_stats_show(struct seq_file *s, void *v)
} }
DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_debugfs_safe_stats); DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_debugfs_safe_stats);
static void dpu_debugfs_danger_destroy(struct dpu_kms *dpu_kms) static void dpu_debugfs_danger_init(struct dpu_kms *dpu_kms,
{
debugfs_remove_recursive(dpu_kms->debugfs_danger);
dpu_kms->debugfs_danger = NULL;
}
static int dpu_debugfs_danger_init(struct dpu_kms *dpu_kms,
struct dentry *parent) struct dentry *parent)
{ {
dpu_kms->debugfs_danger = debugfs_create_dir("danger", struct dentry *entry = debugfs_create_dir("danger", parent);
parent); if (IS_ERR_OR_NULL(entry))
if (!dpu_kms->debugfs_danger) { return;
DPU_ERROR("failed to create danger debugfs\n");
return -EINVAL;
}
debugfs_create_file("danger_status", 0600, dpu_kms->debugfs_danger, debugfs_create_file("danger_status", 0600, entry,
dpu_kms, &dpu_debugfs_danger_stats_fops); dpu_kms, &dpu_debugfs_danger_stats_fops);
debugfs_create_file("safe_status", 0600, dpu_kms->debugfs_danger, debugfs_create_file("safe_status", 0600, entry,
dpu_kms, &dpu_debugfs_safe_stats_fops); dpu_kms, &dpu_debugfs_safe_stats_fops);
return 0;
} }
static int _dpu_debugfs_show_regset32(struct seq_file *s, void *data) static int _dpu_debugfs_show_regset32(struct seq_file *s, void *data)
{ {
struct dpu_debugfs_regset32 *regset; struct dpu_debugfs_regset32 *regset = s->private;
struct dpu_kms *dpu_kms; struct dpu_kms *dpu_kms = regset->dpu_kms;
struct drm_device *dev; struct drm_device *dev;
struct msm_drm_private *priv; struct msm_drm_private *priv;
void __iomem *base; void __iomem *base;
uint32_t i, addr; uint32_t i, addr;
if (!s || !s->private) if (!dpu_kms->mmio)
return 0;
regset = s->private;
dpu_kms = regset->dpu_kms;
if (!dpu_kms || !dpu_kms->mmio)
return 0; return 0;
dev = dpu_kms->dev; dev = dpu_kms->dev;
...@@ -250,51 +233,24 @@ void *dpu_debugfs_create_regset32(const char *name, umode_t mode, ...@@ -250,51 +233,24 @@ void *dpu_debugfs_create_regset32(const char *name, umode_t mode,
static int _dpu_debugfs_init(struct dpu_kms *dpu_kms) static int _dpu_debugfs_init(struct dpu_kms *dpu_kms)
{ {
void *p; void *p = dpu_hw_util_get_log_mask_ptr();
int rc; struct dentry *entry;
p = dpu_hw_util_get_log_mask_ptr();
if (!dpu_kms || !p) if (!p)
return -EINVAL; return -EINVAL;
dpu_kms->debugfs_root = debugfs_create_dir("debug", entry = debugfs_create_dir("debug", dpu_kms->dev->primary->debugfs_root);
dpu_kms->dev->primary->debugfs_root); if (IS_ERR_OR_NULL(entry))
if (IS_ERR_OR_NULL(dpu_kms->debugfs_root)) { return -ENODEV;
DRM_ERROR("debugfs create_dir failed %ld\n",
PTR_ERR(dpu_kms->debugfs_root));
return PTR_ERR(dpu_kms->debugfs_root);
}
/* allow root to be NULL */ /* allow root to be NULL */
debugfs_create_x32(DPU_DEBUGFS_HWMASKNAME, 0600, dpu_kms->debugfs_root, p); debugfs_create_x32(DPU_DEBUGFS_HWMASKNAME, 0600, entry, p);
(void) dpu_debugfs_danger_init(dpu_kms, dpu_kms->debugfs_root);
(void) dpu_debugfs_vbif_init(dpu_kms, dpu_kms->debugfs_root);
(void) dpu_debugfs_core_irq_init(dpu_kms, dpu_kms->debugfs_root);
rc = dpu_core_perf_debugfs_init(&dpu_kms->perf, dpu_kms->debugfs_root); dpu_debugfs_danger_init(dpu_kms, entry);
if (rc) { dpu_debugfs_vbif_init(dpu_kms, entry);
DPU_ERROR("failed to init perf %d\n", rc); dpu_debugfs_core_irq_init(dpu_kms, entry);
return rc;
}
return 0; return dpu_core_perf_debugfs_init(dpu_kms, entry);
}
static void _dpu_debugfs_destroy(struct dpu_kms *dpu_kms)
{
/* don't need to NULL check debugfs_root */
if (dpu_kms) {
dpu_debugfs_vbif_destroy(dpu_kms);
dpu_debugfs_danger_destroy(dpu_kms);
dpu_debugfs_core_irq_destroy(dpu_kms);
debugfs_remove_recursive(dpu_kms->debugfs_root);
}
}
#else
static void _dpu_debugfs_destroy(struct dpu_kms *dpu_kms)
{
} }
#endif #endif
...@@ -620,22 +576,7 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) ...@@ -620,22 +576,7 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor) static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor)
{ {
struct dpu_kms *dpu_kms = to_dpu_kms(kms); return _dpu_debugfs_init(to_dpu_kms(kms));
struct drm_device *dev;
int rc;
if (!dpu_kms || !dpu_kms->dev || !dpu_kms->dev->dev) {
DPU_ERROR("invalid dpu_kms\n");
return -EINVAL;
}
dev = dpu_kms->dev;
rc = _dpu_debugfs_init(dpu_kms);
if (rc)
DPU_ERROR("dpu_debugfs init failed: %d\n", rc);
return rc;
} }
#endif #endif
...@@ -659,7 +600,6 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms) ...@@ -659,7 +600,6 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
dpu_kms->hw_intr = NULL; dpu_kms->hw_intr = NULL;
/* safe to call these more than once during shutdown */ /* safe to call these more than once during shutdown */
_dpu_debugfs_destroy(dpu_kms);
_dpu_kms_mmu_destroy(dpu_kms); _dpu_kms_mmu_destroy(dpu_kms);
if (dpu_kms->catalog) { if (dpu_kms->catalog) {
......
...@@ -102,7 +102,6 @@ struct dpu_irq { ...@@ -102,7 +102,6 @@ struct dpu_irq {
atomic_t *enable_counts; atomic_t *enable_counts;
atomic_t *irq_counts; atomic_t *irq_counts;
spinlock_t cb_lock; spinlock_t cb_lock;
struct dentry *debugfs_file;
}; };
struct dpu_kms { struct dpu_kms {
...@@ -111,11 +110,6 @@ struct dpu_kms { ...@@ -111,11 +110,6 @@ struct dpu_kms {
int core_rev; int core_rev;
struct dpu_mdss_cfg *catalog; struct dpu_mdss_cfg *catalog;
/* directory entry for debugfs */
struct dentry *debugfs_root;
struct dentry *debugfs_danger;
struct dentry *debugfs_vbif;
/* io/register spaces: */ /* io/register spaces: */
void __iomem *mmio, *vbif[VBIF_MAX], *reg_dma; void __iomem *mmio, *vbif[VBIF_MAX], *reg_dma;
unsigned long mmio_len, vbif_len[VBIF_MAX], reg_dma_len; unsigned long mmio_len, vbif_len[VBIF_MAX], reg_dma_len;
......
...@@ -120,13 +120,12 @@ static int _dpu_mdss_irq_domain_add(struct dpu_mdss *dpu_mdss) ...@@ -120,13 +120,12 @@ static int _dpu_mdss_irq_domain_add(struct dpu_mdss *dpu_mdss)
return 0; return 0;
} }
static int _dpu_mdss_irq_domain_fini(struct dpu_mdss *dpu_mdss) static void _dpu_mdss_irq_domain_fini(struct dpu_mdss *dpu_mdss)
{ {
if (dpu_mdss->irq_controller.domain) { if (dpu_mdss->irq_controller.domain) {
irq_domain_remove(dpu_mdss->irq_controller.domain); irq_domain_remove(dpu_mdss->irq_controller.domain);
dpu_mdss->irq_controller.domain = NULL; dpu_mdss->irq_controller.domain = NULL;
} }
return 0;
} }
static int dpu_mdss_enable(struct msm_mdss *mdss) static int dpu_mdss_enable(struct msm_mdss *mdss)
{ {
......
...@@ -1262,26 +1262,12 @@ static ssize_t _dpu_plane_danger_read(struct file *file, ...@@ -1262,26 +1262,12 @@ static ssize_t _dpu_plane_danger_read(struct file *file,
char __user *buff, size_t count, loff_t *ppos) char __user *buff, size_t count, loff_t *ppos)
{ {
struct dpu_kms *kms = file->private_data; struct dpu_kms *kms = file->private_data;
struct dpu_mdss_cfg *cfg = kms->catalog; int len;
int len = 0; char buf[40];
char buf[40] = {'\0'};
if (!cfg) len = scnprintf(buf, sizeof(buf), "%d\n", !kms->has_danger_ctrl);
return -ENODEV;
if (*ppos) return simple_read_from_buffer(buff, count, ppos, buf, len);
return 0; /* the end */
len = snprintf(buf, sizeof(buf), "%d\n", !kms->has_danger_ctrl);
if (len < 0 || len >= sizeof(buf))
return 0;
if ((count < sizeof(buf)) || copy_to_user(buff, buf, len))
return -EFAULT;
*ppos += len; /* increase offset */
return len;
} }
static void _dpu_plane_set_danger_state(struct dpu_kms *kms, bool enable) static void _dpu_plane_set_danger_state(struct dpu_kms *kms, bool enable)
...@@ -1311,23 +1297,12 @@ static ssize_t _dpu_plane_danger_write(struct file *file, ...@@ -1311,23 +1297,12 @@ static ssize_t _dpu_plane_danger_write(struct file *file,
const char __user *user_buf, size_t count, loff_t *ppos) const char __user *user_buf, size_t count, loff_t *ppos)
{ {
struct dpu_kms *kms = file->private_data; struct dpu_kms *kms = file->private_data;
struct dpu_mdss_cfg *cfg = kms->catalog;
int disable_panic; int disable_panic;
char buf[10]; int ret;
if (!cfg)
return -EFAULT;
if (count >= sizeof(buf))
return -EFAULT;
if (copy_from_user(buf, user_buf, count))
return -EFAULT;
buf[count] = 0; /* end of string */
if (kstrtoint(buf, 0, &disable_panic)) ret = kstrtouint_from_user(user_buf, count, 0, &disable_panic);
return -EFAULT; if (ret)
return ret;
if (disable_panic) { if (disable_panic) {
/* Disable panic signal for all active pipes */ /* Disable panic signal for all active pipes */
...@@ -1352,33 +1327,10 @@ static const struct file_operations dpu_plane_danger_enable = { ...@@ -1352,33 +1327,10 @@ static const struct file_operations dpu_plane_danger_enable = {
static int _dpu_plane_init_debugfs(struct drm_plane *plane) static int _dpu_plane_init_debugfs(struct drm_plane *plane)
{ {
struct dpu_plane *pdpu; struct dpu_plane *pdpu = to_dpu_plane(plane);
struct dpu_kms *kms; struct dpu_kms *kms = _dpu_plane_get_kms(plane);
struct msm_drm_private *priv; const struct dpu_sspp_cfg *cfg = pdpu->pipe_hw->cap;
const struct dpu_sspp_sub_blks *sblk = 0; const struct dpu_sspp_sub_blks *sblk = cfg->sblk;
const struct dpu_sspp_cfg *cfg = 0;
if (!plane || !plane->dev) {
DPU_ERROR("invalid arguments\n");
return -EINVAL;
}
priv = plane->dev->dev_private;
if (!priv || !priv->kms) {
DPU_ERROR("invalid KMS reference\n");
return -EINVAL;
}
kms = to_dpu_kms(priv->kms);
pdpu = to_dpu_plane(plane);
if (pdpu && pdpu->pipe_hw)
cfg = pdpu->pipe_hw->cap;
if (cfg)
sblk = cfg->sblk;
if (!sblk)
return 0;
/* create overall sub-directory for the pipe */ /* create overall sub-directory for the pipe */
pdpu->debugfs_root = pdpu->debugfs_root =
...@@ -1449,25 +1401,11 @@ static int _dpu_plane_init_debugfs(struct drm_plane *plane) ...@@ -1449,25 +1401,11 @@ static int _dpu_plane_init_debugfs(struct drm_plane *plane)
return 0; return 0;
} }
static void _dpu_plane_destroy_debugfs(struct drm_plane *plane)
{
struct dpu_plane *pdpu;
if (!plane)
return;
pdpu = to_dpu_plane(plane);
debugfs_remove_recursive(pdpu->debugfs_root);
}
#else #else
static int _dpu_plane_init_debugfs(struct drm_plane *plane) static int _dpu_plane_init_debugfs(struct drm_plane *plane)
{ {
return 0; return 0;
} }
static void _dpu_plane_destroy_debugfs(struct drm_plane *plane)
{
}
#endif #endif
static int dpu_plane_late_register(struct drm_plane *plane) static int dpu_plane_late_register(struct drm_plane *plane)
...@@ -1477,7 +1415,9 @@ static int dpu_plane_late_register(struct drm_plane *plane) ...@@ -1477,7 +1415,9 @@ static int dpu_plane_late_register(struct drm_plane *plane)
static void dpu_plane_early_unregister(struct drm_plane *plane) static void dpu_plane_early_unregister(struct drm_plane *plane)
{ {
_dpu_plane_destroy_debugfs(plane); struct dpu_plane *pdpu = to_dpu_plane(plane);
debugfs_remove_recursive(pdpu->debugfs_root);
} }
static const struct drm_plane_funcs dpu_plane_funcs = { static const struct drm_plane_funcs dpu_plane_funcs = {
......
...@@ -310,31 +310,25 @@ void dpu_vbif_init_memtypes(struct dpu_kms *dpu_kms) ...@@ -310,31 +310,25 @@ void dpu_vbif_init_memtypes(struct dpu_kms *dpu_kms)
} }
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
void dpu_debugfs_vbif_destroy(struct dpu_kms *dpu_kms)
{
debugfs_remove_recursive(dpu_kms->debugfs_vbif);
dpu_kms->debugfs_vbif = NULL;
}
int dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root) void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root)
{ {
char vbif_name[32]; char vbif_name[32];
struct dentry *debugfs_vbif; struct dentry *entry, *debugfs_vbif;
int i, j; int i, j;
dpu_kms->debugfs_vbif = debugfs_create_dir("vbif", debugfs_root); entry = debugfs_create_dir("vbif", debugfs_root);
if (!dpu_kms->debugfs_vbif) { if (IS_ERR_OR_NULL(entry))
DPU_ERROR("failed to create vbif debugfs\n"); return;
return -EINVAL;
}
for (i = 0; i < dpu_kms->catalog->vbif_count; i++) { for (i = 0; i < dpu_kms->catalog->vbif_count; i++) {
struct dpu_vbif_cfg *vbif = &dpu_kms->catalog->vbif[i]; struct dpu_vbif_cfg *vbif = &dpu_kms->catalog->vbif[i];
snprintf(vbif_name, sizeof(vbif_name), "%d", vbif->id); snprintf(vbif_name, sizeof(vbif_name), "%d", vbif->id);
debugfs_vbif = debugfs_create_dir(vbif_name, debugfs_vbif = debugfs_create_dir(vbif_name, entry);
dpu_kms->debugfs_vbif); if (IS_ERR_OR_NULL(debugfs_vbif))
continue;
debugfs_create_u32("features", 0600, debugfs_vbif, debugfs_create_u32("features", 0600, debugfs_vbif,
(u32 *)&vbif->features); (u32 *)&vbif->features);
...@@ -376,7 +370,5 @@ int dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root) ...@@ -376,7 +370,5 @@ int dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root)
(u32 *)&cfg->ot_limit); (u32 *)&cfg->ot_limit);
} }
} }
return 0;
} }
#endif #endif
...@@ -78,17 +78,6 @@ void dpu_vbif_clear_errors(struct dpu_kms *dpu_kms); ...@@ -78,17 +78,6 @@ void dpu_vbif_clear_errors(struct dpu_kms *dpu_kms);
*/ */
void dpu_vbif_init_memtypes(struct dpu_kms *dpu_kms); void dpu_vbif_init_memtypes(struct dpu_kms *dpu_kms);
#ifdef CONFIG_DEBUG_FS void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root);
int dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root);
void dpu_debugfs_vbif_destroy(struct dpu_kms *dpu_kms);
#else
static inline int dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms,
struct dentry *debugfs_root)
{
return 0;
}
static inline void dpu_debugfs_vbif_destroy(struct dpu_kms *dpu_kms)
{
}
#endif
#endif /* __DPU_VBIF_H__ */ #endif /* __DPU_VBIF_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment