dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
@ 2023-09-15  4:54 Ramya SR
  2023-09-22  9:41 ` Ramya SR
  2023-09-22 19:02 ` Lyude Paul
  0 siblings, 2 replies; 11+ messages in thread
From: Ramya SR @ 2023-09-15  4:54 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter, Lyude Paul, Wayne Lin, Jani Nikula,
	Imre Deak, Alex Deucher, Jeff Layton, dri-devel, linux-kernel
  Cc: Ramya SR

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@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);
+fail:
 	drm_dp_mst_topology_put_port(port);
 	return ret;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-15  4:54 [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect Ramya SR
@ 2023-09-22  9:41 ` Ramya SR
  2023-09-22 19:02 ` Lyude Paul
  1 sibling, 0 replies; 11+ messages in thread
From: Ramya SR @ 2023-09-22  9:41 UTC (permalink / raw)
  To: Ramya SR (QUIC),
	David Airlie, Daniel Vetter, Lyude Paul, Wayne Lin, Jani Nikula,
	Imre Deak, Alex Deucher, Jeff Layton, dri-devel, linux-kernel

Gentle Reminder. Please review the commit.

-----Original Message-----
From: Ramya SR (QUIC) <quic_rsr@quicinc.com> 
Sent: Friday, September 15, 2023 10:25 AM
To: David Airlie <airlied@gmail.com>; Daniel Vetter <daniel@ffwll.ch>; Lyude Paul <lyude@redhat.com>; Wayne Lin <Wayne.Lin@amd.com>; Jani Nikula <jani.nikula@intel.com>; Imre Deak <imre.deak@intel.com>; Alex Deucher <alexander.deucher@amd.com>; Jeff Layton <jlayton@kernel.org>; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org
Cc: Ramya SR (QUIC) <quic_rsr@quicinc.com>
Subject: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect

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@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);
+fail:
 	drm_dp_mst_topology_put_port(port);
 	return ret;
 }
--
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-15  4:54 [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect Ramya SR
  2023-09-22  9:41 ` Ramya SR
@ 2023-09-22 19:02 ` Lyude Paul
  2023-09-22 19:22   ` Imre Deak
  1 sibling, 1 reply; 11+ messages in thread
From: Lyude Paul @ 2023-09-22 19:02 UTC (permalink / raw)
  To: Ramya SR, David Airlie, Daniel Vetter, Wayne Lin, Jani Nikula,
	Imre Deak, Alex Deucher, Jeff Layton, dri-devel, linux-kernel


Oh! wow thank you for catching this:

Reviewed-by: Lyude Paul <lyude@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@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);
> +fail:
>  	drm_dp_mst_topology_put_port(port);
>  	return ret;
>  }

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-22 19:02 ` Lyude Paul
@ 2023-09-22 19:22   ` Imre Deak
  2023-09-22 19:23     ` Lyude Paul
  2023-09-25 14:57     ` Alex Deucher
  0 siblings, 2 replies; 11+ messages in thread
From: Imre Deak @ 2023-09-22 19:22 UTC (permalink / raw)
  To: Lyude Paul
  Cc: Jani Nikula, Jeff Layton, linux-kernel, dri-devel, Wayne Lin,
	Alex Deucher, Ramya SR

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@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@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() ?

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-22 19:22   ` Imre Deak
@ 2023-09-22 19:23     ` Lyude Paul
  2023-09-25 14:57     ` Alex Deucher
  1 sibling, 0 replies; 11+ messages in thread
From: Lyude Paul @ 2023-09-22 19:23 UTC (permalink / raw)
  To: imre.deak
  Cc: Jani Nikula, Jeff Layton, linux-kernel, dri-devel, Wayne Lin,
	Alex Deucher, Ramya SR

…ugh, thanks for catching that :|

yes you're completely right - NAK on this patch then

On Fri, 2023-09-22 at 22:22 +0300, Imre Deak 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@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@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() ?
> 
> > > +fail:
> > >  	drm_dp_mst_topology_put_port(port);
> > >  	return ret;
> > >  }
> > 
> > -- 
> > Cheers,
> >  Lyude Paul (she/her)
> >  Software Engineer at Red Hat
> > 
> 

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-22 19:22   ` Imre Deak
  2023-09-22 19:23     ` Lyude Paul
@ 2023-09-25 14:57     ` Alex Deucher
  2023-09-26 10:41       ` Ramya SR
  1 sibling, 1 reply; 11+ messages in thread
From: Alex Deucher @ 2023-09-25 14:57 UTC (permalink / raw)
  To: imre.deak
  Cc: Jani Nikula, Jeff Layton, linux-kernel, dri-devel, Wayne Lin,
	Alex Deucher, Ramya SR

On Fri, Sep 22, 2023 at 3:22 PM Imre Deak <imre.deak@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@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@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

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-25 14:57     ` Alex Deucher
@ 2023-09-26 10:41       ` Ramya SR
  2023-09-28  2:25         ` Ramya SR
  0 siblings, 1 reply; 11+ messages in thread
From: Ramya SR @ 2023-09-26 10:41 UTC (permalink / raw)
  To: Alex Deucher, imre.deak
  Cc: Jani Nikula, Jeff Layton, linux-kernel, dri-devel, Wayne Lin,
	Alex Deucher, Ramya SR (QUIC)



-----Original Message-----
From: Alex Deucher <alexdeucher@gmail.com> 
Sent: Monday, September 25, 2023 8:27 PM
To: imre.deak@intel.com
Cc: Lyude Paul <lyude@redhat.com>; Jani Nikula <jani.nikula@intel.com>; Jeff Layton <jlayton@kernel.org>; linux-kernel@vger.kernel.org; dri-devel@lists.freedesktop.org; Wayne Lin <Wayne.Lin@amd.com>; Alex Deucher <alexander.deucher@amd.com>; Ramya SR (QUIC) <quic_rsr@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@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@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@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
> >

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-26 10:41       ` Ramya SR
@ 2023-09-28  2:25         ` Ramya SR
  2023-09-28  8:23           ` Jani Nikula
  2023-09-29  4:44           ` Ramya SR
  0 siblings, 2 replies; 11+ messages in thread
From: Ramya SR @ 2023-09-28  2:25 UTC (permalink / raw)
  To: Alex Deucher, imre.deak
  Cc: Jani Nikula, Jeff Layton, linux-kernel, dri-devel, Wayne Lin,
	Alex Deucher, Ramya SR (QUIC)

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@gmail.com>; imre.deak@intel.com
Cc: Lyude Paul <lyude@redhat.com>; Jani Nikula <jani.nikula@intel.com>; Jeff Layton <jlayton@kernel.org>; linux-kernel@vger.kernel.org; dri-devel@lists.freedesktop.org; Wayne Lin <Wayne.Lin@amd.com>; Alex Deucher <alexander.deucher@amd.com>; Ramya SR (QUIC) <quic_rsr@quicinc.com>
Subject: RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect



-----Original Message-----
From: Alex Deucher <alexdeucher@gmail.com>
Sent: Monday, September 25, 2023 8:27 PM
To: imre.deak@intel.com
Cc: Lyude Paul <lyude@redhat.com>; Jani Nikula <jani.nikula@intel.com>; Jeff Layton <jlayton@kernel.org>; linux-kernel@vger.kernel.org; dri-devel@lists.freedesktop.org; Wayne Lin <Wayne.Lin@amd.com>; Alex Deucher <alexander.deucher@amd.com>; Ramya SR (QUIC) <quic_rsr@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@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@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@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
> >

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-28  2:25         ` Ramya SR
@ 2023-09-28  8:23           ` Jani Nikula
  2023-09-29  4:44           ` Ramya SR
  1 sibling, 0 replies; 11+ messages in thread
From: Jani Nikula @ 2023-09-28  8:23 UTC (permalink / raw)
  To: Ramya SR, Alex Deucher, imre.deak
  Cc: Jeff Layton, linux-kernel, dri-devel, Wayne Lin, Alex Deucher,
	Ramya SR (QUIC)

On Thu, 28 Sep 2023, Ramya SR <rsr@qti.qualcomm.com> wrote:
> Reminder. Please review the reply comment.

Maybe send a patch to review?

It's also not helping that your previous mail looks like it's just
quoting other messages [1].


BR,
Jani.


[1] https://lore.kernel.org/all/BN0PR02MB79517B267D593DC484BA34DF81C3A@BN0PR02MB7951.namprd02.prod.outlook.com/


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

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-28  2:25         ` Ramya SR
  2023-09-28  8:23           ` Jani Nikula
@ 2023-09-29  4:44           ` Ramya SR
  2023-09-29  7:53             ` Jani Nikula
  1 sibling, 1 reply; 11+ messages in thread
From: Ramya SR @ 2023-09-29  4:44 UTC (permalink / raw)
  To: Alex Deucher, imre.deak
  Cc: Jani Nikula, Jeff Layton, linux-kernel, dri-devel, Wayne Lin,
	Alex Deucher, Ramya SR (QUIC)

Hi All ,

Please review the reply comment.

Regards,
Ramya SR

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

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@gmail.com>; imre.deak@intel.com
Cc: Lyude Paul <lyude@redhat.com>; Jani Nikula <jani.nikula@intel.com>; Jeff Layton <jlayton@kernel.org>; linux-kernel@vger.kernel.org; dri-devel@lists.freedesktop.org; Wayne Lin <Wayne.Lin@amd.com>; Alex Deucher <alexander.deucher@amd.com>; Ramya SR (QUIC) <quic_rsr@quicinc.com>
Subject: RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect



-----Original Message-----
From: Alex Deucher <alexdeucher@gmail.com>
Sent: Monday, September 25, 2023 8:27 PM
To: imre.deak@intel.com
Cc: Lyude Paul <lyude@redhat.com>; Jani Nikula <jani.nikula@intel.com>; Jeff Layton <jlayton@kernel.org>; linux-kernel@vger.kernel.org; dri-devel@lists.freedesktop.org; Wayne Lin <Wayne.Lin@amd.com>; Alex Deucher <alexander.deucher@amd.com>; Ramya SR (QUIC) <quic_rsr@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@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@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@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
> >

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect
  2023-09-29  4:44           ` Ramya SR
@ 2023-09-29  7:53             ` Jani Nikula
  0 siblings, 0 replies; 11+ messages in thread
From: Jani Nikula @ 2023-09-29  7:53 UTC (permalink / raw)
  To: Ramya SR, Alex Deucher, imre.deak
  Cc: Jeff Layton, linux-kernel, dri-devel, Wayne Lin, Alex Deucher,
	Ramya SR (QUIC)

On Fri, 29 Sep 2023, Ramya SR <rsr@qti.qualcomm.com> wrote:
> Hi All ,
>
> Please review the reply comment.

Please read the responses you do get [1]. Please stop
top-posting. Please fix your mail client.

BR,
Jani.


[1] https://lore.kernel.org/r/877coak8o3.fsf@intel.com

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

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-09-29  8:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-15  4:54 [PATCH v1] drm/dp/mst: fix missing modeset unlock for MST port detect Ramya SR
2023-09-22  9:41 ` Ramya SR
2023-09-22 19:02 ` Lyude Paul
2023-09-22 19:22   ` Imre Deak
2023-09-22 19:23     ` Lyude Paul
2023-09-25 14:57     ` Alex Deucher
2023-09-26 10:41       ` Ramya SR
2023-09-28  2:25         ` Ramya SR
2023-09-28  8:23           ` Jani Nikula
2023-09-29  4:44           ` Ramya SR
2023-09-29  7:53             ` Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).