Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1291718pxb; Tue, 17 Aug 2021 08:15:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6MinpJjeLpGMzduJtQ7gXglPIv5j2diSxqWUBNSpPYF0T2IAOrMGYNascq+u5goZvy+pn X-Received: by 2002:a2e:8906:: with SMTP id d6mr3764696lji.248.1629213348175; Tue, 17 Aug 2021 08:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629213348; cv=none; d=google.com; s=arc-20160816; b=mVLlJV4MCg3mHvzQyFxpZJ82qAI7y/ajFaJNs7LOBSW5a4NkaqQ3bBokY4bnTFi9/m WZPxKaJaGkhu/5o6QSKX59xoqcSQvUbaD+iACAH60v6zpLZtbZk6ebCfvFtTIPKMfUD9 7d9ZWUq+EZoLc+VyUZxiEKQ+v+p4PMvwmz103011G31TSldmUASdq0dm1ScJbmTSKnuA 6UcB7756yyiEE6wwmEZwlTotjDgLZMLErfFC03wHQo5ZVoyYz6PKYkvu2S84g9Uf4kqO f/d0dx1xSKGju0Kc5fUcPryYcBo1Wvnh2ZWi/7JwgkLMiFFBgPeLIirjdG2ad/KW5iLy 1rBg== 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:sender:dkim-signature; bh=jPbqByzTm8MXGyaQ1QC2qzWAEW9nZn7Ccx15UsL0t/A=; b=Qx7xbYpIJsUeiC2txa9GNqWSw3uvSoUlR4Eczvw40DNjf8+Mb/Ut+6+AxKcpl1aJsL 6L7qN/w08NGMVcSyS5fodLG1KfmtoXMWYfbggmJLlJX67C90Hr1WkHD1fzYt29Q19zT8 /E/OX2MHi/7YgPmqX8oMiODLnf+LD8l+p3gH5rMghZF+NDKAg8GndXLw3C07ujjqeIT9 DvyuSQcHO8sUa2OE+Yi8JaCH3yx1ZlQJ5FbLirFidz20i83f0TtwnaW1ttC67NdWBwZT 6WKD4Ttm4yDmnbPWTdVsuf6W5dM9QQFEuOsTGpsIWggamGAIe/hDGSzr1++Te5UsyMC2 YbOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ISa12CYR; 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 l1si2784505ejo.68.2021.08.17.08.15.20; Tue, 17 Aug 2021 08:15:48 -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=@gmail.com header.s=20161025 header.b=ISa12CYR; 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 S238117AbhHQPOH (ORCPT + 99 others); Tue, 17 Aug 2021 11:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237052AbhHQPOF (ORCPT ); Tue, 17 Aug 2021 11:14:05 -0400 Received: from mail-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 686C6C061764; Tue, 17 Aug 2021 08:13:32 -0700 (PDT) Received: by mail-oo1-xc2d.google.com with SMTP id s21-20020a4ae5550000b02902667598672bso5989644oot.12; Tue, 17 Aug 2021 08:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jPbqByzTm8MXGyaQ1QC2qzWAEW9nZn7Ccx15UsL0t/A=; b=ISa12CYRPeVW2UgDuHHF4aifAy3qP6wGWcw9iPYZTdAOQABarK6a3u4p2dsVxUQSb/ u6rPribtafsqULWLT2Hb8dwqMrQnuflU/uItdu4d8iLme4/ilwY+s2L5hxudXbJKWAHq L1WxqVkU0+pfGxmffpHuCdT59zL48O2VkgJrYiaF5RONnz4/CndIrSzZG1eBNuT8IolS xtARGtCTM7E/YM0QD4k4Gmt3uJh7OKr3lGxND3kQniwrHjnW3AI0m5uhnZd0v4cnvuoZ aGInx0i1bw3askxl+XscNoqDhUSQvfhd+Gks9K56bZGUU6y5KKHJLBUfptOpViuucRUm HFiA== 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:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jPbqByzTm8MXGyaQ1QC2qzWAEW9nZn7Ccx15UsL0t/A=; b=LDyMFiNWdWLgdD8GDm47TbFP4LKq+dYG+lNh4HBK+Cc84cGHP9DMtP3K75RyaDxPZp D/aHe/q7ZoUmrik46VgQqZCM8OaitXuiItJQiJCdlheuNYn3hCj+SmrvoZIapEgxbs2j oCn4YDl0ZXrKru31jsy2J+rFc/UGONOtwD473g84KCqXLp1RxuoAwxpX111oAkdo65Gr bFGuQJcQ1+gOqU43NW93FVcilpLEnwvj5WMZ92M5kAZPpnlff4jD5DbV2LzfImqHjfTP ZR1f4kpk8vM6jjRpaT+ru3AvF3Wkz1EJJwSvj20ZXFR4/MNfBsybq81kMAwIv9SzHiKB KYCQ== X-Gm-Message-State: AOAM532ORiKe5BPhglYN07vheWjZZl3++b73mO4pTPGgz/K/xy4Vzj49 lMSgzViL9gygzYQ0k5ECFA77ivYBgPo= X-Received: by 2002:a4a:9bc1:: with SMTP id b1mr2971340ook.69.1629213211443; Tue, 17 Aug 2021 08:13:31 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q7sm429669otl.45.2021.08.17.08.13.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Aug 2021 08:13:30 -0700 (PDT) Sender: Guenter Roeck Subject: Re: [PATCH] usb: typec: tcpm: always rediscover when swapping DR To: Heikki Krogerus , Icenowy Zheng Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210813043131.833006-1-icenowy@aosc.io> From: Guenter Roeck Message-ID: <58034df4-f18c-ab3e-1fcc-dc85fc35320f@roeck-us.net> Date: Tue, 17 Aug 2021 08:13:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/17/21 2:36 AM, Heikki Krogerus wrote: > On Fri, Aug 13, 2021 at 12:31:31PM +0800, Icenowy Zheng wrote: >> Currently, TCPM code omits discover when swapping to gadget, and assume >> that no altmodes are available when swapping from gadget. However, we do >> send discover when we get attached as gadget -- this leads to modes to be >> discovered twice when attached as gadget and then swap to host. >> >> Always re-send discover when swapping DR, regardless of what change is >> being made; and because of this, the assumption that no altmodes are >> registered with gadget role is broken, and altmodes de-registeration is >> always needed now. >> >> Signed-off-by: Icenowy Zheng >> --- >> drivers/usb/typec/tcpm/tcpm.c | 9 ++++----- >> 1 file changed, 4 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c >> index b9bb63d749ec..ab6d0d51ee1c 100644 >> --- a/drivers/usb/typec/tcpm/tcpm.c >> +++ b/drivers/usb/typec/tcpm/tcpm.c >> @@ -4495,15 +4495,14 @@ static void run_state_machine(struct tcpm_port *port) >> tcpm_set_state(port, ready_state(port), 0); >> break; >> case DR_SWAP_CHANGE_DR: >> - if (port->data_role == TYPEC_HOST) { >> - tcpm_unregister_altmodes(port); >> + tcpm_unregister_altmodes(port); >> + if (port->data_role == TYPEC_HOST) >> tcpm_set_roles(port, true, port->pwr_role, >> TYPEC_DEVICE); >> - } else { >> + else >> tcpm_set_roles(port, true, port->pwr_role, >> TYPEC_HOST); >> - port->send_discover = true; >> - } >> + port->send_discover = true; >> tcpm_ams_finish(port); >> tcpm_set_state(port, ready_state(port), 0); >> break; > > Why is it necessary to do discovery with data role swap in general? > > thanks, > Additional question: There are two patches pending related to DR_SWAP and discovery. Are they both needed, or do they both solve the same problem ? Thanks, Guenter