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)
Dec 22 2023, 11:30 PM
Unknown Object (File)
Dec 13 2023, 6:19 AM
Unknown Object (File)
Nov 27 2023, 7:06 AM
Unknown Object (File)
Nov 23 2023, 7:22 PM
Unknown Object (File)
Sep 15 2023, 4:36 AM
Unknown Object (File)
Aug 20 2023, 7:00 PM
Unknown Object (File)
Aug 16 2023, 8:17 AM
Unknown Object (File)
Jul 8 2023, 2:27 PM

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