From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70060C432BE for ; Tue, 17 Aug 2021 10:55:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D97360F58 for ; Tue, 17 Aug 2021 10:55:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239657AbhHQKzt (ORCPT ); Tue, 17 Aug 2021 06:55:49 -0400 Received: from mga03.intel.com ([134.134.136.65]:56076 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbhHQKzr (ORCPT ); Tue, 17 Aug 2021 06:55:47 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10078"; a="216073268" X-IronPort-AV: E=Sophos;i="5.84,328,1620716400"; d="scan'208";a="216073268" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2021 03:55:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,328,1620716400"; d="scan'208";a="593311540" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 17 Aug 2021 03:55:11 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 17 Aug 2021 13:55:10 +0300 Date: Tue, 17 Aug 2021 13:55:10 +0300 From: Heikki Krogerus To: Kyle Tso Cc: linux@roeck-us.net, gregkh@linuxfoundation.org, badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: typec: tcpm: Raise vdm_sm_running flag only when VDM SM is running Message-ID: References: <20210816075449.2236547-1-kyletso@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 17, 2021 at 06:32:55PM +0800, Kyle Tso wrote: > On Tue, Aug 17, 2021 at 5:39 PM Heikki Krogerus > wrote: > > > > On Mon, Aug 16, 2021 at 03:54:49PM +0800, Kyle Tso wrote: > > > If the port is going to send Discover_Identity Message, vdm_sm_running > > > flag was intentionally set before entering Ready States in order to > > > avoid the conflict because the port and the port partner might start > > > AMS at almost the same time after entering Ready States. > > > > > > However, the original design has a problem. When the port is doing > > > DR_SWAP from Device to Host, it raises the flag. Later in the > > > tcpm_send_discover_work, the flag blocks the procedure of sending the > > > Discover_Identity and it might never be cleared until disconnection. > > > > This is a bit off-topic, but I just asked this in another thread: Why > > do we have to do discovery with data role swap? > > > > thanks, > > > > This can be separated into two cases: > > 1. in PD2: If the port is originally UFP, it cannot send > Discover_Identity Message according to the Spec. And then DR_SWAP > happens. The port becomes DFP, and now it can do that. > > 2. in PD3: DFP and UFP are allowed to send Discover_Identity Message > and the responses may differ based on which roles they are active on. > > Quote from the PD3 Spec: > ``` > The Discover Identity Command Shall be used to determine the identity > and/or capabilities of the Port Partner. The following products Shall > return a Discover Identity Command ACK in response to a Discover > Identity Command request sent to SOP: > > • A PD-Capable UFP that supports Modal Operation. > • A PD-Capable product that has multiple DFPs. > • A PD-Capable [USB4] product. > ``` Got it. Thanks for the explanation. > > > Since there exists another flag send_discover representing that the port > > > is going to send Discover_Identity or not, it is enough to use that flag > > > to prevent the conflict. Also change the timing of the set/clear of > > > vdm_sm_running to indicate whether the VDM SM is actually running or > > > not. > > > > > > Fixes: c34e85fa69b9 ("usb: typec: tcpm: Send DISCOVER_IDENTITY from dedicated work") > > > Cc: Badhri Jagan Sridharan > > > Signed-off-by: Kyle Tso FWIW: Acked-by: Heikki Krogerus thanks, -- heikki