usb: typec: displayport: correct DP sink plug/receptacle pin parsing
Subsystems (3)
PATCH v2 1/1 usb: typec: displayport: correct DP sink plug/receptacle pin parsing
The current code always reads bits 23:16 for both DP Sink device direct-attach plug and receptacle cases. As per VESA DPAM v2.1b Table 5-6, the expected behavior is to read:
- bits 15:8 for a DP Sink plug
- bits 23:16 for a receptacle
Example:
- Partner Capability VDO = 0x00001c05
- bits 1:0 = 1, indicating DP Sink Device Capable
- bit 6 = 0, indicating the DP interface is presented on a USB-C plug
Based on bits 1:0 and bit 6, the pin assignment should be parsed from bits 15:8, which gives 0x1c
---
v2:
- Added Fixes tag as per the review comment.
drivers/usb/typec/altmodes/displayport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/altmodes/displayport.c +1 -1
@@ -114,7 +114,7 @@ static int dp_altmode_configure(struct dp_altmode *dp, u8 con)return 0 ;case DP_STATUS_CON_DFP_D : conf |=DP_CONF_UFP_U_AS_DFP_D ; - pin_assign =DP_CAP_UFP_D_PIN_ASSIGN (dp->alt->vdo) & + pin_assign =DP_CAP_PIN_ASSIGN_UFP_D (dp->alt->vdo) &DP_CAP_DFP_D_PIN_ASSIGN (dp->port->vdo);/* Account for active cable capabilities */ if (dp->plug_prime)
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] usb: typec: displayport: wrong DP role pin macro in dp_altmode_configure() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] usb: typec: displayport: wrong DP role pin macro in dp_altmode_configure()
--
commit dce41c371c3e05eb264489df01883dfe3fa7a213
Author: Jignesh Patel <[email protected]>
usb: typec: displayport: correct DP sink plug/receptacle pin parsing
This commit updates the pin assignment macro used for the partner VDO in the DP_STATUS_CON_DFP_D case of dp_altmode_configure() from DP_CAP_UFP_D_PIN_ASSIGN() to DP_CAP_PIN_ASSIGN_UFP_D().
drivers/usb/typec/altmodes/displayport.c static int dp_altmode_configure(struct dp_altmode *dp, u8 con) · line 120
Quoted 13 lines
drivers/usb/typec/altmodes/displayport.c +1
-1@@ -114,7 +114,7 @@ static int dp_altmode_configure(struct dp_altmode *dp, u8 con)return 0 ;case DP_STATUS_CON_DFP_D : conf |=DP_CONF_UFP_U_AS_DFP_D ; - pin_assign =DP_CAP_UFP_D_PIN_ASSIGN (dp->alt->vdo) & + pin_assign =DP_CAP_PIN_ASSIGN_UFP_D (dp->alt->vdo) &DP_CAP_DFP_D_PIN_ASSIGN (dp->port->vdo);/* Account for active cable capabilities */ if (dp->plug_prime)
[Severity: High]
Does DP_STATUS_CON_DFP_D configure the partner (dp->alt) as a DFP_D (DP Source) rather than a UFP_D (DP Sink)?
This case sets DP_CONF_UFP_U_AS_DFP_D, which configures the UFP_U partner as a DFP_D, whereas a UFP_D (DP Sink) partner is configured by the DP_STATUS_CON_UFP_D case right below:
drivers/usb/typec/altmodes/displayport.c:dp_altmode_configure() {
...
case DP_STATUS_CON_UFP_D:
case DP_STATUS_CON_BOTH: /* NOTE: First acting as DP source */
conf |= DP_CONF_UFP_U_AS_UFP_D;
pin_assign = DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo) &
DP_CAP_PIN_ASSIGN_DFP_D(dp->port->vdo);
...
}Using DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo) in DP_STATUS_CON_DFP_D reads the UFP_D pin field on an actual DFP_D partner (which is 0 on both plug and receptacle DFP_D devices), causing dp_altmode_configure() to fail with -EINVAL.
When a UFP_D plug partner (such as 0x00001c05) reaches DP_STATUS_CON_DFP_D (for example via ucsi_displayport_status_update(), which checks DP_CAP_UFP_D on the local port VDO and reports DP_STATUS_CON_DFP_D), this branch sets DP_CONF_UFP_U_AS_DFP_D in dp->data.conf. That configures the sink partner as a DP source and causes get_current_pin_assignments() to check DP_CAP_PIN_ASSIGN_DFP_D(dp->alt->vdo), returning 0 and breaking the pin_assignment and configuration sysfs attributes.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1