diff mbox series

[V2,1/4] drm/bridge: Remove duplication from drm_bridge and drm_atomic_bridge chains

Message ID 67888b7a05a896c8b9b0f15bd81ef614d082dc9f.1646406653.git.dave.stevenson@raspberrypi.com (mailing list archive)
State New, archived
Headers show
Series DSI host and peripheral initialisation ordering | expand

Commit Message

Dave Stevenson March 4, 2022, 3:17 p.m. UTC
drm_bridge_chain_pre_enable is a subset of
drm_atomic_bridge_chain_pre_enable, and drm_bridge_chain_post_disable
is a subset of drm_atomic_bridge_chain_post_disable.

Change drm_bridge_chain_pre_enable and drm_bridge_chain_post_disable to
call the atomic versions with a NULL state, and ensure that atomic
calls are not made if there is no state.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/gpu/drm/drm_bridge.c | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

Comments

Dmitry Baryshkov June 8, 2022, 11 a.m. UTC | #1
On 04/03/2022 18:17, Dave Stevenson wrote:
> drm_bridge_chain_pre_enable is a subset of
> drm_atomic_bridge_chain_pre_enable, and drm_bridge_chain_post_disable
> is a subset of drm_atomic_bridge_chain_post_disable.
> 
> Change drm_bridge_chain_pre_enable and drm_bridge_chain_post_disable to
> call the atomic versions with a NULL state, and ensure that atomic
> calls are not made if there is no state.
> 
> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

I think we should update parade-ps8640 to use drm_atomic_bridge_chain_() 
and drop drm_bridge_chain_* API completely.

> ---
>   drivers/gpu/drm/drm_bridge.c | 30 ++++--------------------------
>   1 file changed, 4 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index c96847fc0ebc..198fd471a488 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -527,16 +527,7 @@ EXPORT_SYMBOL(drm_bridge_chain_disable);
>    */
>   void drm_bridge_chain_post_disable(struct drm_bridge *bridge)
>   {
> -	struct drm_encoder *encoder;
> -
> -	if (!bridge)
> -		return;
> -
> -	encoder = bridge->encoder;
> -	list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
> -		if (bridge->funcs->post_disable)
> -			bridge->funcs->post_disable(bridge);
> -	}
> +	drm_atomic_bridge_chain_post_disable(bridge, NULL);
>   }
>   EXPORT_SYMBOL(drm_bridge_chain_post_disable);
>   
> @@ -582,20 +573,7 @@ EXPORT_SYMBOL(drm_bridge_chain_mode_set);
>    */
>   void drm_bridge_chain_pre_enable(struct drm_bridge *bridge)
>   {
> -	struct drm_encoder *encoder;
> -	struct drm_bridge *iter;
> -
> -	if (!bridge)
> -		return;
> -
> -	encoder = bridge->encoder;
> -	list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
> -		if (iter->funcs->pre_enable)
> -			iter->funcs->pre_enable(iter);
> -
> -		if (iter == bridge)
> -			break;
> -	}
> +	drm_atomic_bridge_chain_pre_enable(bridge, NULL);
>   }
>   EXPORT_SYMBOL(drm_bridge_chain_pre_enable);
>   
> @@ -690,7 +668,7 @@ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
>   
>   	encoder = bridge->encoder;
>   	list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
> -		if (bridge->funcs->atomic_post_disable) {
> +		if (old_state && bridge->funcs->atomic_post_disable) {
>   			struct drm_bridge_state *old_bridge_state;
>   
>   			old_bridge_state =
> @@ -732,7 +710,7 @@ void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
>   
>   	encoder = bridge->encoder;
>   	list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
> -		if (iter->funcs->atomic_pre_enable) {
> +		if (old_state && iter->funcs->atomic_pre_enable) {
>   			struct drm_bridge_state *old_bridge_state;
>   
>   			old_bridge_state =
Sam Ravnborg July 18, 2022, 6:16 p.m. UTC | #2
Hi Dmitry,

On Wed, Jun 08, 2022 at 02:00:57PM +0300, Dmitry Baryshkov wrote:
> On 04/03/2022 18:17, Dave Stevenson wrote:
> > drm_bridge_chain_pre_enable is a subset of
> > drm_atomic_bridge_chain_pre_enable, and drm_bridge_chain_post_disable
> > is a subset of drm_atomic_bridge_chain_post_disable.
> > 
> > Change drm_bridge_chain_pre_enable and drm_bridge_chain_post_disable to
> > call the atomic versions with a NULL state, and ensure that atomic
> > calls are not made if there is no state.
> > 
> > Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> 
> I think we should update parade-ps8640 to use drm_atomic_bridge_chain_() and
> drop drm_bridge_chain_* API completely.

This is done in a few of the patches you can find here:
https://lore.kernel.org/dri-devel/20220717174454.46616-1-sam@ravnborg.org/

Review/testing would be appreciated.

	Sam
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index c96847fc0ebc..198fd471a488 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -527,16 +527,7 @@  EXPORT_SYMBOL(drm_bridge_chain_disable);
  */
 void drm_bridge_chain_post_disable(struct drm_bridge *bridge)
 {
-	struct drm_encoder *encoder;
-
-	if (!bridge)
-		return;
-
-	encoder = bridge->encoder;
-	list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
-		if (bridge->funcs->post_disable)
-			bridge->funcs->post_disable(bridge);
-	}
+	drm_atomic_bridge_chain_post_disable(bridge, NULL);
 }
 EXPORT_SYMBOL(drm_bridge_chain_post_disable);
 
@@ -582,20 +573,7 @@  EXPORT_SYMBOL(drm_bridge_chain_mode_set);
  */
 void drm_bridge_chain_pre_enable(struct drm_bridge *bridge)
 {
-	struct drm_encoder *encoder;
-	struct drm_bridge *iter;
-
-	if (!bridge)
-		return;
-
-	encoder = bridge->encoder;
-	list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
-		if (iter->funcs->pre_enable)
-			iter->funcs->pre_enable(iter);
-
-		if (iter == bridge)
-			break;
-	}
+	drm_atomic_bridge_chain_pre_enable(bridge, NULL);
 }
 EXPORT_SYMBOL(drm_bridge_chain_pre_enable);
 
@@ -690,7 +668,7 @@  void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
 
 	encoder = bridge->encoder;
 	list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
-		if (bridge->funcs->atomic_post_disable) {
+		if (old_state && bridge->funcs->atomic_post_disable) {
 			struct drm_bridge_state *old_bridge_state;
 
 			old_bridge_state =
@@ -732,7 +710,7 @@  void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
 
 	encoder = bridge->encoder;
 	list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
-		if (iter->funcs->atomic_pre_enable) {
+		if (old_state && iter->funcs->atomic_pre_enable) {
 			struct drm_bridge_state *old_bridge_state;
 
 			old_bridge_state =