Skip to content

[DO NOT MERGE] Fix usb suspend reset #27415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: earlgrey_1.0.0
Choose a base branch
from

Conversation

pamaury
Copy link
Contributor

@pamaury pamaury commented Jun 11, 2025

The usb suspend tests use hub operations to reset the device but doing so bypasses the kernel which will not try to configure the device afterwards. Includes #27337

Due to an unfortunate pin conflict, IOA2 is used both to trigger
SPI rescue and to control the USB VBUS sense buffer on the teacup
board. To work around this, introduce a strapping that set IOA2
as input to prevent interference.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
@pamaury pamaury requested a review from a team as a code owner June 11, 2025 15:00
@pamaury pamaury requested review from cfrantz and removed request for a team June 11, 2025 15:00
pamaury added 2 commits June 11, 2025 15:04
Apply the strapping that disables IOA2 in all USB tests to avoid
intereference on the VBUS sense buffer.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Instead of printing an error message saying that several devices
were found, actually provide the list of devices found.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
@pamaury pamaury force-pushed the fix_usb_suspend_reset branch from e089473 to 263c3a5 Compare June 11, 2025 15:04
@pamaury pamaury added the CherryPick:master This PR should be cherry-picked to master label Jun 11, 2025
pamaury added 4 commits July 1, 2025 14:13
See explanation in the code.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Per the USB hub specification, when performing port operations, we
should look at the port status to make sure that the operation was
performed. This replaces the artificial 100ms delay which does not
correspond to any real specification timing.

This commit also introduces stricter checks on the port status:
an error will occur if trying to suspend/resume a port with
incompatible status (though even stricter checks are possible such
as making sure that a device is connected).

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
The timeout accounts for all operations (port status check, ...)
and since the spec only requires at most 50ms per request, 100ms
seems a bit low (although it works in practice). Bump to 1sec just
to avoid stupid failures.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
@pamaury pamaury force-pushed the fix_usb_suspend_reset branch from 941f496 to 947f7a2 Compare July 1, 2025 14:14
@pamaury pamaury requested review from rswarbrick and a team as code owners July 3, 2025 14:28
@pamaury pamaury requested review from timothytrippel and removed request for a team July 3, 2025 14:28
@pamaury pamaury force-pushed the fix_usb_suspend_reset branch from 7802937 to dd46344 Compare July 3, 2025 14:41
@pamaury pamaury changed the title Fix usb suspend reset [DO NOT MERGE] Fix usb suspend reset Jul 3, 2025
@pamaury pamaury force-pushed the fix_usb_suspend_reset branch from 1444920 to e2b4def Compare July 10, 2025 11:57
@pamaury pamaury force-pushed the fix_usb_suspend_reset branch from cb432ee to 188a4ef Compare July 22, 2025 08:58
pamaury added 4 commits August 4, 2025 17:05
When the device enters the shutdown phase, it will very quickly
configure the usbdev interface, try to connect and very shortly
afterwards disable the interface. This means that the device may
or may not appear on the bus (most likely not). Meanwhile, the
host is trying to suspend the device in this phase which is incorrect.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
When enabling/disable VBUS sense, it is necessary to wait for a
while for things to stabilize. Make this delay configurable.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
It seems that 100ms is too low on certain boards. It is not clear
why but there is no real harm in increasing this delay.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
@pamaury pamaury force-pushed the fix_usb_suspend_reset branch from 188a4ef to 0673806 Compare August 4, 2025 17:05
pamaury added 2 commits August 4, 2025 17:07
Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
@pamaury pamaury force-pushed the fix_usb_suspend_reset branch from 0673806 to b894444 Compare August 4, 2025 17:07
pamaury added 5 commits August 6, 2025 13:56
Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
When the host fails due to some error (like hub status failure),
the UART output will not be printed. This can make debugging the
test challenging since some crucial information about the device
state is lost. Change the test so that in case of failure, the
UART is drained and displayed.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Currently there is a sequence where the devices prints a message,
suspends and then waits for a resume. On the host side, we need
to wait for the UART message, send a request to the hub to suspend,
observe that the suspend was successfull and then resume. The current
timeout between suspend and resume is only 40ms which can be quite
tight since hub operations can take a long time. Increase this
delay to avoid flakiness.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
See explanation in the code.

Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
@pamaury pamaury force-pushed the fix_usb_suspend_reset branch from 8e5ed0f to f50a818 Compare August 6, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPick:master This PR should be cherry-picked to master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant