Skip to content

usb: device_next: hid: Cherry-pick USB next fixes #1762

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

Merged
merged 8 commits into from
Jun 4, 2024

Conversation

MarekPieta
Copy link
Contributor

@MarekPieta MarekPieta commented Jun 3, 2024

Cherry-pick USB next fixes:

  • fix HID report get buffer handling
  • update USB remote wakeup log level

Copy link
Contributor

@tmon-nordic tmon-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking until 73657 is reviewed upstream by Johann.

@MarekPieta MarekPieta force-pushed the usb_fix_cherrypick branch from 0667a82 to 3efa3af Compare June 4, 2024 05:50
jfischer-no and others added 2 commits June 4, 2024 08:50
After the get_report() callback, we need to determine how many bytes the
HID device wrote to the report buffer. Use the callback return value to
do this, and modify the net_buf data length value if get_report was
successful.

Reported-by: Marek Pieta <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
(cherry picked from commit af63e48)
The `Remote wakeup feature not enabled or not suspended` log is not
related to an actual error (connected host might not enable USB remote
wakeup feature). Use warning log level.

Signed-off-by: Marek Pieta <[email protected]>
(cherry picked from commit 0596430)
@MarekPieta MarekPieta force-pushed the usb_fix_cherrypick branch from 3efa3af to 080f883 Compare June 4, 2024 06:51
@MarekPieta MarekPieta changed the title [nrf fromlist] usb: device_next: hid: fix Get Report buffer handling usb: device_next: hid: Cherry-pick USB next fixes Jun 4, 2024
Copy link
Contributor

@tmon-nordic tmon-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You changed the title to Cherry-pick USB next fixes. Could you please then cherry-pick also the other PRs that are already merged (73255, 73142, 73561, 73463)?

… enable

If CDC ACM uart side has TX enabled when the configuration gets enabled,
depending on fifo state following has to happen:
  * if the fifo is empty - trigger TX ready interrupt
  * if the fifo is not empty - queue TX data on IN endpoint

Signed-off-by: Tomasz Moń <[email protected]>
(cherry picked from commit c30ac4d)
Do not set NAK bit again for endpoints that already have NAK bit set.
Do not wait for OUT endpoint 0 disable because it cannot be disabled by
application (DOEPCTL0 EPDis bit is Read-Only).

Disable endpoints before disabling interrupts because it is necessary to
handle RXFLVL interrupt (in Slave mode) for GOUTNAKEFF to become active.

Signed-off-by: Tomasz Moń <[email protected]>
(cherry picked from commit 4db14f8)
Flushing TxFIFO is racing with actual use of the TxFIFO. The software
controls only one side of the race (flush trigger) while the host
controls the other side. Therefore, locking interrupts before flushing
TxFIFO is not protecting against the race condition.

Disable the endpoint on dequeue to make sure that TxFIFO flushing won't
conflict with host actions (because the endpoint would be forced to NAK
the IN tokens before the TxFIFO is flushed).

Signed-off-by: Tomasz Moń <[email protected]>
(cherry picked from commit 2368623)
Explicitly initialize bNumDeviceCaps to 0 because the bos descriptor is
stored on stack.

Fixes: b0d7d70 ("usb: device_next: add initial BOS support")
Coverity-CID: 368798

Signed-off-by: Tomasz Moń <[email protected]>
(cherry picked from commit a1afd34)
Add the missing "t" to struct usbd_contex. No functional changes.

Signed-off-by: Tomasz Moń <[email protected]>
(cherry picked from commit 8d344cc)
@hermabe hermabe removed their request for review June 4, 2024 08:58
@MarekPieta MarekPieta requested a review from tmon-nordic June 4, 2024 08:58
@MarekPieta
Copy link
Contributor Author

Hi @tmon-nordic,
I did the requested cherry-pick. Please rereview

On nRF54H20DK the USB PHY is powered from VBUS. When the USB cable is
not connected, the PHY is not powered and the PHY clock disappears.

Because the GOUTNAKEFF and INEPNAKEFF can only ever be set when PHY
clock is active, the waits for these bits do timeout if cable is
disconnected. Workaround the issue by aborting the wait if vendor quirk
indicates that PHY clock has abruptly vanished.

Upstream PR: zephyrproject-rtos/zephyr#73461

Signed-off-by: Tomasz Moń <[email protected]>
@tmon-nordic tmon-nordic added this to the ncs-2.7.0 milestone Jun 4, 2024
@rlubos rlubos merged commit 09fb10e into nrfconnect:main Jun 4, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants