[PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect

Ramya SR rsr at qti.qualcomm.com
Thu Sep 28 02:25:25 UTC 2023


Reminder. Please review the reply comment.

Thanks and Regards,
Ramya SR

-----Original Message-----
From: Ramya SR 
Sent: Tuesday, September 26, 2023 4:12 PM
To: Alex Deucher <alexdeucher at gmail.com>; imre.deak at intel.com
Cc: Lyude Paul <lyude at redhat.com>; Jani Nikula <jani.nikula at intel.com>; Jeff Layton <jlayton at kernel.org>; linux-kernel at vger.kernel.org; dri-devel at lists.freedesktop.org; Wayne Lin <Wayne.Lin at amd.com>; Alex Deucher <alexander.deucher at amd.com>; Ramya SR (QUIC) <quic_rsr at quicinc.com>
Subject: RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect



-----Original Message-----
From: Alex Deucher <alexdeucher at gmail.com>
Sent: Monday, September 25, 2023 8:27 PM
To: imre.deak at intel.com
Cc: Lyude Paul <lyude at redhat.com>; Jani Nikula <jani.nikula at intel.com>; Jeff Layton <jlayton at kernel.org>; linux-kernel at vger.kernel.org; dri-devel at lists.freedesktop.org; Wayne Lin <Wayne.Lin at amd.com>; Alex Deucher <alexander.deucher at amd.com>; Ramya SR (QUIC) <quic_rsr at quicinc.com>
Subject: Re: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect

WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros.

On Fri, Sep 22, 2023 at 3:22 PM Imre Deak <imre.deak at intel.com> wrote:
>
> On Fri, Sep 22, 2023 at 03:02:23PM -0400, Lyude Paul wrote:
> >
> > Oh! wow thank you for catching this:
> >
> > Reviewed-by: Lyude Paul <lyude at redhat.com>
> >
> > I will go and push this to drm-misc-next in just a moment
> >
> > On Fri, 2023-09-15 at 10:24 +0530, Ramya SR wrote:
> > > Modeset mutex unlock is missing in drm_dp_mst_detect_port function.
> > > This will lead to deadlock if calling the function multiple times 
> > > in an atomic operation, for example, getting imultiple MST ports 
> > > status for a DP MST bonding scenario.
> > >
> > > Signed-off-by: Ramya SR <quic_rsr at quicinc.com>
> > > ---
> > >  drivers/gpu/drm/display/drm_dp_mst_topology.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> > > b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> > > index ed96cfc..d6512c4 100644
> > > --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> > > +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> > > @@ -4154,7 +4154,7 @@ drm_dp_mst_detect_port(struct drm_connector 
> > > *connector,
> > >
> > >     ret = drm_modeset_lock(&mgr->base.lock, ctx);
> > >     if (ret)
> > > -           goto out;
> > > +           goto fail;
> > >
> > >     ret = connector_status_disconnected;
> > >
> > > @@ -4181,6 +4181,8 @@ drm_dp_mst_detect_port(struct drm_connector *connector,
> > >             break;
> > >     }
> > >  out:
> > > +   drm_modeset_unlock(&mgr->base.lock);
>
> Isn't this supposed to be unlocked only by
> drm_helper_probe_detect_ctx() / drm_helper_probe_detect() ?

Maybe adding a comment to that effect would be helpful for the future.

Alex

>this is different lock, above function mentioned is locking/unlocking the global connection_mutex, that is required always locked during the atomic >check/commit. Here we are talking about MST topology manager mutex "mgr->base.lock".

>For normal non-bond MST, it's ok, the calling sequence for detecting 
>MST connector status is  dp_mst_connector_detect 
>->mst->mst_fw_cbs->detect_port_ctx = dp_mst_detect_port 
>->drm_dp_mst_detect_port (where mgr->base.lock is locked)

> Then for the bond MST case, to figure out if the sibling connectors 
> are also connected, so that the bonding is possible, we need detect 
> two or more connectors >in single dp_mst_connector_detect call

>dp_mst_connector_detect ->mst->mst_fw_cbs->detect_port_ctx = 
>dp_mst_detect_port ->drm_dp_mst_detect_port (where mgr->base.lock is 
>locked) dp_mst_find_sibling_connector 
>->mst->mst_fw_cbs->detect_port_ctx = dp_mst_detect_port 
>->drm_dp_mst_detect_port (blocked by mgr->base.lock)

>
> > > +fail:
> > >     drm_dp_mst_topology_put_port(port);
> > >     return ret;
> > >  }
> >
> > --
> > Cheers,
> >  Lyude Paul (she/her)
> >  Software Engineer at Red Hat
> >


More information about the dri-devel mailing list