From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Myrrh Periwinkle <myrrhperiwinkle@qtmlabs.xyz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 1/2] usb: typec: ucsi: Check if power role change actually happened before handling
Date: Tue, 19 May 2026 17:14:03 +0300 [thread overview]
Message-ID: <agxwK43LRZytVxPK@kuha> (raw)
In-Reply-To: <20260519-ucsi-fix-2-v1-1-6f1239535187@qtmlabs.xyz>
On Tue, May 19, 2026 at 06:41:39PM +0700, Myrrh Periwinkle wrote:
> The CrOS EC may send a connector status change event with the power
> direction changed flag set even if the power direction hasn't actually
> changed after initiating a SET_PDR command internally [1]. In practice
> this happens on every system suspend due to other changes performed by
> the EC [2][3][4], causing suspend to fail.
>
> Fix this by checking if the power role change actually happened before
> handling it.
>
> [1]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/subsys/pd_controller/pdc_power_mgmt.c;l=1689;drc=2d5a1cffce4e5ac8a39442cb3b764d2d5e1cf794
> [2]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/subsys/pd_controller/pdc_power_mgmt.c;l=3923;drc=2d5a1cffce4e5ac8a39442cb3b764d2d5e1cf794
> [3]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/subsys/pd_controller/pdc_power_mgmt.c;l=5094;drc=2d5a1cffce4e5ac8a39442cb3b764d2d5e1cf794
> [4]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/subsys/pd_controller/pdc_power_mgmt.c;l=2229;drc=2d5a1cffce4e5ac8a39442cb3b764d2d5e1cf794
>
> Cc: stable@vger.kernel.org
> Fixes: 7616f006db07 ("usb: typec: ucsi: Update power_supply on power role change")
> Signed-off-by: Myrrh Periwinkle <myrrhperiwinkle@qtmlabs.xyz>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/ucsi/ucsi.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 5b7ad9e99cb9..e19b656609e4 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1277,7 +1277,7 @@ static void ucsi_handle_connector_change(struct work_struct *work)
> work);
> struct ucsi *ucsi = con->ucsi;
> u8 curr_scale, volt_scale;
> - enum typec_role role;
> + enum typec_role role, prev_role;
> u16 change;
> int ret;
> u32 val;
> @@ -1288,6 +1288,8 @@ static void ucsi_handle_connector_change(struct work_struct *work)
> dev_err_once(ucsi->dev, "%s entered without EVENT_PENDING\n",
> __func__);
>
> + prev_role = UCSI_CONSTAT(con, PWR_DIR);
> +
> ret = ucsi_get_connector_status(con, true);
> if (ret) {
> dev_err(ucsi->dev, "%s: GET_CONNECTOR_STATUS failed (%d)\n",
> @@ -1304,7 +1306,7 @@ static void ucsi_handle_connector_change(struct work_struct *work)
> change = UCSI_CONSTAT(con, CHANGE);
> role = UCSI_CONSTAT(con, PWR_DIR);
>
> - if (change & UCSI_CONSTAT_POWER_DIR_CHANGE) {
> + if ((change & UCSI_CONSTAT_POWER_DIR_CHANGE) && role != prev_role) {
> typec_set_pwr_role(con->port, role);
> ucsi_port_psy_changed(con);
>
>
> --
> 2.54.0
--
heikki
next prev parent reply other threads:[~2026-05-19 14:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 11:41 [PATCH 0/2] usb: typec: ucsi: Additional checks for power role change handling Myrrh Periwinkle
2026-05-19 11:41 ` [PATCH 1/2] usb: typec: ucsi: Check if power role change actually happened before handling Myrrh Periwinkle
2026-05-19 14:14 ` Heikki Krogerus [this message]
2026-05-19 14:22 ` Heikki Krogerus
2026-05-19 14:24 ` Myrrh Periwinkle
2026-05-21 5:01 ` Sergey Senozhatsky
2026-05-19 11:41 ` [PATCH 2/2] usb: typec: ucsi: Don't update power_supply on power role change if not connected Myrrh Periwinkle
2026-05-21 5:01 ` Sergey Senozhatsky
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=agxwK43LRZytVxPK@kuha \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=myrrhperiwinkle@qtmlabs.xyz \
--cc=senozhatsky@chromium.org \
--cc=stable@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.