* [PATCH RFC] usb: typec: ucsi: Schedule connector worker on freezable workqueue
@ 2025-02-05 11:45 Abel Vesa
2025-02-05 17:31 ` Dmitry Baryshkov
2026-10-16 12:50 ` Joonhoe Kim
0 siblings, 2 replies; 3+ messages in thread
From: Abel Vesa @ 2025-02-05 11:45 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson,
Konrad Dybcio
Cc: Caleb Connolly, Dmitry Baryshkov, Johan Hovold, Neil Armstrong,
linux-arm-msm, linux-usb, linux-kernel, Abel Vesa
Currently, the UCSI connector worker is scheduled on the non-freezable
system workqueue. During system suspend, on a plug/unplug event, the
worker can run before the devices have actually resumed. The UCSI
instances can implement operations that might need to do some HW accesses
while the devices are still suspended.
Scheduling the USCI connector worker on the freezable system workqueue
instead will ensure the devices are resumed by the time the worker is
scheduled to run.
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
Sending this as an RFC since I'm not really sure if this should be done
in the ucsi generic implementation or in the pmic glink UCSI instance.
For context, on some Qualcomm Snapdragon X Elite laptops, there are some
i2c interfaced USB Type-C retimers (ParadeTech PS8830) that need to be
configured on each plug/unplug event. Since the i2c controller is
suspended when the UCSI connector worker gets scheduled, it results in
the following:
[ 70.036669] i2c i2c-4: Transfer while suspended
[ 70.036802] WARNING: CPU: 0 PID: 819 at drivers/i2c/i2c-core.h:56 __i2c_transfer+0xb4/0x57c [i2c_core]
[ 70.036945] CPU: 0 UID: 0 PID: 819 Comm: kworker/0:4 Tainted: G W 6.13.0+ #84
[ 70.036949] Tainted: [W]=WARN
[ 70.036950] Hardware name: LENOVO 21N10007UK/21N10007UK, BIOS N42ET85W (2.15 ) 11/22/2024
[ 70.036952] Workqueue: events ucsi_handle_connector_change [typec_ucsi]
[ 70.036959] pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
[ 70.036961] pc : __i2c_transfer+0xb4/0x57c [i2c_core]
[ 70.036963] lr : __i2c_transfer+0xb0/0x57c [i2c_core]
[ 70.036964] sp : ffff800082ffba90
[ 70.036966] x29: ffff800082ffba90 x28: 0000000000000000 x27: ffff1cc400dba0a0
[ 70.036969] x26: 0000000000000000 x25: ffff1cc4034bd500 x24: ffff1cc400010005
[ 70.036970] x23: 0000000000000000 x22: ffff1cc400dba0a1 x21: 0000000000000001
[ 70.036972] x20: ffff1cc4011ab0f0 x19: ffff1cc4011ab160 x18: 000000000009eb8a
[ 70.036974] x17: 00000005bf44b304 x16: 00000000000000cc x15: 0000000000000004
[ 70.036976] x14: ffffde65ecd46798 x13: 0000000000000fff x12: 0000000000000003
[ 70.036978] x11: ffff3e658f1f7000 x10: 00000000ffffffff x9 : 340eced73efb4000
[ 70.036980] x8 : 340eced73efb4000 x7 : 656c696877207265 x6 : 66736e617254203a
[ 70.036982] x5 : ffffde65ece89084 x4 : ffffde65c9120093 x3 : 0000000000000000
[ 70.036984] x2 : ffff800082ffb854 x1 : 00000000000000c0 x0 : 00000000ffffff94
[ 70.036987] Call trace:
[ 70.036989] __i2c_transfer+0xb4/0x57c [i2c_core] (P)
[ 70.036994] i2c_transfer+0x98/0xf0 [i2c_core]
[ 70.036995] i2c_transfer_buffer_flags+0x54/0x88 [i2c_core]
[ 70.036997] regmap_i2c_write+0x20/0x48 [regmap_i2c]
[ 70.037001] _regmap_raw_write_impl+0x780/0x944
[ 70.037012] _regmap_bus_raw_write+0x60/0x7c
[ 70.037014] _regmap_write+0x134/0x184
[ 70.037016] regmap_write+0x54/0x78
[ 70.037018] ps883x_set+0x58/0xec [ps883x]
[ 70.037021] ps883x_sw_set+0x60/0x84 [ps883x]
[ 70.037022] typec_switch_set+0x48/0x74 [typec]
[ 70.037026] typec_set_orientation+0x24/0x6c [typec]
[ 70.037027] pmic_glink_ucsi_connector_status+0x30/0x7c [ucsi_glink]
[ 70.037032] ucsi_handle_connector_change+0x98/0x614 [typec_ucsi]
[ 70.037034] process_scheduled_works+0x1a0/0x2d0
[ 70.037045] worker_thread+0x2a8/0x3c8
[ 70.037046] kthread+0xfc/0x184
[ 70.037048] ret_from_fork+0x10/0x20
---
drivers/usb/typec/ucsi/ucsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index fcf499cc9458c0d12015a7e36e5f1ac448c3a431..8c6081e0cd6155a59ca733070cd93e6b79398b3e 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -1307,7 +1307,7 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num)
}
if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags))
- schedule_work(&con->work);
+ queue_work(system_freezable_wq, &con->work);
}
EXPORT_SYMBOL_GPL(ucsi_connector_change);
---
base-commit: 00f3246adeeacbda0bd0b303604e46eb59c32e6e
change-id: 20250205-ucsi-schedule-conn-worker-on-freezable-wq-cff0a880b08b
Best regards,
--
Abel Vesa <abel.vesa@linaro.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] usb: typec: ucsi: Schedule connector worker on freezable workqueue
2025-02-05 11:45 [PATCH RFC] usb: typec: ucsi: Schedule connector worker on freezable workqueue Abel Vesa
@ 2025-02-05 17:31 ` Dmitry Baryshkov
2026-10-16 12:50 ` Joonhoe Kim
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2025-02-05 17:31 UTC (permalink / raw)
To: Abel Vesa
Cc: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson,
Konrad Dybcio, Caleb Connolly, Johan Hovold, Neil Armstrong,
linux-arm-msm, linux-usb, linux-kernel
On Wed, Feb 05, 2025 at 01:45:05PM +0200, Abel Vesa wrote:
> Currently, the UCSI connector worker is scheduled on the non-freezable
> system workqueue. During system suspend, on a plug/unplug event, the
> worker can run before the devices have actually resumed. The UCSI
> instances can implement operations that might need to do some HW accesses
> while the devices are still suspended.
>
> Scheduling the USCI connector worker on the freezable system workqueue
> instead will ensure the devices are resumed by the time the worker is
> scheduled to run.
>
> Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> ---
> Sending this as an RFC since I'm not really sure if this should be done
> in the ucsi generic implementation or in the pmic glink UCSI instance.
Can we really fix PMIC GLINK instead, please? Previously you were saying
that it for some reason has to be woken up earlier.
>
> For context, on some Qualcomm Snapdragon X Elite laptops, there are some
> i2c interfaced USB Type-C retimers (ParadeTech PS8830) that need to be
> configured on each plug/unplug event. Since the i2c controller is
> suspended when the UCSI connector worker gets scheduled, it results in
> the following:
>
> [ 70.036669] i2c i2c-4: Transfer while suspended
> [ 70.036802] WARNING: CPU: 0 PID: 819 at drivers/i2c/i2c-core.h:56 __i2c_transfer+0xb4/0x57c [i2c_core]
> [ 70.036945] CPU: 0 UID: 0 PID: 819 Comm: kworker/0:4 Tainted: G W 6.13.0+ #84
> [ 70.036949] Tainted: [W]=WARN
> [ 70.036950] Hardware name: LENOVO 21N10007UK/21N10007UK, BIOS N42ET85W (2.15 ) 11/22/2024
> [ 70.036952] Workqueue: events ucsi_handle_connector_change [typec_ucsi]
> [ 70.036959] pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
> [ 70.036961] pc : __i2c_transfer+0xb4/0x57c [i2c_core]
> [ 70.036963] lr : __i2c_transfer+0xb0/0x57c [i2c_core]
> [ 70.036964] sp : ffff800082ffba90
> [ 70.036966] x29: ffff800082ffba90 x28: 0000000000000000 x27: ffff1cc400dba0a0
> [ 70.036969] x26: 0000000000000000 x25: ffff1cc4034bd500 x24: ffff1cc400010005
> [ 70.036970] x23: 0000000000000000 x22: ffff1cc400dba0a1 x21: 0000000000000001
> [ 70.036972] x20: ffff1cc4011ab0f0 x19: ffff1cc4011ab160 x18: 000000000009eb8a
> [ 70.036974] x17: 00000005bf44b304 x16: 00000000000000cc x15: 0000000000000004
> [ 70.036976] x14: ffffde65ecd46798 x13: 0000000000000fff x12: 0000000000000003
> [ 70.036978] x11: ffff3e658f1f7000 x10: 00000000ffffffff x9 : 340eced73efb4000
> [ 70.036980] x8 : 340eced73efb4000 x7 : 656c696877207265 x6 : 66736e617254203a
> [ 70.036982] x5 : ffffde65ece89084 x4 : ffffde65c9120093 x3 : 0000000000000000
> [ 70.036984] x2 : ffff800082ffb854 x1 : 00000000000000c0 x0 : 00000000ffffff94
> [ 70.036987] Call trace:
> [ 70.036989] __i2c_transfer+0xb4/0x57c [i2c_core] (P)
> [ 70.036994] i2c_transfer+0x98/0xf0 [i2c_core]
> [ 70.036995] i2c_transfer_buffer_flags+0x54/0x88 [i2c_core]
> [ 70.036997] regmap_i2c_write+0x20/0x48 [regmap_i2c]
> [ 70.037001] _regmap_raw_write_impl+0x780/0x944
> [ 70.037012] _regmap_bus_raw_write+0x60/0x7c
> [ 70.037014] _regmap_write+0x134/0x184
> [ 70.037016] regmap_write+0x54/0x78
> [ 70.037018] ps883x_set+0x58/0xec [ps883x]
> [ 70.037021] ps883x_sw_set+0x60/0x84 [ps883x]
> [ 70.037022] typec_switch_set+0x48/0x74 [typec]
> [ 70.037026] typec_set_orientation+0x24/0x6c [typec]
> [ 70.037027] pmic_glink_ucsi_connector_status+0x30/0x7c [ucsi_glink]
> [ 70.037032] ucsi_handle_connector_change+0x98/0x614 [typec_ucsi]
> [ 70.037034] process_scheduled_works+0x1a0/0x2d0
> [ 70.037045] worker_thread+0x2a8/0x3c8
> [ 70.037046] kthread+0xfc/0x184
> [ 70.037048] ret_from_fork+0x10/0x20
> ---
> drivers/usb/typec/ucsi/ucsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index fcf499cc9458c0d12015a7e36e5f1ac448c3a431..8c6081e0cd6155a59ca733070cd93e6b79398b3e 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1307,7 +1307,7 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num)
> }
>
> if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags))
> - schedule_work(&con->work);
> + queue_work(system_freezable_wq, &con->work);
> }
> EXPORT_SYMBOL_GPL(ucsi_connector_change);
>
>
> ---
> base-commit: 00f3246adeeacbda0bd0b303604e46eb59c32e6e
> change-id: 20250205-ucsi-schedule-conn-worker-on-freezable-wq-cff0a880b08b
>
> Best regards,
> --
> Abel Vesa <abel.vesa@linaro.org>
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] usb: typec: ucsi: Schedule connector worker on freezable workqueue
2025-02-05 11:45 [PATCH RFC] usb: typec: ucsi: Schedule connector worker on freezable workqueue Abel Vesa
2025-02-05 17:31 ` Dmitry Baryshkov
@ 2026-10-16 12:50 ` Joonhoe Kim
1 sibling, 0 replies; 3+ messages in thread
From: Joonhoe Kim @ 2026-10-16 12:50 UTC (permalink / raw)
To: Abel Vesa
Cc: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson,
Konrad Dybcio, Dmitry Baryshkov, Johan Hovold, Neil Armstrong,
Casey Connolly, linux-arm-msm, linux-usb, linux-kernel
(Resending with the lists on Cc; my earlier reply only went to Abel.)
On Wed, Feb 05, 2025 at 01:45:05PM +0200, Abel Vesa wrote:
> Scheduling the USCI connector worker on the freezable system workqueue
> instead will ensure the devices are resumed by the time the worker is
> scheduled to run.
Hi Abel,
You mentioned respinning this together with the altmode change (now
7d0767c5cd87). Are you still planning to? I hit the same problem on a
Kaanapali tablet (Lenovo Legion Tab Y700 Gen 5) with an FSA4480
orientation switch. Unplugging a USB-C to HDMI adapter during s2idle,
with the altmode change applied:
i2c i2c-2: Transfer while suspended
Workqueue: events ucsi_handle_connector_change
fsa4480_set
typec_switch_set
typec_set_orientation
pmic_glink_ucsi_connector_status
ucsi_handle_connector_change
and the system never resumes. With this patch on v7.3-rc4 it resumes
normally (2 of 2) and the change is handled after thaw.
On Dmitry's question: freezing the ucsi_glink notify_work instead would
also hold back command completions (ucsi_notify_common() ->
complete()), so a command in flight at freeze time would wait for
UCSI_TIMEOUT_MS. That is from reading the code, not tested.
If you respin it, I can reply with a Tested-by. If you'd rather I send
it, I have it rebased on next-20260928; just tell me how to credit you.
Thanks,
Joonhoe Kim
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-16 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 11:45 [PATCH RFC] usb: typec: ucsi: Schedule connector worker on freezable workqueue Abel Vesa
2025-02-05 17:31 ` Dmitry Baryshkov
2026-10-16 12:50 ` Joonhoe Kim
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.