Skip to content

Commit be727d4

Browse files
Andrei Kuchynskigregkh
authored andcommitted
usb: typec: Introduce mode_selection bit
The port driver sets this bit for an alternate mode description to indicate support for the mode selection feature. Once set, individual Alt Mode drivers will no longer attempt to activate their respective modes within their probe functions. This prevents race conditions and non-prioritized activation. The bit is not set by default. If left unset, the system retains the current behavior where Alt Mode drivers manage their own activation logic. Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://patch.msgid.link/20260119131824.2529334-6-akuchynski@chromium.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fb2abc7 commit be727d4

5 files changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/usb/typec/altmodes/displayport.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,10 @@ int dp_altmode_probe(struct typec_altmode *alt)
804804
if (plug)
805805
typec_altmode_set_drvdata(plug, dp);
806806

807-
dp->state = plug ? DP_STATE_ENTER_PRIME : DP_STATE_ENTER;
808-
schedule_work(&dp->work);
807+
if (!alt->mode_selection) {
808+
dp->state = plug ? DP_STATE_ENTER_PRIME : DP_STATE_ENTER;
809+
schedule_work(&dp->work);
810+
}
809811

810812
return 0;
811813
}

drivers/usb/typec/altmodes/thunderbolt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static int tbt_altmode_probe(struct typec_altmode *alt)
307307
typec_altmode_set_drvdata(alt, tbt);
308308
typec_altmode_set_ops(alt, &tbt_altmode_ops);
309309

310-
if (tbt_ready(alt)) {
310+
if (!alt->mode_selection && tbt_ready(alt)) {
311311
if (tbt->plug[TYPEC_PLUG_SOP_P])
312312
tbt->state = TBT_STATE_SOP_P_ENTER;
313313
else if (tbt->plug[TYPEC_PLUG_SOP_PP])

drivers/usb/typec/class.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ typec_register_altmode(struct device *parent,
655655
alt->adev.svid = desc->svid;
656656
alt->adev.mode = desc->mode;
657657
alt->adev.vdo = desc->vdo;
658+
alt->adev.mode_selection = desc->mode_selection;
658659
alt->roles = desc->roles;
659660
alt->id = id;
660661

include/linux/usb/typec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct typec_altmode_desc {
155155
/* Only used with ports */
156156
enum typec_port_data roles;
157157
bool inactive;
158+
bool mode_selection;
158159
};
159160

160161
void typec_partner_set_pd_revision(struct typec_partner *partner, u16 pd_revision);

include/linux/usb/typec_altmode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct typec_altmode {
3737
u32 vdo;
3838
unsigned int active:1;
3939
u8 priority;
40+
bool mode_selection;
4041

4142
char *desc;
4243
const struct typec_altmode_ops *ops;

0 commit comments

Comments
 (0)