Message ID | 1649350286-11504-1-git-send-email-quic_khsieh@quicinc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | drm/msm/dp: add fail safe mode outside of event_mutex context | expand |
On Thu, 7 Apr 2022 at 19:51, Kuogee Hsieh <quic_khsieh@quicinc.com> wrote: > > There is possible circular locking dependency detected on event_mutex. > To break this possible circular locking, this patch move setting fail > safe mode out of event_mutex scope. Please provide the lockdep trace here, it might help other people trying to fix the issue or working on backports to stable kernels. > > Fixes: d4aca422539c ("drm/msm/dp: always add fail-safe mode into connector mode list") > Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com> > --- > drivers/gpu/drm/msm/dp/dp_display.c | 6 ++++++ > drivers/gpu/drm/msm/dp/dp_panel.c | 20 ++++++++++---------- > drivers/gpu/drm/msm/dp/dp_panel.h | 1 + > 3 files changed, 17 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c > index 178b774..a42732b 100644 > --- a/drivers/gpu/drm/msm/dp/dp_display.c > +++ b/drivers/gpu/drm/msm/dp/dp_display.c > @@ -580,6 +580,12 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data) > dp->dp_display.connector_type, state); > mutex_unlock(&dp->event_mutex); > > + /* > + * add fail safe mode outside event_mutex scope > + * to avoid potiential circular lock with drm thread > + */ > + dp_panel_add_fail_safe_mode(dp->dp_display.connector); > + > /* uevent will complete connection part */ > return 0; > }; > diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c > index f141872..26c3653 100644 > --- a/drivers/gpu/drm/msm/dp/dp_panel.c > +++ b/drivers/gpu/drm/msm/dp/dp_panel.c > @@ -151,6 +151,15 @@ static int dp_panel_update_modes(struct drm_connector *connector, > return rc; > } > > +void dp_panel_add_fail_safe_mode(struct drm_connector *connector) > +{ > + /* fail safe edid */ > + mutex_lock(&connector->dev->mode_config.mutex); > + if (drm_add_modes_noedid(connector, 640, 480)) > + drm_set_preferred_mode(connector, 640, 480); > + mutex_unlock(&connector->dev->mode_config.mutex); > +} > + > int dp_panel_read_sink_caps(struct dp_panel *dp_panel, > struct drm_connector *connector) > { > @@ -207,16 +216,7 @@ int dp_panel_read_sink_caps(struct dp_panel *dp_panel, > goto end; > } > > - /* fail safe edid */ > - mutex_lock(&connector->dev->mode_config.mutex); > - if (drm_add_modes_noedid(connector, 640, 480)) > - drm_set_preferred_mode(connector, 640, 480); > - mutex_unlock(&connector->dev->mode_config.mutex); > - } else { > - /* always add fail-safe mode as backup mode */ > - mutex_lock(&connector->dev->mode_config.mutex); > - drm_add_modes_noedid(connector, 640, 480); > - mutex_unlock(&connector->dev->mode_config.mutex); > + dp_panel_add_fail_safe_mode(connector); > } > > if (panel->aux_cfg_update_done) { > diff --git a/drivers/gpu/drm/msm/dp/dp_panel.h b/drivers/gpu/drm/msm/dp/dp_panel.h > index 9023e5b..99739ea 100644 > --- a/drivers/gpu/drm/msm/dp/dp_panel.h > +++ b/drivers/gpu/drm/msm/dp/dp_panel.h > @@ -59,6 +59,7 @@ int dp_panel_init_panel_info(struct dp_panel *dp_panel); > int dp_panel_deinit(struct dp_panel *dp_panel); > int dp_panel_timing_cfg(struct dp_panel *dp_panel); > void dp_panel_dump_regs(struct dp_panel *dp_panel); > +void dp_panel_add_fail_safe_mode(struct drm_connector *connector); > int dp_panel_read_sink_caps(struct dp_panel *dp_panel, > struct drm_connector *connector); > u32 dp_panel_get_mode_bpp(struct dp_panel *dp_panel, u32 mode_max_bpp, > -- > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, > a Linux Foundation Collaborative Project >
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 178b774..a42732b 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -580,6 +580,12 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data) dp->dp_display.connector_type, state); mutex_unlock(&dp->event_mutex); + /* + * add fail safe mode outside event_mutex scope + * to avoid potiential circular lock with drm thread + */ + dp_panel_add_fail_safe_mode(dp->dp_display.connector); + /* uevent will complete connection part */ return 0; }; diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c index f141872..26c3653 100644 --- a/drivers/gpu/drm/msm/dp/dp_panel.c +++ b/drivers/gpu/drm/msm/dp/dp_panel.c @@ -151,6 +151,15 @@ static int dp_panel_update_modes(struct drm_connector *connector, return rc; } +void dp_panel_add_fail_safe_mode(struct drm_connector *connector) +{ + /* fail safe edid */ + mutex_lock(&connector->dev->mode_config.mutex); + if (drm_add_modes_noedid(connector, 640, 480)) + drm_set_preferred_mode(connector, 640, 480); + mutex_unlock(&connector->dev->mode_config.mutex); +} + int dp_panel_read_sink_caps(struct dp_panel *dp_panel, struct drm_connector *connector) { @@ -207,16 +216,7 @@ int dp_panel_read_sink_caps(struct dp_panel *dp_panel, goto end; } - /* fail safe edid */ - mutex_lock(&connector->dev->mode_config.mutex); - if (drm_add_modes_noedid(connector, 640, 480)) - drm_set_preferred_mode(connector, 640, 480); - mutex_unlock(&connector->dev->mode_config.mutex); - } else { - /* always add fail-safe mode as backup mode */ - mutex_lock(&connector->dev->mode_config.mutex); - drm_add_modes_noedid(connector, 640, 480); - mutex_unlock(&connector->dev->mode_config.mutex); + dp_panel_add_fail_safe_mode(connector); } if (panel->aux_cfg_update_done) { diff --git a/drivers/gpu/drm/msm/dp/dp_panel.h b/drivers/gpu/drm/msm/dp/dp_panel.h index 9023e5b..99739ea 100644 --- a/drivers/gpu/drm/msm/dp/dp_panel.h +++ b/drivers/gpu/drm/msm/dp/dp_panel.h @@ -59,6 +59,7 @@ int dp_panel_init_panel_info(struct dp_panel *dp_panel); int dp_panel_deinit(struct dp_panel *dp_panel); int dp_panel_timing_cfg(struct dp_panel *dp_panel); void dp_panel_dump_regs(struct dp_panel *dp_panel); +void dp_panel_add_fail_safe_mode(struct drm_connector *connector); int dp_panel_read_sink_caps(struct dp_panel *dp_panel, struct drm_connector *connector); u32 dp_panel_get_mode_bpp(struct dp_panel *dp_panel, u32 mode_max_bpp,
There is possible circular locking dependency detected on event_mutex. To break this possible circular locking, this patch move setting fail safe mode out of event_mutex scope. Fixes: d4aca422539c ("drm/msm/dp: always add fail-safe mode into connector mode list") Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com> --- drivers/gpu/drm/msm/dp/dp_display.c | 6 ++++++ drivers/gpu/drm/msm/dp/dp_panel.c | 20 ++++++++++---------- drivers/gpu/drm/msm/dp/dp_panel.h | 1 + 3 files changed, 17 insertions(+), 10 deletions(-)