From nobody Tue Dec 2 02:43:45 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 E16012F9DBD for ; Tue, 18 Nov 2025 07:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763449630; cv=none; b=mb5p4SQG8HFmYqg2UHBiWTLSgRbTw2KjPKAl0mfXj6jO1nUIEhIc1RFzXc1iUlEkQWkCOBKI2s8Mx4GF7Y4vyPIrowKyRllSAFYDz8SLpQbF9i96doO5jyqhMXE43hgXUI9n6Bvjd1c5usZXfVoEoy/LXZQzd5QgfC6hl1aAljw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763449630; c=relaxed/simple; bh=umDOm77sBuJHCBd79yvi5yNQyz9vAqFLQFmlwU7STzE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=rxoANJVC+vQoA3z4oyPLWT6TlXU9Ep51H+ub89f3j538ft4B7J4uyhZDA9PxHmwuohr+nh+y7YqiloRhJ+z6UbzYNDSoXPr+lvBDjR/esDMMMPTwb+oC6hIMMMSiP9RwzOpLCF6GN2IqsUmTCR6YPgckGF/Q6CdBjanYt75QShQ= 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=X9xbKzK6; arc=none smtp.client-ip=209.85.210.174 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="X9xbKzK6" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7aa2170adf9so4434676b3a.0 for ; Mon, 17 Nov 2025 23:07:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1763449628; x=1764054428; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=WmeCcJZflztJCaKUB58JB6X8Eme/2R4su01QsX8HZaI=; b=X9xbKzK60x9mBEre/UIoGi7mZcFP6ok7y4Na/cgw8q6hyu51Do2+GdHDAhz2AaVk3x JwfIOMP4f8v+NCvuRketKOL9M0hl26dsKrct4a5clD1IHHbOMEd0zvVHwIGlzFB8wwwD aP8Th7kzerH28nlrvgwaOtOPsHmpjQO87Zo+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763449628; x=1764054428; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WmeCcJZflztJCaKUB58JB6X8Eme/2R4su01QsX8HZaI=; b=DwdEnHIsj9EtVhb5DzYZALkJfOo4MCOk0dfH74P5rgEhBoVuhK1u6EyfK2OA6R9kQ/ Njw6vYLOXjMlM1rx0+PdPcFAgIRS2UAsQS0xEmpZMSkDL7e881QOBk4Mfh06LtufE20l LSMjaCNmTUw0N1CLiJsTKadMEs2ZlhAhikSx61NUBLjUXyKD0NIX0pqzHA4UtSfOxmbq RkiSiZ+y7EVdrSDCEKK8zSKS7x6NWbWQ6tNrxnH4l6fIiqDEYW1h/yD/jtXjAlyzeiQb DaJ/2QEcd6qrpgdYyqzU2PMvzFur0b9PTzNRMCQ11icv47iZsX4eJNXr9BRE9CC46oNu WDFQ== X-Forwarded-Encrypted: i=1; AJvYcCU9OdbMqpXjpVTeR6P7ZHddl1I915C5FBSF6QkPTD2z9O9FWpN0eCOQuOt7k0NHwyX311v4Tobp9tTkiiU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw70XypEn2Uu+SkU2azMagdrOx1wigxD3BV56lY5p8f1QtC36uw R6oTngVLq/2T6t59O5xAC8Y6cu+mO7syfir/R7u/4wNlkDy6KlYv0zZA6rEc/03ZGK+HH87W3aB Y1+g= X-Gm-Gg: ASbGnctQvVmWUUr8l2oi6zrGUpf+7LzX7cGLXYTt/qfgTwLLQU9DfiPdg2e/jmqbQTG Zdo7tnMgbrWijwcRdPnn3H9sg1z07hhaXgri+U5v2mTaWCrmoTrE04ND+ea4OxixE4wRxZmZX1G sHk8i0KZ7l4G/E1+0L6obWgRbepYtoNESTLdgioDYcEl9JvXzzcmBpiISuZDdYfP33WZBuPfVhE eNzayjW/f0/xYnhpB8n7Mq1neIJwnwsapapVw2aBvr99fSRIvL+BIwSZp5GEhvIHnIQqYAZ4Mqh 76YVhG/5Fu3F6gu+5TyXbaF6p6wQTX2/fakZcmRoOP93hM4c01wTDDkQQfCvkI2lCko84OcCOAV KulY2d0ZlJuLkPmAqqduo10pzkbhWsvG+KqRJ0lbB6gb4aPOv2fkrOAEaIXn0u3ydzTO+4fs1RA 23QdtBMNo+R5krSEmHlOherCC+I4eSyN7mrEv79WGRdcj7QvrPyII6BaBih4aNzNzhh8T4M9GqM w== X-Google-Smtp-Source: AGHT+IHwjROVr6/h7ZqbmhEvJE5+ufDX2LOv4LvA1aTtHelQJDQZ533Op61GOUMG0FN7FwY2wKcyHA== X-Received: by 2002:a05:6a20:7294:b0:334:9b5d:3876 with SMTP id adf61e73a8af0-35b9ff88d19mr15606199637.4.1763449628125; Mon, 17 Nov 2025 23:07:08 -0800 (PST) Received: from yuanhsinte-p620-1.tpe.corp.google.com ([2a00:79e0:201d:8:39d6:487:8eb7:3217]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7b927826d51sm15481495b3a.49.2025.11.17.23.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Nov 2025 23:07:07 -0800 (PST) From: Hsin-Te Yuan Date: Tue, 18 Nov 2025 15:06:53 +0800 Subject: [PATCH v2] usb: typec: ucsi: Monitor connector change before getting connector status Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251118-ucsi-v2-1-d314d50333e2@chromium.org> X-B4-Tracking: v=1; b=H4sIAAwbHGkC/12MOw6DMBAFr4K2jiPb4hOlyj0iClgveAtwtA5WI uS741BGr5qn0ewQSZgi3KsdhBJHDmsBe6kA/bDOpNgVBqttY4zp1IaRFVo30Q21bl0HRX0JTfw 5M8++sOf4DvI9q8n83r9AMqrM4YgNDW1txwd6CQtvyzXIDH3O+QCiIm4PmwAAAA== X-Change-ID: 20251117-ucsi-c2dfe8c006d7 To: Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hsin-Te Yuan X-Mailer: b4 0.14.2 Originally, the notification for connector change will be enabled after the first read of the connector status. Therefore, if the event happens during this window, it will be missing and make the status unsynced. Enable the notification for connector change before getting the connector status to ensure the status is synced. Signed-off-by: Hsin-Te Yuan --- Changes in v2: - Remove unnecessary braces. - Link to v1: https://lore.kernel.org/r/20251117-ucsi-v1-1-1dcbc5ea642b@chr= omium.org --- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 3f568f790f39b0271667e80816270274b8dd3008..a7e0023d6504921d5be3795aecf= 84b83d33c66d1 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -1565,7 +1565,7 @@ static int ucsi_register_port(struct ucsi *ucsi, stru= ct ucsi_connector *con) struct typec_capability *cap =3D &con->typec_cap; enum typec_accessory *accessory =3D cap->accessory; enum usb_role u_role =3D USB_ROLE_NONE; - u64 command; + u64 command, ntfy; char *name; int ret; =20 @@ -1659,6 +1659,14 @@ static int ucsi_register_port(struct ucsi *ucsi, str= uct ucsi_connector *con) goto out; } =20 + /* Enable the notification for connector change before getting the connec= tor status */ + ntfy =3D UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR | UCSI_EN= ABLE_NTFY_CONNECTOR_CHANGE; + command =3D UCSI_SET_NOTIFICATION_ENABLE | ntfy; + ret =3D ucsi_send_command(ucsi, command, NULL, 0); + if (ret < 0) + dev_warn(ucsi->dev, "con%d: failed to enable the notification for connec= tor change\n", + con->num); + /* Get the status */ ret =3D ucsi_get_connector_status(con, false); if (ret) { --- base-commit: 6a23ae0a96a600d1d12557add110e0bb6e32730c change-id: 20251117-ucsi-c2dfe8c006d7 Best regards, --=20 Hsin-Te Yuan