mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vladyslav Tymoshchuk <tvlad744@gmail.com>
To: Abel Vesa <abel.vesa@oss.qualcomm.com>, Joonhoe Kim <26rote@gmail.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Dmitry Baryshkov <lumag@kernel.org>,
	Johan Hovold <johan@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Casey Connolly <casey.connolly@linaro.org>,
	linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Vladyslav Tymoshchuk <tvlad744@gmail.com>
Subject: Re: [PATCH RFC] usb: typec: ucsi: Schedule connector worker on freezable workqueue
Date: Sun, 18 Oct 2026 18:01:36 +0300	[thread overview]
Message-ID: <20261018150136.5896-1-tvlad744@gmail.com> (raw)
In-Reply-To: <20261016125044.1085-1-26rote@gmail.com>

Hi Abel, Joonhoe,

On Fri, 16 Oct 2026 21:50:44 +0900, Joonhoe Kim wrote:
> 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.

I see the same on SM8750 (OnePlus Pad 3; the board DT is still local),
v7.3-rc5 plus board patches, but here it is the USB role switch that
breaks, not an i2c retimer or switch. The port is in device role,
connected to a PC. Unplugging the cable during s2idle resets the
board, every time I tried it without this change. My tree also has
local ucsi_glink and qcom_battmgr changes that make a cable plug or
unplug wake the system, similar to Jishnu Prakash's ucsi_glink patch.

A failing run, with times from "PM: resume from suspend-to-idle":

  +12.5 ms  ucsi_handle_connector_change() starts (noirq phase)
  +16.0 ms  GET_CONNECTOR_STATUS and ->connector_status() are done
  +16.8 ms  ucsi_partner_change() calls
            usb_role_switch_set_role(USB_ROLE_NONE)

Nothing is logged after that. The role switch is dwc3 with the
dwc3-qcom glue, and the glue's role notifier writes to QSCRATCH while
the glue clocks are still off. They only come back in
dwc3_qcom_pm_resume(), about 1 s after the resume message. The
pm_runtime_resume_and_get() in the notifier succeeds without doing
anything, as runtime PM is disabled at that point. In a debug build
that skips only the usb_role_switch_set_role() call, the same unplug
resumes fine. The GLINK side works in that window, as the UCSI
commands complete; what breaks is what the connector work calls into.

With the connector work on system_freezable_wq, both unplug runs
resumed (2 of 2). The work started 1.50 and 1.54 s after the resume
message, right after "Restarting tasks", and the partner was removed
without errors. I tested the same queue_work() change behind a module
parameter in my test build, not the patch as posted. The
pmic_glink_altmode worker was on the freezable workqueue too, as with
7d0767c5cd87, but it never runs here (no DP partner).

Plugging in during s2idle survives only because the PPM reports the
partner type in a later event, about 1.4 s after the first one, by
which time dwc3_qcom_pm_resume() has run. The first event still
registers the partner in the noirq phase, and the kernel warns:

  typec port0-partner: PM: parent port0 should not be sleeping

> 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.

One more data point on that question. Here the unplug notification has
to get through during s2idle, as it is what wakes the system, and
GLINK itself works in that window. Only the connector work has to
wait. So a GLINK rework would need both parts that 7d0767c5cd87
describes: letting the notification wake the system, and queueing it
until the system has resumed. From reading the code, dropping
IRQF_NO_SUSPEND would not be enough on its own: the interrupt would
then be re-enabled at the end of the noirq phase, before
dwc3_qcom_pm_resume() runs in the normal resume phase. I can test such
a rework on this board. Until then, this change does for the connector
work what 7d0767c5cd87 does for the altmode worker.

Tested-by: Vladyslav Tymoshchuk <tvlad744@gmail.com> # OnePlus Pad 3 (SM8750)

Separately, I've sent a patch so that the dwc3-qcom role notifier does
not touch the hardware while the glue is suspended [1]; with it alone,
the unplug resumes here too (2 of 2). That does not help the PS8830
and FSA4480 cases, so this change is still needed. I can test a
respin on this board.

[1] https://lore.kernel.org/linux-usb/20261018143126.3978-1-tvlad744@gmail.com/

Thanks,
Vladyslav

(I used an AI assistant, Claude, for the analysis and to draft this
mail; the tests ran on my device.)

      reply	other threads:[~2026-10-18 15:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 11:45 Abel Vesa
2025-02-05 17:31 ` Dmitry Baryshkov
2026-10-16 12:50   ` Joonhoe Kim
2026-10-18 15:01     ` Vladyslav Tymoshchuk [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=20261018150136.5896-1-tvlad744@gmail.com \
    --to=tvlad744@gmail.com \
    --cc=26rote@gmail.com \
    --cc=abel.vesa@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=casey.connolly@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=johan@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=neil.armstrong@linaro.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®