Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp819509pxb; Tue, 3 Nov 2020 13:27:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJws+YIik7+PrBA0mftQilqWY2GDDXalhiur4l9GgGw02bzHSM1Jc9pfpHEPsYxHiAoPzfOx X-Received: by 2002:a50:ff10:: with SMTP id a16mr23806333edu.83.1604438834758; Tue, 03 Nov 2020 13:27:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604438834; cv=none; d=google.com; s=arc-20160816; b=hWPLSnRb9Rq2P1RQTXWAjcq8l/evu5nLxjZ1zw71Ts2Xkg6LYz7nswQZUTW1Hu5CQS MZE48xysorMyhobl1xs1klAZcL3kR2iYUoexnckJS8JV5orE2zPz8E2/BahbR8tbqZno bL4Os3ss7OFjcKT6wy6/lF/Ba8KInYRBVf4O9SCJufsIpK1PUb8RMmNqqt4iSNo+fK0S Wo7BcYaJzlhmr/d+SdDla+SjiPHe8hBjxevsfRhl9SZJXYut+oY+cyFWDIi71SuC2KEV AUU7exgBWYNsTcKjfss4h/d7qGhiJE5ZG0v0mb3CdD6PNDXTH9oMfffeZX0tbEjHOpnz Fi5A== 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=bUwQs5M56jRnU+xeZA/Y+mu3YWSqiR2KfFhBnEiDFac=; b=T+vylbVcgonbP9Ww37LuDiZilcNX3g2xlFARxYA3VmpBFZ7sErWXhtdv1sG+cIuJiA 8mHIR/+DcwlRhA4YHLMwl9kqbSMJT5L4riYKdyqgeWK1tqFJEIvcBezWyYG7H8ntLSXf 7rOr/UoQjDP0NC9JtGH2Tx8JaThbmnPpyt1xFBAI5lbyGF8N6r2tPJS+moHQJWwy527x aZEoNyvvcdu4tquJlArMqpFWj/73jwJoTWvLDVNFi7IgQwCHKt2tIUSHqM3gk77uLJ2V Xv5whJMTzeECZ46zaM5/hhgxn4oklm+Kx/UdxU0wMWdEPF73z7bf2mul+TbzUBOnWauY cN1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n7Q1vzrw; 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 a13si1592595edr.154.2020.11.03.13.26.51; Tue, 03 Nov 2020 13:27:14 -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=n7Q1vzrw; 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 S2388622AbgKCVYV (ORCPT + 99 others); Tue, 3 Nov 2020 16:24:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:41516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731552AbgKCVDq (ORCPT ); Tue, 3 Nov 2020 16:03:46 -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 6267F20757; Tue, 3 Nov 2020 21:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437425; bh=vV9xIQdEGmRAxMhVbWaoeJkccOFSuBMJGcXTxBmXfdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n7Q1vzrwe2Fyt4qTLKPo7MvtZBXIhCO+AYoNCt7mfWWWLxZt7lebpHIxydT7kTYW2 t0VtENDvWHvfHz1UbFCoLDBTAvsoC/id8RMRabRmaqYI0qkM22tuops8e0wZVv3dUY RgByaD13C8+vF547n6Rp3Pn/Qc6rc9pxD7u2V0/g= 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 4.19 071/191] usb: typec: tcpm: During PR_SWAP, source caps should be sent only after tSwapSourceStart Date: Tue, 3 Nov 2020 21:36:03 +0100 Message-Id: <20201103203241.078639421@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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.c | 2 +- include/linux/usb/pd.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 29d72e9b0f017..7086ebb245320 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -3486,7 +3486,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 f2162e0fe531b..bdf4c88d2aa0a 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h @@ -451,6 +451,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