diff mbox

[2/2] drm/dp/mst: take lock around looking up the branch device on hpd irq

Message ID 1434948044-26150-2-git-send-email-airlied@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dave Airlie June 22, 2015, 4:40 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

If we are doing an MST transaction and we've gotten HPD and we
lookup the device from the incoming msg, we should take the mgr
lock around it, so that mst_primary and mstb->ports are valid.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Daniel Vetter June 22, 2015, 7:07 a.m. UTC | #1
On Mon, Jun 22, 2015 at 02:40:44PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> If we are doing an MST transaction and we've gotten HPD and we
> lookup the device from the incoming msg, we should take the mgr
> lock around it, so that mst_primary and mstb->ports are valid.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 3c7e5cd..15a6d8e 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -1175,6 +1175,8 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
>  	struct drm_dp_mst_port *port;
>  	int i;
>  	/* find the port by iterating down */
> +
> +	mutex_lock(&mgr->lock);
>  	mstb = mgr->mst_primary;
>  
>  	for (i = 0; i < lct - 1; i++) {
> @@ -1194,6 +1196,7 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
>  		}
>  	}
>  	kref_get(&mstb->kref);
> +	mutex_unlock(&mgr->lock);
>  	return mstb;
>  }
>  
> -- 
> 2.4.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Jani Nikula Oct. 16, 2015, 9:49 a.m. UTC | #2
On Mon, 22 Jun 2015, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Mon, Jun 22, 2015 at 02:40:44PM +1000, Dave Airlie wrote:
>> From: Dave Airlie <airlied@redhat.com>
>> 
>> If we are doing an MST transaction and we've gotten HPD and we
>> lookup the device from the incoming msg, we should take the mgr
>> lock around it, so that mst_primary and mstb->ports are valid.
>> 
>> Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

The error path fails to unlock the mutex, reported in [1]. There's a fix
in the bug, I've asked Adam to post it to the list.

BR,
Jani.


[1] https://bugs.freedesktop.org/show_bug.cgi?id=92480


>
>> ---
>>  drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
>> index 3c7e5cd..15a6d8e 100644
>> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
>> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
>> @@ -1175,6 +1175,8 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
>>  	struct drm_dp_mst_port *port;
>>  	int i;
>>  	/* find the port by iterating down */
>> +
>> +	mutex_lock(&mgr->lock);
>>  	mstb = mgr->mst_primary;
>>  
>>  	for (i = 0; i < lct - 1; i++) {
>> @@ -1194,6 +1196,7 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
>>  		}
>>  	}
>>  	kref_get(&mstb->kref);
>> +	mutex_unlock(&mgr->lock);
>>  	return mstb;
>>  }
>>  
>> -- 
>> 2.4.1
>> 
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 3c7e5cd..15a6d8e 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -1175,6 +1175,8 @@  static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
 	struct drm_dp_mst_port *port;
 	int i;
 	/* find the port by iterating down */
+
+	mutex_lock(&mgr->lock);
 	mstb = mgr->mst_primary;
 
 	for (i = 0; i < lct - 1; i++) {
@@ -1194,6 +1196,7 @@  static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
 		}
 	}
 	kref_get(&mstb->kref);
+	mutex_unlock(&mgr->lock);
 	return mstb;
 }