Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1056859pxb; Tue, 17 Aug 2021 02:44:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1UPsX9F+lEAJGi8yJHde9UswmA1PVIS92CRymwvqRyHp6qJ1x9p/BMPwcV88V2EvTJGoW X-Received: by 2002:a05:6638:2481:: with SMTP id x1mr2147501jat.69.1629193485015; Tue, 17 Aug 2021 02:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629193485; cv=none; d=google.com; s=arc-20160816; b=dsYPTZ6D60DdE9LKdMS5vJW3hFhLK7Z95S0oGS41bX7xZt3DbRndw7H5OQwBxYFxMZ LDxvx2ShQK9Hvd+SQL+qvY98S8/qTFkdfUUC4aTZqfNngyY/uSWmupLWCboy5TqL4e0S GcQynYW0TK8V4W3cAr/pT44Q6gaZG6wzfQmC6cVIJGBIsiPqPJ6XACmAaZfUSDacfBQu 6CjA/I92C1ixt89TGBDgfvBkgstXGEkHzCMM6VvOPr7tas7cL3H7xn0z+YWsxgcFa3qE IUNJBwjVmK0jT3onRzRsdza7Ej78uESKX4naroIOQpWm4Fma5HuyEB4jBzq2g+nTzto2 0RoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature:ai-spam-status:dkim-signature; bh=dwPGbUCguycUdxudVSEtLvtLFXcJN22y5uUAIa0ok/g=; b=ZwBgloeKwiJ0MU2LFIjNRMDmVBOv2swmh078B5R8z4jPaylffD1Z0C8en3fy/DI61G o0BZvjBt0V3XjQX8I8MVpyxr3FipHggsL/6ERQyN5mafh6utvMWZ8nQxWEeHR5t7KxBO cUPEYZhpBNMbRTWTU9jrHcZc5AX/imyCtjaqgg2f6MrNfMsF4/DdzRlIcN1HADoVRvq5 t2JnWCvRcDDcx7y3IEhVMy7z6p9k/2VwpdBFUBSNkNq0EZlXZOBfuS0/FUB1bW/Wdx8t BBfijmnOIw46CpM3Z15uMBquUexpp+JPyFoNQGQB/TwQxvaNdjGnzd6o2Rf9hqEDNPKf 1sVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mymailcheap.com header.s=default header.b=fYalB656; dkim=fail header.i=@aosc.io header.s=default header.b="jEImuBS/"; 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 y11si1819448ilc.54.2021.08.17.02.44.33; Tue, 17 Aug 2021 02:44:45 -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=fail header.i=@mymailcheap.com header.s=default header.b=fYalB656; dkim=fail header.i=@aosc.io header.s=default header.b="jEImuBS/"; 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 S235191AbhHQJn1 (ORCPT + 99 others); Tue, 17 Aug 2021 05:43:27 -0400 Received: from relay5.mymailcheap.com ([159.100.248.207]:39173 "EHLO relay5.mymailcheap.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234593AbhHQJn0 (ORCPT ); Tue, 17 Aug 2021 05:43:26 -0400 Received: from relay3.mymailcheap.com (relay3.mymailcheap.com [217.182.119.157]) by relay5.mymailcheap.com (Postfix) with ESMTPS id 7AD0D260EB; Tue, 17 Aug 2021 09:42:52 +0000 (UTC) Received: from filter2.mymailcheap.com (filter2.mymailcheap.com [91.134.140.82]) by relay3.mymailcheap.com (Postfix) with ESMTPS id DD9D53F1CC; Tue, 17 Aug 2021 11:42:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by filter2.mymailcheap.com (Postfix) with ESMTP id BA31C2A915; Tue, 17 Aug 2021 11:42:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mymailcheap.com; s=default; t=1629193369; bh=FkrJaXbezoWlUIzlLXe6PbAJUPxZx/ZrdnrQAm77CcY=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=fYalB656gDqDvxzShA8MbsCYDorxNkzWFTuunu5/dTIzs3DFYgH2G01ZB2fZw5n7J kzTVBSQ0UWb8JJhVlnDwO15/TLUylCEUlGidyu+s2b1tT9T7A5u8SmziOLOf1pMFK/ D62pimbqOyvEcL2s8DacxUuBQPvlpUCA7Qtgi+Vk= X-Virus-Scanned: Debian amavisd-new at filter2.mymailcheap.com Received: from filter2.mymailcheap.com ([127.0.0.1]) by localhost (filter2.mymailcheap.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EAh1KGjLN-C1; Tue, 17 Aug 2021 11:42:45 +0200 (CEST) Received: from mail20.mymailcheap.com (mail20.mymailcheap.com [51.83.111.147]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by filter2.mymailcheap.com (Postfix) with ESMTPS; Tue, 17 Aug 2021 11:42:45 +0200 (CEST) Received: from [213.133.102.83] (ml.mymailcheap.com [213.133.102.83]) by mail20.mymailcheap.com (Postfix) with ESMTP id 7166041737; Tue, 17 Aug 2021 09:42:44 +0000 (UTC) Authentication-Results: mail20.mymailcheap.com; dkim=pass (1024-bit key; unprotected) header.d=aosc.io header.i=@aosc.io header.b="jEImuBS/"; dkim-atps=neutral AI-Spam-Status: Not processed Received: from [127.0.0.1] (unknown [59.41.161.211]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail20.mymailcheap.com (Postfix) with ESMTPSA id DA0F240CCF; Tue, 17 Aug 2021 09:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=aosc.io; s=default; t=1629193348; bh=FkrJaXbezoWlUIzlLXe6PbAJUPxZx/ZrdnrQAm77CcY=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=jEImuBS/pbTiB0xTTqHAm22XRPP309CyeMEpkBfGDdYmK7b3MY//C2Up5gVDbcU3T BxrfxQy5DJ3wlDwSk4gcKX44N2gb+FuaajjyJKAo0rJUGVeQlWPEnP9ffuyr2y0VUY VfMeVA96KISIIFEGUa8W1FvLEhPKbC+dCNec+pYc= Date: Tue, 17 Aug 2021 17:41:58 +0800 From: Icenowy Zheng To: Heikki Krogerus CC: Guenter Roeck , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: typec: tcpm: always rediscover when swapping DR User-Agent: K-9 Mail for Android In-Reply-To: References: <20210813043131.833006-1-icenowy@aosc.io> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-0.10 / 10.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(0.00)[aosc.io:s=default]; RECEIVED_SPAMHAUS_PBL(0.00)[59.41.161.211:received]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[aosc.io]; R_SPF_SOFTFAIL(0.00)[~all]; RCPT_COUNT_FIVE(0.00)[5]; ML_SERVERS(-3.10)[213.133.102.83]; DKIM_TRACE(0.00)[aosc.io:+]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:213.133.96.0/19, country:DE]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; HFILTER_HELO_BAREIP(3.00)[213.133.102.83,1] X-Rspamd-Queue-Id: 7166041737 X-Rspamd-Server: mail20.mymailcheap.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =E4=BA=8E 2021=E5=B9=B48=E6=9C=8817=E6=97=A5 GMT+08:00 =E4=B8=8B=E5=8D=885= :36:27, Heikki Krogerus =E5=86=99= =E5=88=B0: >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=2E 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=2E >>=20 >> 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=2E >>=20 >> Signed-off-by: Icenowy Zheng >> --- >> drivers/usb/typec/tcpm/tcpm=2Ec | 9 ++++----- >> 1 file changed, 4 insertions(+), 5 deletions(-) >>=20 >> diff --git a/drivers/usb/typec/tcpm/tcpm=2Ec b/drivers/usb/typec/tcpm/t= cpm=2Ec >> index b9bb63d749ec=2E=2Eab6d0d51ee1c 100644 >> --- a/drivers/usb/typec/tcpm/tcpm=2Ec >> +++ b/drivers/usb/typec/tcpm/tcpm=2Ec >> @@ -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 =3D=3D TYPEC_HOST) { >> - tcpm_unregister_altmodes(port); >> + tcpm_unregister_altmodes(port); >> + if (port->data_role =3D=3D 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 =3D true; >> - } >> + port->send_discover =3D 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? I think it could be possible for devices to expose different altmode with different role=2E > >thanks, >