Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDMI Hotplug Detection Fix #4538

Merged

Conversation

mripard
Copy link
Contributor

@mripard mripard commented Aug 19, 2021

Hi,

Here's a fix for a hotplug detection issue that ultimately resulted in a black screen when using a mode using the scrambler, an application that doesn't handle hotplug events and an hotplug event.

Fixes #4486

@popcornmix
Copy link
Collaborator

@HiassofT

@HiassofT
Copy link
Contributor

A quick test with LE/kodi looks good, but I get two warning splats when putting the TV out of standby - the same happens with kodi stopped and just console active

[   65.842904] ------------[ cut here ]------------
[   65.842916] vc4-drm gpu: drm_WARN_ON(!mutex_is_locked(&dev->mode_config.mutex))
[   65.842953] WARNING: CPU: 1 PID: 122 at _drm_connector_helper_hpd_irq_event+0x1b0/0x1f0
[   65.842956] Modules linked in: ir_rc5_decoder bcm2835_codec(C) bcm2835_gpiomem bcm2835_isp(C) rpivid_hevc(C) bcm2835_mmal_vchiq(C) v4l2_mem2mem videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common videodev mc cdc_acm ir_rc6_decoder rc_rc6_mce gpio_ir_recv nvmem_rmem fuse
[   65.842998] CPU: 1 PID: 122 Comm: irq/43-vc4 hdmi Tainted: G         C        5.10.59 #1
[   65.843001] Hardware name: Raspberry Pi 4 Model B Rev 1.1 (DT)
[   65.843005] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--)
[   65.843010] pc : _drm_connector_helper_hpd_irq_event+0x1b0/0x1f0
[   65.843014] lr : _drm_connector_helper_hpd_irq_event+0x1b0/0x1f0
[   65.843016] sp : ffffffc0123dbd20
[   65.843018] x29: ffffffc0123dbd20 x28: 0000000000000000 
[   65.843024] x27: ffffff80402c0ac8 x26: ffffffc010e10630 
[   65.843029] x25: ffffffc0100af330 x24: ffffffc0100af410 
[   65.843034] x23: ffffff80408b7400 x22: 0000000000000001 
[   65.843040] x21: ffffff8041bf2000 x20: ffffff80408b7400 
[   65.843045] x19: ffffff8041bf3568 x18: 0000000000000000 
[   65.843049] x17: 0000000000000000 x16: 000000000000001c 
[   65.843055] x15: ffffffc010c6ba10 x14: 0000000000000005 
[   65.843059] x13: 000000008b95c1e3 x12: 00000000000001ae 
[   65.843064] x11: 0000000000000000 x10: ffffff80fb085bf0 
[   65.843069] x9 : ffffffc0100a9950 x8 : ffffff80f6500000 
[   65.843074] x7 : ffffff80fb082bc0 x6 : 0000000000000001 
[   65.843078] x5 : ffffff80fb7a3a50 x4 : 0000000000000000 
[   65.843083] x3 : 0000000000000027 x2 : 0000000000000000 
[   65.843088] x1 : 0000000000000000 x0 : ffffff8041bccf80 
[   65.843093] Call trace:
[   65.843098]  _drm_connector_helper_hpd_irq_event+0x1b0/0x1f0
[   65.843102]  drm_connector_helper_hpd_irq_event+0x20/0x30
[   65.843107]  vc4_hdmi_hpd_irq_thread+0x38/0x50
[   65.843112]  irq_thread_fn+0x38/0xb0
[   65.843115]  irq_thread+0x1b4/0x400
[   65.843119]  kthread+0x134/0x140
[   65.843123]  ret_from_fork+0x10/0x38
[   65.843126] ---[ end trace 2c4f4fcd511b028b ]---

full dmesg: http://ix.io/3wtp

The drm_helper_hpd_irq_event() function is iterating over all the
connectors when an hotplug event is detected.

During that iteration, it will call each connector detect function and
figure out if its status changed.

Finally, if any connector changed, it will notify the user-space and the
clients that something changed on the DRM device.

This is supposed to be used for drivers that don't have a hotplug
interrupt for individual connectors. However, drivers that can use an
interrupt for a single connector are left in the dust and can either
reimplement the logic used during the iteration for each connector or
use that helper and iterate over all connectors all the time.

Since both are suboptimal, let's create a helper that will only perform
the status detection on a single connector.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
The drm_helper_hpd_irq_event() documentation states that this function
is "useful for drivers which can't or don't track hotplug interrupts for
each connector." and that "Drivers which support hotplug interrupts for
each connector individually and which have a more fine-grained detect
logic should bypass this code and directly call
drm_kms_helper_hotplug_event()". This is thus what we ended-up doing.

However, what this actually means, and is further explained in the
drm_kms_helper_hotplug_event() documentation, is that
drm_kms_helper_hotplug_event() should be called by drivers that can
track the connection status change, and if it has changed we should call
that function.

This underlying expectation we failed to provide is that the caller of
drm_kms_helper_hotplug_event() should call drm_helper_probe_detect() to
probe the new status of the connector.

Since we didn't do it, it meant that even though we were sending the
notification to user-space and the DRM clients that something changed we
never probed or updated our internal connector status ourselves.

This went mostly unnoticed since the detect callback usually doesn't
have any side-effect. Also, if we were using the DRM fbdev emulation
(which is a DRM client), or any user-space application that can deal
with hotplug events, chances are they would react to the hotplug event
by probing the connector status eventually.

However, now that we have to enable the scrambler in detect() if it was
enabled it has a side effect, and an application such as Kodi or
modetest doesn't deal with hotplug events. This resulted with a black
screen when Kodi or modetest was running when a screen was disconnected
and then reconnected, or switched off and on.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
@mripard mripard force-pushed the rpi/5.10-hotplug-irq-connector branch from 7d20261 to 4de1d45 Compare August 20, 2021 07:19
@mripard
Copy link
Contributor Author

mripard commented Aug 20, 2021

The new version I just pushed fixes the warning

@HiassofT
Copy link
Contributor

Thanks, the updated version works fine here, too

@pelwell pelwell merged commit 7f4de43 into raspberrypi:rpi-5.10.y Aug 20, 2021
@mripard mripard deleted the rpi/5.10-hotplug-irq-connector branch August 20, 2021 14:07
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Aug 23, 2021
kernel: HDMI Hotplug Detection Fix
See: raspberrypi/linux#4538
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this pull request Aug 23, 2021
kernel: HDMI Hotplug Detection Fix
See: raspberrypi/linux#4538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KMS: blank screen after TV is brought out of standby on modes that need scrambling
4 participants