linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] i915 HDMI connector status is connected after disconnection
@ 2018-07-05  7:58 Chris Chiu
  2018-07-05  8:58 ` Jani Nikula
  2018-07-05 14:40 ` Ville Syrjälä
  0 siblings, 2 replies; 15+ messages in thread
From: Chris Chiu @ 2018-07-05  7:58 UTC (permalink / raw)
  To: Jani Nikula, joonas.lahtinen, rodrigo.vivi, David Airlie
  Cc: intel-gfx, dri-devel, Linux Kernel, Linux Upstreaming Team

Hi,
    We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
the HDMI connector status stays connected even the HDMI cable has been
unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
checking the status while plug/unplug the HDMI, it shows
"disconnected" before plug in HDMI cable, then switch to "connected"
after plugin, and still stay "connected" after unplug. This would
cause the audio output path cannot correctly switch from HDMI to
internal speaker after unplugging the HDMI.

I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
present. The full "dmesg" log is here.
https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1

The HDMI cable is plugged in at ~26th second.
"[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
audio support"
then unplug the HDMI at ~73th second.
"[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
audio support"

Please advise what I can do to fix this. Thanks

Chris

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-05  7:58 [BUG] i915 HDMI connector status is connected after disconnection Chris Chiu
@ 2018-07-05  8:58 ` Jani Nikula
  2018-07-05  9:04   ` Chris Wilson
  2018-07-05 14:40 ` Ville Syrjälä
  1 sibling, 1 reply; 15+ messages in thread
From: Jani Nikula @ 2018-07-05  8:58 UTC (permalink / raw)
  To: Chris Chiu, joonas.lahtinen, rodrigo.vivi, David Airlie
  Cc: intel-gfx, dri-devel, Linux Kernel, Linux Upstreaming Team

On Thu, 05 Jul 2018, Chris Chiu <chiu@endlessm.com> wrote:
> Hi,
>     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
> i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
> the HDMI connector status stays connected even the HDMI cable has been
> unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
> checking the status while plug/unplug the HDMI, it shows
> "disconnected" before plug in HDMI cable, then switch to "connected"
> after plugin, and still stay "connected" after unplug. This would
> cause the audio output path cannot correctly switch from HDMI to
> internal speaker after unplugging the HDMI.
>
> I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
> present. The full "dmesg" log is here.
> https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>
> The HDMI cable is plugged in at ~26th second.
> "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
> audio support"
> then unplug the HDMI at ~73th second.
> "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
> audio support"
>
> Please advise what I can do to fix this. Thanks

Seems rather odd. Please file a bug report at [1]. Attach the dmesg on
the bug. Please attach 'xrandr --verbose' output before and after
unplugging on the bug.

Please also try drm-tip branch of [2].

BR,
Jani.


[1] https://bugs.freedesktop.org/enter_bug.cgi?product=DRI&component=DRM/Intel
[2] https://cgit.freedesktop.org/drm/drm-tip


-- 
Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-05  8:58 ` Jani Nikula
@ 2018-07-05  9:04   ` Chris Wilson
  2018-07-05  9:37     ` Jani Nikula
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Wilson @ 2018-07-05  9:04 UTC (permalink / raw)
  To: Chris Chiu, David Airlie, Jani Nikula, joonas.lahtinen, rodrigo.vivi
  Cc: intel-gfx, Linux Upstreaming Team, Linux Kernel, dri-devel

Quoting Jani Nikula (2018-07-05 09:58:57)
> On Thu, 05 Jul 2018, Chris Chiu <chiu@endlessm.com> wrote:
> > Hi,
> >     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
> > i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
> > the HDMI connector status stays connected even the HDMI cable has been
> > unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
> > checking the status while plug/unplug the HDMI, it shows
> > "disconnected" before plug in HDMI cable, then switch to "connected"
> > after plugin, and still stay "connected" after unplug. This would
> > cause the audio output path cannot correctly switch from HDMI to
> > internal speaker after unplugging the HDMI.
> >
> > I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
> > present. The full "dmesg" log is here.
> > https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
> >
> > The HDMI cable is plugged in at ~26th second.
> > "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
> > audio support"
> > then unplug the HDMI at ~73th second.
> > "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
> > audio support"
> >
> > Please advise what I can do to fix this. Thanks
> 
> Seems rather odd. Please file a bug report at [1]. Attach the dmesg on
> the bug. Please attach 'xrandr --verbose' output before and after
> unplugging on the bug.

Note that 'xrandr --verbose' will trigger a reprobe of the devices,
papering over any missed probe following hotplug.  I would suggest
preceding with 'xrandr --current --verbose'.

If all you are doing is checking status, you need to 'echo detect >
status' to trigger a reprobe after hotplug.
-Chris

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-05  9:04   ` Chris Wilson
@ 2018-07-05  9:37     ` Jani Nikula
  2018-07-05 13:02       ` Chris Chiu
  0 siblings, 1 reply; 15+ messages in thread
From: Jani Nikula @ 2018-07-05  9:37 UTC (permalink / raw)
  To: Chris Wilson, Chris Chiu, David Airlie, joonas.lahtinen, rodrigo.vivi
  Cc: intel-gfx, Linux Upstreaming Team, Linux Kernel, dri-devel

On Thu, 05 Jul 2018, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Quoting Jani Nikula (2018-07-05 09:58:57)
>> On Thu, 05 Jul 2018, Chris Chiu <chiu@endlessm.com> wrote:
>> > Hi,
>> >     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>> > i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>> > the HDMI connector status stays connected even the HDMI cable has been
>> > unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>> > checking the status while plug/unplug the HDMI, it shows
>> > "disconnected" before plug in HDMI cable, then switch to "connected"
>> > after plugin, and still stay "connected" after unplug. This would
>> > cause the audio output path cannot correctly switch from HDMI to
>> > internal speaker after unplugging the HDMI.
>> >
>> > I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>> > present. The full "dmesg" log is here.
>> > https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>> >
>> > The HDMI cable is plugged in at ~26th second.
>> > "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>> > audio support"
>> > then unplug the HDMI at ~73th second.
>> > "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>> > audio support"
>> >
>> > Please advise what I can do to fix this. Thanks
>> 
>> Seems rather odd. Please file a bug report at [1]. Attach the dmesg on
>> the bug. Please attach 'xrandr --verbose' output before and after
>> unplugging on the bug.
>
> Note that 'xrandr --verbose' will trigger a reprobe of the devices,
> papering over any missed probe following hotplug.  I would suggest
> preceding with 'xrandr --current --verbose'.
>
> If all you are doing is checking status, you need to 'echo detect >
> status' to trigger a reprobe after hotplug.

I was curious about the logs seemingly indicating that we can read the
EDID even after the user says they've unplugged the cable. The updating
of sysfs status attribute is another matter.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-05  9:37     ` Jani Nikula
@ 2018-07-05 13:02       ` Chris Chiu
  2018-07-05 13:18         ` Jani Nikula
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Chiu @ 2018-07-05 13:02 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Chris Wilson, David Airlie, joonas.lahtinen, rodrigo.vivi,
	intel-gfx, Linux Upstreaming Team, Linux Kernel, dri-devel

On Thu, Jul 5, 2018 at 5:37 PM, Jani Nikula <jani.nikula@intel.com> wrote:
> On Thu, 05 Jul 2018, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> Quoting Jani Nikula (2018-07-05 09:58:57)
>>> On Thu, 05 Jul 2018, Chris Chiu <chiu@endlessm.com> wrote:
>>> > Hi,
>>> >     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>>> > i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>>> > the HDMI connector status stays connected even the HDMI cable has been
>>> > unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>>> > checking the status while plug/unplug the HDMI, it shows
>>> > "disconnected" before plug in HDMI cable, then switch to "connected"
>>> > after plugin, and still stay "connected" after unplug. This would
>>> > cause the audio output path cannot correctly switch from HDMI to
>>> > internal speaker after unplugging the HDMI.
>>> >
>>> > I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>>> > present. The full "dmesg" log is here.
>>> > https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>>> >
>>> > The HDMI cable is plugged in at ~26th second.
>>> > "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>> > audio support"
>>> > then unplug the HDMI at ~73th second.
>>> > "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>> > audio support"
>>> >
>>> > Please advise what I can do to fix this. Thanks
>>>
>>> Seems rather odd. Please file a bug report at [1]. Attach the dmesg on
>>> the bug. Please attach 'xrandr --verbose' output before and after
>>> unplugging on the bug.
>>
>> Note that 'xrandr --verbose' will trigger a reprobe of the devices,
>> papering over any missed probe following hotplug.  I would suggest
>> preceding with 'xrandr --current --verbose'.
>>
>> If all you are doing is checking status, you need to 'echo detect >
>> status' to trigger a reprobe after hotplug.

It's interesting that reprobe triggered by 'xrandr --verbose' after unplug will
get the status back to "disconnected". But if I just do 'xrandr
--current --verbose'
before and after unplugging the cable, the output shows the same status
'connected'.

Here's the output of 'xrandr --verbose' before unplugging HDMI
https://gist.github.com/mschiu77/ea2e843078297f344596243418dcdaf7

And the output of 'xrandr --current --verbose' after unplugging the cable
https://gist.github.com/mschiu77/55756c0801046d49cd9bc3f87712b079

Then do 'xrandr --current --verbose' to trigger reprobe, the ouput
https://gist.github.com/mschiu77/72e6ab5438cbe64443300fc4fd71770c

It means that the HDMI unplug not detected by the driver?

Chris

>
> I was curious about the logs seemingly indicating that we can read the
> EDID even after the user says they've unplugged the cable. The updating
> of sysfs status attribute is another matter.
>
> BR,
> Jani.
>
>
> --
> Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-05 13:02       ` Chris Chiu
@ 2018-07-05 13:18         ` Jani Nikula
  2018-07-05 13:30           ` Chris Chiu
  0 siblings, 1 reply; 15+ messages in thread
From: Jani Nikula @ 2018-07-05 13:18 UTC (permalink / raw)
  To: Chris Chiu
  Cc: Chris Wilson, David Airlie, joonas.lahtinen, rodrigo.vivi,
	intel-gfx, Linux Upstreaming Team, Linux Kernel, dri-devel

On Thu, 05 Jul 2018, Chris Chiu <chiu@endlessm.com> wrote:
> On Thu, Jul 5, 2018 at 5:37 PM, Jani Nikula <jani.nikula@intel.com> wrote:
>> On Thu, 05 Jul 2018, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>>> Quoting Jani Nikula (2018-07-05 09:58:57)
>>>> On Thu, 05 Jul 2018, Chris Chiu <chiu@endlessm.com> wrote:
>>>> > Hi,
>>>> >     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>>>> > i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>>>> > the HDMI connector status stays connected even the HDMI cable has been
>>>> > unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>>>> > checking the status while plug/unplug the HDMI, it shows
>>>> > "disconnected" before plug in HDMI cable, then switch to "connected"
>>>> > after plugin, and still stay "connected" after unplug. This would
>>>> > cause the audio output path cannot correctly switch from HDMI to
>>>> > internal speaker after unplugging the HDMI.
>>>> >
>>>> > I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>>>> > present. The full "dmesg" log is here.
>>>> > https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>>>> >
>>>> > The HDMI cable is plugged in at ~26th second.
>>>> > "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>> > audio support"
>>>> > then unplug the HDMI at ~73th second.
>>>> > "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>> > audio support"
>>>> >
>>>> > Please advise what I can do to fix this. Thanks
>>>>
>>>> Seems rather odd. Please file a bug report at [1]. Attach the dmesg on
>>>> the bug. Please attach 'xrandr --verbose' output before and after
>>>> unplugging on the bug.
>>>
>>> Note that 'xrandr --verbose' will trigger a reprobe of the devices,
>>> papering over any missed probe following hotplug.  I would suggest
>>> preceding with 'xrandr --current --verbose'.
>>>
>>> If all you are doing is checking status, you need to 'echo detect >
>>> status' to trigger a reprobe after hotplug.
>
> It's interesting that reprobe triggered by 'xrandr --verbose' after unplug will
> get the status back to "disconnected". But if I just do 'xrandr
> --current --verbose'
> before and after unplugging the cable, the output shows the same status
> 'connected'.
>
> Here's the output of 'xrandr --verbose' before unplugging HDMI
> https://gist.github.com/mschiu77/ea2e843078297f344596243418dcdaf7
>
> And the output of 'xrandr --current --verbose' after unplugging the cable
> https://gist.github.com/mschiu77/55756c0801046d49cd9bc3f87712b079
>
> Then do 'xrandr --current --verbose' to trigger reprobe, the ouput
> https://gist.github.com/mschiu77/72e6ab5438cbe64443300fc4fd71770c
>
> It means that the HDMI unplug not detected by the driver?

Please do file the bug, and attach the information there. People go on
vacations, the pastebins will go away, and the memory of all of this
will fade.

BR,
Jani.

>
> Chris
>
>>
>> I was curious about the logs seemingly indicating that we can read the
>> EDID even after the user says they've unplugged the cable. The updating
>> of sysfs status attribute is another matter.
>>
>> BR,
>> Jani.
>>
>>
>> --
>> Jani Nikula, Intel Open Source Graphics Center

-- 
Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-05 13:18         ` Jani Nikula
@ 2018-07-05 13:30           ` Chris Chiu
  0 siblings, 0 replies; 15+ messages in thread
From: Chris Chiu @ 2018-07-05 13:30 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Chris Wilson, David Airlie, joonas.lahtinen, rodrigo.vivi,
	intel-gfx, Linux Upstreaming Team, Linux Kernel, dri-devel

On Thu, Jul 5, 2018 at 9:18 PM, Jani Nikula <jani.nikula@intel.com> wrote:
> On Thu, 05 Jul 2018, Chris Chiu <chiu@endlessm.com> wrote:
>> On Thu, Jul 5, 2018 at 5:37 PM, Jani Nikula <jani.nikula@intel.com> wrote:
>>> On Thu, 05 Jul 2018, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>>>> Quoting Jani Nikula (2018-07-05 09:58:57)
>>>>> On Thu, 05 Jul 2018, Chris Chiu <chiu@endlessm.com> wrote:
>>>>> > Hi,
>>>>> >     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>>>>> > i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>>>>> > the HDMI connector status stays connected even the HDMI cable has been
>>>>> > unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>>>>> > checking the status while plug/unplug the HDMI, it shows
>>>>> > "disconnected" before plug in HDMI cable, then switch to "connected"
>>>>> > after plugin, and still stay "connected" after unplug. This would
>>>>> > cause the audio output path cannot correctly switch from HDMI to
>>>>> > internal speaker after unplugging the HDMI.
>>>>> >
>>>>> > I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>>>>> > present. The full "dmesg" log is here.
>>>>> > https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>>>>> >
>>>>> > The HDMI cable is plugged in at ~26th second.
>>>>> > "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>>> > audio support"
>>>>> > then unplug the HDMI at ~73th second.
>>>>> > "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>>> > audio support"
>>>>> >
>>>>> > Please advise what I can do to fix this. Thanks
>>>>>
>>>>> Seems rather odd. Please file a bug report at [1]. Attach the dmesg on
>>>>> the bug. Please attach 'xrandr --verbose' output before and after
>>>>> unplugging on the bug.
>>>>
>>>> Note that 'xrandr --verbose' will trigger a reprobe of the devices,
>>>> papering over any missed probe following hotplug.  I would suggest
>>>> preceding with 'xrandr --current --verbose'.
>>>>
>>>> If all you are doing is checking status, you need to 'echo detect >
>>>> status' to trigger a reprobe after hotplug.
>>
>> It's interesting that reprobe triggered by 'xrandr --verbose' after unplug will
>> get the status back to "disconnected". But if I just do 'xrandr
>> --current --verbose'
>> before and after unplugging the cable, the output shows the same status
>> 'connected'.
>>
>> Here's the output of 'xrandr --verbose' before unplugging HDMI
>> https://gist.github.com/mschiu77/ea2e843078297f344596243418dcdaf7
>>
>> And the output of 'xrandr --current --verbose' after unplugging the cable
>> https://gist.github.com/mschiu77/55756c0801046d49cd9bc3f87712b079
>>
>> Then do 'xrandr --current --verbose' to trigger reprobe, the ouput
>> https://gist.github.com/mschiu77/72e6ab5438cbe64443300fc4fd71770c
>>
>> It means that the HDMI unplug not detected by the driver?
>
> Please do file the bug, and attach the information there. People go on
> vacations, the pastebins will go away, and the memory of all of this
> will fade.
>

Sorry that I missed to list here. I've reported the bug as follows
https://bugs.freedesktop.org/show_bug.cgi?id=107125

Thanks

> BR,
> Jani.
>
>>
>> Chris
>>
>>>
>>> I was curious about the logs seemingly indicating that we can read the
>>> EDID even after the user says they've unplugged the cable. The updating
>>> of sysfs status attribute is another matter.
>>>
>>> BR,
>>> Jani.
>>>
>>>
>>> --
>>> Jani Nikula, Intel Open Source Graphics Center
>
> --
> Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-05  7:58 [BUG] i915 HDMI connector status is connected after disconnection Chris Chiu
  2018-07-05  8:58 ` Jani Nikula
@ 2018-07-05 14:40 ` Ville Syrjälä
  2018-07-06  6:44   ` Chris Chiu
  1 sibling, 1 reply; 15+ messages in thread
From: Ville Syrjälä @ 2018-07-05 14:40 UTC (permalink / raw)
  To: Chris Chiu
  Cc: Jani Nikula, joonas.lahtinen, rodrigo.vivi, David Airlie,
	intel-gfx, Linux Upstreaming Team, Linux Kernel, dri-devel

On Thu, Jul 05, 2018 at 03:58:36PM +0800, Chris Chiu wrote:
> Hi,
>     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
> i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
> the HDMI connector status stays connected even the HDMI cable has been
> unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
> checking the status while plug/unplug the HDMI, it shows
> "disconnected" before plug in HDMI cable, then switch to "connected"
> after plugin, and still stay "connected" after unplug. This would
> cause the audio output path cannot correctly switch from HDMI to
> internal speaker after unplugging the HDMI.
> 
> I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
> present. The full "dmesg" log is here.
> https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
> 
> The HDMI cable is plugged in at ~26th second.
> "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
> audio support"
> then unplug the HDMI at ~73th second.
> "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
> audio support"
> 
> Please advise what I can do to fix this. Thanks

Pull the cable out faster?

I presume this is the same old case of hpd disconnecting slightly
before ddc and we still manage to read the EDID when processing
the hpd irq. We kinda tried to fix that with the live status
check but that thing failed spectacularly.

-- 
Ville Syrjälä
Intel

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-05 14:40 ` Ville Syrjälä
@ 2018-07-06  6:44   ` Chris Chiu
  2018-08-22  6:30     ` Chris Chiu
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Chiu @ 2018-07-06  6:44 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Jani Nikula, joonas.lahtinen, rodrigo.vivi, David Airlie,
	intel-gfx, Linux Upstreaming Team, Linux Kernel, dri-devel

On Thu, Jul 5, 2018 at 10:40 PM, Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
> On Thu, Jul 05, 2018 at 03:58:36PM +0800, Chris Chiu wrote:
>> Hi,
>>     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>> i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>> the HDMI connector status stays connected even the HDMI cable has been
>> unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>> checking the status while plug/unplug the HDMI, it shows
>> "disconnected" before plug in HDMI cable, then switch to "connected"
>> after plugin, and still stay "connected" after unplug. This would
>> cause the audio output path cannot correctly switch from HDMI to
>> internal speaker after unplugging the HDMI.
>>
>> I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>> present. The full "dmesg" log is here.
>> https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>>
>> The HDMI cable is plugged in at ~26th second.
>> "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>> audio support"
>> then unplug the HDMI at ~73th second.
>> "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>> audio support"
>>
>> Please advise what I can do to fix this. Thanks
>
> Pull the cable out faster?
>
> I presume this is the same old case of hpd disconnecting slightly
> before ddc and we still manage to read the EDID when processing
> the hpd irq. We kinda tried to fix that with the live status
> check but that thing failed spectacularly.
>
> --
> Ville Syrjälä
> Intel

Thanks for the suggestion. I tried pulling the cable out faster, the status
shows correctly. I also tried branch drm-tip of
https://cgit.freedesktop.org/drm/drm-tip
but the symptom persists.

Anything I can help here? Or any old commit/patch I can try to do some
experiments?

Chris

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-07-06  6:44   ` Chris Chiu
@ 2018-08-22  6:30     ` Chris Chiu
  2018-08-24 15:04       ` Jani Nikula
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Chiu @ 2018-08-22  6:30 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Jani Nikula, joonas.lahtinen, rodrigo.vivi, David Airlie,
	intel-gfx, Linux Upstreaming Team, Linux Kernel, dri-devel

On Fri, Jul 6, 2018 at 2:44 PM, Chris Chiu <chiu@endlessm.com> wrote:
> On Thu, Jul 5, 2018 at 10:40 PM, Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
>> On Thu, Jul 05, 2018 at 03:58:36PM +0800, Chris Chiu wrote:
>>> Hi,
>>>     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>>> i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>>> the HDMI connector status stays connected even the HDMI cable has been
>>> unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>>> checking the status while plug/unplug the HDMI, it shows
>>> "disconnected" before plug in HDMI cable, then switch to "connected"
>>> after plugin, and still stay "connected" after unplug. This would
>>> cause the audio output path cannot correctly switch from HDMI to
>>> internal speaker after unplugging the HDMI.
>>>
>>> I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>>> present. The full "dmesg" log is here.
>>> https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>>>
>>> The HDMI cable is plugged in at ~26th second.
>>> "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>> audio support"
>>> then unplug the HDMI at ~73th second.
>>> "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>> audio support"
>>>
>>> Please advise what I can do to fix this. Thanks
>>
>> Pull the cable out faster?
>>
>> I presume this is the same old case of hpd disconnecting slightly
>> before ddc and we still manage to read the EDID when processing
>> the hpd irq. We kinda tried to fix that with the live status
>> check but that thing failed spectacularly.
>>
>> --
>> Ville Syrjälä
>> Intel

There's a patch https://bugs.freedesktop.org/show_bug.cgi?id=107125#c8.
And I verified on the X705FD/X560UD which were easy to reproduce, the patch
works as expected. Can anyone kindly give comments about this patch?
We can do anything to help fix this issue upstream. Thanks

Chris

> Thanks for the suggestion. I tried pulling the cable out faster, the status
> shows correctly. I also tried branch drm-tip of
> https://cgit.freedesktop.org/drm/drm-tip
> but the symptom persists.
>
> Anything I can help here? Or any old commit/patch I can try to do some
> experiments?
>
> Chris

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-08-22  6:30     ` Chris Chiu
@ 2018-08-24 15:04       ` Jani Nikula
  2018-09-11 10:25         ` Chris Chiu
  0 siblings, 1 reply; 15+ messages in thread
From: Jani Nikula @ 2018-08-24 15:04 UTC (permalink / raw)
  To: Chris Chiu, Ville Syrjälä
  Cc: joonas.lahtinen, rodrigo.vivi, David Airlie, intel-gfx,
	Linux Upstreaming Team, Linux Kernel, dri-devel

On Wed, 22 Aug 2018, Chris Chiu <chiu@endlessm.com> wrote:
> On Fri, Jul 6, 2018 at 2:44 PM, Chris Chiu <chiu@endlessm.com> wrote:
>> On Thu, Jul 5, 2018 at 10:40 PM, Ville Syrjälä
>> <ville.syrjala@linux.intel.com> wrote:
>>> On Thu, Jul 05, 2018 at 03:58:36PM +0800, Chris Chiu wrote:
>>>> Hi,
>>>>     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>>>> i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>>>> the HDMI connector status stays connected even the HDMI cable has been
>>>> unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>>>> checking the status while plug/unplug the HDMI, it shows
>>>> "disconnected" before plug in HDMI cable, then switch to "connected"
>>>> after plugin, and still stay "connected" after unplug. This would
>>>> cause the audio output path cannot correctly switch from HDMI to
>>>> internal speaker after unplugging the HDMI.
>>>>
>>>> I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>>>> present. The full "dmesg" log is here.
>>>> https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>>>>
>>>> The HDMI cable is plugged in at ~26th second.
>>>> "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>> audio support"
>>>> then unplug the HDMI at ~73th second.
>>>> "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>> audio support"
>>>>
>>>> Please advise what I can do to fix this. Thanks
>>>
>>> Pull the cable out faster?
>>>
>>> I presume this is the same old case of hpd disconnecting slightly
>>> before ddc and we still manage to read the EDID when processing
>>> the hpd irq. We kinda tried to fix that with the live status
>>> check but that thing failed spectacularly.
>>>
>>> --
>>> Ville Syrjälä
>>> Intel
>
> There's a patch https://bugs.freedesktop.org/show_bug.cgi?id=107125#c8.
> And I verified on the X705FD/X560UD which were easy to reproduce, the patch
> works as expected. Can anyone kindly give comments about this patch?
> We can do anything to help fix this issue upstream. Thanks

Seems like a hack. Should look into hw based debouncing or a slight
delay in the hotplug work processing I think.

BR,
Jani.

>
> Chris
>
>> Thanks for the suggestion. I tried pulling the cable out faster, the status
>> shows correctly. I also tried branch drm-tip of
>> https://cgit.freedesktop.org/drm/drm-tip
>> but the symptom persists.
>>
>> Anything I can help here? Or any old commit/patch I can try to do some
>> experiments?
>>
>> Chris

-- 
Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-08-24 15:04       ` Jani Nikula
@ 2018-09-11 10:25         ` Chris Chiu
  2018-09-19 11:20           ` Chris Chiu
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Chiu @ 2018-09-11 10:25 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Ville Syrjälä,
	joonas.lahtinen, rodrigo.vivi, David Airlie, intel-gfx,
	Linux Upstreaming Team, Linux Kernel, dri-devel

On Fri, Aug 24, 2018 at 11:04 PM, Jani Nikula <jani.nikula@intel.com> wrote:
> On Wed, 22 Aug 2018, Chris Chiu <chiu@endlessm.com> wrote:
>> On Fri, Jul 6, 2018 at 2:44 PM, Chris Chiu <chiu@endlessm.com> wrote:
>>> On Thu, Jul 5, 2018 at 10:40 PM, Ville Syrjälä
>>> <ville.syrjala@linux.intel.com> wrote:
>>>> On Thu, Jul 05, 2018 at 03:58:36PM +0800, Chris Chiu wrote:
>>>>> Hi,
>>>>>     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>>>>> i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>>>>> the HDMI connector status stays connected even the HDMI cable has been
>>>>> unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>>>>> checking the status while plug/unplug the HDMI, it shows
>>>>> "disconnected" before plug in HDMI cable, then switch to "connected"
>>>>> after plugin, and still stay "connected" after unplug. This would
>>>>> cause the audio output path cannot correctly switch from HDMI to
>>>>> internal speaker after unplugging the HDMI.
>>>>>
>>>>> I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>>>>> present. The full "dmesg" log is here.
>>>>> https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>>>>>
>>>>> The HDMI cable is plugged in at ~26th second.
>>>>> "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>>> audio support"
>>>>> then unplug the HDMI at ~73th second.
>>>>> "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>>> audio support"
>>>>>
>>>>> Please advise what I can do to fix this. Thanks
>>>>
>>>> Pull the cable out faster?
>>>>
>>>> I presume this is the same old case of hpd disconnecting slightly
>>>> before ddc and we still manage to read the EDID when processing
>>>> the hpd irq. We kinda tried to fix that with the live status
>>>> check but that thing failed spectacularly.
>>>>
>>>> --
>>>> Ville Syrjälä
>>>> Intel
>>
>> There's a patch https://bugs.freedesktop.org/show_bug.cgi?id=107125#c8.
>> And I verified on the X705FD/X560UD which were easy to reproduce, the patch
>> works as expected. Can anyone kindly give comments about this patch?
>> We can do anything to help fix this issue upstream. Thanks
>
> Seems like a hack. Should look into hw based debouncing or a slight
> delay in the hotplug work processing I think.
>
> BR,
> Jani.
>
So you're suggesting to add a slight delay directly in i915_hotplug_work_func()?
And any suggestion about the 'hw based' debouncing? Maybe some examples
that I can refer to?

Thanks

>>
>> Chris
>>
>>> Thanks for the suggestion. I tried pulling the cable out faster, the status
>>> shows correctly. I also tried branch drm-tip of
>>> https://cgit.freedesktop.org/drm/drm-tip
>>> but the symptom persists.
>>>
>>> Anything I can help here? Or any old commit/patch I can try to do some
>>> experiments?
>>>
>>> Chris
>
> --
> Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-09-11 10:25         ` Chris Chiu
@ 2018-09-19 11:20           ` Chris Chiu
  2018-09-19 12:08             ` Jani Nikula
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Chiu @ 2018-09-19 11:20 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Ville Syrjälä,
	joonas.lahtinen, rodrigo.vivi, David Airlie, intel-gfx,
	Linux Upstreaming Team, Linux Kernel, dri-devel

On Tue, Sep 11, 2018 at 6:25 PM, Chris Chiu <chiu@endlessm.com> wrote:
> On Fri, Aug 24, 2018 at 11:04 PM, Jani Nikula <jani.nikula@intel.com> wrote:
>> On Wed, 22 Aug 2018, Chris Chiu <chiu@endlessm.com> wrote:
>>> On Fri, Jul 6, 2018 at 2:44 PM, Chris Chiu <chiu@endlessm.com> wrote:
>>>> On Thu, Jul 5, 2018 at 10:40 PM, Ville Syrjälä
>>>> <ville.syrjala@linux.intel.com> wrote:
>>>>> On Thu, Jul 05, 2018 at 03:58:36PM +0800, Chris Chiu wrote:
>>>>>> Hi,
>>>>>>     We have few ASUS laptops X705FD (The new WiskyLake), X560UD (intel
>>>>>> i5-8250U), X530UN (intel i7-8550U) share the same problem, which is
>>>>>> the HDMI connector status stays connected even the HDMI cable has been
>>>>>> unplugged. Look into the "/sys/class/drm/card0-HDMI-A-1/status" for
>>>>>> checking the status while plug/unplug the HDMI, it shows
>>>>>> "disconnected" before plug in HDMI cable, then switch to "connected"
>>>>>> after plugin, and still stay "connected" after unplug. This would
>>>>>> cause the audio output path cannot correctly switch from HDMI to
>>>>>> internal speaker after unplugging the HDMI.
>>>>>>
>>>>>> I then try to verify with the latest kernel 4.18.0-rc3+, the bug still
>>>>>> present. The full "dmesg" log is here.
>>>>>> https://gist.github.com/mschiu77/d761d7c5cf191b7868d4d7788ae087f1
>>>>>>
>>>>>> The HDMI cable is plugged in at ~26th second.
>>>>>> "[ 26.214371] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>>>> audio support"
>>>>>> then unplug the HDMI at ~73th second.
>>>>>> "[ 73.328361] [drm:drm_detect_monitor_audio [drm]] Monitor has basic
>>>>>> audio support"
>>>>>>
>>>>>> Please advise what I can do to fix this. Thanks
>>>>>
>>>>> Pull the cable out faster?
>>>>>
>>>>> I presume this is the same old case of hpd disconnecting slightly
>>>>> before ddc and we still manage to read the EDID when processing
>>>>> the hpd irq. We kinda tried to fix that with the live status
>>>>> check but that thing failed spectacularly.
>>>>>
>>>>> --
>>>>> Ville Syrjälä
>>>>> Intel
>>>
>>> There's a patch https://bugs.freedesktop.org/show_bug.cgi?id=107125#c8.
>>> And I verified on the X705FD/X560UD which were easy to reproduce, the patch
>>> works as expected. Can anyone kindly give comments about this patch?
>>> We can do anything to help fix this issue upstream. Thanks
>>
>> Seems like a hack. Should look into hw based debouncing or a slight
>> delay in the hotplug work processing I think.
>>
>> BR,
>> Jani.
>>

I tried to add a slight delay in the hotplug work as follows

--- a/drivers/gpu/drm/i915/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/intel_hotplug.c
@@ -378,6 +378,8 @@ static void do_i915_hotplug_check(struct work_struct *work,

        spin_unlock_irq(&dev_priv->irq_lock);

+       msleep(100);
+
        drm_connector_list_iter_begin(dev, &conn_iter);
        drm_for_each_connector_iter(connector, &conn_iter) {
                intel_connector = to_intel_connector(connector);

It does work in most cases, but still fail to update the status if I
unplug the HDMI
cable very slow. I basically pull the HDMI cable in loose connected
state first, and
hold in that state ~1 second, totally unplug after that. The status in
sysfs will report
connected as it used to. There was no problem when I tried the patch
https://bugs.freedesktop.org/show_bug.cgi?id=107125#c8

I'll try to modify this patch a little bit and send upstream for
discussion later. Please
advise if any. Thanks.

Chris

> So you're suggesting to add a slight delay directly in i915_hotplug_work_func()?
> And any suggestion about the 'hw based' debouncing? Maybe some examples
> that I can refer to?
>
> Thanks
>
>>>
>>> Chris
>>>
>>>> Thanks for the suggestion. I tried pulling the cable out faster, the status
>>>> shows correctly. I also tried branch drm-tip of
>>>> https://cgit.freedesktop.org/drm/drm-tip
>>>> but the symptom persists.
>>>>
>>>> Anything I can help here? Or any old commit/patch I can try to do some
>>>> experiments?
>>>>
>>>> Chris
>>
>> --
>> Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-09-19 11:20           ` Chris Chiu
@ 2018-09-19 12:08             ` Jani Nikula
  2018-09-20  7:32               ` Chris Chiu
  0 siblings, 1 reply; 15+ messages in thread
From: Jani Nikula @ 2018-09-19 12:08 UTC (permalink / raw)
  To: Chris Chiu
  Cc: Ville Syrjälä,
	joonas.lahtinen, rodrigo.vivi, David Airlie, intel-gfx,
	Linux Upstreaming Team, Linux Kernel, dri-devel

On Wed, 19 Sep 2018, Chris Chiu <chiu@endlessm.com> wrote:
> I tried to add a slight delay in the hotplug work as follows
>
> --- a/drivers/gpu/drm/i915/intel_hotplug.c
> +++ b/drivers/gpu/drm/i915/intel_hotplug.c
> @@ -378,6 +378,8 @@ static void do_i915_hotplug_check(struct work_struct *work,
>
>         spin_unlock_irq(&dev_priv->irq_lock);
>
> +       msleep(100);
> +
>         drm_connector_list_iter_begin(dev, &conn_iter);
>         drm_for_each_connector_iter(connector, &conn_iter) {
>                 intel_connector = to_intel_connector(connector);
>
> It does work in most cases, but still fail to update the status if I
> unplug the HDMI
> cable very slow. I basically pull the HDMI cable in loose connected
> state first, and
> hold in that state ~1 second, totally unplug after that. The status in
> sysfs will report
> connected as it used to. There was no problem when I tried the patch
> https://bugs.freedesktop.org/show_bug.cgi?id=107125#c8
>
> I'll try to modify this patch a little bit and send upstream for
> discussion later. Please
> advise if any. Thanks.

Please let's not add excessive msleeps in work functions.

My idea was more along the lines of making the hotplug function run in a
delayed work. After a chat with Ville, below is what I came up with.

Please let me know how it works. Feel free to toy with the
delay. However, 1-2 seconds or more seems too much.

BR,
Jani.



From 72515b3e856171e52e96bb74796774f595a7f418 Mon Sep 17 00:00:00 2001
From: Jani Nikula <jani.nikula@intel.com>
Date: Tue, 18 Sep 2018 13:12:34 +0300
Subject: [PATCH] drm/i915: delay hotplug scheduling
Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo
Cc: Jani Nikula <jani.nikula@intel.com>

On some systems we get the hotplug irq on unplug before the DDC pins
have been disconnected, resulting in connector status remaining
connected. Since previous attempts at using hotplug live status before
DDC have failed, the only viable option is to reduce the window for
mistakes. Delay the hotplug processing.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h      |  2 +-
 drivers/gpu/drm/i915/intel_hotplug.c | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 7d4daa7412f1..27f579abddae 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -286,7 +286,7 @@ enum hpd_pin {
 #define HPD_STORM_DEFAULT_THRESHOLD 5
 
 struct i915_hotplug {
-	struct work_struct hotplug_work;
+	struct delayed_work hotplug_work;
 
 	struct {
 		unsigned long last_jiffies;
diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c
index 648a13c6043c..3af64daa5cfc 100644
--- a/drivers/gpu/drm/i915/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/intel_hotplug.c
@@ -110,6 +110,8 @@ enum hpd_pin intel_hpd_pin_default(struct drm_i915_private *dev_priv,
 	}
 }
 
+#define HOTPLUG_DELAY_MS		300
+
 #define HPD_STORM_DETECT_PERIOD		1000
 #define HPD_STORM_REENABLE_DELAY	(2 * 60 * 1000)
 
@@ -319,7 +321,8 @@ static void i915_digport_work_func(struct work_struct *work)
 		spin_lock_irq(&dev_priv->irq_lock);
 		dev_priv->hotplug.event_bits |= old_bits;
 		spin_unlock_irq(&dev_priv->irq_lock);
-		schedule_work(&dev_priv->hotplug.hotplug_work);
+		schedule_delayed_work(&dev_priv->hotplug.hotplug_work,
+				      msecs_to_jiffies(HOTPLUG_DELAY_MS));
 	}
 }
 
@@ -329,7 +332,7 @@ static void i915_digport_work_func(struct work_struct *work)
 static void i915_hotplug_work_func(struct work_struct *work)
 {
 	struct drm_i915_private *dev_priv =
-		container_of(work, struct drm_i915_private, hotplug.hotplug_work);
+		container_of(work, struct drm_i915_private, hotplug.hotplug_work.work);
 	struct drm_device *dev = &dev_priv->drm;
 	struct intel_connector *intel_connector;
 	struct intel_encoder *intel_encoder;
@@ -466,7 +469,8 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
 	if (queue_dig)
 		queue_work(dev_priv->hotplug.dp_wq, &dev_priv->hotplug.dig_port_work);
 	if (queue_hp)
-		schedule_work(&dev_priv->hotplug.hotplug_work);
+		schedule_delayed_work(&dev_priv->hotplug.hotplug_work,
+				      msecs_to_jiffies(HOTPLUG_DELAY_MS));
 }
 
 /**
@@ -586,7 +590,8 @@ void intel_hpd_poll_init(struct drm_i915_private *dev_priv)
 
 void intel_hpd_init_work(struct drm_i915_private *dev_priv)
 {
-	INIT_WORK(&dev_priv->hotplug.hotplug_work, i915_hotplug_work_func);
+	INIT_DELAYED_WORK(&dev_priv->hotplug.hotplug_work,
+			  i915_hotplug_work_func);
 	INIT_WORK(&dev_priv->hotplug.dig_port_work, i915_digport_work_func);
 	INIT_WORK(&dev_priv->hotplug.poll_init_work, i915_hpd_poll_init_work);
 	INIT_DELAYED_WORK(&dev_priv->hotplug.reenable_work,
@@ -604,7 +609,7 @@ void intel_hpd_cancel_work(struct drm_i915_private *dev_priv)
 	spin_unlock_irq(&dev_priv->irq_lock);
 
 	cancel_work_sync(&dev_priv->hotplug.dig_port_work);
-	cancel_work_sync(&dev_priv->hotplug.hotplug_work);
+	cancel_delayed_work_sync(&dev_priv->hotplug.hotplug_work);
 	cancel_work_sync(&dev_priv->hotplug.poll_init_work);
 	cancel_delayed_work_sync(&dev_priv->hotplug.reenable_work);
 }
-- 
2.11.0


-- 
Jani Nikula, Intel Open Source Graphics Center

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

* Re: [BUG] i915 HDMI connector status is connected after disconnection
  2018-09-19 12:08             ` Jani Nikula
@ 2018-09-20  7:32               ` Chris Chiu
  0 siblings, 0 replies; 15+ messages in thread
From: Chris Chiu @ 2018-09-20  7:32 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Ville Syrjälä,
	joonas.lahtinen, rodrigo.vivi, David Airlie, intel-gfx,
	Linux Upstreaming Team, Linux Kernel, dri-devel

On Wed, Sep 19, 2018 at 8:08 PM, Jani Nikula <jani.nikula@intel.com> wrote:
> On Wed, 19 Sep 2018, Chris Chiu <chiu@endlessm.com> wrote:
>> I tried to add a slight delay in the hotplug work as follows
>>
>> --- a/drivers/gpu/drm/i915/intel_hotplug.c
>> +++ b/drivers/gpu/drm/i915/intel_hotplug.c
>> @@ -378,6 +378,8 @@ static void do_i915_hotplug_check(struct work_struct *work,
>>
>>         spin_unlock_irq(&dev_priv->irq_lock);
>>
>> +       msleep(100);
>> +
>>         drm_connector_list_iter_begin(dev, &conn_iter);
>>         drm_for_each_connector_iter(connector, &conn_iter) {
>>                 intel_connector = to_intel_connector(connector);
>>
>> It does work in most cases, but still fail to update the status if I
>> unplug the HDMI
>> cable very slow. I basically pull the HDMI cable in loose connected
>> state first, and
>> hold in that state ~1 second, totally unplug after that. The status in
>> sysfs will report
>> connected as it used to. There was no problem when I tried the patch
>> https://bugs.freedesktop.org/show_bug.cgi?id=107125#c8
>>
>> I'll try to modify this patch a little bit and send upstream for
>> discussion later. Please
>> advise if any. Thanks.
>
> Please let's not add excessive msleeps in work functions.
>
> My idea was more along the lines of making the hotplug function run in a
> delayed work. After a chat with Ville, below is what I came up with.
>
> Please let me know how it works. Feel free to toy with the
> delay. However, 1-2 seconds or more seems too much.
>
> BR,
> Jani.
>

Thanks to the patch. It works in most cases on my problematic laptops.
After lots
of experiments, ex. pull the cable out with different paces, range
delay from 300 to
800 msec, it makes no significant difference for a longer delay. So
300 msec is good
enough for most cases. It at least updates the status correctly with a
visible quick
display blink when disconnecting HDMI. And compared to other machines which have
no such problem, the HDMI cable slow pull out also result in the same
problem. I'll
say the test result is OK for me. Thanks.

Chris

>
>
> From 72515b3e856171e52e96bb74796774f595a7f418 Mon Sep 17 00:00:00 2001
> From: Jani Nikula <jani.nikula@intel.com>
> Date: Tue, 18 Sep 2018 13:12:34 +0300
> Subject: [PATCH] drm/i915: delay hotplug scheduling
> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo
> Cc: Jani Nikula <jani.nikula@intel.com>
>
> On some systems we get the hotplug irq on unplug before the DDC pins
> have been disconnected, resulting in connector status remaining
> connected. Since previous attempts at using hotplug live status before
> DDC have failed, the only viable option is to reduce the window for
> mistakes. Delay the hotplug processing.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h      |  2 +-
>  drivers/gpu/drm/i915/intel_hotplug.c | 15 ++++++++++-----
>  2 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 7d4daa7412f1..27f579abddae 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -286,7 +286,7 @@ enum hpd_pin {
>  #define HPD_STORM_DEFAULT_THRESHOLD 5
>
>  struct i915_hotplug {
> -       struct work_struct hotplug_work;
> +       struct delayed_work hotplug_work;
>
>         struct {
>                 unsigned long last_jiffies;
> diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c
> index 648a13c6043c..3af64daa5cfc 100644
> --- a/drivers/gpu/drm/i915/intel_hotplug.c
> +++ b/drivers/gpu/drm/i915/intel_hotplug.c
> @@ -110,6 +110,8 @@ enum hpd_pin intel_hpd_pin_default(struct drm_i915_private *dev_priv,
>         }
>  }
>
> +#define HOTPLUG_DELAY_MS               300
> +
>  #define HPD_STORM_DETECT_PERIOD                1000
>  #define HPD_STORM_REENABLE_DELAY       (2 * 60 * 1000)
>
> @@ -319,7 +321,8 @@ static void i915_digport_work_func(struct work_struct *work)
>                 spin_lock_irq(&dev_priv->irq_lock);
>                 dev_priv->hotplug.event_bits |= old_bits;
>                 spin_unlock_irq(&dev_priv->irq_lock);
> -               schedule_work(&dev_priv->hotplug.hotplug_work);
> +               schedule_delayed_work(&dev_priv->hotplug.hotplug_work,
> +                                     msecs_to_jiffies(HOTPLUG_DELAY_MS));
>         }
>  }
>
> @@ -329,7 +332,7 @@ static void i915_digport_work_func(struct work_struct *work)
>  static void i915_hotplug_work_func(struct work_struct *work)
>  {
>         struct drm_i915_private *dev_priv =
> -               container_of(work, struct drm_i915_private, hotplug.hotplug_work);
> +               container_of(work, struct drm_i915_private, hotplug.hotplug_work.work);
>         struct drm_device *dev = &dev_priv->drm;
>         struct intel_connector *intel_connector;
>         struct intel_encoder *intel_encoder;
> @@ -466,7 +469,8 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
>         if (queue_dig)
>                 queue_work(dev_priv->hotplug.dp_wq, &dev_priv->hotplug.dig_port_work);
>         if (queue_hp)
> -               schedule_work(&dev_priv->hotplug.hotplug_work);
> +               schedule_delayed_work(&dev_priv->hotplug.hotplug_work,
> +                                     msecs_to_jiffies(HOTPLUG_DELAY_MS));
>  }
>
>  /**
> @@ -586,7 +590,8 @@ void intel_hpd_poll_init(struct drm_i915_private *dev_priv)
>
>  void intel_hpd_init_work(struct drm_i915_private *dev_priv)
>  {
> -       INIT_WORK(&dev_priv->hotplug.hotplug_work, i915_hotplug_work_func);
> +       INIT_DELAYED_WORK(&dev_priv->hotplug.hotplug_work,
> +                         i915_hotplug_work_func);
>         INIT_WORK(&dev_priv->hotplug.dig_port_work, i915_digport_work_func);
>         INIT_WORK(&dev_priv->hotplug.poll_init_work, i915_hpd_poll_init_work);
>         INIT_DELAYED_WORK(&dev_priv->hotplug.reenable_work,
> @@ -604,7 +609,7 @@ void intel_hpd_cancel_work(struct drm_i915_private *dev_priv)
>         spin_unlock_irq(&dev_priv->irq_lock);
>
>         cancel_work_sync(&dev_priv->hotplug.dig_port_work);
> -       cancel_work_sync(&dev_priv->hotplug.hotplug_work);
> +       cancel_delayed_work_sync(&dev_priv->hotplug.hotplug_work);
>         cancel_work_sync(&dev_priv->hotplug.poll_init_work);
>         cancel_delayed_work_sync(&dev_priv->hotplug.reenable_work);
>  }
> --
> 2.11.0
>
>
> --
> Jani Nikula, Intel Open Source Graphics Center

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

end of thread, other threads:[~2018-09-20  7:32 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-05  7:58 [BUG] i915 HDMI connector status is connected after disconnection Chris Chiu
2018-07-05  8:58 ` Jani Nikula
2018-07-05  9:04   ` Chris Wilson
2018-07-05  9:37     ` Jani Nikula
2018-07-05 13:02       ` Chris Chiu
2018-07-05 13:18         ` Jani Nikula
2018-07-05 13:30           ` Chris Chiu
2018-07-05 14:40 ` Ville Syrjälä
2018-07-06  6:44   ` Chris Chiu
2018-08-22  6:30     ` Chris Chiu
2018-08-24 15:04       ` Jani Nikula
2018-09-11 10:25         ` Chris Chiu
2018-09-19 11:20           ` Chris Chiu
2018-09-19 12:08             ` Jani Nikula
2018-09-20  7:32               ` Chris Chiu

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