From nobody Tue Apr 12 22:10:02 2022 X-Original-To: freebsd-usb@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9BD441B04DE6 for ; Tue, 12 Apr 2022 22:10:12 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4KdKfC0hl8z4sF9 for ; Tue, 12 Apr 2022 22:10:10 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 3961A3201DCC for ; Tue, 12 Apr 2022 18:10:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 12 Apr 2022 18:10:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=farhan.codes; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm2; t=1649801403; x=1649887803; bh=4Ka+EQpFv9 5waJ0OJmfN6+A91pdIeusLyTEKwkivjpo=; b=wGmibWvE3LUxkppvoHcMQnXbVF TZmEyXPT0qfVLV2PbjqtQMmfyJ1/aMRVgKxgaqfNWFOu5wyTumGqxk3eYZXO4EdB n7AMEsZTuGuKAGpX8twhpgUE7+8YUBDA2qG38aYJsw2HqdPfoxneFUVRU+Gbp/00 xC8MznFKoDyDuajj/NKTskkSysGMikUUizrYGtF2RN2Sv6/yDngqxgqxEcrZMNSb DtqE87+FfgfCGmJ6B5Msk8VYeGdVeFnCQxwF4uuKPueJ9agRe4GJoUDlCPjUfevk 3GANJDesVdf+kbKE0w+tU6CnVAxbmbE0fuLAvqolIIhbFzcAsSc4msLGW/xg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1649801403; x= 1649887803; bh=4Ka+EQpFv95waJ0OJmfN6+A91pdIeusLyTEKwkivjpo=; b=X USNSqq7/aa1mZVyz4TB96I91ZrLsQrVoN4Dn+Vi6AmVRRqWYunkDHLg0Lwk+b608 /DnnXPzoYQCVAeO089/ee42J6v41QvxgN4RDxykkuJx3olb4dljDrdO8h0VxaSZT huJCfn3P4/ybSbxcTs65s3JkdLagVnpR03t0v1XIHOMHq0BGymc3QRnQJ0ieWPrc N9jDs5mPnLVKz1gAkjoifo0fUsV05dOzH3ugz0NT1raQ8hHJs/pBsR33xUwbT4L+ vFCpIFBaSaAmCGtIjixABQiQLnHakqkJTwMa7dchUNSljjdK/wjsrHGSLe2e3tiS Edjow2D7SKDr/eTNDETOA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekledgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkuffhvffftgfgfgggsehtqhertd dtreejnecuhfhrohhmpefhrghrhhgrnhcumfhhrghnuceofhgrrhhhrghnsehfrghrhhgr nhdrtghouggvsheqnecuggftrfgrthhtvghrnhepgedtlefhieefjefgiedvveeijeekhf fhffffveefieehtdfhledvfeeijefhtedtnecuffhomhgrihhnpehgihhthhhusgdrtgho mhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehfrg hrhhgrnhesfhgrrhhhrghnrdgtohguvghs X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 12 Apr 2022 18:10:03 -0400 (EDT) Message-ID: Subject: Trouble loading firmware to USB device From: Farhan Khan To: freebsd-usb@freebsd.org Date: Tue, 12 Apr 2022 18:10:02 -0400 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.0 (by Flathub.org)) List-Id: FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-usb List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org MIME-Version: 1.0 X-Rspamd-Queue-Id: 4KdKfC0hl8z4sF9 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=farhan.codes header.s=fm2 header.b=wGmibWvE; dkim=pass header.d=messagingengine.com header.s=fm3 header.b="X USNSqq"; dmarc=none; spf=pass (mx1.freebsd.org: domain of farhan@farhan.codes designates 64.147.123.21 as permitted sender) smtp.mailfrom=farhan@farhan.codes X-Spamd-Result: default: False [-4.56 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[farhan.codes:s=fm2,messagingengine.com:s=fm3]; NEURAL_HAM_LONG(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:64.147.123.21]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-usb@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_LOW(-1.00)[messagingengine.com:dkim]; RCVD_COUNT_THREE(0.00)[4]; DMARC_NA(0.00)[farhan.codes]; DKIM_TRACE(0.00)[farhan.codes:+,messagingengine.com:+]; NEURAL_HAM_SHORT(-0.96)[-0.964]; RWL_MAILSPIKE_EXCELLENT(0.00)[64.147.123.21:from]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; MLMMJ_DEST(0.00)[freebsd-usb]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:29838, ipnet:64.147.123.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[64.147.123.21:from] X-ThisMailContainsUnwantedMimeParts: N Hi all, I am trying to load the copy the OpenBSD athn code. Currently I am trying to load the firmware of the device but running an issue where the interrupt RX callback is getting an USB_ERR_CANCELLED event. Based on my reading of the OpenBSD code, it appears that the OpenBSD driver will load the firmware in chunks, then submit a NULL (size 0) usbd_do_request to indicate completion of the firmware. At this, the driver will tsleep() for 1 second. If it breaks with a return value of 0, the driver will continue successfully. My understanding is that this should trigger an Rx Interrupt, which should run the wakup() that the tsleep() is looking for. However, in my case the USB_ST_SETUP condition is run, but it seems to block indefinitely. Meanwhile, the tsleep() expires, returns a EWOULDBLOCK and eventually runs the detach handler. As a result, the blocking callback receives a USB_ST_ERROR with the value USB_ERR_CANCELLED. What might be causing the blocking of the callback? Am I loading the firmware incorrectly? My firmware code is here: https://github.com/khanzf/freebsd/blob/ar9271-check/sys/dev/athn/usb/if_ath= n_usb.c#L934 The interrupt handler, athn_usb_intr, is line 2405. The OpenBSD equivalent of the firmware loader is this: https://github.com/openbsd/src/blob/master/sys/dev/usb/if_athn_usb.c#L642 The interrupt handler is also athn_usb_intr online 1874. Any assistance would be great, been stuck for a few weeks :/ -- Farhan Khan PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE