Skip to content

Commit 6daaae5

Browse files
hverkuillumag
authored andcommitted
gpu: drm_dp_cec: fix broken CEC adapter properties check
If the hotplug detect of a display is low for longer than one second (configurable through drm_dp_cec_unregister_delay), then the CEC adapter is unregistered since we assume the display was disconnected. If the HPD went low for less than one second, then we check if the properties of the CEC adapter have changed, since that indicates that we actually switch to new hardware and we have to unregister the old CEC device and register a new one. Unfortunately, the test for changed properties was written poorly, and after a new CEC capability was added to the CEC core code the test always returned true (i.e. the properties had changed). As a result the CEC device was unregistered and re-registered for every HPD toggle. If the CEC remote controller integration was also enabled (CONFIG_MEDIA_CEC_RC was set), then the corresponding input device was also unregistered and re-registered. As a result the input device in /sys would keep incrementing its number, e.g.: /sys/devices/pci0000:00/0000:00:08.1/0000:e7:00.0/rc/rc0/input20 Since short HPD toggles are common, the number could over time get into the thousands. While not a serious issue (i.e. nothing crashes), it is not intended to work that way. This patch changes the test so that it only checks for the single CEC capability that can actually change, and it ignores any other capabilities, so this is now safe as well if new caps are added in the future. With the changed test the bit under #ifndef CONFIG_MEDIA_CEC_RC can be dropped as well, so that's a nice cleanup. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Reported-by: Farblos <farblos@vodafonemail.de> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Fixes: 2c6d1ff ("drm: add support for DisplayPort CEC-Tunneling-over-AUX") Tested-by: Farblos <farblos@vodafonemail.de> Link: https://patchwork.freedesktop.org/patch/msgid/361bb03d-1691-4e23-84da-0861ead5dbdc@xs4all.nl Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
1 parent 6e64d6b commit 6daaae5

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

drivers/gpu/drm/display/drm_dp_cec.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,6 @@ void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address)
311311
if (!aux->transfer)
312312
return;
313313

314-
#ifndef CONFIG_MEDIA_CEC_RC
315-
/*
316-
* CEC_CAP_RC is part of CEC_CAP_DEFAULTS, but it is stripped by
317-
* cec_allocate_adapter() if CONFIG_MEDIA_CEC_RC is undefined.
318-
*
319-
* Do this here as well to ensure the tests against cec_caps are
320-
* correct.
321-
*/
322-
cec_caps &= ~CEC_CAP_RC;
323-
#endif
324314
cancel_delayed_work_sync(&aux->cec.unregister_work);
325315

326316
mutex_lock(&aux->cec.lock);
@@ -337,7 +327,9 @@ void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address)
337327
num_las = CEC_MAX_LOG_ADDRS;
338328

339329
if (aux->cec.adap) {
340-
if (aux->cec.adap->capabilities == cec_caps &&
330+
/* Check if the adapter properties have changed */
331+
if ((aux->cec.adap->capabilities & CEC_CAP_MONITOR_ALL) ==
332+
(cec_caps & CEC_CAP_MONITOR_ALL) &&
341333
aux->cec.adap->available_log_addrs == num_las) {
342334
/* Unchanged, so just set the phys addr */
343335
cec_s_phys_addr(aux->cec.adap, source_physical_address, false);

0 commit comments

Comments
 (0)