From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Andrei Kuchynski <akuchynski@chromium.org>
Cc: "Abhishek Pandit-Subedi" <abhishekpandit@chromium.org>,
"Benson Leung" <bleung@chromium.org>,
"Jameson Thies" <jthies@google.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
chrome-platform@lists.linux.dev,
"Tzung-Bi Shih" <tzungbi@kernel.org>,
"Guenter Roeck" <groeck@chromium.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>,
"Łukasz Bartosik" <ukaszb@chromium.org>,
"Pooja Katiyar" <pooja.katiyar@intel.com>,
"Johan Hovold" <johan@kernel.org>,
"Hsin-Te Yuan" <yuanhsinte@chromium.org>,
"Madhu M" <madhu.m@intel.com>,
"Venkat Jayaraman" <venkat.jayaraman@intel.com>
Subject: Re: [PATCH v5 5/7] usb: typec: Introduce mode_selection bit
Date: Tue, 20 Jan 2026 17:25:23 +0200 [thread overview]
Message-ID: <aW-eY8JCKNpgwa2I@kuha> (raw)
In-Reply-To: <20260119131824.2529334-6-akuchynski@chromium.org>
Mon, Jan 19, 2026 at 01:18:22PM +0000, Andrei Kuchynski kirjoitti:
> 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>
> ---
> drivers/usb/typec/altmodes/displayport.c | 6 ++++--
> drivers/usb/typec/altmodes/thunderbolt.c | 2 +-
> drivers/usb/typec/class.c | 1 +
> include/linux/usb/typec.h | 1 +
> include/linux/usb/typec_altmode.h | 1 +
> 5 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index d96ab106a980b..d185688a16b13 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -804,8 +804,10 @@ int dp_altmode_probe(struct typec_altmode *alt)
> if (plug)
> typec_altmode_set_drvdata(plug, dp);
>
> - dp->state = plug ? DP_STATE_ENTER_PRIME : DP_STATE_ENTER;
> - schedule_work(&dp->work);
> + if (!alt->mode_selection) {
> + dp->state = plug ? DP_STATE_ENTER_PRIME : DP_STATE_ENTER;
> + schedule_work(&dp->work);
> + }
>
> return 0;
> }
> diff --git a/drivers/usb/typec/altmodes/thunderbolt.c b/drivers/usb/typec/altmodes/thunderbolt.c
> index 6eadf7835f8f6..c4c5da6154da9 100644
> --- a/drivers/usb/typec/altmodes/thunderbolt.c
> +++ b/drivers/usb/typec/altmodes/thunderbolt.c
> @@ -307,7 +307,7 @@ static int tbt_altmode_probe(struct typec_altmode *alt)
> typec_altmode_set_drvdata(alt, tbt);
> typec_altmode_set_ops(alt, &tbt_altmode_ops);
>
> - if (tbt_ready(alt)) {
> + if (!alt->mode_selection && tbt_ready(alt)) {
> if (tbt->plug[TYPEC_PLUG_SOP_P])
> tbt->state = TBT_STATE_SOP_P_ENTER;
> else if (tbt->plug[TYPEC_PLUG_SOP_PP])
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index a48c447125184..dbba53f024977 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -655,6 +655,7 @@ typec_register_altmode(struct device *parent,
> alt->adev.svid = desc->svid;
> alt->adev.mode = desc->mode;
> alt->adev.vdo = desc->vdo;
> + alt->adev.mode_selection = desc->mode_selection;
> alt->roles = desc->roles;
> alt->id = id;
>
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index dbb259d885266..d61ec38216fa9 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -155,6 +155,7 @@ struct typec_altmode_desc {
> /* Only used with ports */
> enum typec_port_data roles;
> bool inactive;
> + bool mode_selection;
> };
>
> void typec_partner_set_pd_revision(struct typec_partner *partner, u16 pd_revision);
> diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h
> index 70026f5f8f997..0513d333b7977 100644
> --- a/include/linux/usb/typec_altmode.h
> +++ b/include/linux/usb/typec_altmode.h
> @@ -37,6 +37,7 @@ struct typec_altmode {
> u32 vdo;
> unsigned int active:1;
> u8 priority;
> + bool mode_selection;
>
> char *desc;
> const struct typec_altmode_ops *ops;
> --
> 2.52.0.457.g6b5491de43-goog
--
heikki
next prev parent reply other threads:[~2026-01-20 15:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-19 13:18 [PATCH v5 0/7] USB Type-C mode selection Andrei Kuchynski
2026-01-19 13:18 ` [PATCH v5 1/7] usb: typec: Add mode_control field to port property Andrei Kuchynski
2026-01-19 13:18 ` [PATCH v5 2/7] platform/chrome: cros_ec_typec: Set no_mode_control flag Andrei Kuchynski
2026-01-19 13:18 ` [PATCH v5 3/7] usb: typec: Expose alternate mode priority via sysfs Andrei Kuchynski
2026-01-20 15:20 ` Heikki Krogerus
2026-01-19 13:18 ` [PATCH v5 4/7] usb: typec: Implement mode selection Andrei Kuchynski
2026-01-20 15:24 ` Heikki Krogerus
2026-01-19 13:18 ` [PATCH v5 5/7] usb: typec: Introduce mode_selection bit Andrei Kuchynski
2026-01-20 15:25 ` Heikki Krogerus [this message]
2026-01-19 13:18 ` [PATCH v5 6/7] usb: typec: ucsi: Support mode selection to activate altmodes Andrei Kuchynski
2026-01-20 15:26 ` Heikki Krogerus
2026-01-19 13:18 ` [PATCH v5 7/7] usb: typec: ucsi: Enforce mode selection for cros_ec_ucsi Andrei Kuchynski
2026-01-20 15:27 ` Heikki Krogerus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aW-eY8JCKNpgwa2I@kuha \
--to=heikki.krogerus@linux.intel.com \
--cc=abhishekpandit@chromium.org \
--cc=akuchynski@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=johan@kernel.org \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=madhu.m@intel.com \
--cc=pooja.katiyar@intel.com \
--cc=tzungbi@kernel.org \
--cc=ukaszb@chromium.org \
--cc=venkat.jayaraman@intel.com \
--cc=yuanhsinte@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox