linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC.
@ 2019-07-25 11:05 Oleksandr Suvorov
  2019-07-25 11:05 ` [PATCH 1/1] drm/bridge: vga-dac: Fix detect of monitor connection Oleksandr Suvorov
  2019-07-25 11:32 ` [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC maxime.ripard
  0 siblings, 2 replies; 6+ messages in thread
From: Oleksandr Suvorov @ 2019-07-25 11:05 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: linux-kernel, dri-devel, Igor Opaniuk, stable, Marcel Ziswiler,
	maxime.ripard, Oleksandr Suvorov, Jonas Karlman, David Airlie,
	Jernej Skrabec, Laurent Pinchart, Daniel Vetter


Even in source code of this driver there is an author's description:
    /*
     * Even if we have an I2C bus, we can't assume that the cable
     * is disconnected if drm_probe_ddc fails. Some cables don't
     * wire the DDC pins, or the I2C bus might not be working at
     * all.
     */

That's true. DDC and VGA channels are independent, and therefore
we cannot decide whether the monitor is connected or not,
depending on the information from the DDC.

So the monitor should always be considered connected.
Thus there is no reason to use connector detect callback for this
driver: DRM sub-system considers monitor always connected if there
is no detect() callback registered with drm_connector_init().

How to reproduce the bug:
* setup: i.MX8QXP, LCDIF video module + gpu/drm/mxsfb driver,
  adv712x VGA DAC + dumb-vga-dac driver, VGA-connector w/o DDC;
* try to use drivers chain mxsfb-drm + dumb-vga-dac;
* any DRM applications consider the monitor is not connected:
  ===========
  $ weston-start
  $ cat /var/log/weston.log
      ...
      DRM: head 'VGA-1' found, connector 32 is disconnected.
      ...
  $ cat /sys/devices/platform/5a180000.lcdif/drm/card0/card0-VGA-1/status
  unknown
  ===========


Oleksandr Suvorov (1):
  drm/bridge: vga-dac: Fix detect of monitor connection

 drivers/gpu/drm/bridge/dumb-vga-dac.c | 18 ------------------
 1 file changed, 18 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/1] drm/bridge: vga-dac: Fix detect of monitor connection
  2019-07-25 11:05 [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC Oleksandr Suvorov
@ 2019-07-25 11:05 ` Oleksandr Suvorov
  2019-07-25 12:14   ` Daniel Vetter
  2019-07-25 11:32 ` [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC maxime.ripard
  1 sibling, 1 reply; 6+ messages in thread
From: Oleksandr Suvorov @ 2019-07-25 11:05 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: linux-kernel, dri-devel, Igor Opaniuk, stable, Marcel Ziswiler,
	maxime.ripard, Oleksandr Suvorov, Jonas Karlman, David Airlie,
	Jernej Skrabec, Laurent Pinchart, Daniel Vetter

DDC and VGA channels are independent, and therefore
we cannot decide whether the monitor is connected or not,
depending on the information from the DDC.

So the monitor should always be considered connected.
Thus there is no reason to use connector detect callback for this
driver.

Fixes DRM error of dumb monitor detection like:
...
DRM: head 'VGA-1' found, connector 32 is disconnected.
...

Cc: stable@vger.kernel.org
Fixes: 56fe8b6f4991 ("drm/bridge: Add RGB to VGA bridge support")
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
---

 drivers/gpu/drm/bridge/dumb-vga-dac.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c b/drivers/gpu/drm/bridge/dumb-vga-dac.c
index d32885b906ae..e37c19356d12 100644
--- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
+++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
@@ -73,25 +73,7 @@ static const struct drm_connector_helper_funcs dumb_vga_con_helper_funcs = {
 	.get_modes	= dumb_vga_get_modes,
 };
 
-static enum drm_connector_status
-dumb_vga_connector_detect(struct drm_connector *connector, bool force)
-{
-	struct dumb_vga *vga = drm_connector_to_dumb_vga(connector);
-
-	/*
-	 * Even if we have an I2C bus, we can't assume that the cable
-	 * is disconnected if drm_probe_ddc fails. Some cables don't
-	 * wire the DDC pins, or the I2C bus might not be working at
-	 * all.
-	 */
-	if (!IS_ERR(vga->ddc) && drm_probe_ddc(vga->ddc))
-		return connector_status_connected;
-
-	return connector_status_unknown;
-}
-
 static const struct drm_connector_funcs dumb_vga_con_funcs = {
-	.detect			= dumb_vga_connector_detect,
 	.fill_modes		= drm_helper_probe_single_connector_modes,
 	.destroy		= drm_connector_cleanup,
 	.reset			= drm_atomic_helper_connector_reset,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC.
  2019-07-25 11:05 [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC Oleksandr Suvorov
  2019-07-25 11:05 ` [PATCH 1/1] drm/bridge: vga-dac: Fix detect of monitor connection Oleksandr Suvorov
@ 2019-07-25 11:32 ` maxime.ripard
  2019-07-29 10:58   ` Oleksandr Suvorov
  1 sibling, 1 reply; 6+ messages in thread
From: maxime.ripard @ 2019-07-25 11:32 UTC (permalink / raw)
  To: Oleksandr Suvorov
  Cc: Andrzej Hajda, Neil Armstrong, linux-kernel, dri-devel,
	Igor Opaniuk, stable, Marcel Ziswiler, Jonas Karlman,
	David Airlie, Jernej Skrabec, Laurent Pinchart, Daniel Vetter

65;5603;1c
On Thu, Jul 25, 2019 at 11:05:23AM +0000, Oleksandr Suvorov wrote:
>
> Even in source code of this driver there is an author's description:
>     /*
>      * Even if we have an I2C bus, we can't assume that the cable
>      * is disconnected if drm_probe_ddc fails. Some cables don't
>      * wire the DDC pins, or the I2C bus might not be working at
>      * all.
>      */
>
> That's true. DDC and VGA channels are independent, and therefore
> we cannot decide whether the monitor is connected or not,
> depending on the information from the DDC.
>
> So the monitor should always be considered connected.

Well, no. Like you said, we cannot decided whether is connected or
not.

> Thus there is no reason to use connector detect callback for this
> driver: DRM sub-system considers monitor always connected if there
> is no detect() callback registered with drm_connector_init().
>
> How to reproduce the bug:
> * setup: i.MX8QXP, LCDIF video module + gpu/drm/mxsfb driver,
>   adv712x VGA DAC + dumb-vga-dac driver, VGA-connector w/o DDC;
> * try to use drivers chain mxsfb-drm + dumb-vga-dac;
> * any DRM applications consider the monitor is not connected:
>   ===========
>   $ weston-start
>   $ cat /var/log/weston.log
>       ...
>       DRM: head 'VGA-1' found, connector 32 is disconnected.
>       ...
>   $ cat /sys/devices/platform/5a180000.lcdif/drm/card0/card0-VGA-1/status
>   unknown

And that's exactly what's being reported here: we cannot decide if it
is connected or not, so it's unknown.

If weston chooses to ignore connectors that are in an unknown state,
I'd say it's weston's problem, since it's much broader than this
particular device.

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] drm/bridge: vga-dac: Fix detect of monitor connection
  2019-07-25 11:05 ` [PATCH 1/1] drm/bridge: vga-dac: Fix detect of monitor connection Oleksandr Suvorov
@ 2019-07-25 12:14   ` Daniel Vetter
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2019-07-25 12:14 UTC (permalink / raw)
  To: Oleksandr Suvorov
  Cc: Andrzej Hajda, Neil Armstrong, linux-kernel, dri-devel,
	Igor Opaniuk, stable, Marcel Ziswiler, maxime.ripard,
	Jonas Karlman, David Airlie, Jernej Skrabec, Laurent Pinchart,
	Daniel Vetter

On Thu, Jul 25, 2019 at 11:05:24AM +0000, Oleksandr Suvorov wrote:
> DDC and VGA channels are independent, and therefore
> we cannot decide whether the monitor is connected or not,
> depending on the information from the DDC.
> 
> So the monitor should always be considered connected.
> Thus there is no reason to use connector detect callback for this
> driver.
> 
> Fixes DRM error of dumb monitor detection like:
> ...
> DRM: head 'VGA-1' found, connector 32 is disconnected.
> ...
> 
> Cc: stable@vger.kernel.org
> Fixes: 56fe8b6f4991 ("drm/bridge: Add RGB to VGA bridge support")
> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>

Uh nope :-)

Yes VGA monitors are broken, but the way to fix that is to either override
that on the kernel cmdline, or in your userspace somewhere. Not hardcode
this in the kernel for everyone. Because not everyone does have a broken
VGA monitor, but if you do this _every_ desktop will try to light up that
broken monitor. Which leads to lots of bug reports and regressions.

This case is exactly what connector_status_unknown is meant for: The
kernel couldn't authoritatively figure out whether there is a monitor or
not. Userspace should/can try this into account for autoconfiguration.

Note a more proper fix would be to somehow wire up load detection. That
will work even for dumb VGA monitors, and e.g. i915 then gives you an
authoritative connector_status_disconnected if it could execute a load
detect cycle (not always possible on some hw) and there's no screen
detected with that.

Maybe we should document this better somewhere in docs? Would be great if
you can type a patch for this ...
-Daniel

> ---
> 
>  drivers/gpu/drm/bridge/dumb-vga-dac.c | 18 ------------------
>  1 file changed, 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c b/drivers/gpu/drm/bridge/dumb-vga-dac.c
> index d32885b906ae..e37c19356d12 100644
> --- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
> +++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
> @@ -73,25 +73,7 @@ static const struct drm_connector_helper_funcs dumb_vga_con_helper_funcs = {
>  	.get_modes	= dumb_vga_get_modes,
>  };
>  
> -static enum drm_connector_status
> -dumb_vga_connector_detect(struct drm_connector *connector, bool force)
> -{
> -	struct dumb_vga *vga = drm_connector_to_dumb_vga(connector);
> -
> -	/*
> -	 * Even if we have an I2C bus, we can't assume that the cable
> -	 * is disconnected if drm_probe_ddc fails. Some cables don't
> -	 * wire the DDC pins, or the I2C bus might not be working at
> -	 * all.
> -	 */
> -	if (!IS_ERR(vga->ddc) && drm_probe_ddc(vga->ddc))
> -		return connector_status_connected;
> -
> -	return connector_status_unknown;
> -}
> -
>  static const struct drm_connector_funcs dumb_vga_con_funcs = {
> -	.detect			= dumb_vga_connector_detect,
>  	.fill_modes		= drm_helper_probe_single_connector_modes,
>  	.destroy		= drm_connector_cleanup,
>  	.reset			= drm_atomic_helper_connector_reset,
> -- 
> 2.20.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC.
  2019-07-25 11:32 ` [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC maxime.ripard
@ 2019-07-29 10:58   ` Oleksandr Suvorov
  2019-07-29 22:03     ` Daniel Vetter
  0 siblings, 1 reply; 6+ messages in thread
From: Oleksandr Suvorov @ 2019-07-29 10:58 UTC (permalink / raw)
  To: maxime.ripard
  Cc: Andrzej Hajda, Neil Armstrong, linux-kernel, dri-devel,
	Igor Opaniuk, stable, Marcel Ziswiler, Jonas Karlman,
	David Airlie, Jernej Skrabec, Laurent Pinchart, Daniel Vetter,
	Suvorov Alexander

On Thu, Jul 25, 2019 at 5:41 PM maxime.ripard@free-electrons.com
<maxime.ripard@free-electrons.com> wrote:
>
> On Thu, Jul 25, 2019 at 11:05:23AM +0000, Oleksandr Suvorov wrote:
> >
> > Even in source code of this driver there is an author's description:
> >     /*
> >      * Even if we have an I2C bus, we can't assume that the cable
> >      * is disconnected if drm_probe_ddc fails. Some cables don't
> >      * wire the DDC pins, or the I2C bus might not be working at
> >      * all.
> >      */
> >
> > That's true. DDC and VGA channels are independent, and therefore
> > we cannot decide whether the monitor is connected or not,
> > depending on the information from the DDC.
> >
> > So the monitor should always be considered connected.
>
> Well, no. Like you said, we cannot decided whether is connected or
> not.

Maxime, thanks, I agree that's a bad solution.
But I still think we should be able to define the DT node of a device for
this driver to claim the connector is always connected.
Please see my following thoughts.

> > Thus there is no reason to use connector detect callback for this
> > driver: DRM sub-system considers monitor always connected if there
> > is no detect() callback registered with drm_connector_init().
> >
> > How to reproduce the bug:
> > * setup: i.MX8QXP, LCDIF video module + gpu/drm/mxsfb driver,
> >   adv712x VGA DAC + dumb-vga-dac driver, VGA-connector w/o DDC;
> > * try to use drivers chain mxsfb-drm + dumb-vga-dac;
> > * any DRM applications consider the monitor is not connected:
> >   ===========
> >   $ weston-start
> >   $ cat /var/log/weston.log
> >       ...
> >       DRM: head 'VGA-1' found, connector 32 is disconnected.
> >       ...
> >   $ cat /sys/devices/platform/5a180000.lcdif/drm/card0/card0-VGA-1/status
> >   unknown
>
> And that's exactly what's being reported here: we cannot decide if it
> is connected or not, so it's unknown.
>
> If weston chooses to ignore connectors that are in an unknown state,
> I'd say it's weston's problem, since it's much broader than this
> particular device.

If we look at the code of drm_probe_helper.c, we can see, the
drm_helper_probe_detect_ctx() assume the cable is connected if there is no
detect() callback registered.
...
                if (funcs->detect_ctx)
                         ret = funcs->detect_ctx(connector, &ctx, force);
                 else if (connector->funcs->detect)
                         ret = connector->funcs->detect(connector, force);
                 else
                         ret = connector_status_connected;
...

The driver dumb-vga-dac supports both DT configurations:
- with DDC channel, that allows us to detect if the cable is connected;
- without DDC channel. In this case, IMHO, the driver should behave
the same way as a
  connector driver without registered detect() callback.

So what about the patch like?

@@ -81,6 +81,13 @@ dumb_vga_connector_detect(struct drm_connector
*connector, bool force)
 {
        struct dumb_vga *vga = drm_connector_to_dumb_vga(connector);

+       /*
+        * If I2C bus for DDC is not defined, asume that the cable
+        * is always connected.
+        */
+       if (PTR_ERR(vga->ddc) == -ENODEV)
+               return connector_status_connected;
+
        /*
         * Even if we have an I2C bus, we can't assume that the cable
         * is disconnected if drm_probe_ddc fails. Some cables don't

-- 
Best regards
Oleksandr Suvorov

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
4800 (main line)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC.
  2019-07-29 10:58   ` Oleksandr Suvorov
@ 2019-07-29 22:03     ` Daniel Vetter
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2019-07-29 22:03 UTC (permalink / raw)
  To: Oleksandr Suvorov
  Cc: maxime.ripard, Andrzej Hajda, Neil Armstrong, linux-kernel,
	dri-devel, Igor Opaniuk, stable, Marcel Ziswiler, Jonas Karlman,
	David Airlie, Jernej Skrabec, Laurent Pinchart,
	Suvorov Alexander

On Mon, Jul 29, 2019 at 12:58 PM Oleksandr Suvorov
<oleksandr.suvorov@toradex.com> wrote:
>
> On Thu, Jul 25, 2019 at 5:41 PM maxime.ripard@free-electrons.com
> <maxime.ripard@free-electrons.com> wrote:
> >
> > On Thu, Jul 25, 2019 at 11:05:23AM +0000, Oleksandr Suvorov wrote:
> > >
> > > Even in source code of this driver there is an author's description:
> > >     /*
> > >      * Even if we have an I2C bus, we can't assume that the cable
> > >      * is disconnected if drm_probe_ddc fails. Some cables don't
> > >      * wire the DDC pins, or the I2C bus might not be working at
> > >      * all.
> > >      */
> > >
> > > That's true. DDC and VGA channels are independent, and therefore
> > > we cannot decide whether the monitor is connected or not,
> > > depending on the information from the DDC.
> > >
> > > So the monitor should always be considered connected.
> >
> > Well, no. Like you said, we cannot decided whether is connected or
> > not.
>
> Maxime, thanks, I agree that's a bad solution.
> But I still think we should be able to define the DT node of a device for
> this driver to claim the connector is always connected.
> Please see my following thoughts.
>
> > > Thus there is no reason to use connector detect callback for this
> > > driver: DRM sub-system considers monitor always connected if there
> > > is no detect() callback registered with drm_connector_init().
> > >
> > > How to reproduce the bug:
> > > * setup: i.MX8QXP, LCDIF video module + gpu/drm/mxsfb driver,
> > >   adv712x VGA DAC + dumb-vga-dac driver, VGA-connector w/o DDC;
> > > * try to use drivers chain mxsfb-drm + dumb-vga-dac;
> > > * any DRM applications consider the monitor is not connected:
> > >   ===========
> > >   $ weston-start
> > >   $ cat /var/log/weston.log
> > >       ...
> > >       DRM: head 'VGA-1' found, connector 32 is disconnected.
> > >       ...
> > >   $ cat /sys/devices/platform/5a180000.lcdif/drm/card0/card0-VGA-1/status
> > >   unknown
> >
> > And that's exactly what's being reported here: we cannot decide if it
> > is connected or not, so it's unknown.
> >
> > If weston chooses to ignore connectors that are in an unknown state,
> > I'd say it's weston's problem, since it's much broader than this
> > particular device.
>
> If we look at the code of drm_probe_helper.c, we can see, the
> drm_helper_probe_detect_ctx() assume the cable is connected if there is no
> detect() callback registered.
> ...
>                 if (funcs->detect_ctx)
>                          ret = funcs->detect_ctx(connector, &ctx, force);
>                  else if (connector->funcs->detect)
>                          ret = connector->funcs->detect(connector, force);
>                  else
>                          ret = connector_status_connected;
> ...
>
> The driver dumb-vga-dac supports both DT configurations:
> - with DDC channel, that allows us to detect if the cable is connected;
> - without DDC channel. In this case, IMHO, the driver should behave
> the same way as a
>   connector driver without registered detect() callback.
>
> So what about the patch like?

Still no. The "always connected" case is for outputs which are
physically always connected and typing a dummy function which would
unconditionally return connected would be silly. Like built-in panels.
This is _not_ for external screens.
-Daniel

>
> @@ -81,6 +81,13 @@ dumb_vga_connector_detect(struct drm_connector
> *connector, bool force)
>  {
>         struct dumb_vga *vga = drm_connector_to_dumb_vga(connector);
>
> +       /*
> +        * If I2C bus for DDC is not defined, asume that the cable
> +        * is always connected.
> +        */
> +       if (PTR_ERR(vga->ddc) == -ENODEV)
> +               return connector_status_connected;
> +
>         /*
>          * Even if we have an I2C bus, we can't assume that the cable
>          * is disconnected if drm_probe_ddc fails. Some cables don't
>
> --
> Best regards
> Oleksandr Suvorov
>
> Toradex AG
> Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
> 4800 (main line)



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-29 22:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-25 11:05 [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC Oleksandr Suvorov
2019-07-25 11:05 ` [PATCH 1/1] drm/bridge: vga-dac: Fix detect of monitor connection Oleksandr Suvorov
2019-07-25 12:14   ` Daniel Vetter
2019-07-25 11:32 ` [PATCH 0/1] This patch fixes connection detection for monitors w/o DDC maxime.ripard
2019-07-29 10:58   ` Oleksandr Suvorov
2019-07-29 22:03     ` Daniel Vetter

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).