From nobody Mon Dec 1 22:03:23 2025 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD40B30CD8D for ; Mon, 1 Dec 2025 12:26:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764591983; cv=none; b=GBZSDhGSSSXQwL3CVg90YfJtvc7RSkpLEIiVQf6YducM57UpAY5EENJZXScydA/Bwfbmv8VXPPFvG3B+eKsNZKvY20soVPEjFddUGyzTWCaxaTtq92qp1BUPFX2jrHtkiPhXy19lS6kn53B2u6BcIIKRUOR4Mvv/ZTRdN+Dzv4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764591983; c=relaxed/simple; bh=2fgxrQ6jc8GbzE02aljh/gumtmLhDqXZ2JKdgPay0tQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LTz/apcj3SpfmPztqkHMctleUBjjH3Iw346KgrN/Bq8AC1PbTijEAY2dXk+0PJPywYQq1qbslybOKpinqJdw24q90/U2OoxEEONpzgComDPtlJfp14s5QfMKarSu0oGYXWfbyHpdMcAzj9uahNtvko/ztLb5ptPcYIrsrC484Ac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=FlTyu7YO; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FlTyu7YO" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-b7277324204so652080366b.0 for ; Mon, 01 Dec 2025 04:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1764591979; x=1765196779; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HQwsVtSafiZd3UhajYLeZRsX8ICttvoyqVoP0kXhJGQ=; b=FlTyu7YO8kqqXe2M25mbovei5S+TIqE+GJ4890teKAQvCOw/7gRd5gdzrhEkhwWdcB VjSbEH1y9xKUtuJBFt+SxmPtdM4SMf+VSB6GnzHlI7V9wtI+yL6+1ckv93orrAWT8iIB Mq17yYjva9V5DIDgHXDtSL9I2a6leq4yveZ00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764591979; x=1765196779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HQwsVtSafiZd3UhajYLeZRsX8ICttvoyqVoP0kXhJGQ=; b=Ti+sT+vVy7cuWLwC/Ce+XAz4cf1ggry70HtswgXmeiA8hWMFm8OIxcCccbc9Flv/vs 9MUw5wC4G2IbvJXn1uP19AIrrPeqOI8KCunh3hejt/xPkfJuXy321NEloQzNVOLsl4sP d8hyG6riW+WWN8xCfwvLNxt6hkXGt4SwM3y15ejeWGZF05qTljYyaW4oyMqeClbXcQPD eftDw+XsTxUrvJRNUcK27eM4ewmM08ANA6YP7TmztVVCkeRMCJrW7oN0n6RusC9dg4A6 ee01oCYOhaMahtsGrBZpYoRJnMSlO7sMdzfF53m4yoQRq7OjMf7GzfT1kBHrR20K5SRJ ax9Q== X-Forwarded-Encrypted: i=1; AJvYcCW1NfY4AGGekgyJEHKCV96h+gwXRfnX2GgBd/L3JradVofK5j+r+Etmf/rLcJO/dgZiio/jglcXYrt1GXE=@vger.kernel.org X-Gm-Message-State: AOJu0YyxGWL7J4YzhlvCRmy4YfRnNXHlx6c19jdzv/x1yKUXJ898iqQ+ 70zyp905I/yjBLNYHkChW3tFokeDs0RWAybkeBm8s3JQeFfZqiEE3EHayaNtxxZNpA== X-Gm-Gg: ASbGncvPUKsG4b+TsP3A3T/I4fT/QR9SqtVhhJ2vGBhk8qSNHTs/+u1BsAsslM/oDPB rcjI7ysdfEeAs1Kl3JW/XzBqu6Wulb2Ocj841ghThUxFWyceYRHv+Qg7y/0wQrvsnyDi2P5wp8m TzB2nWoG8+vG1coZzPoGCpgIY/iXvd3WBTQHgRAZMp+6TS8F9JuYs3Rpp/GekPobwBY+PDTKNgj cfTxpOLEZMt7MhHtGjm8ZscTyDX8elhT8kZT7FX4lK4ZbYajAJnETPkHtdQK+1hrrWAhHkR4xdw wRmRt/SfGzMRbDy2WAdsv9shQItE1otnAO2sN8DAVbPY9SIOz9A7zpduxIdd7J6Th+UKbMoRpQ2 bs4yGqa6lY2omYWpDL9sY3Vhez2PzU0qie1dUSFaqPNim3qSWLL23D8ucpbOtGeGVMCLInayZ8O +g6wwTNgK7ngFC4ubIqto8BO+4uozXZqd2XD907VrX9haCO350qfDyYWCyOdmXSoxF2SgPe9bl6 N79vwSFqxA= X-Google-Smtp-Source: AGHT+IH3FHNKiHqdnaGg19IfebqWiFqLmfFp6qr3dC+UY3zUwt8OkPTo0J+bJm2U71ymQvdRKypR8Q== X-Received: by 2002:a17:907:78a:b0:b73:5b9a:47c7 with SMTP id a640c23a62f3a-b76c555dc15mr2821605766b.51.1764591978997; Mon, 01 Dec 2025 04:26:18 -0800 (PST) Received: from akuchynski.c.googlers.com.com (218.127.147.34.bc.googleusercontent.com. [34.147.127.218]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b76f519e331sm1229049266b.24.2025.12.01.04.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 04:26:18 -0800 (PST) From: Andrei Kuchynski To: Heikki Krogerus , Abhishek Pandit-Subedi , Benson Leung , Jameson Thies , Tzung-Bi Shih , linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Cc: Guenter Roeck , Greg Kroah-Hartman , Dmitry Baryshkov , "Christian A. Ehrhardt" , Abel Vesa , Pooja Katiyar , Pavan Holla , Madhu M , Venkat Jayaraman , linux-kernel@vger.kernel.org, Andrei Kuchynski Subject: [PATCH RFC 3/8] usb: typec: Introduce mode_selection bit Date: Mon, 1 Dec 2025 12:25:59 +0000 Message-ID: <20251201122604.1268071-4-akuchynski@chromium.org> X-Mailer: git-send-email 2.52.0.158.g65b55ccf14-goog In-Reply-To: <20251201122604.1268071-1-akuchynski@chromium.org> References: <20251201122604.1268071-1-akuchynski@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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/a= ltmodes/displayport.c index 8d111ad3b71b..49d5a123e4c4 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -800,8 +800,10 @@ int dp_altmode_probe(struct typec_altmode *alt) if (plug) typec_altmode_set_drvdata(plug, dp); =20 - dp->state =3D plug ? DP_STATE_ENTER_PRIME : DP_STATE_ENTER; - schedule_work(&dp->work); + if (!alt->mode_selection) { + dp->state =3D plug ? DP_STATE_ENTER_PRIME : DP_STATE_ENTER; + schedule_work(&dp->work); + } =20 return 0; } diff --git a/drivers/usb/typec/altmodes/thunderbolt.c b/drivers/usb/typec/a= ltmodes/thunderbolt.c index 6eadf7835f8f..c4c5da6154da 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); =20 - if (tbt_ready(alt)) { + if (!alt->mode_selection && tbt_ready(alt)) { if (tbt->plug[TYPEC_PLUG_SOP_P]) tbt->state =3D 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 049d1829be98..cffe3c7d1671 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -639,6 +639,7 @@ typec_register_altmode(struct device *parent, alt->adev.svid =3D desc->svid; alt->adev.mode =3D desc->mode; alt->adev.vdo =3D desc->vdo; + alt->adev.mode_selection =3D desc->mode_selection; alt->roles =3D desc->roles; alt->id =3D id; =20 diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 59d5fd7e4ff4..7a9dec9b0775 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -152,6 +152,7 @@ struct typec_altmode_desc { /* Only used with ports */ enum typec_port_data roles; bool inactive; + bool mode_selection; }; =20 void typec_partner_set_pd_revision(struct typec_partner *partner, u16 pd_r= evision); diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_al= tmode.h index faf72e4d6ceb..c72065fddb7b 100644 --- a/include/linux/usb/typec_altmode.h +++ b/include/linux/usb/typec_altmode.h @@ -31,6 +31,7 @@ struct typec_altmode { u32 vdo; unsigned int active:1; u8 priority; + bool mode_selection; =20 char *desc; const struct typec_altmode_ops *ops; --=20 2.52.0.158.g65b55ccf14-goog