public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Peter Rosin <peda@axentia.se>
Cc: Martyn Welch <martyn.welch@collabora.co.uk>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	linux-samsung-soc@vger.kernel.org,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	linux-rockchip@lists.infradead.org, Kukjin Kim <kgene@kernel.org>,
	Peter Senna Tschudin <peter.senna@collabora.com>,
	Martin Donnelly <martin.donnelly@ge.com>,
	linux-arm-msm@vger.kernel.org, Jyri Sarha <jsarha@ti.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Vincent Abriou <vincent.abriou@st.com>,
	linux-arm-kernel@lists.infradead.org,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-mediatek@lists.infradead.org,
	freedreno@lists.freedesktop.org
Subject: Re: [PATCH v2 26/26] drm/bridge: establish a link between the bridge supplier and consumer
Date: Mon, 14 May 2018 18:28:28 +0200	[thread overview]
Message-ID: <20180514162828.GE28661@phenom.ffwll.local> (raw)
In-Reply-To: <c25f81e0-5b7b-c605-5b58-0ecc88830124@axentia.se>

On Fri, May 11, 2018 at 09:37:47AM +0200, Peter Rosin wrote:
> On 2018-05-10 10:10, Andrzej Hajda wrote:
> > On 04.05.2018 15:52, Peter Rosin wrote:
> >> If the bridge supplier is unbound, this will bring the bridge consumer
> >> down along with the bridge. Thus, there will no longer linger any
> >> dangling pointers from the bridge consumer (the drm_device) to some
> >> non-existent bridge supplier.
> >>
> >> Signed-off-by: Peter Rosin <peda@axentia.se>
> >> ---
> >>  drivers/gpu/drm/drm_bridge.c | 18 ++++++++++++++++++
> >>  include/drm/drm_bridge.h     |  2 ++
> >>  2 files changed, 20 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> >> index 78d186b6831b..0259f0a3ff27 100644
> >> --- a/drivers/gpu/drm/drm_bridge.c
> >> +++ b/drivers/gpu/drm/drm_bridge.c
> >> @@ -26,6 +26,7 @@
> >>  #include <linux/mutex.h>
> >>  
> >>  #include <drm/drm_bridge.h>
> >> +#include <drm/drm_device.h>
> >>  #include <drm/drm_encoder.h>
> >>  
> >>  #include "drm_crtc_internal.h"
> >> @@ -127,12 +128,25 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
> >>  	if (bridge->dev)
> >>  		return -EBUSY;
> >>  
> >> +	if (encoder->dev->dev != bridge->odev) {
> > 
> > I wonder why device_link_add does not handle this case (self dependency)
> > silently as noop, as it seems to be a correct behavior.
> 
> It's kind-of a silly corner-case though, so perfectly understandable
> that it isn't handled.
> 
> >> +		bridge->link = device_link_add(encoder->dev->dev,
> >> +					       bridge->odev, 0);
> >> +		if (!bridge->link) {
> >> +			dev_err(bridge->odev, "failed to link bridge to %s\n",
> >> +				dev_name(encoder->dev->dev));
> >> +			return -EINVAL;
> >> +		}
> >> +	}
> >> +
> >>  	bridge->dev = encoder->dev;
> >>  	bridge->encoder = encoder;
> >>  
> >>  	if (bridge->funcs->attach) {
> >>  		ret = bridge->funcs->attach(bridge);
> >>  		if (ret < 0) {
> >> +			if (bridge->link)
> >> +				device_link_del(bridge->link);
> >> +			bridge->link = NULL;
> >>  			bridge->dev = NULL;
> >>  			bridge->encoder = NULL;
> >>  			return ret;
> >> @@ -159,6 +173,10 @@ void drm_bridge_detach(struct drm_bridge *bridge)
> >>  	if (bridge->funcs->detach)
> >>  		bridge->funcs->detach(bridge);
> >>  
> >> +	if (bridge->link)
> >> +		device_link_del(bridge->link);
> >> +	bridge->link = NULL;
> >> +
> >>  	bridge->dev = NULL;
> >>  }
> >>  
> >> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> >> index b656e505d11e..804189c63a4c 100644
> >> --- a/include/drm/drm_bridge.h
> >> +++ b/include/drm/drm_bridge.h
> >> @@ -261,6 +261,7 @@ struct drm_bridge_timings {
> >>   * @list: to keep track of all added bridges
> >>   * @timings: the timing specification for the bridge, if any (may
> >>   * be NULL)
> >> + * @link: drm consumer <-> bridge supplier
> > 
> > Nitpick: "<->" suggests symmetry, maybe "device link from drm consumer
> > to the bridge" would be better.
> 
> I meant "<->" to indicate that the link is bidirectional, not that the
> relationship is in any way symmetric. I wasn't aware of any implication
> of a symmetric relationship when using "<->", do you have a reference?
> But I guess the different arrow notations in math are somewhat overloaded
> and that someone at some point must have used "<->" to indicate a
> symmetric relationship...

Yeah I agree with Andrzej here, for me <-> implies a symmetric
relationship. Spelling it out like Andrzej suggested sounds like the
better idea.
-Daniel

> 
> > Anyway:
> > Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
> 
> Thanks!
> 
> Cheers,
> Peter
> 
> >  --
> > Regards
> > Andrzej
> > 
> >>   * @funcs: control functions
> >>   * @driver_private: pointer to the bridge driver's internal context
> >>   */
> >> @@ -271,6 +272,7 @@ struct drm_bridge {
> >>  	struct drm_bridge *next;
> >>  	struct list_head list;
> >>  	const struct drm_bridge_timings *timings;
> >> +	struct device_link *link;
> >>  
> >>  	const struct drm_bridge_funcs *funcs;
> >>  	void *driver_private;
> > 
> > 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-05-14 16:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04 13:51 [PATCH v2 00/26] device link, bridge supplier <-> drm device Peter Rosin
     [not found] ` <20180504135212.26977-1-peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2018-05-04 13:51   ` [PATCH v2 01/26] drm/bridge: allow optionally specifying an owner .odev device Peter Rosin
2018-05-09 15:08     ` Andrzej Hajda
     [not found]       ` <4e92fdea-0609-0fff-0e3f-d9f78f596eb7-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2018-05-09 15:53         ` Peter Rosin
     [not found]           ` <4be4448e-763c-4832-f194-6b79afe87d08-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
2018-05-09 22:21             ` Peter Rosin
2018-05-10  7:00               ` Andrzej Hajda
2018-05-04 13:52   ` [PATCH v2 24/26] drm/bridge: remove the .of_node member Peter Rosin
2018-05-04 13:52   ` [PATCH v2 25/26] drm/bridge: require the owner .odev to be filled in on drm_bridge_add/attach Peter Rosin
2018-05-10  7:13     ` Andrzej Hajda
2018-05-04 13:52   ` [PATCH v2 26/26] drm/bridge: establish a link between the bridge supplier and consumer Peter Rosin
2018-05-07 12:59     ` Andrzej Hajda
     [not found]       ` <4cdcd215-8caf-e045-a478-f438f128c9f2-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2018-05-07 13:43         ` Peter Rosin
2018-05-08  9:03           ` Andrzej Hajda
2018-05-07 13:53         ` Daniel Vetter
     [not found]           ` <20180507135341.GI12521-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-05-08  6:36             ` Andrzej Hajda
2018-05-10  8:10     ` Andrzej Hajda
     [not found]       ` <a723ad4a-8caa-4ff5-d39d-52db98a56d7b-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2018-05-11  7:37         ` Peter Rosin
2018-05-14 16:28           ` Daniel Vetter [this message]
     [not found]             ` <20180514162828.GE28661-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-05-14 20:40               ` Peter Rosin
     [not found]             ` <73fa1ca3-28e4-96c5-1fc6-23e9c0cebb49@axentia.se>
2018-05-15 10:22               ` Daniel Vetter
     [not found]                 ` <CAKMK7uECSUo5k6uG3-y+yKQTGxB3FfGcwzMT+ZP5uux2SbpfUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-05-15 11:09                   ` Peter Rosin
2018-05-16  9:31                     ` Daniel Vetter
2018-05-07 13:56 ` [PATCH v2 00/26] device link, bridge supplier <-> drm device Daniel Vetter
     [not found]   ` <20180507135601.GJ12521-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-05-07 14:09     ` Peter Rosin

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=20180514162828.GE28661@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=martin.donnelly@ge.com \
    --cc=martyn.welch@collabora.co.uk \
    --cc=matthias.bgg@gmail.com \
    --cc=peda@axentia.se \
    --cc=peter.senna@collabora.com \
    --cc=sw0312.kim@samsung.com \
    --cc=vincent.abriou@st.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