On Mon, Nov 05, 2018 at 04:31:01PM -0700, Jordan Crouse wrote: > 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. There's probably 2 patches in this one, but since it's debug code it's probably not worth respinning. Reviewed-by: Sean Paul <sean@xxxxxxxxxx> > > v2: Add more code; most of the dpu debugfs files should be > addressed now. > > Signed-off-by: Jordan Crouse <jcrouse@xxxxxxxxxxxxxx> > --- > drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c | 30 +---- > drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.h | 9 +- > drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 105 +++++------------- > drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h | 7 +- > drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 30 +---- > drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 31 +----- > drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 104 ++++------------- > drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 6 - > drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c | 3 +- > drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 90 +++------------ > drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c | 24 ++-- > drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.h | 15 +-- > 12 files changed, 93 insertions(+), 361 deletions(-) > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c > index f66070cb2f42..f188c78dd736 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c > @@ -307,10 +307,8 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v) > unsigned long irq_flags; > int i, irq_count, enable_count, cb_count; > > - if (!irq_obj || !irq_obj->enable_counts || !irq_obj->irq_cb_tbl) { > - DPU_ERROR("invalid parameters\n"); > + if (WARN_ON(!irq_obj->enable_counts || !irq_obj->irq_cb_tbl)) > return 0; > - } > > for (i = 0; i < irq_obj->total_irqs; i++) { > spin_lock_irqsave(&irq_obj->cb_lock, irq_flags); > @@ -331,31 +329,11 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v) > > DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_core_irq); > > -int 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, > +void dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms, > struct dentry *parent) > { > - return 0; > -} > - > -void dpu_debugfs_core_irq_destroy(struct dpu_kms *dpu_kms) > -{ > + debugfs_create_file("core_irq", 0600, parent, &dpu_kms->irq_obj, > + &dpu_debugfs_core_irq_fops); > } > #endif > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.h > index 884f77fa3eb6..e9015a2b23fe 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.h > @@ -132,15 +132,8 @@ int dpu_core_irq_unregister_callback( > * dpu_debugfs_core_irq_init - register core irq debugfs > * @dpu_kms: pointer to kms > * @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); > > -/** > - * 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__ */ > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c > index e68ccb7a898a..8a7653a2fc7a 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c > @@ -24,8 +24,6 @@ > #include "dpu_crtc.h" > #include "dpu_core_perf.h" > > -#define DPU_PERF_MODE_STRING_SIZE 128 > - > /** > * enum dpu_perf_mode - performance tuning mode > * @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, > struct dpu_core_perf *perf = file->private_data; > struct dpu_perf_cfg *cfg = &perf->catalog->perf; > u32 perf_mode = 0; > - char buf[10]; > - > - 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 */ > + int ret; > > - if (kstrtouint(buf, 0, &perf_mode)) > - return -EFAULT; > + ret = kstrtouint_from_user(user_buf, count, 0, &perf_mode); > + if (ret) > + return ret; > > if (perf_mode >= DPU_PERF_MODE_MAX) > - return -EFAULT; > + return -EINVAL; > > if (perf_mode == DPU_PERF_MODE_FIXED) { > DRM_INFO("fix performance mode\n"); > @@ -493,29 +481,16 @@ static ssize_t _dpu_core_perf_mode_read(struct file *file, > char __user *buff, size_t count, loff_t *ppos) > { > struct dpu_core_perf *perf = file->private_data; > - int len = 0; > - char buf[DPU_PERF_MODE_STRING_SIZE] = {'\0'}; > + int len; > + char buf[128]; > > - if (!perf) > - return -ENODEV; > - > - if (*ppos) > - return 0; /* the end */ > - > - len = snprintf(buf, sizeof(buf), > + len = scnprintf(buf, sizeof(buf), > "mode %d min_mdp_clk %llu min_bus_vote %llu\n", > perf->perf_tune.mode, > perf->perf_tune.min_core_clk, > 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 len; > + return simple_read_from_buffer(buff, count, ppos, buf, len); > } > > 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, > }; > > -static void dpu_core_perf_debugfs_destroy(struct dpu_core_perf *perf) > -{ > - debugfs_remove_recursive(perf->debugfs_root); > - perf->debugfs_root = NULL; > -} > - > -int dpu_core_perf_debugfs_init(struct dpu_core_perf *perf, > - struct dentry *parent) > +int dpu_core_perf_debugfs_init(struct dpu_kms *dpu_kms, struct dentry *parent) > { > + struct dpu_core_perf *perf = &dpu_kms->perf; > struct dpu_mdss_cfg *catalog = perf->catalog; > - struct msm_drm_private *priv; > - 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); > + struct dentry *entry; > > - perf->debugfs_root = debugfs_create_dir("core_perf", parent); > - if (!perf->debugfs_root) { > - DPU_ERROR("failed to create core perf debugfs\n"); > + entry = debugfs_create_dir("core_perf", parent); > + if (IS_ERR_OR_NULL(entry)) > 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); > - debugfs_create_u64("core_clk_rate", 0600, perf->debugfs_root, > + debugfs_create_u64("core_clk_rate", 0600, entry, > &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); > - debugfs_create_u32("threshold_low", 0600, perf->debugfs_root, > + debugfs_create_u32("threshold_low", 0600, entry, > (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); > - debugfs_create_u32("min_core_ib", 0600, perf->debugfs_root, > + debugfs_create_u32("min_core_ib", 0600, entry, > (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); > - debugfs_create_u32("min_dram_ib", 0600, perf->debugfs_root, > + debugfs_create_u32("min_dram_ib", 0600, entry, > (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); > - 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); > - 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); > - 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); > > 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 > > 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; > } > > - dpu_core_perf_debugfs_destroy(perf); > perf->max_core_clk_rate = 0; > perf->core_clk = NULL; > perf->phandle = NULL; > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h > index fbcbe0c7527a..668cac71736b 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.h > @@ -122,12 +122,13 @@ int dpu_core_perf_init(struct dpu_core_perf *perf, > struct dpu_power_handle *phandle, > struct dss_clk *core_clk); > > +struct dpu_kms; > + > /** > * 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 > */ > -int dpu_core_perf_debugfs_init(struct dpu_core_perf *perf, > - struct dentry *parent); > +int dpu_core_perf_debugfs_init(struct dpu_kms *dpu_kms, struct dentry *parent); > > #endif /* _DPU_CORE_PERF_H_ */ > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > index 00b18bee287a..edcc4580d41b 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > @@ -1246,9 +1246,6 @@ static int dpu_crtc_debugfs_status_show(struct seq_file *s, void *data) > > int i, out_width; > > - if (!s || !s->private) > - return -EINVAL; > - > dpu_crtc = s->private; > crtc = &dpu_crtc->base; > > @@ -1378,14 +1375,7 @@ DEFINE_SHOW_ATTRIBUTE(dpu_crtc_debugfs_state); > > static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc) > { > - struct dpu_crtc *dpu_crtc; > - struct dpu_kms *dpu_kms; > - > - if (!crtc) > - return -EINVAL; > - dpu_crtc = to_dpu_crtc(crtc); > - > - dpu_kms = _dpu_crtc_get_kms(crtc); > + struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc); > > dpu_crtc->debugfs_root = debugfs_create_dir(dpu_crtc->name, > crtc->dev->primary->debugfs_root); > @@ -1403,25 +1393,11 @@ static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc) > > 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 > static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc) > { > return 0; > } > - > -static void _dpu_crtc_destroy_debugfs(struct drm_crtc *crtc) > -{ > -} > #endif /* CONFIG_DEBUG_FS */ > > static int dpu_crtc_late_register(struct drm_crtc *crtc) > @@ -1431,7 +1407,9 @@ static int dpu_crtc_late_register(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 = { > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > index 5559e5d40142..2811860f2688 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > @@ -1838,14 +1838,9 @@ void dpu_encoder_prepare_commit(struct drm_encoder *drm_enc) > #ifdef CONFIG_DEBUG_FS > 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; > > - if (!s || !s->private) > - return -EINVAL; > - > - dpu_enc = s->private; > - > mutex_lock(&dpu_enc->enc_lock); > for (i = 0; i < dpu_enc->num_phys_encs; i++) { > struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; > @@ -1879,18 +1874,17 @@ DEFINE_SHOW_ATTRIBUTE(dpu_encoder_status); > > 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 dpu_kms *dpu_kms; > int i; > 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"); > return -EINVAL; > } > > - dpu_enc = to_dpu_encoder_virt(drm_enc); > priv = drm_enc->dev->dev_private; > dpu_kms = to_dpu_kms(priv->kms); > > @@ -1915,26 +1909,11 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc) > > 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 > static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc) > { > return 0; > } > - > -static void _dpu_encoder_destroy_debugfs(struct drm_encoder *drm_enc) > -{ > -} > #endif > > static int dpu_encoder_late_register(struct drm_encoder *encoder) > @@ -1944,7 +1923,9 @@ static int dpu_encoder_late_register(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( > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > index 2a91881048c8..3d0c93c49764 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c > @@ -81,7 +81,7 @@ static int _dpu_danger_signal_status(struct seq_file *s, > struct dpu_danger_safe_status status; > 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"); > return 0; > } > @@ -125,46 +125,29 @@ static int dpu_debugfs_safe_stats_show(struct seq_file *s, void *v) > } > DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_safe_stats); > > -static void dpu_debugfs_danger_destroy(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, > +static void dpu_debugfs_danger_init(struct dpu_kms *dpu_kms, > struct dentry *parent) > { > - dpu_kms->debugfs_danger = debugfs_create_dir("danger", > - parent); > - if (!dpu_kms->debugfs_danger) { > - DPU_ERROR("failed to create danger debugfs\n"); > - return -EINVAL; > - } > + struct dentry *entry = debugfs_create_dir("danger", parent); > + if (IS_ERR_OR_NULL(entry)) > + return; > > - debugfs_create_file("danger_status", 0600, dpu_kms->debugfs_danger, > + debugfs_create_file("danger_status", 0600, entry, > 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); > - > - return 0; > } > > static int dpu_debugfs_regset32_show(struct seq_file *s, void *data) > { > - struct dpu_debugfs_regset32 *regset; > - struct dpu_kms *dpu_kms; > + struct dpu_debugfs_regset32 *regset = s->private; > + struct dpu_kms *dpu_kms = regset->dpu_kms; > struct drm_device *dev; > struct msm_drm_private *priv; > void __iomem *base; > uint32_t i, addr; > > - if (!s || !s->private) > - return 0; > - > - regset = s->private; > - > - dpu_kms = regset->dpu_kms; > - if (!dpu_kms || !dpu_kms->mmio) > + if (!dpu_kms->mmio) > return 0; > > dev = dpu_kms->dev; > @@ -226,51 +209,24 @@ void *dpu_debugfs_create_regset32(const char *name, umode_t mode, > > static int _dpu_debugfs_init(struct dpu_kms *dpu_kms) > { > - void *p; > - int rc; > - > - p = dpu_hw_util_get_log_mask_ptr(); > + void *p = dpu_hw_util_get_log_mask_ptr(); > + struct dentry *entry; > > - if (!dpu_kms || !p) > + if (!p) > return -EINVAL; > > - dpu_kms->debugfs_root = debugfs_create_dir("debug", > - dpu_kms->dev->primary->debugfs_root); > - if (IS_ERR_OR_NULL(dpu_kms->debugfs_root)) { > - DRM_ERROR("debugfs create_dir failed %ld\n", > - PTR_ERR(dpu_kms->debugfs_root)); > - return PTR_ERR(dpu_kms->debugfs_root); > - } > + entry = debugfs_create_dir("debug", dpu_kms->dev->primary->debugfs_root); > + if (IS_ERR_OR_NULL(entry)) > + return -ENODEV; > > /* allow root to be NULL */ > - debugfs_create_x32(DPU_DEBUGFS_HWMASKNAME, 0600, dpu_kms->debugfs_root, 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); > + debugfs_create_x32(DPU_DEBUGFS_HWMASKNAME, 0600, entry, p); > > - rc = dpu_core_perf_debugfs_init(&dpu_kms->perf, dpu_kms->debugfs_root); > - if (rc) { > - DPU_ERROR("failed to init perf %d\n", rc); > - return rc; > - } > + dpu_debugfs_danger_init(dpu_kms, entry); > + dpu_debugfs_vbif_init(dpu_kms, entry); > + dpu_debugfs_core_irq_init(dpu_kms, entry); > > - return 0; > -} > - > -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) > -{ > + return dpu_core_perf_debugfs_init(dpu_kms, entry); > } > #endif > > @@ -583,22 +539,7 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) > #ifdef CONFIG_DEBUG_FS > static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor) > { > - struct dpu_kms *dpu_kms = 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; > + return _dpu_debugfs_init(to_dpu_kms(kms)); > } > #endif > > @@ -626,7 +567,6 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms) > &dpu_kms->phandle, dpu_kms->power_event); > > /* safe to call these more than once during shutdown */ > - _dpu_debugfs_destroy(dpu_kms); > _dpu_kms_mmu_destroy(dpu_kms); > > if (dpu_kms->catalog) { > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h > index e7539c9870e4..cb1a685dcfee 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h > @@ -102,7 +102,6 @@ struct dpu_irq { > atomic_t *enable_counts; > atomic_t *irq_counts; > spinlock_t cb_lock; > - struct dentry *debugfs_file; > }; > > struct dpu_kms { > @@ -115,11 +114,6 @@ struct dpu_kms { > struct dpu_power_client *core_client; > struct dpu_power_event *power_event; > > - /* directory entry for debugfs */ > - struct dentry *debugfs_root; > - struct dentry *debugfs_danger; > - struct dentry *debugfs_vbif; > - > /* io/register spaces: */ > void __iomem *mmio, *vbif[VBIF_MAX], *reg_dma; > unsigned long mmio_len, vbif_len[VBIF_MAX], reg_dma_len; > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c > index 19abf719811a..5ecc26fdc328 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c > @@ -120,13 +120,12 @@ static int _dpu_mdss_irq_domain_add(struct dpu_mdss *dpu_mdss) > 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) { > irq_domain_remove(dpu_mdss->irq_controller.domain); > dpu_mdss->irq_controller.domain = NULL; > } > - return 0; > } > static int dpu_mdss_enable(struct msm_mdss *mdss) > { > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c > index 98d8315f625d..bcd8d46ffc38 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c > @@ -1264,26 +1264,12 @@ static ssize_t _dpu_plane_danger_read(struct file *file, > char __user *buff, size_t count, loff_t *ppos) > { > struct dpu_kms *kms = file->private_data; > - struct dpu_mdss_cfg *cfg = kms->catalog; > - int len = 0; > - char buf[40] = {'\0'}; > + int len; > + char buf[40]; > > - if (!cfg) > - return -ENODEV; > + len = scnprintf(buf, sizeof(buf), "%d\n", !kms->has_danger_ctrl); > > - if (*ppos) > - 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; > + return simple_read_from_buffer(buff, count, ppos, buf, len); > } > > static void _dpu_plane_set_danger_state(struct dpu_kms *kms, bool enable) > @@ -1313,23 +1299,12 @@ static ssize_t _dpu_plane_danger_write(struct file *file, > const char __user *user_buf, size_t count, loff_t *ppos) > { > struct dpu_kms *kms = file->private_data; > - struct dpu_mdss_cfg *cfg = kms->catalog; > int disable_panic; > - char buf[10]; > - > - 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 */ > + int ret; > > - if (kstrtoint(buf, 0, &disable_panic)) > - return -EFAULT; > + ret = kstrtouint_from_user(user_buf, count, 0, &disable_panic); > + if (ret) > + return ret; > > if (disable_panic) { > /* Disable panic signal for all active pipes */ > @@ -1354,33 +1329,10 @@ static const struct file_operations dpu_plane_danger_enable = { > > static int _dpu_plane_init_debugfs(struct drm_plane *plane) > { > - struct dpu_plane *pdpu; > - struct dpu_kms *kms; > - struct msm_drm_private *priv; > - const struct dpu_sspp_sub_blks *sblk = 0; > - 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; > + struct dpu_plane *pdpu = to_dpu_plane(plane); > + struct dpu_kms *kms = _dpu_plane_get_kms(plane); > + const struct dpu_sspp_cfg *cfg = pdpu->pipe_hw->cap; > + const struct dpu_sspp_sub_blks *sblk = cfg->sblk; > > /* create overall sub-directory for the pipe */ > pdpu->debugfs_root = > @@ -1451,25 +1403,11 @@ static int _dpu_plane_init_debugfs(struct drm_plane *plane) > > 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 > static int _dpu_plane_init_debugfs(struct drm_plane *plane) > { > return 0; > } > -static void _dpu_plane_destroy_debugfs(struct drm_plane *plane) > -{ > -} > #endif > > static int dpu_plane_late_register(struct drm_plane *plane) > @@ -1479,7 +1417,9 @@ static int dpu_plane_late_register(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 = { > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c > index ff5091d2555d..ef753ea9c499 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c > @@ -310,31 +310,25 @@ void dpu_vbif_init_memtypes(struct dpu_kms *dpu_kms) > } > > #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]; > - struct dentry *debugfs_vbif; > + struct dentry *entry, *debugfs_vbif; > int i, j; > > - dpu_kms->debugfs_vbif = debugfs_create_dir("vbif", debugfs_root); > - if (!dpu_kms->debugfs_vbif) { > - DPU_ERROR("failed to create vbif debugfs\n"); > - return -EINVAL; > - } > + entry = debugfs_create_dir("vbif", debugfs_root); > + if (IS_ERR_OR_NULL(entry)) > + return; > > for (i = 0; i < dpu_kms->catalog->vbif_count; i++) { > struct dpu_vbif_cfg *vbif = &dpu_kms->catalog->vbif[i]; > > snprintf(vbif_name, sizeof(vbif_name), "%d", vbif->id); > > - debugfs_vbif = debugfs_create_dir(vbif_name, > - dpu_kms->debugfs_vbif); > + debugfs_vbif = debugfs_create_dir(vbif_name, entry); > + if (IS_ERR_OR_NULL(debugfs_vbif)) > + continue; > > debugfs_create_u32("features", 0600, debugfs_vbif, > (u32 *)&vbif->features); > @@ -376,7 +370,5 @@ int dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root) > (u32 *)&cfg->ot_limit); > } > } > - > - return 0; > } > #endif > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.h > index f17af52dbbd5..6356876d7a66 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.h > @@ -78,17 +78,6 @@ void dpu_vbif_clear_errors(struct dpu_kms *dpu_kms); > */ > void dpu_vbif_init_memtypes(struct dpu_kms *dpu_kms); > > -#ifdef CONFIG_DEBUG_FS > -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 > +void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root); > + > #endif /* __DPU_VBIF_H__ */ > -- > 2.18.0 > -- Sean Paul, Software Engineer, Google / Chromium OS