From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Kyle Tso <kyletso@google.com>
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
Date: Tue, 11 May 2021 10:06:49 +0300 [thread overview]
Message-ID: <YJotCZU9TYg+EVrG@kuha.fi.intel.com> (raw)
In-Reply-To: <20210507062300.1945009-3-kyletso@google.com>
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 <kyletso@google.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> 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
prev parent reply other threads:[~2021-05-11 7:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-07 6:22 [PATCH v3 0/2] VDM management improvement and some bug fixes Kyle Tso
2021-05-07 6:22 ` [PATCH v3 1/2] usb: typec: tcpm: Send DISCOVER_IDENTITY from dedicated work Kyle Tso
2021-05-07 6:23 ` [PATCH v3 2/2] usb: typec: tcpm: Fix wrong handling for Not_Supported in VDM AMS Kyle Tso
2021-05-07 13:55 ` Guenter Roeck
2021-05-11 7:06 ` Heikki Krogerus [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YJotCZU9TYg+EVrG@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=kyletso@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).