Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2032382rwd; Thu, 15 Jun 2023 20:45:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7aGXif3jx6DcwdaPNxnRtP6+ewSQVaXXt59wx4aWLAS+Ee2FT/1nMqH1OfleOBWIjCrV1V X-Received: by 2002:a17:90a:1906:b0:25e:a8ab:9157 with SMTP id 6-20020a17090a190600b0025ea8ab9157mr735385pjg.22.1686887143921; Thu, 15 Jun 2023 20:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686887143; cv=none; d=google.com; s=arc-20160816; b=DVaTEKnnFITBdtpQtyx0yqpVqyikZQKNXvkoVwWhGDWLgMYkOOnavZ8vfUugykasHK Wi8vqnNH/XBehKLbKmaFFzrNuD4iPmu1BCi8Lx5i7Ya310Kn5VHPpYeOXSsb9zEH4M/j Z9d3k+L3QYwy/Ax1XVqRjVBUaKJ5Gq6oOA725b3Pg+RTXPBP75muY0wtUjAC+GUwGTfG jYuGV2r0BjFw9+yTAx0rLX3saeIUDggUz/dsQodEntCI6cDYIRhRx28Q+T4JCqZc4PqC EyB0PZ339g8x3l0G+RqxdZD5DPK1Ho6SjnY16dM51QelNUdrcFbWFTj2C4bmKF4wJDJl lOow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=k1bdlw2mSQ/Jxpi3GlsB18uYci+HTUHDeQTcYGwyLxs=; b=x7CK/cX3/Q7v73PN1lN9AJ1w6KiAFzzAcGg1M7bhGVQ5mAA4Yx84WzFtWV7s3EI1f8 cFi//K1/yDOd+5tmEvr2AID7qP/ddLG+BQ2l9yW5f6EidvLcgf9qwF4HkeP5S1V/sJ/c OhW9sBNxblOorr0IgemuiPpdTwMlwyYrpmYw8Zr8OK+z9QbUoRDfzJbFs5P39mxukfD3 p5n3Tygd70PaM6KdXA4z3Db4BVYI+SayuCA3BWphVnC0Ehg1i5A0OUjq1GfBI8w34Hlx B2wgrdvQT6ceJCWbuRZMzdWTEhut3guRdVO9erGvF6010Wtaw1i2ZMBwXz9TAU0O1kdU 64Ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z14-20020a17090a66ce00b00256001d8f68si767198pjl.2.2023.06.15.20.45.29; Thu, 15 Jun 2023 20:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbjFPDDe (ORCPT + 99 others); Thu, 15 Jun 2023 23:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241482AbjFPDD0 (ORCPT ); Thu, 15 Jun 2023 23:03:26 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E422D72; Thu, 15 Jun 2023 20:03:23 -0700 (PDT) Received: from [192.168.60.56] (unknown [103.29.142.67]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id B72D02803D6; Fri, 16 Jun 2023 11:03:14 +0800 (CST) Message-ID: Date: Fri, 16 Jun 2023 11:03:14 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: usb: typec: tcpm: fix cc role at port reset Content-Language: en-US To: Guenter Roeck Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, sebastian.reichel@collabora.com, heiko@sntech.de, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, huangtao@rock-chips.com, william.wu@rock-chips.com, jianwei.zheng@rock-chips.com, yubing.zhang@rock-chips.com, wmc@rock-chips.com References: <20230616022001.25819-1-frank.wang@rock-chips.com> <3c3fbecd-caf9-c432-0890-93cceade98c1@roeck-us.net> From: Frank Wang In-Reply-To: <3c3fbecd-caf9-c432-0890-93cceade98c1@roeck-us.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDGE5PVh0YHR8ZQkMfTRpLH1UTARMWGhIXJBQOD1 lXWRgSC1lBWUpLSFVJQlVKT0lVTUxZV1kWGg8SFR0UWUFZT0tIVUpISkJIS1VKS0tVS1kG X-HM-Tid: 0a88c228375a2eb1kusnb72d02803d6 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Oj46Ohw5GD1MPhAMSUIIKlY2 ETIaFEtVSlVKTUNNQ0NPTkJNS0NIVTMWGhIXVR0JGhUQVQwaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlKS0hVSUJVSk9JVU1MWVdZCAFZQUhPQkI3Bg++ X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter, On 2023/6/16 10:27, Guenter Roeck wrote: > On 6/15/23 19:20, Frank Wang wrote: >> In the current implementation, the tcpm set CC1/CC2 role to open when >> it do port reset would cause the VBUS removed by the Type-C partner. >> >> This sets CC1/CC2 according to the default state of port to fix it. >> >> Comments are suggested by Guenter Roeck. >> > > I have no idea (recollection) of what I suggested here :-( Aha, this is also an old patch I have sent before, you suggested that the cc role should require some tweaking based on the port type or default state, do you remember it now? Anyway, Can you help to review this patch again? BR. Frank > > Guenter > >> Signed-off-by: Frank Wang >> --- >>   drivers/usb/typec/tcpm/tcpm.c | 3 ++- >>   1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/usb/typec/tcpm/tcpm.c >> b/drivers/usb/typec/tcpm/tcpm.c >> index 3c6b0c8e2d3ae..9f6aaa3e70ca8 100644 >> --- a/drivers/usb/typec/tcpm/tcpm.c >> +++ b/drivers/usb/typec/tcpm/tcpm.c >> @@ -4885,7 +4885,8 @@ static void run_state_machine(struct tcpm_port >> *port) >>           break; >>       case PORT_RESET: >>           tcpm_reset_port(port); >> -        tcpm_set_cc(port, TYPEC_CC_OPEN); >> +        tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ? >> +                TYPEC_CC_RD : tcpm_rp_cc(port)); >>           tcpm_set_state(port, PORT_RESET_WAIT_OFF, >>                      PD_T_ERROR_RECOVERY); >>           break; >