diff mbox series

[v4,4/5] drm/dp-mst: Fill branch->num_ports

Message ID 20190822135741.12923-5-David.Francis@amd.com (mailing list archive)
State New, archived
Headers show
Series MST DSC support in drm-mst | expand

Commit Message

Francis, David Aug. 22, 2019, 1:57 p.m. UTC
This field on drm_dp_mst_branch was never filled

Initialize it to zero when the list of ports is created.
When a port is added to the list, increment num_ports,
and when a port is removed from the list, decrement num_ports.

v2: remember to decrement on port removal

Signed-off-by: David Francis <David.Francis@amd.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Lyude Paul Aug. 22, 2019, 9:55 p.m. UTC | #1
On Thu, 2019-08-22 at 09:57 -0400, David Francis wrote:
> This field on drm_dp_mst_branch was never filled
> 
> Initialize it to zero when the list of ports is created.
> When a port is added to the list, increment num_ports,
> and when a port is removed from the list, decrement num_ports.
> 
> v2: remember to decrement on port removal
> 
> Signed-off-by: David Francis <David.Francis@amd.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>
> ---
>  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 50a044718439..af4b5cec7c84 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -919,6 +919,7 @@ static struct drm_dp_mst_branch
> *drm_dp_add_mst_branch_device(u8 lct, u8 *rad)
>  	INIT_LIST_HEAD(&mstb->ports);
>  	kref_init(&mstb->topology_kref);
>  	kref_init(&mstb->malloc_kref);
> +	mstb->num_ports = 0;

Just realized as well, we can drop the mstb->num_ports = 0; here, since we're
allocating the struct with kzalloc()

>  	return mstb;
>  }
>  
> @@ -1669,6 +1670,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch
> *mstb,
>  		mutex_lock(&mstb->mgr->lock);
>  		drm_dp_mst_topology_get_port(port);
>  		list_add(&port->next, &mstb->ports);
> +		mstb->num_ports++;
>  		mutex_unlock(&mstb->mgr->lock);
>  	}
>  
> @@ -1703,6 +1705,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch
> *mstb,
>  			/* remove it from the port list */
>  			mutex_lock(&mstb->mgr->lock);
>  			list_del(&port->next);
> +			mstb->num_ports--;
>  			mutex_unlock(&mstb->mgr->lock);
>  			/* drop port list reference */
>  			drm_dp_mst_topology_put_port(port);
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 50a044718439..af4b5cec7c84 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -919,6 +919,7 @@  static struct drm_dp_mst_branch *drm_dp_add_mst_branch_device(u8 lct, u8 *rad)
 	INIT_LIST_HEAD(&mstb->ports);
 	kref_init(&mstb->topology_kref);
 	kref_init(&mstb->malloc_kref);
+	mstb->num_ports = 0;
 	return mstb;
 }
 
@@ -1669,6 +1670,7 @@  static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
 		mutex_lock(&mstb->mgr->lock);
 		drm_dp_mst_topology_get_port(port);
 		list_add(&port->next, &mstb->ports);
+		mstb->num_ports++;
 		mutex_unlock(&mstb->mgr->lock);
 	}
 
@@ -1703,6 +1705,7 @@  static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
 			/* remove it from the port list */
 			mutex_lock(&mstb->mgr->lock);
 			list_del(&port->next);
+			mstb->num_ports--;
 			mutex_unlock(&mstb->mgr->lock);
 			/* drop port list reference */
 			drm_dp_mst_topology_put_port(port);