dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Archit Taneja <architt@codeaurora.org>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	Alison Wang <alison.wang@freescale.com>,
	Jingoo Han <jingoohan1@gmail.com>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Xinwei Kong <kong.kongxinwei@hisilicon.com>,
	dri-devel@lists.freedesktop.org,
	linux-renesas-soc@vger.kernel.org,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Xinliang Liu <z.liuxinliang@hisilicon.com>,
	Chen Feng <puck.chen@hisilicon.com>,
	Rongrong Zou <zourongrong@gmail.com>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Vincent Abriou <vincent.abriou@st.com>
Subject: Re: [PATCH v3 03/13] drm: bridge: Link encoder and bridge in core code
Date: Wed, 30 Nov 2016 13:05:46 +0200	[thread overview]
Message-ID: <2651171.INF8CSizt8@avalon> (raw)
In-Reply-To: <3e8816d8-d461-d010-bff8-a38011e24a96@codeaurora.org>

Hi Archit,

On Wednesday 30 Nov 2016 16:30:53 Archit Taneja wrote:
> On 11/30/2016 03:53 PM, Laurent Pinchart wrote:
> > On Wednesday 30 Nov 2016 10:35:02 Archit Taneja wrote:
> >> On 11/29/2016 11:27 PM, Laurent Pinchart wrote:
> >>> On Tuesday 29 Nov 2016 15:57:06 Archit Taneja wrote:
> >>>> On 11/29/2016 02:34 PM, Laurent Pinchart wrote:
> >>>>> Instead of linking encoders and bridges in every driver (and getting
> >>>>> it wrong half of the time, as many drivers forget to set the
> >>>>> drm_bridge encoder pointer), do so in core code. The
> >>>>> drm_bridge_attach() function needs the encoder and optional previous
> >>>>> bridge to perform that task, update all the callers.
> >>>>> 
> >>>>> Signed-off-by: Laurent Pinchart
> >>>>> <laurent.pinchart+renesas@ideasonboard.com>
> >>>>> ---

[snip]

> >>>> I think we could derive previous from the encoder itself. Something
> >>>> like:
> >>>>
> >>>> 	previous = encoder->bridge;
> >>>> 	while (previous && previous->next)
> >>>> 		previous = previous->next;
> >>> 
> >>> That's a very good point. It would however prevent us from catching
> >>> drivers that attach bridges in the wrong order, which the !previous->dev
> >>> currently allows us to do (and it should be turned into a WARN_ON as
> >>> Daniel proposed).
> >> 
> >> With the simpler API, I don't think we will ever hit the case of
> >> !previous->dev. The previous bridge (if it exists) in the chain would
> >> already have a dev attached to it. In other words, we would remove the
> >> risk of the chance of the 'previous' bridge being unattached.
> >> 
> >> I'm a bit unclear about what you mean about the order part. If a kms
> >> driver
> >> wants to create a chain: encoder->bridge1->bridge2, it should ideally do:
> >> 
> >> drm_bridge_attach(encoder, bridge1, NULL);
> >> drm_bridge_attach(encoder, bridge2, bridge1);
> > 
> > Correct.
> > 
> >> We can't do much if the kms driver does the opposite:
> >> 
> >> drm_bridge_attach(encoder, bridge2, NULL);
> >> drm_bridge_attach(encoder, bridge2, bridge1);
> > 
> > That would certainly be a very stupid thing for a driver to do :-) The
> > problem that we could catch with my current proposal is
> > 
> > drm_bridge_attach(encoder, bridge2, bridge1);
> > ...
> > drm_bridge_attach(encoder, bridge1, NULL);
> > 
> > which I expect to happen from time to time as the two bridge can be
> > attached through separate code paths sometimes a bit difficult to trace.
> > It's not a big deal though, you could convince me that the advantages of
> > a simpler API exceed its drawbacks.
> 
> Having no 'previous' argument would prevent the possibility of this
> altogether, won't it?
> 
> With no 'previous' arg in the API, the driver can only do:
> 
> drm_bridge_attach(encoder, bridge1);
> drm_bridge_attach(encoder, bridge2);
> 
> or
> 
> drm_bridge_attach(encoder, bridge2);
> drm_bridge_attach(encoder, bridge1);

Correct.

> For the latter, we can't do much as discussed above.

Except that with the currently proposed API the code would be

drm_bridge_attach(encoder, bridge2, bridge1);
drm_bridge_attach(encoder, bridge1, NULL);

(correct case)

or

drm_bridge_attach(encoder, bridge2, bridge1);
drm_bridge_attach(encoder, bridge1, NULL);

(incorrect case)

The second one could be caught by the drm_bridge_attach() function as bridge1-
>dev will be NULL when attaching bridge2 in the incorrect case.

-- 
Regards,

Laurent Pinchart

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

  reply	other threads:[~2016-11-30 11:05 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29  9:04 [PATCH v3 00/13] R-Car DU: Use drm bridge API Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 01/13] drm: Don't include <drm/drm_encoder.h> in <drm/drm_crtc.h> Laurent Pinchart
2016-11-29  9:30   ` Daniel Vetter
2016-11-29  9:37     ` Laurent Pinchart
2016-12-02 21:21   ` Sinclair Yeh
2016-11-29  9:04 ` [PATCH v3 02/13] drm: Fix compilation warning caused by static inline forward declaration Laurent Pinchart
2016-11-29  9:31   ` Daniel Vetter
2016-11-29  9:04 ` [PATCH v3 03/13] drm: bridge: Link encoder and bridge in core code Laurent Pinchart
2016-11-29  9:35   ` Daniel Vetter
2016-11-29  9:43     ` Laurent Pinchart
2016-11-29 10:05       ` Daniel Vetter
2016-11-29 18:02         ` Laurent Pinchart
2016-11-29 18:51           ` Laurent Pinchart
2016-11-29 10:27   ` Archit Taneja
2016-11-29 17:57     ` Laurent Pinchart
2016-11-30  5:05       ` Archit Taneja
2016-11-30 10:23         ` Laurent Pinchart
2016-11-30 11:00           ` Archit Taneja
2016-11-30 11:05             ` Laurent Pinchart [this message]
2016-11-30 13:27               ` Archit Taneja
2016-11-29 17:01   ` Stefan Agner
2016-11-29 19:58   ` Boris Brezillon
2016-11-30 15:30   ` Vincent ABRIOU
2016-11-29  9:04 ` [PATCH v3 04/13] drm: bridge: Detach bridge from encoder at encoder cleanup time Laurent Pinchart
2016-11-29  9:48   ` Daniel Vetter
2016-11-29 19:00     ` Laurent Pinchart
2016-11-29 10:34   ` Archit Taneja
2016-11-29 18:56     ` Laurent Pinchart
2016-11-29 20:22       ` Daniel Vetter
2016-11-29 21:54         ` [PATCH] drm: bridge: Detach all bridges in a chain " Laurent Pinchart
     [not found] ` <1480410283-28698-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2016-11-29  9:04   ` [PATCH v3 05/13] drm: bridge: Add LVDS encoder DT bindings Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 06/13] drm: bridge: Add LVDS encoder driver Laurent Pinchart
2016-11-29  9:54   ` Daniel Vetter
2016-11-29 20:57     ` Laurent Pinchart
2017-01-04  1:33       ` Laurent Pinchart
2017-01-04  8:18       ` Daniel Vetter
2017-01-04 13:08         ` Laurent Pinchart
2017-01-04 13:51           ` Daniel Vetter
2017-01-04 14:33             ` Laurent Pinchart
2017-01-04 14:58               ` Daniel Vetter
2017-01-04 15:13                 ` Laurent Pinchart
2017-03-02  0:30                   ` Laurent Pinchart
2017-03-02  7:05                     ` Daniel Vetter
2016-11-29  9:04 ` [PATCH v3 07/13] drm: bridge: vga-dac: Add adi, adv7123 compatible string Laurent Pinchart
2016-11-29  9:50   ` [PATCH v3 07/13] drm: bridge: vga-dac: Add adi,adv7123 " Maxime Ripard
2016-11-29  9:04 ` [PATCH v3 08/13] drm: bridge: lvds-encoder: Add thine, thc63lvdm83d " Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 09/13] drm: Add encoder_type field to the drm_bridge structure Laurent Pinchart
2016-11-29  9:56   ` Daniel Vetter
2016-11-29  9:58     ` Laurent Pinchart
2016-11-29 10:27       ` Daniel Vetter
2016-11-29 17:49         ` Laurent Pinchart
2016-11-29 20:25           ` Daniel Vetter
2016-11-29 22:42             ` Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 10/13] drm: bridge: Set bridges' encoder type Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 11/13] drm: Set on-chip " Laurent Pinchart
2016-11-30 15:28   ` Vincent ABRIOU
2016-11-29  9:04 ` [PATCH v3 12/13] drm: rcar-du: Replace manual bridge implementation with DRM bridge Laurent Pinchart
2016-12-27 12:40   ` Geert Uytterhoeven
2016-11-29  9:04 ` [PATCH v3 13/13] drm: rcar-du: Initialize encoder's type based on the bridge's type Laurent Pinchart

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=2651171.INF8CSizt8@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=alison.wang@freescale.com \
    --cc=architt@codeaurora.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=puck.chen@hisilicon.com \
    --cc=sw0312.kim@samsung.com \
    --cc=vincent.abriou@st.com \
    --cc=z.liuxinliang@hisilicon.com \
    --cc=zourongrong@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).