From: Marek Maslanka <mmaslanka@google.com>
To: tzungbi@kernel.org
Cc: bleung@chromium.org, abhishekpandit@chromium.org,
jthies@google.com, akuchynski@chromium.org, groeck@chromium.org,
raduvele@google.com, chrome-platform@lists.linux.dev,
linux-kernel@vger.kernel.org,
Marek Maslanka <mmaslanka@google.com>
Subject: Re: [PATCH] platform/chrome: cros_ec_typec: Poll for role swap completion
Date: Wed, 30 Sep 2026 20:55:00 +0200 [thread overview]
Message-ID: <20260930185500.198456-1-mmaslanka@google.com> (raw)
In-Reply-To: <art-pgdLHXiCm5l4@google.com>
On Tue, Sep 29, 2026 at 09:02:30AM +0000, Tzung-Bi Shih wrote:
> On Wed, Sep 23, 2026 at 07:44:19PM +0200, Marek Maslanka wrote:
> > + req.swap = USB_PD_CTRL_SWAP_NONE;
> > + end = jiffies + msecs_to_jiffies(ROLE_SWAP_TIMEOUT_MS);
> > + for (;;) {
> > + if ((resp.enabled & PD_CTRL_RESP_ENABLED_CONNECTED) &&
>
> Shouldn't PD_CTRL_RESP_ENABLED_CONNECTED remain set during the entire poll?
>
> > + cros_typec_resp_to_role(&resp, swap_type) == target_role)
> > + break;
> > +
> > + if (time_after_eq(jiffies, end)) {
> > + if (!(resp.enabled & PD_CTRL_RESP_ENABLED_CONNECTED)) {
> > + dev_err(data->dev, "Port disconnected during role swap\n");
> > + return -ENOTCONN;
> > + }
>
> Same here: if PD_CTRL_RESP_ENABLED_CONNECTED isn't set in the loop, should
> it return -ENOTCONN early (i.e., out of this if-block)?
Yea Right, thanks. PD_CTRL_RESP_ENABLED_CONNECTED remains set
throughout the role swap in the EC (both TCPMv2 and PDC keep the port
in an attached state while a PR_Swap or DR_Swap is in progress).
The original reason for checking PD_CTRL_RESP_ENABLED_CONNECTED before
comparing the role was to avoid misinterpreting a cleared resp.role (0)
on disconnect as TYPEC_SINK or TYPEC_DEVICE, but checking
!(resp.enabled & PD_CTRL_RESP_ENABLED_CONNECTED) at the start of the
loop and returning -ENOTCONN immediately is much cleaner and avoids
waiting for the timeout when the port disconnects.
I will update this in v2.
prev parent reply other threads:[~2026-09-30 18:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 17:44 Marek Maslanka
2026-09-29 9:02 ` Tzung-Bi Shih
2026-09-30 18:55 ` Marek Maslanka [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=20260930185500.198456-1-mmaslanka@google.com \
--to=mmaslanka@google.com \
--cc=abhishekpandit@chromium.org \
--cc=akuchynski@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=raduvele@google.com \
--cc=tzungbi@kernel.org \
/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
all inboxes | Powered by JetHome®