All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Stone <daniel@fooishbar.org>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	linux-amarula <linux-amarula@amarulasolutions.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Michael Nazzareno Trimarchi <michael@amarulasolutions.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Maxime Ripard <maxime@cerno.tech>
Subject: Re: DRM Master ignoring hotplug event during display switching (QT)
Date: Thu, 31 Mar 2022 00:11:38 +0100	[thread overview]
Message-ID: <CAPj87rO7a=NbarOyZp1pE=19Lf2aGjWu7sru-eHwGjX0fpN+-A@mail.gmail.com> (raw)
In-Reply-To: <YkSzrvnto3WEJr04@phenom.ffwll.local>

Hi,

On Wed, 30 Mar 2022 at 20:47, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Mar 31, 2022 at 12:14:31AM +0530, Jagan Teki wrote:
> > Does it mean the userspace knows when to disconnect and connect the
> > LVDS or HDMI? What if display-switch ISR will disconnect LVDS and
> > connect HDMI when HPD is On and connect LVDS and disconnect HDMI when
> > HDP is Off of-course it makes only one enable at a time.

Don't do that. :)

Be fully clear and explicit to userspace. Declare that there are
multiple connectors (one LVDS, one HDMI), with different backing
encoders as well. Declare their connection status appropriately, and
send hotplug events when it changes.

It is the responsibility of userspace to listen to these events, check
the status, and react accordingly. In the absence of userspace, fbcon
pretends to be userspace and tries to do the right thing.

> If your QT app directly uses kms, but doesn't handle hotplugs, then yes
> nothing at all happens. But that's just a userspace bug, not a kernel bug,
> and we really should _not_ work around random userspace issues like this
> in the kernel.
>
> Actually we cannot, because doing so would upset real kms compositors,
> since the kernel doing funny stuff underneath it will at best confuse it.
> And it some cases it resulted in crashes.

FWIW, this is not because userspace sucks and can't handle corner
cases; it's because hotplug is an unfixable race condition. The
correct way to handle this is eventual consistency; you make the
previous connections a zombie (allow them to continue even if they are
no longer alive), tell userspace that the connections have changed,
and trust that it will make the appropriate changes.

> > Does it mean to initialize to encoder instances and start attaching
> > those to respective bridge pipelines?
>
> I haven't checked, but I think it's not possible to change the bridge
> chaining after drm_dev_register is called due to locking.
>
> So doing bridge attach/detach from the hotplug handler is a no-go. The
> bridges need to be set up at driver load.
>
> Also with this design each bridge chain has its own drm_connector (HDMI
> and LVDS, if I got you right). But that's just how bridges work.

Yep.

> > Can you link some references in the source tree for it to make a quick check?
>
> See the atomic_best_encoder callback, doc link here:
>
> https://dri.freedesktop.org/docs/drm/gpu/drm-kms-helpers.html?highlight=atomic_best_encoder#c.drm_connector_helper_funcs
>
> Although thinking about this you should have only 1 encoder for each
> drm_connector (if you go with separate connector for hdmi and lvds), and
> in that case the atomic helpers will take care of everything for you. Well
> except making sure that only one encoder of the two is enabled at the same
> time.

Yep again. But that's fine: declare one DRM connector for each
physical connector, only ever report one connector (and thus encoder)
connected at a time, and things will work.

Any userspace which tries to light up an output reported as
'disconnected' will expect that it will not work. Any userspace which
does not react to hotplug events cannot work with outputs which are
being hotplugged. And that's OK. You don't need to solve this with
elaborate workarounds in your drivers, you just need to give userspace
all the information it needs to make the right decisions, and then fix
it if it doesn't.

Cheers,
Daniel

  reply	other threads:[~2022-03-30 23:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 18:08 DRM Master ignoring hotplug event during display switching (QT) Jagan Teki
2022-03-30  8:52 ` Maxime Ripard
2022-03-30  9:11   ` Jagan Teki
2022-03-30  9:57   ` Daniel Vetter
2022-03-30 18:44     ` Jagan Teki
2022-03-30 19:46       ` Daniel Vetter
2022-03-30 23:11         ` Daniel Stone [this message]
2022-06-02 15:43     ` Jagan Teki
2022-06-07 14:34       ` Daniel Vetter
2022-06-07 17:33         ` Jagan Teki
2022-06-08 15:41           ` Daniel Vetter
2022-06-08 15:42             ` Daniel Vetter

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='CAPj87rO7a=NbarOyZp1pE=19Lf2aGjWu7sru-eHwGjX0fpN+-A@mail.gmail.com' \
    --to=daniel@fooishbar.org \
    --cc=a.hajda@samsung.com \
    --cc=daniel@ffwll.ch \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jagan@amarulasolutions.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=maxime@cerno.tech \
    --cc=michael@amarulasolutions.com \
    --cc=narmstrong@baylibre.com \
    --cc=sam@ravnborg.org \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.