From nobody Mon Feb 9 19:25:30 2026 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.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 000CE369985 for ; Mon, 19 Jan 2026 13:18:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768828744; cv=none; b=Hjv2NqluyDnGITvFEWyqGwQQlp7kOJCWG5bGY+asrnYiF3MlQYzEi4S075hb7DV7N0msjSB96677dP+A6VK2cU6dROfuT51KP61A1TSwuxMEM74ucuuySxHnJEe5zgYRzvtNuFgx9DCTQi8qJ0BkUsnTBujt6242Qj0aJNc09sQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768828744; c=relaxed/simple; bh=zFB/wu9zF/WPehhEPtbWl8UOJvP9spgPqLlItDsGdnM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fHWNRhg7EXGl3huhILrVhn+dVXGoiamDXhZNGukmbMxCISz+FtUfpeC/ZOBMDqhzaZAih9YjefBmSVYb5dRLFmz6916/5RjdaUvgO+5KFcxtH8VQRmVf9lYfdN1s85nv9SxT77xLnXP+sSrChnL11cidY4MYvStO3S2qA4xqZw8= 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=bIGmewBI; arc=none smtp.client-ip=209.85.208.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="bIGmewBI" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-64baaa754c6so6527983a12.3 for ; Mon, 19 Jan 2026 05:18:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1768828737; x=1769433537; 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=4Jj9JdVBqHdqB0HXN619HZiSF0v0HIUhhUTLIyvICbg=; b=bIGmewBIoAq+cT0Qhjb/uS492Db3u8Tp0aySa1K31MSvBb2Hh2KY+jm0afvZKLOvZL RCzWUzRFhtYiuamP+bLmf9+DpEZS68T31VQQdHgC3OF0+bG2yY2NI/lD5TrP3XPN05ju pJL+o+T03+h+9EjDNwqPIobfBvMAazWmaXELM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768828737; x=1769433537; 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=4Jj9JdVBqHdqB0HXN619HZiSF0v0HIUhhUTLIyvICbg=; b=vzdF380CjdVcgT0B1EyiHbokKTg7Hxex2d5I8nv5aZpv9W2wNzYbmWWnUaNLYNL6ZZ ePW0JzhSmvBrC+8+ANP2TD3uDeBSEY9aSDHi/4e8CxBIZS8EvoRZhw6ZyOTf/XP+xAE/ 935JwCiecVkaHe49vpQd+rESfpwJ7kjpXOy5Y0vVfARtSvCXkDc4ODq53lP6o1spqos2 OP3g0EEkFuYpKc5wvVHE2baQTEKlinoCRYxAwappsk4vAO6YlMIt/2agwtzpCxR1z0/0 8JAbfK80v4Vc2kXfZCUfenGpnahxNmrWN1PFsBDy+meL7/OT30qXbgasC+5QCZKzqCcP ikDA== X-Forwarded-Encrypted: i=1; AJvYcCXvg/CPH3wjqJfsgiaFvCEG04AQdohcouD7gmIz97Tyan6u3+YJSLqO4Yzv6o8vI2vNCU3oFrL2r+kv3PY=@vger.kernel.org X-Gm-Message-State: AOJu0YxvrWtnVwa6MDDUuYNCXh683RfoVOEbq8OlfdUEbwZLeyrlO0ps GVxWw6J/QDfY2C8oANNzRZmNtdpMnC4rThP6CBNYP7G+zMmeU5VIx3TCk8G7Ramygg== X-Gm-Gg: AY/fxX7zs7+Qse2JH7gPUmFVwSGFUca7NH8kD/aNqwsAgSnvKIKy73npVg7RDqyChW0 yaV3XHe1HNqH1GpXBUXVCWPIU5ralmONop0e8lJqO2SQr8cvu4NbphDxgpRrmIhaoMpsvYjzyfi ZePaC37Jy3GpiBR0uB7M958CyuDA6hihVSALEPlAIWfvSw7nKmVKicBCCLDWbF3yXAqH38J9yp5 udo/WoD2tTAefnTXxC0OP/GksVlJBp1Ivi/1vXfuywxFqPagJTpOj6OriLBPymRgRrSSpPKECMe gDg5Jf4LT+xkT95jNl/6Q/mD4E/+aw7jiD8Rwruia2zKgKzFlee2wNh3RwaFbMZ7HNY2Hq2ZWsG wdW8Kk845DL5Q9ubjjf/kiG4pbor1/O7P1MnTtb65JZSI0L/g3zHKleCcnfZsvgrl4weQP5/e9p 9mV2o4vFemMeCQJkGizckoT4Jx6RGD8UBiH234ozN8NMfAuwna0VzRQqp/51+oLMu3+k7fk0e6y AUQ3g88 X-Received: by 2002:a17:907:8692:b0:b87:6ce:1269 with SMTP id a640c23a62f3a-b8792de8e4cmr919137966b.19.1768828737282; Mon, 19 Jan 2026 05:18:57 -0800 (PST) Received: from akuchynski.c.googlers.com.com (150.230.32.34.bc.googleusercontent.com. [34.32.230.150]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b87959c9a14sm1078801866b.45.2026.01.19.05.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jan 2026 05:18:56 -0800 (PST) From: Andrei Kuchynski To: Heikki Krogerus , Abhishek Pandit-Subedi , Benson Leung , Jameson Thies , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: Tzung-Bi Shih , Guenter Roeck , Greg Kroah-Hartman , Dmitry Baryshkov , =?UTF-8?q?=C5=81ukasz=20Bartosik?= , Pooja Katiyar , Johan Hovold , Hsin-Te Yuan , Madhu M , Venkat Jayaraman , Andrei Kuchynski Subject: [PATCH v5 7/7] usb: typec: ucsi: Enforce mode selection for cros_ec_ucsi Date: Mon, 19 Jan 2026 13:18:24 +0000 Message-ID: <20260119131824.2529334-8-akuchynski@chromium.org> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog In-Reply-To: <20260119131824.2529334-1-akuchynski@chromium.org> References: <20260119131824.2529334-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 mode selection sequence is initiated by the driver after all partner alternate modes have been successfully registered. When a partner is disconnected, the driver also stops the mode selection process and releases resources via `typec_mode_selection_delete`. Signed-off-by: Andrei Kuchynski --- Changes in V5: - Use the no_mode_control field instead of con->ucsi->cap.features & UCSI_CAP_ALT_MODE_OVERRIDE drivers/usb/typec/ucsi/cros_ec_ucsi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi= /cros_ec_ucsi.c index eed2a7d0ebc63..6bca2dce211cd 100644 --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #include "ucsi.h" =20 @@ -33,6 +34,11 @@ /* Number of times to attempt recovery from a write timeout before giving = up. */ #define WRITE_TMO_CTR_MAX 5 =20 +/* Delay between mode entry/exit attempts, ms */ +static const unsigned int mode_selection_delay =3D 1000; +/* Timeout for a mode entry attempt, ms */ +static const unsigned int mode_selection_timeout =3D 4000; + struct cros_ucsi_data { struct device *dev; struct ucsi *ucsi; @@ -134,6 +140,20 @@ static int cros_ucsi_sync_control(struct ucsi *ucsi, u= 64 cmd, u32 *cci, return ret; } =20 +static void cros_ucsi_add_partner_altmodes(struct ucsi_connector *con) +{ + if (!con->typec_cap.no_mode_control) + typec_mode_selection_start(con->partner, + mode_selection_delay, + mode_selection_timeout); +} + +static void cros_ucsi_remove_partner_altmodes(struct ucsi_connector *con) +{ + if (!con->typec_cap.no_mode_control) + typec_mode_selection_delete(con->partner); +} + static const struct ucsi_operations cros_ucsi_ops =3D { .read_version =3D cros_ucsi_read_version, .read_cci =3D cros_ucsi_read_cci, @@ -141,6 +161,8 @@ static const struct ucsi_operations cros_ucsi_ops =3D { .read_message_in =3D cros_ucsi_read_message_in, .async_control =3D cros_ucsi_async_control, .sync_control =3D cros_ucsi_sync_control, + .add_partner_altmodes =3D cros_ucsi_add_partner_altmodes, + .remove_partner_altmodes =3D cros_ucsi_remove_partner_altmodes, }; =20 static void cros_ucsi_work(struct work_struct *work) --=20 2.52.0.457.g6b5491de43-goog