From patchwork Tue Oct 22 17:28:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yanik Fuchs X-Patchwork-Id: 13845993 Received: from ZR1P278CU001.outbound.protection.outlook.com (mail-switzerlandnorthazon11022081.outbound.protection.outlook.com [40.107.168.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D1366EB7C; Tue, 22 Oct 2024 17:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.168.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729618137; cv=fail; b=QOZKYIl2a1ss6MkI8bpHINyp5rHiJydUA0JGSXTWpOoovZCZjcXcVc/xCk88JaCk0sqlF3cvWmXMjV6HrKdEqgLV78fv9R0DKe710i7CjMWwgxiVi+PblJZM/ifYdissJe2U127HxqCDWeCVX5oloUsNoofYSI3Y3gJbxtjDT5c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729618137; c=relaxed/simple; bh=l3FJE3F1GNT8xcufy4EqEY5p0YaO8fFvVGL2y2w0cKc=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=tFWJsl8WKawsbAO4rw9mfWyAvSYA6j8dtlLUFAu3LB9JT+3Kvc6qi+nIqwRUhQ4lCX9qnVNZzH2p4NZHK3RO0qCPwJ7wz4sLKigDCv8JXDS4hTlaaLk/gAssKEyXpHLeCV7cAv83zrKkiQ7q4F1mYB8GaIWwnrqvp2nksBMExnE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mbv.ch; spf=pass smtp.mailfrom=mbv.ch; dkim=pass (1024-bit key) header.d=newgenag.onmicrosoft.com header.i=@newgenag.onmicrosoft.com header.b=ACdRNVcG; arc=fail smtp.client-ip=40.107.168.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mbv.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mbv.ch Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=newgenag.onmicrosoft.com header.i=@newgenag.onmicrosoft.com header.b="ACdRNVcG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=paM2oP+qUwlAKvjkns/IiuvZL5SlK1p1GKYrylMQgNg7KnihBqut+2ft20mFWsFIKO3tN6N6fR3u3ixyRwu1VSKl1oqjm6cL2HoyGo0ETt9zRDHX9FnVmWcQbbXUNnO2nVTbt3IFCjbu0yRLO9lmYvKFJGii2EtzTqkVbt8M4M4lJUvSXBhlsjtdwvTspN5CnkarrFL2zEmfDjSMm5SlLFJELMTcw4Yv8flvEbmJmsFPg9m16J/keoEIUWqmUSsJExyxYEHkPoPRYHkVH4cWp0JWDe94+NxyfSHkgkJzFF6wlU8lhYYtdDOW4NOaLs+Gs/cKkFQSmOCr9Yf2YnGv1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6NjVe3C78BbUTU6R+TCZ5ngIxsbsYi+1Q1slHoWddsc=; b=IQiKHI34SshsyDNRd2dX3mV3VuprRY1bjEuDK2vHTsJJLRVA7giHHKdnDV9xVIdprYWRfn5tBXAKlNxpVrh/GJBX01+mbfz1WvyKBO681cEn0ZfKt8E7i7Cg9xxyhHJJ/aGUqPhjqjcsDFqAS37mMKJ0vrifNzrAxTDJNzAS4stOfzK5wGoPk3Os2t1Cd9Fteq4IVa/DSXGcF0gSgDZs4hrST0A4KF4vVJDSGcUjqmNY8pAW64eFUhLcPOa5SLv4SfrpbX8hLRlItUrRq08Roye3QloSgQP5PT2uCSDVJQLBEkjdUtK7mXHYwUr7hdSop0v+A8JgWLAe3EsigHcvOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mbv.ch; dmarc=pass action=none header.from=mbv.ch; dkim=pass header.d=mbv.ch; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newgenag.onmicrosoft.com; s=selector1-newgenag-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6NjVe3C78BbUTU6R+TCZ5ngIxsbsYi+1Q1slHoWddsc=; b=ACdRNVcGEz1l0piKaRiJAZyW1ZScLNm5+G4xjcmA21mHKckujrD+eVY4+mDgDQxWlLW1BBSDUgW1zjVLjjUDEXc9hsEOpQfCMAXi2fRIL55QSncbnh26r6nl6XekM+ygeTGqVJrD8nbWOcRLBWztQAdRK+jEr4EvExicwce7org= Received: from GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:49::12) by ZRAP278MB0109.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:12::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Tue, 22 Oct 2024 17:28:51 +0000 Received: from GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM ([fe80::373:3184:90d1:31b6]) by GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM ([fe80::373:3184:90d1:31b6%3]) with mapi id 15.20.8069.027; Tue, 22 Oct 2024 17:28:51 +0000 From: Yanik Fuchs To: "heikki.krogerus@linux.intel.com" , "gregkh@linuxfoundation.org" , "rdbabiera@google.com" , "linux@roeck-us.net" , "kyletso@google.com" , "badhri@google.com" , "xu.yang_2@nxp.com" , "amitsd@google.com" CC: "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] usb: typec: tcpm: Prevent Hard_Reset if Vbus was never low Thread-Topic: [PATCH] usb: typec: tcpm: Prevent Hard_Reset if Vbus was never low Thread-Index: AQHbJKZBKbAlUNbL60mUuxGGz7rdEw== Date: Tue, 22 Oct 2024 17:28:51 +0000 Message-ID: Accept-Language: de-DE, de-CH, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=mbv.ch; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: GVAP278MB0662:EE_|ZRAP278MB0109:EE_ x-ms-office365-filtering-correlation-id: 43480654-e877-496a-a616-08dcf2beff28 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?AZGlTc/gnJPqtook6V/DtOrHk/?= =?iso-8859-1?q?lTaICmQb7dblINAIAUu6zJtKZRghEkzt97YrPrNXGqTimVXIV6tOk7r1Gf78?= =?iso-8859-1?q?XwZyXNpVxh0qQjvAmUmhYxv3m5CJ24TszetEOOG46qmeRcnS1xemNr5sArSg?= =?iso-8859-1?q?zTo2ATPLpGlBf5G1fWKZ8aC56ci3iprAPOFttMBCBAAORPKFQIn1Ln2K6r95?= =?iso-8859-1?q?9cNn1p9Apldy78kaHQgMOhSQW1a1hAiWGr+q0fPMT1bf0NagbQ4JyeNFs6Xh?= =?iso-8859-1?q?GhUpo86ntkMEFO4I9qhZxKCPiGA6BZjpakV1fKCj4f49pOJvfH62VGCpqKrW?= =?iso-8859-1?q?R5YO1KJu8xsRZGGH3kyXuN5bqWQh716bGYA7nqGwFgnaWvo1af2cX0UlTzMZ?= =?iso-8859-1?q?VnwR1ymKYPIKwYN6FgqSgevx5R9YPnN6VnfBuh/uGZQ6YlmeT9v+STBDnWtH?= =?iso-8859-1?q?6Y8LtS9+C0AWTjyUPaa8EdrwOVuZs7xM3iG+n7GAidQYT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2gcyyeRj0UjGeOL4e3/KKMXrkb41M2NMus6qIt4Y=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024)(38070700018);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?ZsaKZp+yzTjfV3FAS6W99X/?= =?iso-8859-1?q?yojbTsYR/4Douoxfdj0JS9P6wcpixz/VRK2ytibuybaoqvDKIOVs3ztvKFMR?= =?iso-8859-1?q?37z2651ff9NS1QoVrOSoQuanIg/pldLS/+nN1LONYVUPuPI+mMyC420ixoV8?= =?iso-8859-1?q?wZbQT8ZOy+F7RnIVDnL3BHhtrzXx+wqltffVI37wLvzFiq2BYqPnhya1K8BP?= =?iso-8859-1?q?hwjVIIGo7KZ5VXwNQ2V0fUwEVZi1lynNOzddcoxPVXrDL0lsXP06cDgAU2ur?= =?iso-8859-1?q?PdqFHWRo3IdGhe58ADN1Y+wU5yFRuat+0fShfUE+rvxWXQIf6/K6jHYIrOsS?= =?iso-8859-1?q?JOtXfVVQtBbofDRgVFTEqwjU5B8AUsvFXjyfiBQHv0n0cXFl85u4G0jppLPT?= =?iso-8859-1?q?nITs7Us3++ZB4wK5zf18TwIjHK0yYTEqvWmEPOySqHV5uPa4bR3KzEYGzzoS?= =?iso-8859-1?q?dwKsiY0PLExPVRJ3C8chzn0+z0w7mhG5wGZPAakN4nx4pALEyIrrE0wjfEAm?= =?iso-8859-1?q?C9PQw/Y8HmBWSRaelB0cUFVeJiWJBvbmCZCNnUhLpx4HtiyO6uc0fUQLjDq1?= =?iso-8859-1?q?fBhRCQbeGRueS3iRJTBU+SOe9Exvb7e/p/wlYi5L+Q26TG/0JbWMd4ViTB3c?= =?iso-8859-1?q?u0PS1Q6L8TjZT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PCmf2t1N28yT+?= =?iso-8859-1?q?A1yFbslTKljykKYXvGadnHPJEK39+gueGrRh5clUgwKYk75H9oBNQwk4=3D?= Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: mbv.ch X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: GVAP278MB0662.CHEP278.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 43480654-e877-496a-a616-08dcf2beff28 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Oct 2024 17:28:51.7722 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0b9c2100-a992-4d02-9349-895ecb1a1527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mqkvy/jeMbQD3P+vCStOrU21PiUxta75WPIxWr5VboZWZlYrB0ry4+FJwknaVM8pCWS7/gm3rr/CXpbVXCBU6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZRAP278MB0109 Good Evening Here is a Patch to resolve an issue with TCPM if Vbus was never low. Please consider that this is one of my first kernel pull requests, I may have missunderstood the process. Freundliche GrĂ¼sse Best regards Yanik Fuchs --- From 604b97b6394b5643394bc63d4ac691c098c99c40 Mon Sep 17 00:00:00 2001 From: yfu Date: Tue, 22 Oct 2024 18:23:18 +0200 Subject: [PATCH] usb: typec: tcpm: Prevent Hard_Reset if Vbus was never low Before this patch, tcpm went into SOFT_RESET state, if Vbus was never low resulting in Hard_Reset, if power supply does not support USB_PD Soft_Reset. In order to prevent this, I remove the Vbus check completely, so that we go as well into the SNK_WAIT_CAPABILITIES_TIMEOUT state. There, we send PD_CTRL_GET_SOURCE_CAP which many power supply do support. (122968f8dda8 usb: typec: tcpm: avoid resets for missing source capability messages) Additionally, I added SOFT_RESET (instead of Hard_Reset) as Fallback solution if we still not have gotten any capabilities. Hard_Reset is now only done, if PD_CTRL_GET_SOURCE_CAP and SOFT_RESET fail to get capabilities. --- drivers/usb/typec/tcpm/tcpm.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index fc619478200f..c7a59c9f78ee 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -5038,14 +5038,8 @@ static void run_state_machine(struct tcpm_port *port) * were already in a stable contract before this boot. * Do this only once. */ - if (port->vbus_never_low) { - port->vbus_never_low = false; - tcpm_set_state(port, SNK_SOFT_RESET, + tcpm_set_state(port, SNK_WAIT_CAPABILITIES_TIMEOUT, PD_T_SINK_WAIT_CAP); - } else { - tcpm_set_state(port, SNK_WAIT_CAPABILITIES_TIMEOUT, - PD_T_SINK_WAIT_CAP); - } break; case SNK_WAIT_CAPABILITIES_TIMEOUT: /* @@ -5064,7 +5058,7 @@ static void run_state_machine(struct tcpm_port *port) * according to the specification. */ if (tcpm_pd_send_control(port, PD_CTRL_GET_SOURCE_CAP, TCPC_TX_SOP)) - tcpm_set_state_cond(port, hard_reset_state(port), 0); + tcpm_set_state_cond(port, SNK_SOFT_RESET, 0); else tcpm_set_state(port, hard_reset_state(port), PD_T_SINK_WAIT_CAP); break;