From 91291bb9c41e8975db76ed74140f420fd50b40d1 Mon Sep 17 00:00:00 2001 From: Yashwanth Date: Tue, 17 Nov 2020 18:37:53 +0530 Subject: [PATCH] disp: msm: sde: add vblank mutex lock during irq unregister Currently, during ctl reset in video mode, irq register or unregister might result in race condition with vblank enable/disable calls on event thread resulting in enable cnt mismatch. This change adds mutex locks to avoid race conditions in such cases. Change-Id: I45aef19864475ac1b02dd8e84810eee233fc60ea Signed-off-by: Yashwanth --- msm/sde/sde_encoder_phys_vid.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/msm/sde/sde_encoder_phys_vid.c b/msm/sde/sde_encoder_phys_vid.c index 08cafe491a5a..3411c58f32e0 100644 --- a/msm/sde/sde_encoder_phys_vid.c +++ b/msm/sde/sde_encoder_phys_vid.c @@ -924,6 +924,7 @@ static int sde_encoder_phys_vid_prepare_for_kickoff( struct drm_connector *conn; int event; int rc; + int irq_enable; if (!phys_enc || !params || !phys_enc->hw_ctl) { SDE_ERROR("invalid encoder/parameters\n"); @@ -952,12 +953,21 @@ static int sde_encoder_phys_vid_prepare_for_kickoff( /* to avoid flooding, only log first time, and "dead" time */ if (vid_enc->error_count == 1) { SDE_EVT32(DRMID(phys_enc->parent), SDE_EVTLOG_FATAL); + mutex_lock(phys_enc->vblank_ctl_lock); - sde_encoder_helper_unregister_irq( + irq_enable = atomic_read(&phys_enc->vblank_refcount); + + if (irq_enable) + sde_encoder_helper_unregister_irq( phys_enc, INTR_IDX_VSYNC); + SDE_DBG_DUMP("all", "dbg_bus", "vbif_dbg_bus"); - sde_encoder_helper_register_irq( + + if (irq_enable) + sde_encoder_helper_register_irq( phys_enc, INTR_IDX_VSYNC); + + mutex_unlock(phys_enc->vblank_ctl_lock); } /*