From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, grzegorz.alibozek@gmail.com,
bastian@rieck.me, andrew.co@free.fr, meven29@gmail.com,
pchernik@gmail.com, jorge.cep.mart@gmail.com,
danielmorgan@disroot.org, bernie@codewiz.org,
saipavanchitta1998@gmail.com, rubin@starset.net,
maniette@gmail.com, nate@kde.org
Subject: [RFC PATCH 1/2] usb: typec: ucsi: Check the connection on resume
Date: Wed, 7 Sep 2022 14:56:25 +0300 [thread overview]
Message-ID: <20220907115626.21976-2-heikki.krogerus@linux.intel.com> (raw)
In-Reply-To: <20220907115626.21976-1-heikki.krogerus@linux.intel.com>
This fixes an issue where the partner device is not unregistered
properly after resume if it's unplugged during suspend.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=210425
Fixes: a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
drivers/usb/typec/ucsi/ucsi.c | 42 ++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 7f2624f427241..33e1cee9dc184 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -183,16 +183,6 @@ int ucsi_send_command(struct ucsi *ucsi, u64 command,
}
EXPORT_SYMBOL_GPL(ucsi_send_command);
-int ucsi_resume(struct ucsi *ucsi)
-{
- u64 command;
-
- /* Restore UCSI notification enable mask after system resume */
- command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
-
- return ucsi_send_command(ucsi, command, NULL, 0);
-}
-EXPORT_SYMBOL_GPL(ucsi_resume);
/* -------------------------------------------------------------------------- */
struct ucsi_work {
@@ -746,6 +736,7 @@ static void ucsi_partner_change(struct ucsi_connector *con)
static int ucsi_check_connection(struct ucsi_connector *con)
{
+ u8 prev_flags = con->status.flags;
u64 command;
int ret;
@@ -756,10 +747,13 @@ static int ucsi_check_connection(struct ucsi_connector *con)
return ret;
}
+ if (con->status.flags == prev_flags)
+ return 0;
+
if (con->status.flags & UCSI_CONSTAT_CONNECTED) {
- if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) ==
- UCSI_CONSTAT_PWR_OPMODE_PD)
- ucsi_partner_task(con, ucsi_check_altmodes, 30, 0);
+ ucsi_register_partner(con);
+ ucsi_pwr_opmode_change(con);
+ ucsi_partner_change(con);
} else {
ucsi_partner_change(con);
ucsi_port_psy_changed(con);
@@ -1280,6 +1274,28 @@ static int ucsi_init(struct ucsi *ucsi)
return ret;
}
+int ucsi_resume(struct ucsi *ucsi)
+{
+ struct ucsi_connector *con;
+ u64 command;
+ int ret;
+
+ /* Restore UCSI notification enable mask after system resume */
+ command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
+ ret = ucsi_send_command(ucsi, command, NULL, 0);
+ if (ret < 0)
+ return ret;
+
+ for (con = ucsi->connector; con->port; con++) {
+ mutex_lock(&con->lock);
+ ucsi_check_connection(con);
+ mutex_unlock(&con->lock);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ucsi_resume);
+
static void ucsi_init_work(struct work_struct *work)
{
struct ucsi *ucsi = container_of(work, struct ucsi, work.work);
--
2.35.1
next prev parent reply other threads:[~2022-09-07 11:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 11:56 [RFC PATCH 0/2] usb: typec: ucsi: Check connection on resume Heikki Krogerus
2022-09-07 11:56 ` Heikki Krogerus [this message]
2022-09-07 11:56 ` [RFC PATCH 2/2] usb: typec: ucsi: acpi: Add PM hooks Heikki Krogerus
2022-09-07 21:33 ` [RFC PATCH 0/2] usb: typec: ucsi: Check connection on resume Grzegorz Alibożek
2022-09-08 5:01 ` Bastian Rieck
2022-09-09 6:22 ` Heikki Krogerus
2022-09-16 10:46 ` Heikki Krogerus
2022-10-07 10:00 ` Bastian Rieck
2022-10-07 10:04 ` Heikki Krogerus
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=20220907115626.21976-2-heikki.krogerus@linux.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=andrew.co@free.fr \
--cc=bastian@rieck.me \
--cc=bernie@codewiz.org \
--cc=danielmorgan@disroot.org \
--cc=grzegorz.alibozek@gmail.com \
--cc=jorge.cep.mart@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=maniette@gmail.com \
--cc=meven29@gmail.com \
--cc=nate@kde.org \
--cc=pchernik@gmail.com \
--cc=rubin@starset.net \
--cc=saipavanchitta1998@gmail.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