From owner-freebsd-wireless@freebsd.org Sat Apr 13 14:20:07 2019 Return-Path: Delivered-To: freebsd-wireless@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 647741579DF5 for ; Sat, 13 Apr 2019 14:20:07 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0AD98858B0; Sat, 13 Apr 2019 14:20:07 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1033) id F1EF76B62; Sat, 13 Apr 2019 14:20:06 +0000 (UTC) Date: Sat, 13 Apr 2019 14:20:06 +0000 From: Alexey Dokuchaev To: Adrian Chadd Cc: Matthias Apitz , "freebsd-wireless@freebsd.org" Subject: Re: Atheros AR5B22 WLAN+Bluetooth support on FreeBSD Message-ID: <20190413142006.GA59512@FreeBSD.org> References: <20190409160344.GA83271@FreeBSD.org> <20190410152250.GA37191@FreeBSD.org> <20190411092758.GA6899@FreeBSD.org> <20190411104647.GA3864@c720-r342378> <20190411125242.GA64046@FreeBSD.org> <20190411131328.GA4909@c720-r342378> <20190411131859.GA17806@FreeBSD.org> <20190411142350.GA71446@FreeBSD.org> <20190412171218.GA16463@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190412171218.GA16463@FreeBSD.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 0AD98858B0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.78 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.992,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TAGGED_RCPT(0.00)[]; NEURAL_HAM_SHORT(-0.79)[-0.787,0]; ASN(0.00)[asn:11403, ipnet:96.47.64.0/20, country:US] X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Apr 2019 14:20:07 -0000 On Fri, Apr 12, 2019 at 05:12:18PM +0000, Alexey Dokuchaev wrote: > I've then rebooted back into FreeBSD. Apparently, this AR3012 hardware > is very fragile, it can be easily left in confused state and won't accept > further commands, "usbconfig reset" does not help. To avoid this, it is > better run ./ath3kfw as root, after powercycling machine (to reset the > card). This got me further: > > ath3kfw: opening dev 2.2 > main: state=0x0e > ROM version: 285343744, build version: 155, ram version: 155, ref clock=1 > ath3k_init_firmware: loading ath3k-1.fw > ath3k_load_fwfile: file=/home/danfe/ath3k/share/firmware/ath3k/ath3k-1.fw, > size=246804 > ath3k_load_fwfile: transferring 20 bytes, offset 4096 Looks like there is a bug with the logging, consider this pseudo-patch: @@ ... ath3k_debug("%s: transferring %d bytes, offset %d\n", __func__, - sent, - size); + size, sent); > ... > ath3k_load_fwfile: transferring 65556 bytes, offset 4096 > LIBUSB_FUNCTION: libusb_bulk_transfer enter > LIBUSB_FUNCTION: libusb_submit_transfer enter > LIBUSB_FUNCTION: libusb_submit_transfer leave 0 > LIBUSB_FUNCTION: libusb_handle_events_timeout_completed enter > LIBUSB_FUNCTION: libusb10_handle_events_sub enter > LIBUSB_TRANSFER: sync I/O done > LIBUSB_FUNCTION: libusb_handle_events_timeout_completed exit > LIBUSB_FUNCTION: libusb_bulk_transfer leave > Can't load firmware: err=Timeout, size=4096 > ath3k_load_fwfile: transferring 65556 bytes, offset 4096 I've found seemingly related bug report about Atheros BT devices (ath3k) failing to work on USB 3.0 buses, while working well on USB 2.0: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1400215 In 2015, a work-around for this problem was committed* to Linux kernel: author Adam Lee 2015-01-28 committer Marcel Holtmann 2015-01-29 commit c561a5753dd631920c4459a067d22679b3d110d6 Bluetooth: ath3k: workaround the compatibility issue with xHCI controller ath3k devices fail to load firmwares on xHCI buses, but work well on EHCI, this might be a compatibility issue between xHCI and ath3k chips. As my testing result, those chips will work on xHCI buses again with this patch. This workaround is from Qualcomm, they also did some workarounds in Windows driver. I've patched ath3kfw tool in a similar way like this: +#define TIMEGAP_USEC_MIN 50 +#define TIMEGAP_USEC_MAX 100 + +static inline void +usleep_range(unsigned long min, unsigned long max) +{ + usleep(min); // or usleep(max); +} ... while (count) { + /* workaround the compatibility issue with xHCI controller */ + usleep_range(TIMEGAP_USEC_MIN, TIMEGAP_USEC_MAX); Unfortunately, this hack didn't help, neither with usleep(min) nor with usleep(max). Error message is the same "Can't load firmware: err=Timeout, size=4096". I will try to find a USB 2.0-only laptop which supports mini-PCIe cards to get more data points, but not sure if I can find one easily. It would be nice if someone who has pre-xHCI hardware could conduct this test. ./danfe *) https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/bluetooth/ath3k.c?id=c561a5753dd631920c4459a067d22679b3d110d6