Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp109854pxa; Tue, 11 Aug 2020 19:05:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyESa+Hv3xrnXo0sakrIFlzc1Nky226hX93MkZ882g9FtAE/JZ3VzFQzulH8Egw03GfqGyW X-Received: by 2002:a17:906:9609:: with SMTP id s9mr25462862ejx.232.1597197938418; Tue, 11 Aug 2020 19:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597197938; cv=none; d=google.com; s=arc-20160816; b=l4XKSdiWgnLj7jrtSMS/5FAbDxInyKCer1+cO309B+axZI2f1pgcMZAMPBSTjeurP6 2sdiCu5KmPSKWKp73+6ZaqPJRvpgSanMnecxHm7TZ2TOuk5q4XUlKUfQwYk/0YYYooxe YOhlHckr+mbgMJNyRVQjvSXoD9t5fe1GRyRUHPtB/KGZ0piwp9A7p0j2bJwhDm3T5XFp 3Em3X/UWBHOc+c0StzsH42E44UNYeCl+fLZO4dKw1yqiR6eTEa8au7f3mevHQKXMjYKq cBq3BtYq8L7ZjWCOoENUPa0rFcNXf74zpiQ/kozJ2HbeyaGVrDB9OuVd/KGglehHbxzM RjzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=n4534WVfwtYILd0kDXgE1s8p0HFb/iqe5lFVW/x7HYk=; b=oSrX3z5arOs7Keqk1DpRoPvk7xk1HjbjEI7nEnHsnj9ZVr9lOGyHWr2BrH67z7T+gC CUT74nWfa7lDc7K/rW/V2ZuZdO1PVlcdPWqxRHmtK/5ymTBKh/+CTAe09AYeE2KWHzZv sYHtZ+lZ0z/7k1ZzmYde5FJFA6WdElqYp+7WxVQLq0/AKeFjK5hXlC8P2Umef37pXwkF jVTCq3fKR9KOeYK20Esst7Q4CWXzMz/t/ncYs/CzKkNB7VZ3KfMTz2kAeGHU0tTp67f1 kBO022h9TjnmMP0R++voa/ifGMtl8rpxIkHnK0mOnfCaj4cOe8Q8AyZn7Sc+PwvK3NGh H4pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IKf1A7uH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pk27si256737ejb.130.2020.08.11.19.05.14; Tue, 11 Aug 2020 19:05:38 -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=@google.com header.s=20161025 header.b=IKf1A7uH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726333AbgHLCEO (ORCPT + 99 others); Tue, 11 Aug 2020 22:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbgHLCEO (ORCPT ); Tue, 11 Aug 2020 22:04:14 -0400 Received: from mail-ua1-x944.google.com (mail-ua1-x944.google.com [IPv6:2607:f8b0:4864:20::944]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E9AEC06174A for ; Tue, 11 Aug 2020 19:04:14 -0700 (PDT) Received: by mail-ua1-x944.google.com with SMTP id u15so167989uau.10 for ; Tue, 11 Aug 2020 19:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=n4534WVfwtYILd0kDXgE1s8p0HFb/iqe5lFVW/x7HYk=; b=IKf1A7uH52OPGehWEpED5AkCkL4zOEG3tTiTlxNacw9w3OstUOrxwpJfPyCWahbDST R0KqBAQOh8IrJ7chFno4IlJMA1MIABC88eQpuVPVejbMwNHgYaj9ox4jmOgYmiV6asdc sQyzLeDLT2O31ISy2GzWBXc7slzBExHqsFcygckPTIBs27T5KIwObJGooIpIIAUP0cG1 FipE1ngHE5JtewIk1xpVkdxewJSbn9XBlTCvitAyfxryt78rWAvBA5Ndpj9yX1KGGrnS jaBgH9Xf9xE9x+rWFi+s27lB/sEHTJkwV7nK96lPah9vEJ3z/Z3vLo2iV045Yv+LnzkB DhTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n4534WVfwtYILd0kDXgE1s8p0HFb/iqe5lFVW/x7HYk=; b=AHC65gouNWaMVITVtwbMW9IiNniWGMUuOT+j2sGj/crkPClbFivM9KJflQlcUEnMGp Xb7151yvQdMDO3KY20H1IJyNT00/5aMwTiuQpA5pJsGh2d1zycaFLXjPsUwN7RSXyYUE vsdV4xbUdxNyTsDy8gd1vbKOYlJ93kr7Rtp/7uPjYggMGYMjNwSuG2QJnoMxOBOlxdUd q3D4IQ2J1U6L99e2A/UDsppCzSBjNX6clNPl0koULiIcuvYOp4+KgR/88ajbPNyBIGTX jmQ4krMpUo+to7Jq4K4VbsXcoH4L8g+54no+bJ2pPVzECp+xc5m/YvlA1lRuEILG9Aem 4qew== X-Gm-Message-State: AOAM531BtO930s2uxsgKCWGODGIev4qkaD+6uurq1gFLjWQHxHhGcKSy QBl4h6Dz0LkWhI8LwdMc1D1O9DGJwsxz0FBlloOkgVeyr4io/Q== X-Received: by 2002:ab0:69d6:: with SMTP id u22mr25938205uaq.65.1597197853120; Tue, 11 Aug 2020 19:04:13 -0700 (PDT) MIME-Version: 1.0 References: <20200811011126.130297-1-badhri@google.com> <20200811184507.GB86545@roeck-us.net> <8a2e77f4-1470-ebf0-402c-df90ab6332bb@roeck-us.net> <5461f039-ca37-daaa-78c1-d6fc69d17004@roeck-us.net> In-Reply-To: <5461f039-ca37-daaa-78c1-d6fc69d17004@roeck-us.net> From: Badhri Jagan Sridharan Date: Tue, 11 Aug 2020 19:03:36 -0700 Message-ID: Subject: Re: [PATCH v1] usb: typec: tcpm: Fix TDA 2.2.1.1 and TDA 2.2.1.2 failures To: Guenter Roeck Cc: Heikki Krogerus , Greg Kroah-Hartman , USB , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 11, 2020 at 6:44 PM Guenter Roeck wrote: > > On 8/11/20 6:08 PM, Badhri Jagan Sridharan wrote: > > Yes I did ! https://lkml.org/lkml/2020/8/11/788 ! > > > > For me gmail is grouping V1 and V2 patches in the same thread so > > thought you saw the v2 patch :P > > > > You copied me on v1, but not on v2. I am not on any of the mailing lists > you sent v2 to, so I did not see it. > > Guenter My bad ! Apologies Guenter ! Screwed up while performing the git send-email command. Will make sure that I double check next time. Thanks, Badhri > > > Thanks, > > Badhri > > > > On Tue, Aug 11, 2020 at 5:36 PM Guenter Roeck wrote: > >> > >> 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; > >>>>>>>>> > >>>>>>>> > >>>> > >> >