Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp411004pxb; Wed, 13 Jan 2021 06:48:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFGy9LS2tylPz6zUET5qR4j6+AZrGQHLiPnZnVR0/w8aF3oz8gnrcOCOafLHxGlxLQBo/m X-Received: by 2002:a17:907:b09:: with SMTP id h9mr1827807ejl.155.1610549308095; Wed, 13 Jan 2021 06:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610549308; cv=none; d=google.com; s=arc-20160816; b=nwPM/8SXpTBhKSlipSVIHh8aK2rP8p36q6WM3IRYRkD5aZr0ix76x7tY9Z9qqEaiW5 K2hwWDhmdUYR0xGU+nKa+z08zCx0D0p3+yRMiJ1zEjsW9+qRRrjXqjWhXlx3sO1T7AAy e2/MtHXIkJ4HzUTm4hxvSL3XLvYlc6ljRWMd53O+WMC1Up7CsMRsP73f8C4iUZt2BhWz zfpurq7eGiEGEnXX3buj/k1fYpdiSb8znPjiMnZX7HZhRJZNiy1XoHwKuoxjEfm84tC9 GXirPZ/CwAte+GIZMLgFKMr+4D47HJvwNGkr97FAN/n+2QeAdgtOWKXg6v1NsStaUyz5 hsAw== 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=yfGUinF7cIPTVWbvopOeCfPw7+d2tiRR9kb2ydRYjts=; b=hqXgmLi+jFhHx0UpI0gVBJyugdpKmO1vrKaJdpBEt80wblnyWhyrZobyR0OKas0fdM 6vacjTpvGxXsh3pVjF82vWLdytvrMyfkJEQ9t9rehG/D8RQ/HiFlDQiHjUHlq/mCquEV GdQ+vTvxBia/Pvu9Hz4yjnqbJ5Jkomf0101JJCrinQnGUhuZJh+FDdsjQsvkjKT8hJH+ EjS5SJXRGODBvEJe8wcygC16vb/cBp2jRNlz1pvTC3mbZwXCowXLQWw9GFTiqVAqr+Ik S5k5BKd3UP1/Kr1zSUs73MwZS1ALZCTAMAq6YWayEtD8TD/T6r1KJNlKs5tnr1JJGMEd EeSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="J4/q39rX"; 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 sb9si1066683ejb.219.2021.01.13.06.48.04; Wed, 13 Jan 2021 06:48:28 -0800 (PST) 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="J4/q39rX"; 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 S1727054AbhAMOrF (ORCPT + 99 others); Wed, 13 Jan 2021 09:47:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbhAMOrF (ORCPT ); Wed, 13 Jan 2021 09:47:05 -0500 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3F6FC061786 for ; Wed, 13 Jan 2021 06:46:24 -0800 (PST) Received: by mail-qt1-x830.google.com with SMTP id z20so1221739qtq.3 for ; Wed, 13 Jan 2021 06:46:24 -0800 (PST) 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=yfGUinF7cIPTVWbvopOeCfPw7+d2tiRR9kb2ydRYjts=; b=J4/q39rXLtLSsirgM/gp1ycmF+EZoU05U8LXkrMPwtg4txTNhNhQnlC2qYlKMce0oe +ZdYlec0FYkjTXfKKU6QDihEXaFhAZqO49Zs7BW2uz2Dji4aTKNSgwmmcM6klgcdazVH 77e45GEIUaThtehfmed1GqE5qIu5QIWqCf3cMtp/9Scg+5Qff6/rmi2FIe6yr2K7QyPv osxiCBsEs2VWHrPO8zB7NauGwnEJQquo5ZxK5UEg+8TSwyiO9/ygO3WjtIkgFK2jdi0i Ecu/jlSSCeRJOpAZ9O88Ki4nY7cQW3aDWL9t1FfU3w/B8Al+Euiv+9jcJ/SEWCjsETQw 04lg== 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=yfGUinF7cIPTVWbvopOeCfPw7+d2tiRR9kb2ydRYjts=; b=YS2saLPssJXi5gJqP+MsEBauP29KWEsvuAUR4LZZQkYu4/SFt67NBawAm8FcQRtIKD 2LQ5vZqloN9ycPSJj2/UOgAkBpfRF2Hiv8FE0Ra8byO1HvH4nSfixm9IctLla5c1/juP qDBddJ74KqPSOJyetF9DDNcvUC4MPtqAj6XhFnq1kunv02WE4VbO85PG+G6Wwq62vPG5 Z11jBTUQHAY6XJu3nGnxTLRuvBHQFnTfHoQI0x+eDW/CCEkFCESriShijEGUML5Okh+Y WqaCURK1h2vYpSqkeH1QYdDI1xnoGm2j/4zpowWRk5GdIsLt9vNTDMwgG4vfiV6DtNdh bwEQ== X-Gm-Message-State: AOAM530d4+UzzCjTZwmfNXOUancXo5qsVGq81L5n+beHmzZtmL5SjWEb VWUO5Tb3JoBeiu3LLnPtDMRx7hmU/zSqW9Mx9ZN5DA== X-Received: by 2002:ac8:877:: with SMTP id x52mr2584682qth.334.1610549183656; Wed, 13 Jan 2021 06:46:23 -0800 (PST) MIME-Version: 1.0 References: <20210105163927.1376770-1-kyletso@google.com> <20210105163927.1376770-2-kyletso@google.com> <20210112132925.GC2020859@kuha.fi.intel.com> In-Reply-To: From: Kyle Tso Date: Wed, 13 Jan 2021 22:46:07 +0800 Message-ID: Subject: Re: [PATCH v5 1/3] usb: typec: tcpm: AMS and Collision Avoidance To: Badhri Jagan Sridharan Cc: Heikki Krogerus , Guenter Roeck , Greg Kroah-Hartman , Hans de Goede , USB , LKML , Will McVicker Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2021 at 2:11 PM Badhri Jagan Sridharan wrote: > > Hi Kyle, > > Do you want to handle the FAST_ROLE_SWAP case as well ? > I forgot this part.... Thanks for catching this. I will fix it. > You would have to fix up in two places: > > #1 > - if (port->state == SNK_READY) > - tcpm_set_state(port, FR_SWAP_SEND, 0); > - else > + if (port->state == SNK_READY) { > + int ret; > + > + port->upcoming_state = FR_SWAP_SEND; > + ret = tcpm_ams_start(port, FAST_ROLE_SWAP); > + if (ret == -EAGAIN) > + port->upcoming_state = INVALID_STATE; > + } else { > tcpm_log(port, "Discarding FRS_SIGNAL! > Not in sink ready"); > + } > > #2 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -4449,9 +4449,14 @@ static void tcpm_enable_frs_work(struct > kthread_work *work) > if (port->state != SNK_READY || port->vdm_state != > VDM_STATE_DONE || port->send_discover) > goto resched; > > - tcpm_set_state(port, GET_SINK_CAP, 0); > - port->sink_cap_done = true; > - > + port->upcoming_state = GET_SINK_CAP; > + ret = tcpm_ams_start(port, GET_SINK_CAPABILITIES); > + if (ret == -EAGAIN) { > + port->upcoming_state = INVALID_STATE; > + } else { > + port->sink_cap_done = true; > + goto unlock; > + } > > Thanks, > Badhri > >