Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp844899pxb; Tue, 3 Nov 2020 14:12:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2og9rH+m182ktHcXDRcxx3mLZ85+TICLCc3U+AdzGuIK5Vc/JjZi3pRif3qY5C3WAvHCS X-Received: by 2002:a50:e087:: with SMTP id f7mr23370631edl.96.1604441570136; Tue, 03 Nov 2020 14:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604441570; cv=none; d=google.com; s=arc-20160816; b=dDyIUkW000cNfIgV+B20bjodXSvUVLJeVps22pxfDzkEJPALfcsMdZ0cLLyDmgIArb Ea4XLxe27feBTIOW1+H0qWLrNPNvcGJD7HsBir7LlehM+MI31crjY0NXTuRyRnE7yZVr D7JJoGiS2xeZI6/8e5l7uQ2VpmIPw2+KjZwn0MEX6TSV2jf83mYgdXQNWn7odKAEUWSJ Sfze9Rw025LGHklH8qVG0tK5RS8agvtgMHYwgmif/A6CornVcIQi6X2dNN3Kg4CyZEj1 6gdGewnSXBOKfmUHW3imMS1t93PZmMFGXSoakkWgKq0y46/ZwV+1FlTz6MgQ0UYSH1qY fR6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xWfbAQKPN22gn/cp3gYoel0yrUbtTrgQkEva3ws34HU=; b=hSnp2Zd70ym1PfOaHjlwEtyM6vn9m89+VLMvhIl46yG33T0LWdwnl3/Rdqod2O8JZ7 RonjtOY0L/h1+54XrNul9Tk0qp7Z8O3CUQOo7aLba+onMsHKraDQEc/o4rjNbx/UyXmi Y8OZTIZ9POAwpJx4O1s5k8mtknZPvMq/FzFqcW001EMgCM2QC6npwqCKFpYwGqLvlSsf YWjQOe/cmjjox2syMXHi0p/N7cD1mzBOvukRpmSKev1CxIMW9ehfJjq3TKTPdfyBB8i7 3RF/G0Q+9FfcNwv8aajvhP05VhJUzyGfXQQe/B08o0SKVkv6/8cMtNccwGD4kwZFPYWl CYyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=naybG8kB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m11si14350667edl.523.2020.11.03.14.12.27; Tue, 03 Nov 2020 14:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=naybG8kB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730336AbgKCUlQ (ORCPT + 99 others); Tue, 3 Nov 2020 15:41:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:52806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730296AbgKCUlJ (ORCPT ); Tue, 3 Nov 2020 15:41:09 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1A48C2224E; Tue, 3 Nov 2020 20:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436068; bh=MHusWCzQbXS8q5RPNup4zvh14xCVYve4H+UBac0n7j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=naybG8kBBgLIYhuZd4wrSJYLFiOw+BaCcay5NJkoExT3XH2+izERVmCHpWjyJMwgL QBvGkmMPxClb0F1W7GgVf2HCRURpClosFKw+PABDJB54BxRnhkU6zWhe8N0g8ghO9U XFKv39yL3zddRR8kwzb0HbOvufoIEiuH9WB9Ma3g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Badhri Jagan Sridharan , Guenter Roeck , Heikki Krogerus , Sasha Levin Subject: [PATCH 5.9 088/391] usb: typec: tcpm: During PR_SWAP, source caps should be sent only after tSwapSourceStart Date: Tue, 3 Nov 2020 21:32:19 +0100 Message-Id: <20201103203352.932284730@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Badhri Jagan Sridharan [ Upstream commit 6bbe2a90a0bb4af8dd99c3565e907fe9b5e7fd88 ] The patch addresses the compliance test failures while running TD.PD.CP.E3, TD.PD.CP.E4, TD.PD.CP.E5 of the "Deterministic PD Compliance MOI" test plan published in https://www.usb.org/usbc. For a product to be Type-C compliant, it's expected that these tests are run on usb.org certified Type-C compliance tester as mentioned in https://www.usb.org/usbc. The purpose of the tests TD.PD.CP.E3, TD.PD.CP.E4, TD.PD.CP.E5 is to verify the PR_SWAP response of the device. While doing so, the test asserts that Source Capabilities message is NOT received from the test device within tSwapSourceStart min (20 ms) from the time the last bit of GoodCRC corresponding to the RS_RDY message sent by the UUT was sent. If it does then the test fails. This is in line with the requirements from the USB Power Delivery Specification Revision 3.0, Version 1.2: "6.6.8.1 SwapSourceStartTimer The SwapSourceStartTimer Shall be used by the new Source, after a Power Role Swap or Fast Role Swap, to ensure that it does not send Source_Capabilities Message before the new Sink is ready to receive the Source_Capabilities Message. The new Source Shall Not send the Source_Capabilities Message earlier than tSwapSourceStart after the last bit of the EOP of GoodCRC Message sent in response to the PS_RDY Message sent by the new Source indicating that its power supply is ready." The patch makes sure that TCPM does not send the Source_Capabilities Message within tSwapSourceStart(20ms) by transitioning into SRC_STARTUP only after tSwapSourceStart(20ms). Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20200817183828.1895015-1-badhri@google.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/typec/tcpm/tcpm.c | 2 +- include/linux/usb/pd.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index a48e3f90d1961..1e676ee44c937 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3573,7 +3573,7 @@ static void run_state_machine(struct tcpm_port *port) */ tcpm_set_pwr_role(port, TYPEC_SOURCE); tcpm_pd_send_control(port, PD_CTRL_PS_RDY); - tcpm_set_state(port, SRC_STARTUP, 0); + tcpm_set_state(port, SRC_STARTUP, PD_T_SWAP_SRC_START); break; case VCONN_SWAP_ACCEPT: diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h index b6c233e79bd45..1df895e4680b2 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h @@ -473,6 +473,7 @@ static inline unsigned int rdo_max_power(u32 rdo) #define PD_T_ERROR_RECOVERY 100 /* minimum 25 is insufficient */ #define PD_T_SRCSWAPSTDBY 625 /* Maximum of 650ms */ #define PD_T_NEWSRC 250 /* Maximum of 275ms */ +#define PD_T_SWAP_SRC_START 20 /* Minimum of 20ms */ #define PD_T_DRP_TRY 100 /* 75 - 150 ms */ #define PD_T_DRP_TRYWAIT 600 /* 400 - 800 ms */ -- 2.27.0