From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"balbi@kernel.org" <balbi@kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"johan@kernel.org" <johan@kernel.org>,
"quic_wcheng@quicinc.com" <quic_wcheng@quicinc.com>,
"kernel@gpiccoli.net" <kernel@gpiccoli.net>,
"kernel-dev@igalia.com" <kernel-dev@igalia.com>,
Andrey Smirnov <andrew.smirnov@gmail.com>,
Vivek Dasmohapatra <vivek@collabora.com>,
piyush.mehta@amd.com, ray.huang@amd.com
Subject: Re: [PATCH] usb: dwc3: Fix spurious wakeup when port is on device mode
Date: Tue, 5 Dec 2023 11:40:42 -0300 [thread overview]
Message-ID: <9efaed91-d246-cf3c-efc0-e866f88a943d@igalia.com> (raw)
In-Reply-To: <20231205012336.mn7b7f4zypwcyv6w@synopsys.com>
Hi Thinh, thanks for your response. I'll clarify inline below:
On 04/12/2023 22:23, Thinh Nguyen wrote:
> [...]
>>> It was noticed that on plugging a low-power USB source on Steam
>>> Deck USB-C port (handled by dwc3), if such port is on device role,
>
> I'm not clear of the testing sequence here. Can you clarify further? Is
> this device operating as host mode but then it switches role to device
> mode when no device is connected?
>
Exactly this. We have a driver that changes between host/device mode
according to ACPI notifications on port connect. But to make
tests/discussion easier and eliminate more variables, we just dropped
this driver and do it manually.
So the steps are:
(A) host mode test
1) Put the port on host mode using debugfs interface.
2) Wait 30 seconds, plug a cable connecting the Steam Deck to a laptop -
we call this connection a "low-power source", since it seems to charge
slowly the Deck.
3) Suspend the Deck after some seconds (S3/deep) - success
(B) device mode test
1) Put the port on device mode using debugfs interface.
2) Wait 30 seconds, plug a cable connecting the Steam Deck to a laptop.
3) Suspend the Deck after some seconds (S3/deep) - fails
3a) If pcie_pme is using MSIs, it fails showing that a wakeup interrupt
is pending, in this case the Steam Deck effectively doesn't enter suspend.
3b) if PCIe PME is not using MSIs, Deck suspends and right after (less
than a second), wakes up properly.
>>> the HW somehow keep asseting the PCIe PME line and triggering a
>>> wakeup event on S3/deep suspend (that manifests as a PME wakeup
>>> interrupt, failing the suspend path). That doesn't happen when the USB
>>> port is on host mode or if the USB device connected is not a low-power
>>> type (for example, a connected keyboard doesn't reproduce that).
>
> Is the PME continuously generating non-stop? Did you test this in USB3
> speed? Does this happen for every low-power device or just this specific
> low-power device?
It seems PME is continuously being generated, yes. I tested by
connecting to my laptop as mentioned, I guess others tested different
scenarios, not always reproduces. An example: a keyboard or a disk
connected when the USB port is on device mode doesn't reproduce. Also, I
think I didn't test "in USB3 speed" - could you detail more, not sure if
I understood that properly.
> [...]
> Even if you masked all the interrupts, and the events are still
> generating? Did you check if the driver handled wakeup from PME and
> properly restore the controller?
>
Ok, let me clarify a bit. From the ACPI perspective, I was able to check
from kernel that some GPEs were generated on resume when the issue
happens (and potentially even when the issue doesn't happen, in host
mode for example). So, what I did was masking all these GPEs using the
kernel sysfs interface. After masking, the issue still reproduces but
the GPEs count doesn't increase.
Regarding the PME interrupt now: if MSI is used on PME, I can see an
increase of 1 in every suspend/resume attempt (checking
/proc/interrupts). Now if MSIs are not used, guess what? There was no
increase in the interrupt at all. I didn't mask the PME interrupt on
PCIe PME driver...but even with PME driver disabled, IIRC the problem
reproduces.
"Did you check if the driver handled wakeup from PME and properly
restore the controller?" <- I think I didn't - how do you suggest me to
check that?
What I've noticed is that either the system can't suspend, or if no MSIs
are used on PCIe PME, it suspends and resumes right after, with success.
In this latter case, dwc3 works normally again, resume is successful.
Let me know if you want me to check any other path or function called, etc.
> [...]
>
> Some platforms may need a soft reset before a change to prtcapdir. This
> may break some setups. This seems to be a workaround and should not be
> treated as part of a normal flow.
OK, do you have any other idea of a register change that is softer than
changing "prtcapdir" and could prevent the issue? Also, would that
workaround makes sense as...a quirk?
We could guard it for Deck's HW exclusively, using DMI if you think it
does make sense...or the dwc3 quirks (already have some for AMD right?)
I'm CCing Piyush and Huang from AMD, since this is AMD HW. Any other
suggestions are much appreciated.
Thanks,
Guilherme
next prev parent reply other threads:[~2023-12-05 14:40 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 16:51 [PATCH] usb: dwc3: Fix spurious wakeup when port is on device mode Guilherme G. Piccoli
2023-12-04 11:36 ` Guilherme G. Piccoli
2023-12-05 1:23 ` Thinh Nguyen
2023-12-05 14:40 ` Guilherme G. Piccoli [this message]
2024-01-09 18:00 ` Guilherme G. Piccoli
2024-01-11 2:01 ` Thinh Nguyen
2024-01-11 16:13 ` Guilherme G. Piccoli
2024-01-13 1:33 ` Thinh Nguyen
2024-01-15 10:44 ` Vivek Dasmohapatra
2024-01-17 0:37 ` Thinh Nguyen
2024-01-16 16:11 ` Guilherme G. Piccoli
2024-01-17 0:34 ` Thinh Nguyen
2024-01-17 10:44 ` Guilherme G. Piccoli
2024-01-18 0:39 ` Thinh Nguyen
2024-01-21 17:48 ` Guilherme G. Piccoli
2024-01-23 2:12 ` Thinh Nguyen
2024-01-28 15:25 ` Guilherme G. Piccoli
2024-01-30 2:17 ` Thinh Nguyen
2024-01-31 18:16 ` Guilherme G. Piccoli
2024-01-31 19:16 ` Guilherme G. Piccoli
2024-02-01 1:23 ` Thinh Nguyen
2024-02-01 1:23 ` Thinh Nguyen
2024-02-01 14:39 ` Guilherme G. Piccoli
2024-02-06 2:53 ` Thinh Nguyen
2024-02-06 10:30 ` Guilherme G. Piccoli
2024-02-08 23:53 ` Thinh Nguyen
2024-02-09 1:18 ` Guilherme G. Piccoli
2024-03-04 15:59 ` Guilherme G. Piccoli
2024-03-05 2:41 ` Thinh Nguyen
2024-03-07 0:40 ` Thinh Nguyen
2024-03-07 19:22 ` Guilherme G. Piccoli
2024-03-08 2:42 ` Thinh Nguyen
2024-03-08 11:52 ` Guilherme G. Piccoli
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=9efaed91-d246-cf3c-efc0-e866f88a943d@igalia.com \
--to=gpiccoli@igalia.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=andrew.smirnov@gmail.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=kernel-dev@igalia.com \
--cc=kernel@gpiccoli.net \
--cc=linux-usb@vger.kernel.org \
--cc=piyush.mehta@amd.com \
--cc=quic_wcheng@quicinc.com \
--cc=ray.huang@amd.com \
--cc=vivek@collabora.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