Re: [PATCH RFC 11/19] drm/bridge: Patch atomic hooks to take a drm_bridge_state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Boris,

Thank you for the patch.

On Thu, Aug 08, 2019 at 05:11:42PM +0200, Boris Brezillon wrote:
> Instead of a drm_atomic_state. The only driver implementing those hooks
> is patched too.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
> ---
>  .../drm/bridge/analogix/analogix_dp_core.c    | 12 ++--
>  drivers/gpu/drm/drm_bridge.c                  | 57 +++++++++++++++----
>  include/drm/drm_bridge.h                      |  8 +--
>  3 files changed, 57 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index b096a7a75c14..02b9ee0e4f7a 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1290,8 +1290,9 @@ struct drm_crtc *analogix_dp_get_new_crtc(struct analogix_dp_device *dp,
>  }
>  
>  static void analogix_dp_bridge_atomic_pre_enable(struct drm_bridge *bridge,
> -						 struct drm_atomic_state *state)
> +						 struct drm_bridge_state *bstate)
>  {
> +	struct drm_atomic_state *state = bstate->base.state;
>  	struct analogix_dp_device *dp = bridge->driver_private;
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *old_crtc_state;
> @@ -1367,8 +1368,9 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp)
>  }
>  
>  static void analogix_dp_bridge_atomic_enable(struct drm_bridge *bridge,
> -					     struct drm_atomic_state *state)
> +					     struct drm_bridge_state *bstate)
>  {
> +	struct drm_atomic_state *state = bstate->base.state;
>  	struct analogix_dp_device *dp = bridge->driver_private;
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *old_crtc_state;
> @@ -1441,8 +1443,9 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)
>  }
>  
>  static void analogix_dp_bridge_atomic_disable(struct drm_bridge *bridge,
> -					      struct drm_atomic_state *state)
> +					      struct drm_bridge_state *bstate)
>  {
> +	struct drm_atomic_state *state = bstate->base.state;
>  	struct analogix_dp_device *dp = bridge->driver_private;
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *new_crtc_state = NULL;
> @@ -1465,8 +1468,9 @@ static void analogix_dp_bridge_atomic_disable(struct drm_bridge *bridge,
>  
>  static
>  void analogix_dp_bridge_atomic_post_disable(struct drm_bridge *bridge,
> -					    struct drm_atomic_state *state)
> +					    struct drm_bridge_state *bstate)
>  {
> +	struct drm_atomic_state *state = bstate->base.state;
>  	struct analogix_dp_device *dp = bridge->driver_private;
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *new_crtc_state;
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 0280da6be1e6..0528ca941855 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -467,10 +467,18 @@ void drm_atomic_bridge_chain_disable(struct drm_encoder *encoder,
>  
>  	list_for_each_entry_reverse(bridge, &encoder->bridge_chain,
>  				    chain_node) {
> -		if (bridge->funcs->atomic_disable)
> -			bridge->funcs->atomic_disable(bridge, state);
> -		else if (bridge->funcs->disable)
> +		if (bridge->funcs->atomic_disable) {
> +			struct drm_bridge_state *bridge_state;
> +
> +			bridge_state = drm_atomic_get_old_bridge_state(state,
> +								       bridge);
> +			if (WARN_ON(!bridge_state))
> +				return;
> +
> +			bridge->funcs->atomic_disable(bridge, bridge_state);
> +		} else if (bridge->funcs->disable) {
>  			bridge->funcs->disable(bridge);
> +		}
>  	}
>  }
>  EXPORT_SYMBOL(drm_atomic_bridge_chain_disable);
> @@ -492,10 +500,19 @@ void drm_atomic_bridge_chain_post_disable(struct drm_encoder *encoder,
>  	struct drm_bridge *bridge;
>  
>  	list_for_each_entry(bridge, &encoder->bridge_chain, chain_node) {
> -		if (bridge->funcs->atomic_post_disable)
> -			bridge->funcs->atomic_post_disable(bridge, state);
> -		else if (bridge->funcs->post_disable)
> +		if (bridge->funcs->atomic_post_disable) {
> +			struct drm_bridge_state *bridge_state;
> +
> +			bridge_state = drm_atomic_get_old_bridge_state(state,
> +								       bridge);
> +			if (WARN_ON(!bridge_state))
> +				return;
> +
> +			bridge->funcs->atomic_post_disable(bridge,
> +							   bridge_state);
> +		} else if (bridge->funcs->post_disable) {
>  			bridge->funcs->post_disable(bridge);
> +		}
>  	}
>  }
>  EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable);
> @@ -518,10 +535,18 @@ void drm_atomic_bridge_chain_pre_enable(struct drm_encoder *encoder,
>  
>  	list_for_each_entry_reverse(bridge, &encoder->bridge_chain,
>  				    chain_node) {
> -		if (bridge->funcs->atomic_pre_enable)
> -			bridge->funcs->atomic_pre_enable(bridge, state);
> -		else if (bridge->funcs->pre_enable)
> +		if (bridge->funcs->atomic_pre_enable) {
> +			struct drm_bridge_state *bridge_state;
> +
> +			bridge_state = drm_atomic_get_new_bridge_state(state,
> +								       bridge);

Shouldn't you get the old state here ? The new state in commit-related
operations is supposed to be obtained from the object itself, and the
old state is passed to the function. See how the CRTC and encoder
.atomic_enable() are called in drm_atomic_helper_commit_modeset_enables
(drm_atomic_helper.c) for instance.

You should update the documentation of the bridge atomic operations to
makes this explicit. The documentation of the bridge helpers
(drm_atomic_bridge_enable() & co.) is also misleading, they get passed
the old state, while the documentation states "atomic state being
committed". I think you should rename all those state parameters to
old_state to make this clearer.

Last but not least, the implementation in the analogix bridge driver
seems to expect the new state, so I think it's buggy.

> +			if (WARN_ON(!bridge_state))
> +				return;
> +
> +			bridge->funcs->atomic_pre_enable(bridge, bridge_state);
> +		} else if (bridge->funcs->pre_enable) {
>  			bridge->funcs->pre_enable(bridge);
> +		}
>  	}
>  }
>  EXPORT_SYMBOL(drm_atomic_bridge_chain_pre_enable);
> @@ -542,10 +567,18 @@ void drm_atomic_bridge_chain_enable(struct drm_encoder *encoder,
>  	struct drm_bridge *bridge;
>  
>  	list_for_each_entry(bridge, &encoder->bridge_chain, chain_node) {
> -		if (bridge->funcs->atomic_enable)
> -			bridge->funcs->atomic_enable(bridge, state);
> -		else if (bridge->funcs->enable)
> +		if (bridge->funcs->atomic_enable) {
> +			struct drm_bridge_state *bridge_state;
> +
> +			bridge_state = drm_atomic_get_new_bridge_state(state,
> +								       bridge);
> +			if (WARN_ON(!bridge_state))
> +				return;
> +
> +			bridge->funcs->atomic_enable(bridge, bridge_state);
> +		} else if (bridge->funcs->enable) {
>  			bridge->funcs->enable(bridge);
> +		}
>  	}
>  }
>  EXPORT_SYMBOL(drm_atomic_bridge_chain_enable);
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index 8ca25d266d0c..9383b4e4b853 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -280,7 +280,7 @@ struct drm_bridge_funcs {
>  	 * The @atomic_pre_enable callback is optional.
>  	 */
>  	void (*atomic_pre_enable)(struct drm_bridge *bridge,
> -				  struct drm_atomic_state *state);
> +				  struct drm_bridge_state *state);
>  
>  	/**
>  	 * @atomic_enable:
> @@ -305,7 +305,7 @@ struct drm_bridge_funcs {
>  	 * The enable callback is optional.
>  	 */
>  	void (*atomic_enable)(struct drm_bridge *bridge,
> -			      struct drm_atomic_state *state);
> +			      struct drm_bridge_state *state);
>  	/**
>  	 * @atomic_disable:
>  	 *
> @@ -328,7 +328,7 @@ struct drm_bridge_funcs {
>  	 * The disable callback is optional.
>  	 */
>  	void (*atomic_disable)(struct drm_bridge *bridge,
> -			       struct drm_atomic_state *state);
> +			       struct drm_bridge_state *state);
>  
>  	/**
>  	 * @atomic_post_disable:
> @@ -354,7 +354,7 @@ struct drm_bridge_funcs {
>  	 * The post_disable callback is optional.
>  	 */
>  	void (*atomic_post_disable)(struct drm_bridge *bridge,
> -				    struct drm_atomic_state *state);
> +				    struct drm_bridge_state *state);
>  
>  	/**
>  	 * @atomic_duplicate_state:

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux