Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp70776pxa; Tue, 11 Aug 2020 17:40:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc8TU4z9Esgty7HPdkofty+vRydOjmJii7zD90Q/3PKDvOcumZTn28wBok1jMS6xwU+DAw X-Received: by 2002:aa7:dc44:: with SMTP id g4mr28968189edu.273.1597192803117; Tue, 11 Aug 2020 17:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597192803; cv=none; d=google.com; s=arc-20160816; b=WLd5GSDuWlqRURKbwXkHaAj/xqcWXVyQq5hoGW4QoSJGAaK3Ax9PwexvidCs3P0J2P oROKG/CYIF0PryWe1RXem0eR4tBfWTaj+P7slgr5ZHnBi/PD0YM+m6HarCA9mmMKJ4/0 /QphF3SvFhkpQ/Qne/IPobCW7Zjk1ledTvPHiSKrkpygLqnQU8oeu9pmyqLywFQ9ExaF WMyzZApod9B3Y39K5UW4TjH05dzTv0d+e89npuqWdQHgIZuwxtIHenBaBq+sYpl2tg8Q H8ixM7A9BpNorE6efhNzBkog/9fDRISGKL5d1B9xdHcqj1Q/J+1wK092Lli80B8eFQ6P yMWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=WYaWZJjZHwHMaKTfLN9uVQQLDMXNukkghtb8ebejAf0=; b=vtNuJ0vlpPqTZI6BuE7FqpioDFhPneKdswMS5ywqsbcdZy/dz2w+sRa+t2i16Ra7Ho YxYRjA8cb5c4xZk5lz9cuRLY7bpJkOZUIm8GGjcYzAnjHfdAXA8kcFNAPfGSER/tx+GS 13WexJ/dx4zM80bf+Tr8+2w+bfaQ9e2Tlm3JNHdEtz9LlteEhtPqW2mMA1nYj6ybHkEn 6JyuX2AZ7qa0jT1XIJy6qIEWsV7XFQ7v1Vt1QZbWLr2MxqIr9j5FmGpG/pOY+5j5CONR ZoCck8tzLAh+8z5n9CA/+U/Twe6BDiHaBV5uCEI4XrreKmb7tWaJYOHHXE8ZQwH9Y+xs w79A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VOVgQYRg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r10si225670edy.93.2020.08.11.17.39.38; Tue, 11 Aug 2020 17:40:03 -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=fail header.i=@gmail.com header.s=20161025 header.b=VOVgQYRg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbgHLAgT (ORCPT + 99 others); Tue, 11 Aug 2020 20:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbgHLAgS (ORCPT ); Tue, 11 Aug 2020 20:36:18 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 936DAC06174A; Tue, 11 Aug 2020 17:36:18 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p8so115065pgn.13; Tue, 11 Aug 2020 17:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WYaWZJjZHwHMaKTfLN9uVQQLDMXNukkghtb8ebejAf0=; b=VOVgQYRgGPgk46r9ZWYh1I8ys842aAdXntlnC0eejRK1Zq0EiEIN8YIoASb2fWD80b qyKtvhxfX2Z4BBvBmQHbYMWbn7w2BMc88w8ieechwFfdWo6lpO0JHKegkzGBwTNjU5hd 82PCy9UOLLpn0Pov3fpVoCKN4b0D0EkzAUlgGaCkUH3Xl2FeT2rfG4REvtY2GkD405mb Ow2V1VRXePsHads4+HN+EdCuSw/IIYdPkT2kzdQ8AlLTJrfSsqs3wad2amwLDP79SNnI lzbHQaT3XJzSpmqjssy0HSJvfhIPkKeYrVzL+DfbZcy43U51ZCy5cAkNKF0j6cRefKHF lc3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=WYaWZJjZHwHMaKTfLN9uVQQLDMXNukkghtb8ebejAf0=; b=sm8FphwTKFj4QgKPI86iBOztTgyE6Gj2VMkO6T+KABkSr6237DG+ALNcdgIBl3g8gy tE7aw0hhdhOUy85bGe39vsD4NQ6sHuIqVLgFeX8nTJ6Gyj1RKUoUv2zxCmwROz+Kohv7 0yf5lGVBg9JOzT6bC7wCP7Lijpz84wG5lVKg1ypodeBEo/B/+knWjhkolwB8j7FO8vby xS49rjUWARdVP6usYSE92/+tG0T2TI23jRVVgaK7yHTxXiC/f30D/I0MNclPHcPXY5If NrHv97mpIIziFv8/vlzqCTRHZRliB3GettVNFENunZ8LFSHRMiR28JFuaZPKajcpZ8Qk Rz0A== X-Gm-Message-State: AOAM533UaDkUlDgsDg0kAJwe7qGCYiMtW7vkVBgy+Y2BzIiynKaSuyoJ RUSuGHdszO8e8SqNVH3Qj1fvDXar X-Received: by 2002:aa7:9241:: with SMTP id 1mr9121783pfp.188.1597192577713; Tue, 11 Aug 2020 17:36:17 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f89sm166178pje.11.2020.08.11.17.36.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2020 17:36:16 -0700 (PDT) Subject: Re: [PATCH v1] usb: typec: tcpm: Fix TDA 2.2.1.1 and TDA 2.2.1.2 failures To: Badhri Jagan Sridharan Cc: Heikki Krogerus , Greg Kroah-Hartman , USB , LKML References: <20200811011126.130297-1-badhri@google.com> <20200811184507.GB86545@roeck-us.net> <8a2e77f4-1470-ebf0-402c-df90ab6332bb@roeck-us.net> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk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eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= Message-ID: Date: Tue, 11 Aug 2020 17:36:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/11/20 4:21 PM, Badhri Jagan Sridharan wrote: > Thanks Guenter ! However I don't see a reviewed-by tag :) > Confused. Did you send a v2 with the changes we discussed ? I didn't see that. Thanks, Guenter > On Tue, Aug 11, 2020 at 1:18 PM Guenter Roeck wrote: >> >> On 8/11/20 12:39 PM, Badhri Jagan Sridharan wrote: >>> On Tue, Aug 11, 2020 at 11:45 AM Guenter Roeck wrote: >>>> >>>> On Tue, Aug 11, 2020 at 11:24:07AM -0700, Badhri Jagan Sridharan wrote: >>>>> On Mon, Aug 10, 2020 at 6:51 PM Guenter Roeck wrote: >>>>>> >>>>>> On 8/10/20 6:11 PM, Badhri Jagan Sridharan wrote: >>>>>>> >From the spec: >>>>>>> "7.1.5 Response to Hard Resets >>>>>>> Hard Reset Signaling indicates a communication failure has occurred and >>>>>>> the Source Shall stop driving VCONN, Shall remove Rp from the VCONN pin >>>>>>> and Shall drive VBUS to vSafe0V as shown in Figure 7-9. The USB connection >>>>>>> May reset during a Hard Reset since the VBUS voltage will be less than >>>>>>> vSafe5V for an extended period of time. After establishing the vSafe0V >>>>>>> voltage condition on VBUS, the Source Shall wait tSrcRecover before >>>>>>> re-applying VCONN and restoring VBUS to vSafe5V. A Source Shall conform >>>>>>> to the VCONN timing as specified in [USB Type-C 1.3]." >>>>>>> >>>>>>> Signed-off-by: Badhri Jagan Sridharan >>>>>>> --- >>>>>>> drivers/usb/typec/tcpm/tcpm.c | 16 +++++++++++++--- >>>>>>> 1 file changed, 13 insertions(+), 3 deletions(-) >>>>>>> >>>>>>> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c >>>>>>> index 3ef37202ee37..e41c4e5d3c71 100644 >>>>>>> --- a/drivers/usb/typec/tcpm/tcpm.c >>>>>>> +++ b/drivers/usb/typec/tcpm/tcpm.c >>>>>>> @@ -3372,13 +3372,19 @@ static void run_state_machine(struct tcpm_port *port) >>>>>>> tcpm_set_state(port, SNK_HARD_RESET_SINK_OFF, 0); >>>>>>> break; >>>>>>> case SRC_HARD_RESET_VBUS_OFF: >>>>>>> - tcpm_set_vconn(port, true); >>>>>>> + /* >>>>>>> + * 7.1.5 Response to Hard Resets >>>>>>> + * Hard Reset Signaling indicates a communication failure has occurred and the >>>>>>> + * Source Shall stop driving VCONN, Shall remove Rp from the VCONN pin and Shall >>>>>>> + * drive VBUS to vSafe0V as shown in Figure 7-9. >>>>>>> + */ >>>>>>> + tcpm_set_vconn(port, false); >>>>>>> tcpm_set_vbus(port, false); >>>>>>> tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE, >>>>>>> tcpm_data_role_for_source(port)); >>>>>>> - tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); >>>>>> >>>>>> I am a bit concerned about this. If I understand correctly, it means that >>>>>> we won't turn VBUS back on unless a SRC_HARD_RESET_VBUS_OFF PD event is received. >>>>>> Is that correct ? What happens if that event is never received ? >>>>>> >>>>>> Thanks, >>>>>> Guenter >>>>> >>>>> The term PD event is a little ambiguous to me. Trying to summarize the workflow. >>>>> Lower level tcpc driver would have to call tcpm_vbus_change which >>>>> would in-turn trigger TCPM_VBUS_EVENT >>>>> and queries port->tcpc->get_vbus to get the vbus status. It is not >>>>> really a PD protocol driven event hence the >>>>> confusion. >>>>> >>>>> "What happens if that event is never received ?" >>>>> Yeah TCPM would be in SRC_HARD_RESET_VBUS_OFF till the tcpc calls the >>>>> tcpm_vbus_change. >>>>> Do you suspect that existing tcpc would not have the capability to >>>>> monitor vbus status while sourcing and call tcpm_vbus_change? >>>>> >>>> That, or the driver might be buggy, or the hardware does't signal a status >>>> update, or the update gets lost. I think we should have some backup, >>>> to trigger if the event is not received in a reasonable amout of time. >>>> I don't know if the specification has some kind of maximum limit. If >>>> not, we should still have something >>>> >>>> Thanks, >>>> Guenter >>> >>> Got it ! The specification actually has a bound for vbus off. >>> tSafe0V - Time to reach vSafe0V max - 650ms. (PD_T_SAFE_0V). >>> So I will bound it to that. >>> >> >> Excellent. Thanks a lot for looking into this! >> >> Guenter >> >>> >From Table 7-12 Sequence Description for a Source Initiated Hard Reset: >>> 4.Policy Engine waits tPSHardReset after sending Hard Reset Signaling >>> and then tells the Device Policy Manager to instruct the power supply >>> to perform a Hard Reset. The transition to vSafe0V Shall occur within >>> tSafe0V (t2). >>> 5 After tSrcRecover the Source applies power to VBUS in an attempt to >>> re-establish communication with the Sink and resume USB Default >>> Operation. The transition to vSafe5V Shall occur within tSrcTurnOn >>> (t4). >>> >>> Thanks, >>> Badhri >>> >>>> >>>>> Thanks, >>>>> Badhri >>>>> >>>>> >>>>>>> break; >>>>>>> case SRC_HARD_RESET_VBUS_ON: >>>>>>> + tcpm_set_vconn(port, true); >>>>>>> tcpm_set_vbus(port, true); >>>>>>> port->tcpc->set_pd_rx(port->tcpc, true); >>>>>>> tcpm_set_attached_state(port, true); >>>>>>> @@ -3944,7 +3950,11 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) >>>>>>> tcpm_set_state(port, SNK_HARD_RESET_WAIT_VBUS, 0); >>>>>>> break; >>>>>>> case SRC_HARD_RESET_VBUS_OFF: >>>>>>> - tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, 0); >>>>>>> + /* >>>>>>> + * After establishing the vSafe0V voltage condition on VBUS, the Source Shall wait >>>>>>> + * tSrcRecover before re-applying VCONN and restoring VBUS to vSafe5V. >>>>>>> + */ >>>>>>> + tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); >>>>>>> break; >>>>>>> case HARD_RESET_SEND: >>>>>>> break; >>>>>>> >>>>>> >>