devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Armstrong <narmstrong@baylibre.com>
To: Boris Brezillon <boris.brezillon@collabora.com>,
	dri-devel@lists.freedesktop.org
Cc: Lucas Stach <l.stach@pengutronix.de>,
	Chris Healy <cphealy@gmail.com>,
	Andrey Smirnov <andrew.smirnov@gmail.com>,
	Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
	kernel@collabora.com, Daniel Vetter <daniel@ffwll.ch>,
	Inki Dae <inki.dae@samsung.com>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Rob Clark <robdclark@gmail.com>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@siol.net>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v3 07/21] drm/bridge: Make the bridge chain a double-linked list
Date: Tue, 5 Nov 2019 17:02:30 +0100	[thread overview]
Message-ID: <d41c745d-3ddb-db99-8d1b-81a39dbcde3e@baylibre.com> (raw)
In-Reply-To: <d0da3b19-62c9-bf1d-8a41-3a6a06b82fb0@baylibre.com>

Hi,


On 25/10/2019 15:29, Neil Armstrong wrote:
> On 23/10/2019 17:44, Boris Brezillon wrote:
>> So that each element in the chain can easily access its predecessor.
>> This will be needed to support bus format negotiation between elements
>> of the bridge chain.
>>
>> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
>> ---
>> Changes in v3:
>> * None
>>
>> Changes in v2:
>> * Adjust things to the "dummy encoder bridge" change (patch 2 in this
>>   series)
>> ---
>>  drivers/gpu/drm/drm_bridge.c  | 171 ++++++++++++++++++++++------------
>>  drivers/gpu/drm/drm_encoder.c |  16 +---
>>  include/drm/drm_bridge.h      |  12 ++-
>>  include/drm/drm_encoder.h     |   9 +-
>>  4 files changed, 135 insertions(+), 73 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
>> index 54c874493c57..c5cf8a9c4237 100644
>> --- a/drivers/gpu/drm/drm_bridge.c
>> +++ b/drivers/gpu/drm/drm_bridge.c

[...]

>>  
>> @@ -426,15 +471,23 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable);
>>  void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
>>  					struct drm_atomic_state *state)
>>  {
>> +	struct drm_encoder *encoder;
>> +	struct drm_bridge *iter;
>> +
>>  	if (!bridge)
>>  		return;
>>  
>> -	drm_atomic_bridge_chain_pre_enable(bridge->next, state);
>> +	encoder = bridge->encoder;
>> +	list_for_each_entry_reverse(iter, &bridge->encoder->bridge_chain,
>> +				    chain_node) {

This should use the encoder local variable in list_for_each_entry_reverse()

>> +		if (iter->funcs->atomic_pre_enable)
>> +			iter->funcs->atomic_pre_enable(iter, state);
>> +		else if (iter->funcs->pre_enable)
>> +			iter->funcs->pre_enable(iter);
>>  
>> -	if (bridge->funcs->atomic_pre_enable)
>> -		bridge->funcs->atomic_pre_enable(bridge, state);
>> -	else if (bridge->funcs->pre_enable)
>> -		bridge->funcs->pre_enable(bridge);
>> +		if (iter == bridge)
>> +			break;
>> +	}
>>  }
>>  EXPORT_SYMBOL(drm_atomic_bridge_chain_pre_enable);
>>  
>> @@ -453,15 +506,19 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_pre_enable);
>>  void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge,
>>  				    struct drm_atomic_state *state)
>>  {
>> +	struct drm_encoder *encoder;
>> +
>>  	if (!bridge)
>>  		return;
>>  
>> -	if (bridge->funcs->atomic_enable)
>> -		bridge->funcs->atomic_enable(bridge, state);
>> -	else if (bridge->funcs->enable)
>> -		bridge->funcs->enable(bridge);
>> -
>> -	drm_atomic_bridge_chain_enable(bridge->next, state);
>> +	encoder = bridge->encoder;
>> +	list_for_each_entry_from(bridge, &bridge->encoder->bridge_chain,
>> +				 chain_node) {

This should use encoder instead of bridge->encoder otherwise bridge will
change and bridge->encoder->bridge_chain won't be valid during the for_each and
cause the following :

[   79.082861] WARNING: CPU: 2 PID: 1999 at drivers/gpu/drm/drm_bridge.c:607 drm_atomic_bridge_chain_enable+0xac/0xc0
...
[   79.210153]  drm_atomic_bridge_chain_enable+0xac/0xc0
[   79.215156]  drm_atomic_helper_commit_modeset_enables+0x138/0x248
[   79.221190]  drm_atomic_helper_commit_tail_rpm+0x2c/0x78
[   79.226452]  commit_tail+0x50/0xc0
[   79.229815]  drm_atomic_helper_commit+0xe8/0x168
[   79.234386]  drm_atomic_commit+0x48/0x58
[   79.238269]  drm_client_modeset_commit_atomic.isra.15+0x184/0x220
[   79.244305]  drm_client_modeset_commit_force+0x64/0x1a0
[   79.249482]  drm_fb_helper_restore_fbdev_mode_unlocked+0x70/0xe8
[   79.255432]  drm_fbdev_client_restore+0x14/0x20
[   79.259920]  drm_client_dev_restore+0x80/0xd8
[   79.264231]  drm_lastclose+0x4c/0x58
[   79.267765]  drm_release+0xa8/0x178

>> +		if (bridge->funcs->atomic_enable)
>> +			bridge->funcs->atomic_enable(bridge, state);
>> +		else if (bridge->funcs->enable)
>> +			bridge->funcs->enable(bridge);
>> +	}
>>  }
>>  EXPORT_SYMBOL(drm_atomic_bridge_chain_enable);
>>  
>> diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
>> index 4fe9e723e227..e555281f43d4 100644
>> --- a/drivers/gpu/drm/drm_encoder.c
>> +++ b/drivers/gpu/drm/drm_encoder.c
>> @@ -140,6 +140,7 @@ int drm_encoder_init(struct drm_device *dev,
>>  		goto out_put;
>>  	}
>>  
>> +	INIT_LIST_HEAD(&encoder->bridge_chain);
>>  	list_add_tail(&encoder->head, &dev->mode_config.encoder_list);
>>  	encoder->index = dev->mode_config.num_encoder++;
>>  
>> @@ -160,23 +161,16 @@ EXPORT_SYMBOL(drm_encoder_init);
>>  void drm_encoder_cleanup(struct drm_encoder *encoder)
>>  {
>>  	struct drm_device *dev = encoder->dev;
>> +	struct drm_bridge *bridge, *next;
>>  
>>  	/* Note that the encoder_list is considered to be static; should we
>>  	 * remove the drm_encoder at runtime we would have to decrement all
>>  	 * the indices on the drm_encoder after us in the encoder_list.
>>  	 */
>>  
>> -	if (encoder->bridge) {
>> -		struct drm_bridge *bridge;
>> -		struct drm_bridge *next;
>> -
>> -		bridge = drm_bridge_chain_get_first_bridge(encoder);
>> -		while (bridge) {
>> -			next = bridge->next;
>> -			drm_bridge_detach(bridge);
>> -			bridge = next;
>> -		}
>> -	}
>> +	list_for_each_entry_safe(bridge, next, &encoder->bridge_chain,
>> +				 chain_node)
>> +		drm_bridge_detach(bridge);
>>  
>>  	drm_mode_object_unregister(dev, &encoder->base);
>>  	kfree(encoder->name);
>> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
>> index 27eef63ce0ff..3ab16c95e59e 100644
>> --- a/include/drm/drm_bridge.h
>> +++ b/include/drm/drm_bridge.h
>> @@ -384,8 +384,8 @@ struct drm_bridge {
>>  	struct drm_device *dev;
>>  	/** @encoder: encoder to which this bridge is connected */
>>  	struct drm_encoder *encoder;
>> -	/** @next: the next bridge in the encoder chain */
>> -	struct drm_bridge *next;
>> +	/** @chain_node: used to form a bridge chain */
>> +	struct list_head chain_node;
>>  #ifdef CONFIG_OF
>>  	/** @of_node: device node pointer to the bridge */
>>  	struct device_node *of_node;
>> @@ -420,7 +420,10 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
>>  static inline struct drm_bridge *
>>  drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge)
>>  {
>> -	return bridge->next;
>> +	if (list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain))
>> +		return NULL;
>> +
>> +	return list_next_entry(bridge, chain_node);
>>  }
>>  
>>  /**
>> @@ -434,7 +437,8 @@ drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge)
>>  static inline struct drm_bridge *
>>  drm_bridge_chain_get_first_bridge(struct drm_encoder *encoder)
>>  {
>> -	return encoder->bridge;
>> +	return list_first_entry_or_null(&encoder->bridge_chain,
>> +					struct drm_bridge, chain_node);
>>  }
>>  
>>  bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
>> diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h
>> index f06164f44efe..9b3dde177c81 100644
>> --- a/include/drm/drm_encoder.h
>> +++ b/include/drm/drm_encoder.h
>> @@ -172,7 +172,14 @@ struct drm_encoder {
>>  	 * &drm_connector_state.crtc.
>>  	 */
>>  	struct drm_crtc *crtc;
>> -	struct drm_bridge *bridge;
>> +
>> +	/**
>> +	 * @bridge_chain: Bridges attached to this encoder. The first entry of
>> +	 * this list is always &drm_encoder.bridge. It may be followed by other
>> +	 * bridge entities.
>> +	 */
>> +	struct list_head bridge_chain;
>> +
>>  	const struct drm_encoder_funcs *funcs;
>>  	const struct drm_encoder_helper_funcs *helper_private;
>>  };
>>
> 
> Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
> 

With these fixed, you can keep my Reviewed-by

Neil

  reply	other threads:[~2019-11-05 16:02 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 15:44 [PATCH v3 00/21] drm: Add support for bus-format negotiation Boris Brezillon
2019-10-23 15:44 ` [PATCH v3 01/21] drm/vc4: Declare the DSI encoder as a bridge element Boris Brezillon
2019-11-24 10:01   ` Laurent Pinchart
2019-11-24 10:47     ` Boris Brezillon
2019-10-23 15:44 ` [PATCH v3 02/21] drm/exynos: Don't reset bridge->next Boris Brezillon
2019-10-28 12:19   ` Inki Dae
2019-10-23 15:44 ` [PATCH v3 03/21] drm/exynos: Declare the DSI encoder as a bridge element Boris Brezillon
2019-11-24 10:24   ` Laurent Pinchart
2019-11-24 13:17     ` Boris Brezillon
2019-11-24 13:28       ` Boris Brezillon
2019-11-24 14:02       ` Laurent Pinchart
2019-10-23 15:44 ` [PATCH v3 04/21] drm/bridge: Rename bridge helpers targeting a bridge chain Boris Brezillon
2019-10-25 13:26   ` Neil Armstrong
2019-11-24 10:28   ` Laurent Pinchart
2019-10-23 15:44 ` [PATCH v3 05/21] drm/bridge: Introduce drm_bridge_chain_get_next_bridge() Boris Brezillon
2019-10-25 13:27   ` Neil Armstrong
2019-11-24 10:33   ` Laurent Pinchart
2019-11-24 10:56     ` Boris Brezillon
2019-11-24 14:04       ` Laurent Pinchart
2019-10-23 15:44 ` [PATCH v3 06/21] drm: Stop accessing encoder->bridge directly Boris Brezillon
2019-10-25 13:28   ` Neil Armstrong
2019-11-24 10:39   ` Laurent Pinchart
2019-11-24 13:40     ` Boris Brezillon
2019-10-23 15:44 ` [PATCH v3 07/21] drm/bridge: Make the bridge chain a double-linked list Boris Brezillon
2019-10-25 13:29   ` Neil Armstrong
2019-11-05 16:02     ` Neil Armstrong [this message]
2019-11-24  7:48       ` Boris Brezillon
2019-11-24 13:57   ` Laurent Pinchart
2019-10-23 15:44 ` [PATCH v3 08/21] drm/bridge: Add the drm_for_each_bridge_in_chain() helper Boris Brezillon
2019-10-25 13:30   ` Neil Armstrong
2019-11-24 14:07   ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 09/21] drm/bridge: Add a drm_bridge_state object Boris Brezillon
2019-10-25 14:35   ` Neil Armstrong
2019-11-05 16:05   ` Neil Armstrong
2019-11-24  7:50     ` Boris Brezillon
2019-12-02 16:42   ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 10/21] drm/bridge: Clarify the atomic enable/disable hooks semantics Boris Brezillon
2019-10-25 14:33   ` Neil Armstrong
2019-12-02 16:50   ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 11/21] drm/bridge: Patch atomic hooks to take a drm_bridge_state Boris Brezillon
2019-12-02 16:57   ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 12/21] drm/bridge: Add an ->atomic_check() hook Boris Brezillon
2019-10-25 14:35   ` Neil Armstrong
2019-12-02 17:03   ` Laurent Pinchart
2019-12-03 10:11     ` Boris Brezillon
2019-12-03 10:15       ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 13/21] drm/bridge: Add the drm_bridge_chain_get_prev_bridge() helper Boris Brezillon
2019-10-25 14:34   ` Neil Armstrong
2019-12-02 17:05   ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 14/21] drm/bridge: Add the necessary bits to support bus format negotiation Boris Brezillon
2019-12-03 10:03   ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 15/21] drm/imx: pd: Use bus format/flags provided by the bridge when available Boris Brezillon
2019-12-03 13:50   ` Philipp Zabel
2019-10-23 15:45 ` [PATCH v3 16/21] drm/bridge: lvds-encoder: Implement basic bus format negotiation Boris Brezillon
2019-12-03 10:14   ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 17/21] dt-bindings: display: bridge: lvds-transmitter: Add new props Boris Brezillon
2019-10-25 19:57   ` Rob Herring
2019-10-31 13:04     ` Boris Brezillon
2019-12-02 17:11   ` Laurent Pinchart
2019-12-03 12:38     ` Boris Brezillon
2019-12-03 13:22       ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 18/21] drm/bridge: panel: Propage bus format/flags Boris Brezillon
2019-12-03 10:17   ` Laurent Pinchart
2020-01-22  9:27     ` Boris Brezillon
2019-10-23 15:45 ` [PATCH v3 19/21] drm/panel: simple: Add support for Toshiba LTA089AC29000 panel Boris Brezillon
2019-12-02 17:17   ` Laurent Pinchart
2019-12-03 12:42     ` Boris Brezillon
2019-12-03 13:28       ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 20/21] dt-bindings: display: panel: Add the LTA089AC29000 variant Boris Brezillon
2019-10-25 19:58   ` Rob Herring
2019-12-02 17:19   ` Laurent Pinchart
2019-10-23 15:45 ` [PATCH v3 21/21] ARM: dts: imx: imx51-zii-rdu1: Fix the display pipeline definition Boris Brezillon
2019-10-24 11:27 ` [PATCH v3 00/21] drm: Add support for bus-format negotiation Neil Armstrong
2019-10-24 13:22   ` Boris Brezillon
2019-11-24  0:46 ` Ezequiel Garcia
2019-11-24  7:32   ` Boris Brezillon
2019-11-24  9:34     ` Ezequiel Garcia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d41c745d-3ddb-db99-8d1b-81a39dbcde3e@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=andrew.smirnov@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=cphealy@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=jernej.skrabec@siol.net \
    --cc=jonas@kwiboo.se \
    --cc=jy0922.shim@samsung.com \
    --cc=kernel@collabora.com \
    --cc=kyungmin.park@samsung.com \
    --cc=l.stach@pengutronix.de \
    --cc=mark.rutland@arm.com \
    --cc=nikita.yoush@cogentembedded.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robdclark@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=sw0312.kim@samsung.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).