Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp829966pxb; Tue, 3 Nov 2020 13:46:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8CUGFVjLC+I4eHEy4j9ASYtyAUojM0toWoc/s89qiyQDB3kC5XLorVclUK2sh28U/ToSH X-Received: by 2002:a17:906:3a55:: with SMTP id a21mr21526277ejf.357.1604439982068; Tue, 03 Nov 2020 13:46:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439982; cv=none; d=google.com; s=arc-20160816; b=0fdu546aCHgfUzgb0mgwhaEI7XnIJyjZm/Z3h7YX00um71q4sb0v/lro6UcwD7VqCk j/Po/X6VZJxt0Dd5YnY3kfcsrCW7b5i5Nw4f2uwmtmaHRpgYt8boo/K7fu6fKFid/K/v gPhAg/TH8ISYom6/yvXUliWvzYFtt/+SG9tvfGURzwwTwELmFfE8W0eRvTrolVdHPpj5 eHb98okqB6qKe2U4z0JMTuA9zq0R/6sKzVPTv9/6vQ6G+cVYjxUX3uvuLVY9gim0/0Tx wJWluloKDoCa3x2JfhlnWn+XUflA5j3Nk5jbE6Igp6QUkFdpTMiVOo+O4LKre3wcFhp1 SRdA== 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=oEynB4kBla5wpifVFzi2QH6aLX+79CDHIgf1mBYw8sE=; b=At9Rdy0cj+SfWpLHQ+gbt1HsSJRhUd7Ar4kMiAA6a2YTD3gapm5VSZUn5gYwpn2ZoJ Grk0Qu9/xsZmQI2JsbWJuVsPkm6R7XH+fcZ9Ma0IuXiMBeuQ9pAWog9uM/9VEJ/vxkT6 gODoftojFWTb0BC9mufLZ1R+nqzSoKvx4YLdy4Fm0eQEVFgN2ROKKBGiklpceJxsezdx T46lwXpvUgF9TbdH1wjXJMoD2H8omABgXFr1Q6gsb3hldTfS/taMEIuUwaC8CMDQmQer dIzCdle1BEsPoe1msDD3HhFkTZgth3UWcKnDrKjTe1+9M6NdFaEpiJiHr7Lw5a1fSSeX n1Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fsTGlD5q; 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 f2si90832ejc.542.2020.11.03.13.45.59; Tue, 03 Nov 2020 13:46:22 -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=fsTGlD5q; 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 S1732585AbgKCUy1 (ORCPT + 99 others); Tue, 3 Nov 2020 15:54:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:53230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732558AbgKCUyS (ORCPT ); Tue, 3 Nov 2020 15:54:18 -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 3A824223AC; Tue, 3 Nov 2020 20:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436857; bh=XPrpLHp8SJ7X+ZnC6pm4Ws7zcjeZ9mA/aqASE+QZaKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fsTGlD5qbXSIKon0+ZSMiWAWt8hV+0O+7F+kyKemaTu56FBOgYxOXFC26iwOrDn3x 6p+7Mvljl4BvMkfy2DTodXRuUF/5udmlUH6FsOfPzZDNG/G44whGYP2m3nTc/438ni B9tHdWWaoJEyJiHnI6DRMtJX/ow/Nj16i5Vm0qzk= 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.4 042/214] usb: typec: tcpm: During PR_SWAP, source caps should be sent only after tSwapSourceStart Date: Tue, 3 Nov 2020 21:34:50 +0100 Message-Id: <20201103203254.037737252@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@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 355a2c7fac0b4..16e124753df72 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3482,7 +3482,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 145c38e351c25..6655ce32feff1 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h @@ -442,6 +442,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