From: Guenter Roeck <linux@roeck-us.net>
To: Frank Wang <frank.wang@rock-chips.com>,
heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
heiko@sntech.de
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rockchip@lists.infradead.org, huangtao@rock-chips.com,
william.wu@rock-chips.com, jianwei.zheng@rock-chips.com,
yubing.zhang@rock-chips.com, wmc@rock-chips.com
Subject: Re: [PATCH 4/4] usb: typec: tcpm: fix source caps may lost after soft reset
Date: Fri, 17 Mar 2023 05:58:06 -0700 [thread overview]
Message-ID: <f5650fa4-db16-b1e4-f5b4-917fbcabb415@roeck-us.net> (raw)
In-Reply-To: <20230313025843.17162-5-frank.wang@rock-chips.com>
On 3/12/23 19:58, Frank Wang wrote:
> Invoke set_pd_rx() may flush the RX FIFO of PD controller, so do
> set_pd_rx() before sending Soft Reset in case Source caps may be flushed
> at debounce time between SOFT_RESET_SEND and SNK_WAIT_CAPABILITIES state.
>
Isn't that a problem of the fusb302 driver that it flushes its buffers
unconditionally when its set_pd_rx() callback is called ?
Guenter
> Without this patch, in PD charger stress test, the FUSB302 driver may
> occur the following exceptions in power negotiation stage.
>
> [ ...]
> [ 4.512252] fusb302_irq_intn
> [ 4.512260] AMS SOFT_RESET_AMS finished
> [ 4.512269] state change SOFT_RESET_SEND ->SNK_WAIT_CAPABILITIES [rev3 NONE_AMS]
> [ 4.514511] pd := on
> [ 4.514516] pending state change SNK_WAIT_CAPABILITIES ->HARD_RESET_SEND @ 310 ms [rev3 NONE_AMS]
> [ 4.515428] IRQ: 0x51, a: 0x00, b: 0x01, status0: 0x93
> [ 4.515431] IRQ: BC_LVL, handler pending
> [ 4.515435] IRQ: PD sent good CRC
> [ 4.516434] PD message header: 0
> [ 4.516437] PD message len: 0
> [ 4.516444] PD RX, header: 0x0 [1]
>
> Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
> ---
> drivers/usb/typec/tcpm/tcpm.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 9e583060e64fc..ba6bf71838eed 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4321,10 +4321,12 @@ static void run_state_machine(struct tcpm_port *port)
> tcpm_set_state(port, unattached_state(port), 0);
> break;
> case SNK_WAIT_CAPABILITIES:
> - ret = port->tcpc->set_pd_rx(port->tcpc, true);
> - if (ret < 0) {
> - tcpm_set_state(port, SNK_READY, 0);
> - break;
> + if (port->prev_state != SOFT_RESET_SEND) {
> + ret = port->tcpc->set_pd_rx(port->tcpc, true);
> + if (ret < 0) {
> + tcpm_set_state(port, SNK_READY, 0);
> + break;
> + }
> }
> /*
> * If VBUS has never been low, and we time out waiting
> @@ -4603,6 +4605,7 @@ static void run_state_machine(struct tcpm_port *port)
> case SOFT_RESET_SEND:
> port->message_id = 0;
> port->rx_msgid = -1;
> + port->tcpc->set_pd_rx(port->tcpc, true);
> if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET))
> tcpm_set_state_cond(port, hard_reset_state(port), 0);
> else
next prev parent reply other threads:[~2023-03-17 12:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 2:58 [PATCH 0/4] Fix some defects related Type-C TCPM Frank Wang
2023-03-13 2:58 ` [PATCH 1/4] usb: typec: tcpm: fix cc role at port reset Frank Wang
2023-03-14 9:20 ` Heikki Krogerus
2023-03-15 2:55 ` Frank Wang
2023-03-17 11:24 ` Heikki Krogerus
2023-03-17 12:47 ` Guenter Roeck
2023-03-20 2:28 ` Frank Wang
2023-03-13 2:58 ` [PATCH 2/4] usb: typec: tcpm: fix multiple times discover svids error Frank Wang
2023-03-14 9:22 ` Heikki Krogerus
2023-03-15 2:57 ` Frank Wang
2023-03-13 2:58 ` [PATCH 3/4] usb: typec: tcpm: add get max power support Frank Wang
2023-03-13 2:58 ` [PATCH 4/4] usb: typec: tcpm: fix source caps may lost after soft reset Frank Wang
2023-03-17 12:58 ` Guenter Roeck [this message]
2023-03-20 2:38 ` Frank Wang
2023-03-20 3:35 ` Guenter Roeck
2023-03-20 6:28 ` Frank Wang
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=f5650fa4-db16-b1e4-f5b4-917fbcabb415@roeck-us.net \
--to=linux@roeck-us.net \
--cc=frank.wang@rock-chips.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=heiko@sntech.de \
--cc=huangtao@rock-chips.com \
--cc=jianwei.zheng@rock-chips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=william.wu@rock-chips.com \
--cc=wmc@rock-chips.com \
--cc=yubing.zhang@rock-chips.com \
/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).