Page MenuHomeFreeBSD

Allow user to configure endpoints twice
ClosedPublic

Authored by kjopek_gmail.com on Nov 11 2020, 4:44 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 19, 1:30 AM
Unknown Object (File)
Mon, May 6, 6:28 AM
Unknown Object (File)
Sun, May 5, 1:38 PM
Unknown Object (File)
Apr 28 2024, 1:23 PM
Unknown Object (File)
Apr 23 2024, 3:14 PM
Unknown Object (File)
Apr 23 2024, 9:35 AM
Unknown Object (File)
Apr 20 2024, 4:47 AM
Unknown Object (File)
Apr 20 2024, 3:59 AM

Details

Summary

Revision 356545 changed the behaviour of xhci controller to avoid configuring endpoints multiple times
and effectively made BladeRF 2 unusable with FreeBSD.

Since I cannot verify what other devices may be affected I propose to make xhci controller behaviour
configurable. I do not have also any evidence that r356545 broke anything else than BladeRF 2.

The other option is BladeRF is somehow dependent on original behaviour of xhci controller,
however, similar problem did not appear when using USB 2.0 controller.

Test Plan

Tested on RockPro64:

With post-r356545 behaviour

# bladeRF-cli -l /usr/share/firmware/hostedxA4.rbf 
Loading fpga...
[ERROR @ host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c:123] _bladerf2_initialize: dev->backend->get_fpga_version(dev, &board_data->fpga_version) failed: An unexpected error occurred
[ERROR @ host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c:2186] bladerf2_load_fpga: _bladerf2_initialize(dev) failed: An unexpected error occurred
Error: failed to load FPGA: An unexpected error occurred
[ERROR @ host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c:1936] bladerf2_trigger_init: Board state insufficient for operation (current "FPGA Loaded", requires "Initialized").
[ERROR @ host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c:1936] bladerf2_trigger_init: Board state insufficient for operation (current "FPGA Loaded", requires "Initialized").

With pre-r356545 behaviour:

# sysctl hw.usb.xhci.pre356545=1
hw.usb.xhci.pre356545: 0 -> 1
# bladeRF-cli -l /usr/share/firmware/hostedxA4.rbf
Loading fpga...
Successfully loaded FPGA bitstream!

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Could you do a usbdump of the USB traffic and possibly enable XHCI debug to extract the exact error code.

Thank you!

Maybe I will share results from my investigation.

First of all, I created minimal program to reproduce issue (mainly by extraction of the code from libbladerf):

The problem was exactly after firmware upload. Version detection worked... totally unstable, typically libusb returned LIBUSB_ERROR_OTHER (-99).
I initially thought the problem is somehow related to corruption of firmware image. But when I compared USB traffic from working machine (FreeBSD 12.1 @ AMD64)
with RockPro64 there was no difference.
I recorded USB traffic to debug this problem, here is textual log:

Original recording:

Also, output from rf_debug:

And finally xhci debug messages:

Hi,

Can you try this patch instead:

xhci_check_transfer: slot=1 epno=4 remainder=0 status=27
xhci_check_transfer: slot=1 epno=4 remainder=16 status=4

Means the following errors:

#define XHCI_TRB_ERROR_LENGTH 0x1B
#define XHCI_TRB_ERROR_XACT 0x04

--HPS

Hi,

your patch works perfectly. BladeRF is usable again.

Thank you.

This revision is now accepted and ready to land.Nov 12 2020, 9:15 AM