Skip to content
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

Fix for USB - fix issues that were introduced in 18780d5 #150

Merged
merged 2 commits into from Oct 22, 2018
Merged

Fix for USB - fix issues that were introduced in 18780d5 #150

merged 2 commits into from Oct 22, 2018

Conversation

sp193
Copy link
Contributor

@sp193 sp193 commented Oct 20, 2018

Pull Request checklist

Note: these are not necessarily requirements

  • I reformatted the code with clang-format
  • I checked to make sure my submission worked
  • I am the author of submission or have permission from the original author
  • Requires update of the PS2SDK
  • Requires update of the gsKit
  • Others (please specify below)

Pull Request description

(mass_driver.c) Fix glitches related to USB support that were introduced with commit 18780d5 on June 8th.

  1. Some devices to cease being compatible due to SET INTERFACE failing.
    By the USB 1.1 specification, section 9.4.10: Devices that only support a default setting for the specified interface may return a STALL.
    If that happens, we shall clear the halt state of the interface's pipes and continue, as with Linux.
  2. Fixed faulty logic for reading data from devices with sector sizes > 2048 bytes.
    As the code for making reads in blocks was removed, the loop only iterates once.
    That is wrong, as reading from a 4096-byte device (for example) could require the loop to iterate twice if the last LBA is not aligned with the device's physical LBAs.
    At the 2nd iteration, nsectors would have been 1, when it should then read a complete sector and copy the first half of it with memcpy.

The other commit is something I added in case sceCdInit() is called from a high-priority thread... but may be just more for correctness in the end:

  • (device-usb.c) Increase delay while waiting for USB devices to become ready from 200 to 5000us, to avoid ever blocking the progress of USBD during device detection.

…ced with commit 18780d5 on June 8th.

1. Some devices to cease being compatible due to SET INTERFACE failing.
By the USB 1.1 specification, section 9.4.10: Devices that only support a default setting for the specified interface may return a STALL.
If that happens, we shall clear the halt state of the interface's pipes and continue, as with Linux.

2. Fixed faulty logic for reading data from devices with sector sizes > 2048 bytes.
As the code for making reads in blocks was removed, the loop only iterates once.
That is wrong, as reading from a 4096-byte device (for example) could require the loop to iterate twice if the last LBA is not aligned with the device's physical LBAs.
At the 2nd iteration, nsectors would have been 1, when it should then read a complete sector and copy the first half of it with memcpy.
… ready from 200 to 5000us, to avoid ever blocking the progress of USBD during device detection.
@ElPatas1 ElPatas1 merged commit 5fe82f1 into ps2homebrew:master Oct 22, 2018
@sp193 sp193 deleted the usb-fix-oct18 branch January 6, 2019 01:36
AKuHAK pushed a commit that referenced this pull request Sep 30, 2021
Fix for USB - fix issues that were introduced in dfc6049
citronalco pushed a commit to citronalco/OPL-Daily-Builds that referenced this pull request Sep 10, 2023
Fix for USB - fix issues that were introduced in 18780d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants