drm/msm/dpu: yet another attempt at cleaning up encoder's debugfs
cover drm/msm/dpu: yet another attempt at cleaning up encoder's debugfs
Simplify dpu_encoder slightly by using drm_debugfs_add_file().
Dmitry Baryshkov (2):
drm/msm/dpu: drop (mostly) unused DPU_NAME_SIZE define drm/msm/dpu: switch dpu_encoder to use drm_debugfs_add_file()
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 40 ++++++--------------- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 2 -- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 -- 3 files changed, 11 insertions(+), 33 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/2 drm/msm/dpu: drop (mostly) unused DPU_NAME_SIZE define
This define is used only in one place, in dpu_encoder debugfs code. Inline the value and drop the define completely.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 4 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 2 -- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -2
@@ -2116,14 +2116,14 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc) {struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); -char name[DPU_NAME_SIZE ]; +char name[12 ];if (!drm_enc->dev) {DPU_ERROR ("invalid encoder or kms\n" );return -EINVAL ; } -snprintf (name,DPU_NAME_SIZE ,"encoder%u" , drm_enc->base.id); +snprintf (name,sizeof (name),"encoder%u" , drm_enc->base.id);/* create overall sub-directory for the encoder */ dpu_enc->debugfs_root = debugfs_create_dir(name,
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +0 -2
@@ -63,8 +63,6 @@#define ktime_compare_safe (A ,B ) \ ktime_compare(ktime_sub((A), (B)), ktime_set(0, 0)) -#define DPU_NAME_SIZE 12 -struct dpu_kms {struct msm_kms base;struct drm_device *dev;
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +0 -2
@@ -42,8 +42,6 @@#define SHARP_SMOOTH_THR_DEFAULT 8#define SHARP_NOISE_THR_DEFAULT 2 -#define DPU_NAME_SIZE 12 -#define DPU_PLANE_COLOR_FILL_FLAG BIT(31)#define DPU_ZPOS_MAX 255
Signature · 1 line
2.39.2
PATCH 2/2 drm/msm/dpu: switch dpu_encoder to use drm_debugfs_add_file()
In reply to Dmitry BaryshkovUse drm_debugfs_add_file() for encoder's status file. This changes the name of the status file from encoder%d/status to just encoder%d.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 40 ++++++--------------- 1 file changed, 11 insertions(+), 29 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +11 -29
@@ -14,6 +14,7 @@#include <drm/drm_atomic.h> #include <drm/drm_crtc.h> +#include <drm/drm_debugfs.h> #include <drm/drm_file.h> #include <drm/drm_probe_helper.h>
@@ -142,7 +143,6 @@ enum dpu_enc_rc_states {* @crtc_kickoff_cb: Callback into CRTC that will flush & start * all CTL paths * @crtc_kickoff_cb_data: Opaque user data given to crtc_kickoff_cb -* @debugfs_root: Debug file system root file node * @enc_lock: Lock around physical encoder * create/destroy/enable/disable * @frame_busy_mask: Bitmask tracking which phys_enc we are still
@@ -186,7 +186,6 @@ struct dpu_encoder_virt {struct drm_crtc *crtc;struct drm_connector *connector; -struct dentry *debugfs_root;struct mutex enc_lock;DECLARE_BITMAP (frame_busy_mask,MAX_PHYS_ENCODERS_PER_VIRTUAL );void (*crtc_frame_event_cb)(void *,u32 event);
@@ -2091,7 +2090,8 @@ void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc)#ifdef CONFIG_DEBUG_FS static int _dpu_encoder_status_show (struct seq_file *s,void *data) { -struct dpu_encoder_virt *dpu_enc = s->private; +struct drm_debugfs_entry *entry = s->private; +struct dpu_encoder_virt *dpu_enc = entry->file.data;int i;mutex_lock (&dpu_enc->enc_lock);
@@ -2110,48 +2110,31 @@ static int _dpu_encoder_status_show(struct seq_file *s, void *data)return 0 ; } -DEFINE_SHOW_ATTRIBUTE (_dpu_encoder_status); - -static int _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) +static void _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) {struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); - -char name[12 ]; +char *name;if (!drm_enc->dev) {DPU_ERROR ("invalid encoder or kms\n" ); -return -EINVAL ; +return ; } -snprintf (name,sizeof (name),"encoder%u" , drm_enc->base.id); + name =devm_kasprintf (drm_enc->dev->dev,GFP_KERNEL ,"encoder%u" , drm_enc->base.id); -/* create overall sub-directory for the encoder */ - dpu_enc->debugfs_root =debugfs_create_dir (name, - drm_enc->dev->primary->debugfs_root); - -/* don't error check these */ -debugfs_create_file ("status" ,0600 , - dpu_enc->debugfs_root, dpu_enc, &_dpu_encoder_status_fops); - -return 0 ; +drm_debugfs_add_file (drm_enc->dev, name, _dpu_encoder_status_show, dpu_enc); }#else -static int _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) +static void _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) { -return 0 ; }#endif static int dpu_encoder_late_register (struct drm_encoder *encoder) { -return _dpu_encoder_init_debugfs (encoder); -} - -static void dpu_encoder_early_unregister (struct drm_encoder *encoder) -{ -struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (encoder); +_dpu_encoder_init_debugfs (encoder); -debugfs_remove_recursive (dpu_enc->debugfs_root); +return 0 ; } static int dpu_encoder_virt_add_phys_encs(
@@ -2380,7 +2363,6 @@ static const struct drm_encoder_helper_funcs dpu_encoder_helper_funcs = {static const struct drm_encoder_funcs dpu_encoder_funcs = { .destroy = dpu_encoder_destroy, .late_register = dpu_encoder_late_register, - .early_unregister = dpu_encoder_early_unregister, }; int dpu_encoder_setup(struct drm_device *dev, struct drm_encoder *enc,
Signature · 1 line
2.39.2
Marijn Suijten
reviewerRe: [PATCH 2/2] drm/msm/dpu: switch dpu_encoder to use drm_debugfs_add_file()
Quoted 66 lines · Dmitry Baryshkov
Use
drm_debugfs_add_file()for encoder's status file. This changes the name of the status file from encoder%d/status to just encoder%d.Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 40 ++++++--------------- 1 file changed, 11 insertions(+), 29 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +6
-9@@ -14,6 +14,7 @@#include <drm/drm_atomic.h> #include <drm/drm_crtc.h> +#include <drm/drm_debugfs.h> #include <drm/drm_file.h> #include <drm/drm_probe_helper.h> @@ -142,7 +143,6 @@ enum dpu_enc_rc_states {* @crtc_kickoff_cb: Callback into CRTC that will flush & start * all CTL paths * @crtc_kickoff_cb_data: Opaque user data given to crtc_kickoff_cb -* @debugfs_root: Debug file system root file node * @enc_lock: Lock around physical encoder * create/destroy/enable/disable * @frame_busy_mask: Bitmask tracking which phys_enc we are still @@ -186,7 +186,6 @@ struct dpu_encoder_virt {struct drm_crtc *crtc;struct drm_connector *connector; -struct dentry *debugfs_root;struct mutex enc_lock;DECLARE_BITMAP (frame_busy_mask,MAX_PHYS_ENCODERS_PER_VIRTUAL );void (*crtc_frame_event_cb)(void *,u32 event);@@ -2091,7 +2090,8 @@ void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc)#ifdef CONFIG_DEBUG_FS static int _dpu_encoder_status_show (struct seq_file *s,void *data) { -struct dpu_encoder_virt *dpu_enc = s->private; +struct drm_debugfs_entry *entry = s->private; +struct dpu_encoder_virt *dpu_enc = entry->file.data;int i;mutex_lock (&dpu_enc->enc_lock);@@ -2110,48 +2110,31 @@ static int _dpu_encoder_status_show(struct seq_file *s, void *data)return 0 ; } -DEFINE_SHOW_ATTRIBUTE (_dpu_encoder_status); - -static int _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) +static void _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) {struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); - -char name[12 ]; +char *name;if (!drm_enc->dev) {DPU_ERROR ("invalid encoder or kms\n" ); -return -EINVAL ; +return ; }
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c static int _dpu_encoder_status_show(struct seq_file *s, void *data) · line 2134
Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +1
-8-snprintf (name,sizeof (name),"encoder%u" , drm_enc->base.id); + name =devm_kasprintf (drm_enc->dev->dev,GFP_KERNEL ,"encoder%u" , drm_enc->base.id); -/* create overall sub-directory for the encoder */ - dpu_enc->debugfs_root =debugfs_create_dir (name, - drm_enc->dev->primary->debugfs_root); - -/* don't error check these */ -debugfs_create_file ("status" ,0600 , - dpu_enc->debugfs_root, dpu_enc, &_dpu_encoder_status_fops);
I still have a looping callback to late_register() here, what series does this depend on?
- Marijn
Quoted 38 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +4
-12- -return 0 ; +drm_debugfs_add_file (drm_enc->dev, name, _dpu_encoder_status_show, dpu_enc); }#else -static int _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) +static void _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) { -return 0 ; }#endif static int dpu_encoder_late_register (struct drm_encoder *encoder) { -return _dpu_encoder_init_debugfs (encoder); -} - -static void dpu_encoder_early_unregister (struct drm_encoder *encoder) -{ -struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (encoder); +_dpu_encoder_init_debugfs (encoder); -debugfs_remove_recursive (dpu_enc->debugfs_root); +return 0 ; } static int dpu_encoder_virt_add_phys_encs(@@ -2380,7 +2363,6 @@ static const struct drm_encoder_helper_funcs dpu_encoder_helper_funcs = {static const struct drm_encoder_funcs dpu_encoder_funcs = { .destroy = dpu_encoder_destroy, .late_register = dpu_encoder_late_register, - .early_unregister = dpu_encoder_early_unregister, }; int dpu_encoder_setup(struct drm_device *dev, struct drm_encoder *enc,Signature · 1 line
2.39.2
Re: [PATCH 2/2] drm/msm/dpu: switch dpu_encoder to use drm_debugfs_add_file()
Quoted 70 lines · Marijn Suijten
Quoted 69 lines · Dmitry Baryshkov
Use
drm_debugfs_add_file()for encoder's status file. This changes the name of the status file from encoder%d/status to just encoder%d.Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 40 ++++++--------------- 1 file changed, 11 insertions(+), 29 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +7
-10@@ -14,6 +14,7 @@#include <drm/drm_atomic.h> #include <drm/drm_crtc.h> +#include <drm/drm_debugfs.h> #include <drm/drm_file.h> #include <drm/drm_probe_helper.h> @@ -142,7 +143,6 @@ enum dpu_enc_rc_states {* @crtc_kickoff_cb: Callback into CRTC that will flush & start * all CTL paths * @crtc_kickoff_cb_data: Opaque user data given to crtc_kickoff_cb -* @debugfs_root: Debug file system root file node * @enc_lock: Lock around physical encoder * create/destroy/enable/disable * @frame_busy_mask: Bitmask tracking which phys_enc we are still @@ -186,7 +186,6 @@ struct dpu_encoder_virt {struct drm_crtc *crtc;struct drm_connector *connector; -struct dentry *debugfs_root;struct mutex enc_lock;DECLARE_BITMAP (frame_busy_mask,MAX_PHYS_ENCODERS_PER_VIRTUAL );void (*crtc_frame_event_cb)(void *,u32 event);@@ -2091,7 +2090,8 @@ void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc)#ifdef CONFIG_DEBUG_FS static int _dpu_encoder_status_show (struct seq_file *s,void *data) { -struct dpu_encoder_virt *dpu_enc = s->private; +struct drm_debugfs_entry *entry = s->private; +struct dpu_encoder_virt *dpu_enc = entry->file.data;int i;mutex_lock (&dpu_enc->enc_lock);@@ -2110,48 +2110,31 @@ static int _dpu_encoder_status_show(struct seq_file *s, void *data)return 0 ; } -DEFINE_SHOW_ATTRIBUTE (_dpu_encoder_status); - -static int _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) +static void _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) {struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); - -char name[12 ]; +char *name;if (!drm_enc->dev) {DPU_ERROR ("invalid encoder or kms\n" ); -return -EINVAL ; +return ; } -snprintf (name,sizeof (name),"encoder%u" , drm_enc->base.id); + name =devm_kasprintf (drm_enc->dev->dev,GFP_KERNEL ,"encoder%u" , drm_enc->base.id);
Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c static int _dpu_encoder_status_show(struct seq_file *s, void *data) · line 2134
Quoted 7 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0
-7-/* create overall sub-directory for the encoder */ - dpu_enc->debugfs_root =debugfs_create_dir (name, - drm_enc->dev->primary->debugfs_root); - -/* don't error check these */ -debugfs_create_file ("status" ,0600 , - dpu_enc->debugfs_root, dpu_enc, &_dpu_encoder_status_fops);I still have a looping callback to
late_register()here, what series does this depend on?
Argh, I have sent 2 patches instead of sending 3.
Quoted 41 lines
- Marijn
Quoted 38 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +4
-12- -return 0 ; +drm_debugfs_add_file (drm_enc->dev, name, _dpu_encoder_status_show, dpu_enc); }#else -static int _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) +static void _dpu_encoder_init_debugfs (struct drm_encoder *drm_enc) { -return 0 ; }#endif static int dpu_encoder_late_register (struct drm_encoder *encoder) { -return _dpu_encoder_init_debugfs (encoder); -} - -static void dpu_encoder_early_unregister (struct drm_encoder *encoder) -{ -struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (encoder); +_dpu_encoder_init_debugfs (encoder); -debugfs_remove_recursive (dpu_enc->debugfs_root); +return 0 ; } static int dpu_encoder_virt_add_phys_encs(@@ -2380,7 +2363,6 @@ static const struct drm_encoder_helper_funcs dpu_encoder_helper_funcs = {static const struct drm_encoder_funcs dpu_encoder_funcs = { .destroy = dpu_encoder_destroy, .late_register = dpu_encoder_late_register, - .early_unregister = dpu_encoder_early_unregister, }; int dpu_encoder_setup(struct drm_device *dev, struct drm_encoder *enc,Signature · 1 line
2.39.2
Signature · 2 lines
With best wishes Dmitry