Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp121269rwb; Thu, 12 Jan 2023 17:02:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXu+8KTwupsSSYQjHWI5/KSbb2a1+lp89hj+Qw88CKsu4bZIosinJbh1ch9qnAMtBe8DzE3C X-Received: by 2002:a17:907:8b89:b0:7c1:6f86:eeb with SMTP id tb9-20020a1709078b8900b007c16f860eebmr65207932ejc.7.1673571728109; Thu, 12 Jan 2023 17:02:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673571728; cv=none; d=google.com; s=arc-20160816; b=Zv8iPbI6sAm8vl0ow4nwIwaLP2dMnxi7fE/4Ms6rvVEK+pGQAth/rRyx+D4CEIxg+9 PJXGAgOuJ635lQ1lzsLWs6ptNuKZDy6WHpnxUHuhvk3fRUo//3hFY/ev4I0ADCNENCV8 0m8svzHJiaEkBGm6EfsrMqU+1ij3jzZIShIag6kfvuyaE0f3tF+a9NbjO891MieOGefe 3WlFHPp8lf0IEi5Zpov8BKF5mxmgaZdZDphP1mlvNPaPW4rVFik7PeCtmKTSK0bvOkDa 9/3fKwRelt/cLK1cHJ9YSqY57xXNHxQHf6fVHpvtwWJp48GMGjv9VWQZTH4OlI9O5YdP lNJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qCnLlBafyh4GwT6zVHEN0+uHO/uAkzlVBLePEGOwfww=; b=YZRFtbNmujlrMEzsrsk078IgbpUsS0N6N42i+U2vwiCB2MEyn/l6TL3B39C6Z7ors5 iG/3UDacrejpc1t5sLGcZibTbL4BG46X4h7Rgg/x4fQ/GYbn5jljZxjmPWCx9DViQ9i+ UJB+A+6sywIMXND6GD76xNw8qOjsVvddLJe+LYIo8vPkPJDVbYE6Ym36tP7t91wDlkpO bZeuVYjs+TPuiruzWoEjG5oVZMrleKmYzQxXGBmOZGXhZmig0u8sE8SjLF3bV3Lnr9PF nO2ccCv3iHbVVlZ0zLVT2tdW/st975FcRH/TSGtUYaJDnZHsn7e/iroa/gRW7qmO1fS4 zLUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qo14-20020a170907874e00b007bc7d5c73ecsi16322956ejc.336.2023.01.12.17.01.54; Thu, 12 Jan 2023 17:02:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232470AbjAMAdq (ORCPT + 52 others); Thu, 12 Jan 2023 19:33:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232730AbjAMAdj (ORCPT ); Thu, 12 Jan 2023 19:33:39 -0500 Received: from mg.richtek.com (mg.richtek.com [220.130.44.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A31E061448; Thu, 12 Jan 2023 16:33:32 -0800 (PST) X-MailGates: (flag:4,DYNAMIC,BADHELO,RELAY,NOHOST:PASS)(compute_score:DE LIVER,40,3) Received: from 192.168.10.46 by mg.richtek.com with MailGates ESMTP Server V5.0(16491:0:AUTH_RELAY) (envelope-from ); Fri, 13 Jan 2023 08:33:08 +0800 (CST) Received: from ex4.rt.l (192.168.10.47) by ex3.rt.l (192.168.10.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Fri, 13 Jan 2023 08:33:08 +0800 Received: from linuxcarl2.richtek.com (192.168.10.154) by ex4.rt.l (192.168.10.45) with Microsoft SMTP Server id 15.2.1118.20 via Frontend Transport; Fri, 13 Jan 2023 08:33:08 +0800 Date: Fri, 13 Jan 2023 08:33:07 +0800 From: ChiYuan Huang To: , , CC: , , , , , , Subject: Re: [PATCH RESEND v2] usb: typec: tcpm: Fix altmode re-registration causes sysfs create fail Message-ID: <20230113003307.GA4232@linuxcarl2.richtek.com> References: <1673248790-15794-1-git-send-email-cy_huang@richtek.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1673248790-15794-1-git-send-email-cy_huang@richtek.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 09, 2023 at 03:19:50PM +0800, cy_huang@richtek.com wrote: > From: ChiYuan Huang > > There's the altmode re-registeration issue after data role > swap (DR_SWAP). > > Comparing to USBPD 2.0, in USBPD 3.0, it loose the limit that only DFP > can initiate the VDM command to get partner identity information. > > For a USBPD 3.0 UFP device, it may already get the identity information > from its port partner before DR_SWAP. If DR_SWAP send or receive at the > mean time, 'send_discover' flag will be raised again. It causes discover > identify action restart while entering ready state. And after all > discover actions are done, the 'tcpm_register_altmodes' will be called. > If old altmode is not unregistered, this sysfs create fail can be found. > > In 'DR_SWAP_CHANGE_DR' state case, only DFP will unregister altmodes. > For UFP, the original altmodes keep registered. > > This patch fix the logic that after DR_SWAP, 'tcpm_unregister_altmodes' > must be called whatever the current data role is. > > Reviewed-by: Macpaul Lin > Fixes: ae8a2ca8a221 ("usb: typec: Group all TCPCI/TCPM code together) > Reported-by: TommyYl Chen > Cc: stable@vger.kernel.org > Signed-off-by: ChiYuan Huang > --- > Since v2: > - Correct the mail sent from Richtek. > - Add 'Reviewed-by' tag. > Sorry, it seems I focus on the email testing and forget to attach the issue log in the v2 patch appendix. If anyone check this issue. Please refer to the v1 patch link. https://lore.kernel.org/lkml/1671096096-20307-1-git-send-email-u0084500@gmail.com/ Inside this, the issue log show how it happened. This can help better analyze this issue. ChiYuan Huang. > Hi, Greg: > > Please check this one. I have strongly requested our MIS to remove the confidential string. > > ChiYuan Huang. > --- > drivers/usb/typec/tcpm/tcpm.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index 904c7b4..59b366b 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -4594,14 +4594,13 @@ 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); > - } > tcpm_ams_finish(port); > tcpm_set_state(port, ready_state(port), 0); > break; > -- > 2.7.4 >