From 773b7b1613c128207c308913eacedf5076c3a587 Mon Sep 17 00:00:00 2001 From: Jayant Shekhar Date: Mon, 24 Jul 2017 11:14:43 +0530 Subject: [PATCH] msm: mdss: Fix race condition during mdp dump In mdp debugfs, pipe, mixer, buffers and ctl information is dumped. While dumping pipe buffer information using pipe's buffer list, acquire list lock mutex. This is done to prevent crash if at the same time buffer is freed in commit thread. Change-Id: Ibd26cc1484fb08ae7d0852f405100f6bbfa707de Signed-off-by: Jayant Shekhar --- drivers/video/fbdev/msm/mdss_mdp_debug.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/msm/mdss_mdp_debug.c b/drivers/video/fbdev/msm/mdss_mdp_debug.c index 1035d23fe9ce..09d1dab0d180 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_debug.c +++ b/drivers/video/fbdev/msm/mdss_mdp_debug.c @@ -1863,12 +1863,14 @@ static void __print_buf(struct seq_file *s, struct mdss_mdp_data *buf, seq_puts(s, "\n"); } -static void __dump_pipe(struct seq_file *s, struct mdss_mdp_pipe *pipe) +static void __dump_pipe(struct seq_file *s, struct mdss_mdp_pipe *pipe, + struct msm_fb_data_type *mfd) { struct mdss_mdp_data *buf; int format; int smps[4]; int i; + struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd); seq_printf(s, "\nSSPP #%d type=%s ndx=%x flags=0x%16llx play_cnt=%u xin_id=%d\n", pipe->num, mdss_mdp_pipetype2str(pipe->type), @@ -1923,11 +1925,14 @@ static void __dump_pipe(struct seq_file *s, struct mdss_mdp_pipe *pipe) seq_puts(s, "Data:\n"); + mutex_lock(&mdp5_data->list_lock); list_for_each_entry(buf, &pipe->buf_queue, pipe_list) __print_buf(s, buf, false); + mutex_unlock(&mdp5_data->list_lock); } -static void __dump_mixer(struct seq_file *s, struct mdss_mdp_mixer *mixer) +static void __dump_mixer(struct seq_file *s, struct mdss_mdp_mixer *mixer, + struct msm_fb_data_type *mfd) { struct mdss_mdp_pipe *pipe; int i, cnt = 0; @@ -1944,7 +1949,7 @@ static void __dump_mixer(struct seq_file *s, struct mdss_mdp_mixer *mixer) for (i = 0; i < ARRAY_SIZE(mixer->stage_pipe); i++) { pipe = mixer->stage_pipe[i]; if (pipe) { - __dump_pipe(s, pipe); + __dump_pipe(s, pipe, mfd); cnt++; } } @@ -2019,8 +2024,8 @@ static void __dump_ctl(struct seq_file *s, struct mdss_mdp_ctl *ctl) seq_printf(s, "Play Count=%u Underrun Count=%u\n", ctl->play_cnt, ctl->underrun_cnt); - __dump_mixer(s, ctl->mixer_left); - __dump_mixer(s, ctl->mixer_right); + __dump_mixer(s, ctl->mixer_left, ctl->mfd); + __dump_mixer(s, ctl->mixer_right, ctl->mfd); } static int __dump_mdp(struct seq_file *s, struct mdss_data_type *mdata)