Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1030198pxx; Tue, 27 Oct 2020 06:43:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXtZTT81fX3p8r+35DCKCzy0NBUkeq7vB4vLMoMOhq44kcVaXlGLTpDvfbddaHJiFKFd3S X-Received: by 2002:aa7:cf95:: with SMTP id z21mr2293657edx.346.1603806237148; Tue, 27 Oct 2020 06:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603806237; cv=none; d=google.com; s=arc-20160816; b=04ndNG25wdxsdcfObRF1utcq9Km+G3pCudWKQoRbZd6cb+7xuUSD7KW8rqikBpSd0X 6cvDDJ0gMAyYM1hyW4pvKyFa5yJfifBITmKTkrCncwB8cknyVx6uJJSH3h22H4c4Qgav HNoATSo1YVKgG8jwIfoADHBHmxFhnxCCehLSb9sYTSB2EpPyrDgeKsFrTAZG5Dm+1ld7 JEyemG9Rn4AqrQL2Jvf8R2M3fDdkRSOvLn5EcgtGBfleX6BgIcd9/V0tQgfTryhZtBOB 5ZnVdVJmcOO2IILzrVYxSWlQjXVWuc/SvhSbVGO8Txpy1TUkD0drV7/T3LGMkit4C7xG /kMA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O9JGfPYKAdVikA8f1m0r82aqeAJx/c48mAwoEezAkb8=; b=CFk/zMHOcuoaB0tSx09TyYf6Q6urC1zuGXL88GppohLPeYJedx5LTzt34aJWdG0eHz Iu/W+Qizu7VufNp7ENReucfWuEbxfPrGVKwknDQs4x/kNtMQGhgY5veNebVxoKGDk1gq rJRDC8DDuGiCorOj6QL97V+5ebYzovcTeleloQAz8abHs9awoxmX9tpcDsBmYV/mIV8K aJ4aIQuOG+gX3sHWn4TnvbB+ysRdC7AL27vBHFnY9LxpxdePr9371FzPH+oz/FNZfwYo 2uiBxjJ51XZ4+X2M3NqTp9ZtgTk9DnPunLntbPneoXdbovvYMFRECWSPxrdR2qwcJPwI ZmzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="NH9/w/hZ"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si1061296ejg.133.2020.10.27.06.43.34; Tue, 27 Oct 2020 06:43:57 -0700 (PDT) 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="NH9/w/hZ"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2444478AbgJ0Aiv (ORCPT + 99 others); Mon, 26 Oct 2020 20:38:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409013AbgJZXuF (ORCPT ); Mon, 26 Oct 2020 19:50:05 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F20F120878; Mon, 26 Oct 2020 23:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756204; bh=nbj9deSPQZLAZ1jlVBjgc1/9JvaN1NExZDAKUsZNmog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NH9/w/hZdZXN/OuRjdhFpXvLqQQ8mZNXnuEVvY7OXq3b6jdx9mEugmVi+XEccxgza aZxcZNHxPlyNcdsCWYPB3R0OusIkY/LGKh5iHUTqph5EA4u+4WA8ATRb2ulD3S14Nm P4F4eXQ1VW8QRnG/NigSFI7UgsC6yfPLtDC/wGEE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Badhri Jagan Sridharan , Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 047/147] usb: typec: tcpm: During PR_SWAP, source caps should be sent only after tSwapSourceStart Date: Mon, 26 Oct 2020 19:47:25 -0400 Message-Id: <20201026234905.1022767-47-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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.25.1