Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1053310pxb; Tue, 17 Aug 2021 02:38:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw75oPHzhtbkKf+wbRvjq4WqG+0fkAVPgU2nvl3+o1HYcz5e5oS4jKzmy0522ETNdgaDtVT X-Received: by 2002:a17:906:9c84:: with SMTP id fj4mr2968879ejc.180.1629193091453; Tue, 17 Aug 2021 02:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629193091; cv=none; d=google.com; s=arc-20160816; b=TLRkG0W7+gPxRvXaJFdOss2puYzdxVG9S84aMi2P8Fi/c6ElbvA1UArRmt904z48L1 8IUgtnYywtyIZ5EpRIRFHLsuFVM9ajE56+mmbq4ecAcjQLG0BoiRROnYY8y5obq3JeUa hH5BEWddSkepCzynlFSNgVTu1cyAzvyPkPI+D2U3/TXOReIqxkZ1KboF5s7HUlNB8eX2 vasE5mMXIhYSUJ9sFtqUSD6XRsONaR3+wL4nOpDLzhFauFxeq/W8Mk8o99H6wD3I32tZ drvuMnEKC7akSpnmwt1jBV/DyP0iYq/doAAkqOjETPR/NvKBWy5/6tdWUejv/l30HEV1 yfmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=oS3XE3GMIqV3nR2FByCZWMrPwmZNS157/IPvkIiudKs=; b=sCpmT40hyysJyBEI4agi+MMIJVoD3d0llzz8bFNSbx2Pvc2w8kBx0qGD3xYqDUo4xY xifnhXbMHobmE2Qh8bSfNgl3CBXxowZ3QoOps0CCbsTO5ZXd8UmXgiYQPTW9D46UWmVK 5hUVr0Jn0nOhoerzJq7f2jqDNFKfqgNN1yaZ/+9pGb7ExkaXkQ8leRbyYLbcISoOgaf7 rewpc/a7I818GxnAuehw/dKsmaOAo3xgX6mgvgX8CYaswWRVremyT5Ag7cTqhD3mJTwC UP9iD0sbTTDOQaUdEO3tFSoR0hBdNIVClA2MVLWO4lFXd+XXYxQ7G58MDjAdNZlUbIEQ cp2g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si1803271ejt.205.2021.08.17.02.37.47; Tue, 17 Aug 2021 02:38:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235376AbhHQJhE (ORCPT + 99 others); Tue, 17 Aug 2021 05:37:04 -0400 Received: from mga09.intel.com ([134.134.136.24]:57488 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234593AbhHQJhD (ORCPT ); Tue, 17 Aug 2021 05:37:03 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10078"; a="216030318" X-IronPort-AV: E=Sophos;i="5.84,328,1620716400"; d="scan'208";a="216030318" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2021 02:36:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,328,1620716400"; d="scan'208";a="593293551" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 17 Aug 2021 02:36:27 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 17 Aug 2021 12:36:27 +0300 Date: Tue, 17 Aug 2021 12:36:27 +0300 From: Heikki Krogerus To: Icenowy Zheng 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 Message-ID: References: <20210813043131.833006-1-icenowy@aosc.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210813043131.833006-1-icenowy@aosc.io> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- heikki