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
F81948214: D27174.id.diff
Tue, Apr 23, 3:14 PM
F81932024: D27174.diff
Tue, Apr 23, 9:35 AM
Unknown Object (File)
Sat, Apr 20, 4:47 AM
Unknown Object (File)
Sat, Apr 20, 3:59 AM
Unknown Object (File)
Feb 29 2024, 9:13 AM
Unknown Object (File)
Dec 22 2023, 11:30 PM
Unknown Object (File)
Dec 13 2023, 6:19 AM
Unknown Object (File)
Nov 27 2023, 7:06 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 Not Applicable
Unit
Tests Not Applicable

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