Skip to content

Commit a8f49a0

Browse files
acelansuperm1
authored andcommitted
drm/dp: Add byte-by-byte fallback for broken USB-C adapters
Some USB-C hubs and adapters have buggy firmware where multi-byte AUX reads consistently timeout, while single-byte reads from the same address work correctly. Known affected devices that exhibit this issue: - Lenovo USB-C to VGA adapter (VIA VL817 chipset) idVendor=17ef, idProduct=7217 - Dell DA310 USB-C mobile adapter hub idVendor=413c, idProduct=c010 Analysis of the failure pattern shows: - Single-byte probes to 0xf0000 (LTTPR) succeed - Single-byte probes to 0x00102 (TRAINING_AUX_RD_INTERVAL) succeed - Multi-byte reads from 0x00000 (DPCD capabilities) timeout with -ETIMEDOUT - Retrying does not help - the failure is consistent across all attempts The issue appears to be a firmware bug in the AUX transaction handling that specifically affects multi-byte reads. Add a fallback mechanism in drm_dp_dpcd_read_data() that attempts byte-by-byte reading when the normal multi-byte read fails. This workaround only activates for adapters that fail the standard read path, ensuring no impact on correctly functioning hardware. Tested with: - Lenovo USB-C to VGA adapter (VIA VL817) - now works with fallback - Dell DA310 USB-C hub - now works with fallback - Dell/Analogix Slimport adapter - continues to work with normal path Signed-off-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Link: https://patch.msgid.link/20251204024647.1462866-1-acelan.kao@canonical.com Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
1 parent 9ce4aef commit a8f49a0

1 file changed

Lines changed: 37 additions & 20 deletions

File tree

include/drm/display/drm_dp_helper.h

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,22 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
551551
ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
552552
void *buffer, size_t size);
553553

554+
/**
555+
* drm_dp_dpcd_readb() - read a single byte from the DPCD
556+
* @aux: DisplayPort AUX channel
557+
* @offset: address of the register to read
558+
* @valuep: location where the value of the register will be stored
559+
*
560+
* Returns the number of bytes transferred (1) on success, or a negative
561+
* error code on failure. In most of the cases you should be using
562+
* drm_dp_dpcd_read_byte() instead.
563+
*/
564+
static inline ssize_t drm_dp_dpcd_readb(struct drm_dp_aux *aux,
565+
unsigned int offset, u8 *valuep)
566+
{
567+
return drm_dp_dpcd_read(aux, offset, valuep, 1);
568+
}
569+
554570
/**
555571
* drm_dp_dpcd_read_data() - read a series of bytes from the DPCD
556572
* @aux: DisplayPort AUX channel (SST or MST)
@@ -570,12 +586,29 @@ static inline int drm_dp_dpcd_read_data(struct drm_dp_aux *aux,
570586
void *buffer, size_t size)
571587
{
572588
int ret;
589+
size_t i;
590+
u8 *buf = buffer;
573591

574592
ret = drm_dp_dpcd_read(aux, offset, buffer, size);
575-
if (ret < 0)
576-
return ret;
577-
if (ret < size)
578-
return -EPROTO;
593+
if (ret >= 0) {
594+
if (ret < size)
595+
return -EPROTO;
596+
return 0;
597+
}
598+
599+
/*
600+
* Workaround for USB-C hubs/adapters with buggy firmware that fail
601+
* multi-byte AUX reads but work with single-byte reads.
602+
* Known affected devices:
603+
* - Lenovo USB-C to VGA adapter (VIA VL817, idVendor=17ef, idProduct=7217)
604+
* - Dell DA310 USB-C hub (idVendor=413c, idProduct=c010)
605+
* Attempt byte-by-byte reading as a fallback.
606+
*/
607+
for (i = 0; i < size; i++) {
608+
ret = drm_dp_dpcd_readb(aux, offset + i, &buf[i]);
609+
if (ret < 0)
610+
return ret;
611+
}
579612

580613
return 0;
581614
}
@@ -609,22 +642,6 @@ static inline int drm_dp_dpcd_write_data(struct drm_dp_aux *aux,
609642
return 0;
610643
}
611644

612-
/**
613-
* drm_dp_dpcd_readb() - read a single byte from the DPCD
614-
* @aux: DisplayPort AUX channel
615-
* @offset: address of the register to read
616-
* @valuep: location where the value of the register will be stored
617-
*
618-
* Returns the number of bytes transferred (1) on success, or a negative
619-
* error code on failure. In most of the cases you should be using
620-
* drm_dp_dpcd_read_byte() instead.
621-
*/
622-
static inline ssize_t drm_dp_dpcd_readb(struct drm_dp_aux *aux,
623-
unsigned int offset, u8 *valuep)
624-
{
625-
return drm_dp_dpcd_read(aux, offset, valuep, 1);
626-
}
627-
628645
/**
629646
* drm_dp_dpcd_writeb() - write a single byte to the DPCD
630647
* @aux: DisplayPort AUX channel

0 commit comments

Comments
 (0)