Some USB-C hubs and adapters have buggy firmware where multi-byte AUX
reads from DPCD address 0x00000 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
- 15-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 from the base DPCD address.

Add a fallback mechanism that attempts byte-by-byte reading when the
normal multi-byte drm_dp_read_dpcd_caps() fails. This workaround only
activates for adapters that fail the standard read path, ensuring no
impact on correctly functioning hardware.

The byte-by-byte read uses drm_dp_dpcd_readb() to read each of the 15
DPCD capability bytes individually, working around the firmware bug
while maintaining compatibility with all other adapters.

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) <[email protected]>
---
 .../drm/i915/display/intel_dp_link_training.c | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c 
b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
index aad5fe14962f..738a5bb4adb3 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -213,6 +213,7 @@ static int intel_dp_init_lttpr(struct intel_dp *intel_dp, 
const u8 dpcd[DP_RECEI
 int intel_dp_read_dprx_caps(struct intel_dp *intel_dp, u8 
dpcd[DP_RECEIVER_CAP_SIZE])
 {
        struct intel_display *display = to_intel_display(intel_dp);
+       int ret, i;
 
        if (intel_dp_is_edp(intel_dp))
                return 0;
@@ -226,7 +227,25 @@ int intel_dp_read_dprx_caps(struct intel_dp *intel_dp, u8 
dpcd[DP_RECEIVER_CAP_S
                                      
DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV))
                        return -EIO;
 
-       if (drm_dp_read_dpcd_caps(&intel_dp->aux, dpcd))
+       ret = drm_dp_read_dpcd_caps(&intel_dp->aux, dpcd);
+       if (ret == 0)
+               return 0;
+
+       /*
+        * Workaround for USB-C hubs/adapters with buggy firmware that fail
+        * multi-byte AUX reads from DPCD address 0x00000 but work with
+        * single-byte reads. Known affected devices:
+        * - Lenovo USB-C to VGA adapter (VIA VL817, idVendor=17ef, 
idProduct=7217)
+        * - Dell DA310 USB-C hub (idVendor=413c, idProduct=c010)
+        * Read the DPCD capabilities byte-by-byte as a fallback.
+        */
+       for (i = 0; i < DP_RECEIVER_CAP_SIZE; i++) {
+               ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_DPCD_REV + i, 
&dpcd[i]);
+               if (ret < 0)
+                       return -EIO;
+       }
+
+       if (dpcd[DP_DPCD_REV] == 0)
                return -EIO;
 
        return 0;
-- 
2.43.0

Reply via email to