Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3269985pxj; Tue, 11 May 2021 00:09:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywMRvj8RKNOLf+x4si2xDMaDvLxmRBieZVO5NojtIF4WmFlKF6TF7RO/1tWNROEcAGYUJ6 X-Received: by 2002:a05:6638:221:: with SMTP id f1mr25477687jaq.16.1620716941437; Tue, 11 May 2021 00:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620716941; cv=none; d=google.com; s=arc-20160816; b=0nvQcGktVdmFsTCItc+AIMP6XQynpzq9PPkpQM298yQXCgSFiwmXTREj0PSXgY9iIj Xkl++XXG3X3F3gavqx1ldWqM34z4aNBJjCcJRjSNlCUrtsreeof6A6JHRWHr0gZzdCJT +jToeaOnNHFepVeEF2DlEoFURFT9bDUcyE+sb7qnz/1v+W4khIHZ2sh16D9KTG0cBJam 2HxqiEJZjxTEDTrhE3WQjvS0/1rIDQyXUAqiS+G4BxajUoQ2pQB8gAy8maREOXJBMQgM l6/LPwjEIHPWx1Nt9uEyObB8IUhFSR7BPOwFnYRfTw8YYj2uAmGKm7Mb5d1VQYqKmxJ1 z67w== 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:ironport-sdr :ironport-sdr; bh=H/QDmYsxpsRDS+KxLE2pK0csYgSZMoiNcEmIs6w9BgY=; b=zR1jPlMXLr332NWHi8L5RDM+PfY2k2d5/yY101BPuC9v56/uxnSVlh9b/yCDVa+vD4 DDsS11RjSMzxDw3dQveuMUaNSK7pLsxKKmQqZ2UpXhMJZX1pH5sza0AwYUKmiAtRL31N SBowPuODiwUaArV/Ev+fl5gNLK3ygHzJpbktUkiemKMmphFWs6X/AgG/ed6VVvyfIotA hfdhf+ZGJzyFFEkdweFokjM6b3TWX25xgiYJXJO0eEOz2b/SYspGAjpCHYxyXcfZpQD0 c3xVEc81BCAcuaZs/gf8XETAdeT6p7TUYq3Tccg1uNOj8BoSyhq12NF7gyziI8q1ae22 uY3A== 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 g11si4439261ile.43.2021.05.11.00.08.46; Tue, 11 May 2021 00:09:01 -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 S230305AbhEKHIC (ORCPT + 99 others); Tue, 11 May 2021 03:08:02 -0400 Received: from mga02.intel.com ([134.134.136.20]:46811 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbhEKHIB (ORCPT ); Tue, 11 May 2021 03:08:01 -0400 IronPort-SDR: bUV9DEyqdeaDPe/I80/8vPDjCiXSr5ri8ADzlvUKetNzzCvoNmKafFmqrhltGiB7l0IhOXnwqo UjuOdzo3fXfQ== X-IronPort-AV: E=McAfee;i="6200,9189,9980"; a="186509564" X-IronPort-AV: E=Sophos;i="5.82,290,1613462400"; d="scan'208";a="186509564" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 00:06:52 -0700 IronPort-SDR: l/DNnVZ1UyLOFlRAG2CLSSQJAU7n5Sp1GuZbQtCaWkzunBTtWncPMaLXi7Q34L0gue6QArcp8r VkJLFzp3FXcw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,290,1613462400"; d="scan'208";a="536849445" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 11 May 2021 00:06:49 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 11 May 2021 10:06:49 +0300 Date: Tue, 11 May 2021 10:06:49 +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 v3 2/2] usb: typec: tcpm: Fix wrong handling for Not_Supported in VDM AMS Message-ID: References: <20210507062300.1945009-1-kyletso@google.com> <20210507062300.1945009-3-kyletso@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210507062300.1945009-3-kyletso@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 07, 2021 at 02:23:00PM +0800, Kyle Tso wrote: > Not_Supported Message is acceptable in VDM AMS. Redirect the VDM state > machine to VDM_STATE_DONE when receiving Not_Supported and finish the > VDM AMS. > > Also, after the loop in vdm_state_machine_work, add more conditions of > VDM states to clear the vdm_sm_running flag because those are all > stopping states when leaving the loop. > > In addition, finish the VDM AMS if the port partner responds BUSY. > > Fixes: 8dea75e11380 ("usb: typec: tcpm: Protocol Error handling") > Fixes: 8d3a0578ad1a ("usb: typec: tcpm: Respond Wait if VDM state machine is running") > Signed-off-by: Kyle Tso Acked-by: Heikki Krogerus > --- > Changes since v2: > - no changes > > drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index 07a449f0e8fa..bf97db232f09 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -1897,7 +1897,6 @@ static void vdm_run_state_machine(struct tcpm_port *port) > > if (res < 0) { > port->vdm_state = VDM_STATE_ERR_BUSY; > - port->vdm_sm_running = false; > return; > } > } > @@ -1913,6 +1912,7 @@ static void vdm_run_state_machine(struct tcpm_port *port) > port->vdo_data[0] = port->vdo_retry; > port->vdo_count = 1; > port->vdm_state = VDM_STATE_READY; > + tcpm_ams_finish(port); > break; > case VDM_STATE_BUSY: > port->vdm_state = VDM_STATE_ERR_TMOUT; > @@ -1978,7 +1978,7 @@ static void vdm_state_machine_work(struct kthread_work *work) > port->vdm_state != VDM_STATE_BUSY && > port->vdm_state != VDM_STATE_SEND_MESSAGE); > > - if (port->vdm_state == VDM_STATE_ERR_TMOUT) > + if (port->vdm_state < VDM_STATE_READY) > port->vdm_sm_running = false; > > mutex_unlock(&port->lock); > @@ -2569,6 +2569,16 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port, > port->sink_cap_done = true; > tcpm_set_state(port, ready_state(port), 0); > break; > + case SRC_READY: > + case SNK_READY: > + if (port->vdm_state > VDM_STATE_READY) { > + port->vdm_state = VDM_STATE_DONE; > + if (tcpm_vdm_ams(port)) > + tcpm_ams_finish(port); > + mod_vdm_delayed_work(port, 0); > + break; > + } > + fallthrough; > default: > tcpm_pd_handle_state(port, > port->pwr_role == TYPEC_SOURCE ? > -- > 2.31.1.527.g47e6f16901-goog -- heikki