Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp669823pxb; Wed, 13 Jan 2021 13:02:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQpmtpa4qu/j4of68/3eqSlmghp4+Os0oKp+sSCiZdx7KDi76PGYetpbXpnqTZU1GCe4gb X-Received: by 2002:a17:906:c097:: with SMTP id f23mr3035326ejz.136.1610571728549; Wed, 13 Jan 2021 13:02:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610571728; cv=none; d=google.com; s=arc-20160816; b=CL/K6wlAKs+NaSH5lhm/kPImOwJ1sWcGs3+2pqNbz8V/fyk7r4Lpy8AbLD2w/wiDHK UCbfanO4mf9TTyYMQtvyqxBPzTWycjGpYk1dGOxljQAOpbB9BS8W5pDzxb9TFySclX4I 62wgW9yYSuMd6h5eyaAbDb1LRLfNPTyaVrHxQOaWMIBJhvCB1eLqp5pXHGD2md6Y5qCZ /ZYF0sg+47MyV8ici/sf2Ovgf97VI1FMgyU7PU3My6uOgPNIsVou6rYOcUgZo1vrAZcN JglVk/llBx+OcRaeNHW/Yt3QGI1l/6zPVeUMdamq2VMQQ9F3ESHRZWo8BDhKcv0z1pHe GUgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=KyeVTvomgCzlV9Xq0HncJHDevMWvQaxSid6diziHy50=; b=W0/LEuCUdIdjX26niRfl0V9B0MT8oZeGahGdC030VsCdf3e45noz+E23SkoD2SiALt SQ4GJcJFw2ggRiTee1wXjOI7iQpq/AT1RDLU5yn45cybkslvzJFCsLUJZbVo8qKF8ugD RBcnN536swuDSW/lENhweKf6k0ZraECFWlW8cb6WnjPJtRKEvgITelbCaiQ57XLcaBgG lGL76LJwSK4vKuW08EI0QXo5jLDzZB+8IScZpps3YC0w4KMPoRMf0EWu0S0kSg/VV7KZ s3GNuG6IJFPg/cdXzFt9Xbzyq2CCwSBci8g+/sAHh/cDjTwZ4J5V+7yW+T3J23iKd0wY x+EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iGwsCkDf; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si1762563edp.127.2021.01.13.13.01.43; Wed, 13 Jan 2021 13:02:08 -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=@redhat.com header.s=mimecast20190719 header.b=iGwsCkDf; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728554AbhAMU6d (ORCPT + 99 others); Wed, 13 Jan 2021 15:58:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25689 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728839AbhAMU5f (ORCPT ); Wed, 13 Jan 2021 15:57:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610571422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KyeVTvomgCzlV9Xq0HncJHDevMWvQaxSid6diziHy50=; b=iGwsCkDf0987fTSNdrj/aZfBcSZcbABgvQ3f0kNqZv6giuYdf4AEasgKsmVFcNqv2XACe2 Ea+BzSWptZfWpZ4ALS40gAaHPsQfY1YEcA3XdGWPI9p4ln+gGP7T6Uh+aeXa5x/NkGh9QC mz0MIYZmFzzv3NzP4g7Uh3eca6mJAuQ= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544--URE32o2PNe7apz8LXt7TA-1; Wed, 13 Jan 2021 15:55:52 -0500 X-MC-Unique: -URE32o2PNe7apz8LXt7TA-1 Received: by mail-ed1-f71.google.com with SMTP id cm4so1456874edb.0 for ; Wed, 13 Jan 2021 12:55:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KyeVTvomgCzlV9Xq0HncJHDevMWvQaxSid6diziHy50=; b=P3uXNiua9jvCBS9egCWqQEnyAfeVkYwVspSOWD/wNIepN43ZY4H6XWCo3LBStpqKUp Hyxc8xRstqDIHh/DbjNAnQjDyLxV/g+/takCBG4d6SAa+CcFLz6OVrWjNLe6TiCp33rG +1M5uD6mPP7xA4G9PSicFANecTQv5ABIq1w9iKsfkhLRy3tLPQozEClpbXc+R42KJT2i WX0J8m6r1DXyGbE8E6pJ5rJh/a47W63lmt+UKwzBOFiEob6Klk8vBlYqwH+Nz+vFq8nw oanRaLm9WCrijLSozg8XHtQN1XOrnHcj/dmhJrTNdLV4lztuibMGRpK/6R1C+8kB3Lr7 S3bw== X-Gm-Message-State: AOAM533f4twBm0kXOhsmfOECw110K8uYAoBW0x3LGvQLRiCzhEeFEs5K ix+pp1g0bwsLAgyEdGKAnZBxCPlQBTjoIGpFKRV/UdIblGQrsN2dIOGWnAcgyU7XDkGFXTX1dBb hWe3Ash8YOsqBiBt/Zq4RWxs6 X-Received: by 2002:a17:906:24d1:: with SMTP id f17mr1985211ejb.21.1610571351326; Wed, 13 Jan 2021 12:55:51 -0800 (PST) X-Received: by 2002:a17:906:24d1:: with SMTP id f17mr1985197ejb.21.1610571351193; Wed, 13 Jan 2021 12:55:51 -0800 (PST) Received: from x1.localdomain (2001-1c00-0c1e-bf00-37a3-353b-be90-1238.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:37a3:353b:be90:1238]) by smtp.gmail.com with ESMTPSA id i8sm1312749eds.72.2021.01.13.12.55.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jan 2021 12:55:50 -0800 (PST) Subject: Re: [PATCH v5 1/3] usb: typec: tcpm: AMS and Collision Avoidance To: Kyle Tso , Badhri Jagan Sridharan Cc: Heikki Krogerus , Guenter Roeck , Greg Kroah-Hartman , USB , LKML , Will McVicker References: <20210105163927.1376770-1-kyletso@google.com> <20210105163927.1376770-2-kyletso@google.com> <20210112132925.GC2020859@kuha.fi.intel.com> From: Hans de Goede Message-ID: Date: Wed, 13 Jan 2021 21:55:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 1/13/21 3:46 PM, Kyle Tso wrote: > 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. That sounds like a v6 is upcoming which not only will have code-style changes but also some functional changes ? In that case I will wait a bit before running the tests which I want to run with this patch-set and run those tests with v6 so that I don't have to redo them later. Regards, Hans > > >> 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 >> >> >