Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2911014pxj; Mon, 14 Jun 2021 09:54:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM8hotAz0yWBygBaWchiltCffZZEbiB0wRQMIsEN5RWEO0NW8KmgwSzKMhCdMujEHns5XB X-Received: by 2002:aa7:c354:: with SMTP id j20mr18004578edr.294.1623689649453; Mon, 14 Jun 2021 09:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623689649; cv=none; d=google.com; s=arc-20160816; b=mcsJ0KAIDmsCXejBpqXfKerA5joytvalFmN5xnOi8kOJpppmJ40PyVxsj+xKeb7HjD edBA36qzFgT5U/pXyto6hYIUoZOJPHpuLjhiqK+Ws/lvzh19fIM+JhlLEBs//XLSgiZs SYqr+eCuAjH2UZ8BJ4j0jaXCwxMOovYbJP4KInXAf+fP2HumdoDuluTrSWOYeWApiDDh eDT23VFiGOeYoou4Ep9K1OCR/ne0zaLZf9jV0u7mQ/h03FJfd1dsEAGoGE4nP0n19hZ8 /HfKAf+eiK9hFADTzOiZCNLxAYIQVemCGHKk7Wuw8QZib6WiZxQAPOzLKt4KewFfUc6Q hxWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qI8JpFMh7+nrwzVv1jWVM5ml0OUiY5MJQrtGKYX8w3k=; b=vXY3r8as+L9XeUe+Qq2S9WXOVLGq9Ew6/do6fXz6w5OxJ9rb5nihnlBPeSDmNpaxdz rWRcoJFo0Errwp50YLmXMYEmwolK8CPZOkYxzRZWWhsH3/TDIn4Xrgp2abX9Hz0d/UmJ DkYY3aRuydIkAL22BGzUfDbIQvutasfQ8aQBWLy2k4hpSGUPeJ5KgH6xXZzSh+jnRo0t zkTyuPTuOyedZZyy5Mgl8xRHK/07K/XNzCv23AplhZfRm/i+3+vUJYWqrWlf+v+KdM55 Pu92QTSp4nZwRT/F0AHHIsru3wfB5Hzv163AOrg60akZfo6//ZV3jgTI8IVdFAysnYOU xhUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eVGDtJeB; 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 u15si12024074edo.426.2021.06.14.09.53.47; Mon, 14 Jun 2021 09:54:09 -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=eVGDtJeB; 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 S235229AbhFNQyO (ORCPT + 99 others); Mon, 14 Jun 2021 12:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234835AbhFNQyN (ORCPT ); Mon, 14 Jun 2021 12:54:13 -0400 Received: from mail-vs1-xe2e.google.com (mail-vs1-xe2e.google.com [IPv6:2607:f8b0:4864:20::e2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77856C061574 for ; Mon, 14 Jun 2021 09:52:10 -0700 (PDT) Received: by mail-vs1-xe2e.google.com with SMTP id x13so8149021vsf.11 for ; Mon, 14 Jun 2021 09:52:10 -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=qI8JpFMh7+nrwzVv1jWVM5ml0OUiY5MJQrtGKYX8w3k=; b=eVGDtJeB3NP1YU2OckLCU2+if7afqsRRCInB7mMgNIybpYLMLgzkFefYdr+bFXX+Pb hWcIUU4wrrjVcAsG1xldBIq8Y/94R08Z6b34qYhl6CuMujqc5WzJp0a92p7n3NJrE2rR hZcpCcTurdeVtAylilTWhvpgauRPC9zSn5DSXQR4TfY97RCg91PTjlFD8AoTHiTTUC+J NyaY6Uy/QmLvbqKT116GwLKOiEHJBfMhjIiP+bmqKTYNElNCgk3UTFw4VXNzphhE41uK xTC9JbDWs64guA4T+VE3waJTio+tKZzVPhJflJEFzbs7rxQYfM+fcvIoEstDI4HJDSWQ Bkbg== 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=qI8JpFMh7+nrwzVv1jWVM5ml0OUiY5MJQrtGKYX8w3k=; b=WhYCRHottj4OdWdW/l7rmDagtqo4nhIvpc/SWQY9j2GKPydYBfAOQwKbwtFM0JVV09 XLXI0TkdjDCbEldnS3NgJZFiKQhvMK/NmaS/z9/ztQMH25uzqffz5kKf2fneUQBmirfj 72uPn9XDJFoRtkLvUAVnqRnZscVvA9Yggfu5jwwefylOVfleYFafjKq81iMmTFoD8WR7 +MlOg0AqUYZn83B8cHLhbO+XWfKT5IruD/RikrQ8GrDgqDi1S6xbuYSES0ZYysA7bJpt XGCiKivvLpLNLq8lL5/yi6wFSh0NGmD65cak/p3do+9Id9iW4pfZw6CkTZ0gM9nKDQky bFbA== X-Gm-Message-State: AOAM533/ZULpXDzFmaiVPt7XG1FP9vNsn+1tKDfSUsBb0I4t8gOxOx4g mCimK0C9JCARLa5NjZLblblciSMVWNq52kCKdqlyeg== X-Received: by 2002:a05:6102:2378:: with SMTP id o24mr292281vsa.12.1623689527787; Mon, 14 Jun 2021 09:52:07 -0700 (PDT) MIME-Version: 1.0 References: <20210613151223.563736-1-kyletso@google.com> In-Reply-To: <20210613151223.563736-1-kyletso@google.com> From: Badhri Jagan Sridharan Date: Mon, 14 Jun 2021 09:51:31 -0700 Message-ID: Subject: Re: [PATCH] usb: typec: tcpm: Relax disconnect threshold during power negotiation To: Kyle Tso Cc: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , USB , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kyle, The change doesn't seem to handle the cases where the partner does not accept the request i.e. "case PD_CTRL_REJECT: case PD_CTRL_WAIT: case PD_CTRL_NOT_SUPP:" We should fall back to the disconnect threshold based on the previously negotiated voltage levels in those cases. Regards, Badhri On Sun, Jun 13, 2021 at 8:13 AM Kyle Tso wrote: > > If the voltage is being decreased in power negotiation, the Source will > set the power supply to operate at the new voltage level before sending > PS_RDY. Relax the disconnect threshold for Sink after receiving Accept > Message to ensure the relaxed setting is enabled before the voltage > collapse. And the real threshold will be set after Sink receives PS_RDY > Message. > > Fixes: f321a02caebd ("usb: typec: tcpm: Implement enabling Auto Discharge disconnect support") > Cc: Badhri Jagan Sridharan > Signed-off-by: Kyle Tso > --- > drivers/usb/typec/tcpm/tcpm.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index 0db685d5d9c0..9f3f37da71b6 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -2646,6 +2646,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port, > switch (port->state) { > case SNK_NEGOTIATE_CAPABILITIES: > port->pps_data.active = false; > + /* Voltage is going to be at new level. Relax the threshold here. */ > + tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, 0); > tcpm_set_state(port, SNK_TRANSITION_SINK, 0); > break; > case SNK_NEGOTIATE_PPS_CAPABILITIES: > @@ -2656,6 +2658,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port, > port->req_supply_voltage = port->pps_data.req_out_volt; > port->req_current_limit = port->pps_data.req_op_curr; > power_supply_changed(port->psy); > + /* Voltage is going to be at new level. Relax the threshold here. */ > + tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, 0); > tcpm_set_state(port, SNK_TRANSITION_SINK, 0); > break; > case SOFT_RESET_SEND: > -- > 2.32.0.272.g935e593368-goog >