From nobody Wed Mar 09 09:56:05 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 644911A05F3F for ; Wed, 9 Mar 2022 09:56:56 +0000 (UTC) (envelope-from darius@dons.net.au) Received: from midget.dons.net.au (midget.dons.net.au [61.245.145.238]) (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-signature ECDSA (P-384) client-digest SHA384) (Client CN "dons.net.au", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KD6zm6Pz4z4pBF for ; Wed, 9 Mar 2022 09:56:52 +0000 (UTC) (envelope-from darius@dons.net.au) Received: from midget.dons.net.au (localhost [127.0.0.1]) by midget.dons.net.au (8.17.1/8.16.1) with ESMTPS id 2299uLjc001497 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Wed, 9 Mar 2022 20:26:21 +1030 (ACDT) (envelope-from darius@dons.net.au) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dons.net.au; s=default; t=1646819785; bh=kTs77zxd8QDh8RTMA01jraHiI6euPhwe51+HDfmGf/4=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=D3Ke1AJ/dgPKWtExRecIsnK+4k4iYrA1T4YBZGhgajsLFsyMcF3mXW6Wg3Ls9ZUaH q/9fEgW45tmgyEe+YBXdg5AwHyoJ8jthdnjXSAbjyWyXJQ3WHuqeHSLY5x3BHrAbhd MtncEOcP4cHQNSoQQCqlxGHdp9vN8HqbcpQbLjmU= Received: (from mailnull@localhost) by midget.dons.net.au (8.17.1/8.16.1/Submit) id 2299u5nK001489 for ; Wed, 9 Mar 2022 20:26:05 +1030 (ACDT) (envelope-from darius@dons.net.au) X-MIMEDefang-Relay-0ce1a11234c790b6ab6410cd70c6fdb820520472: 10.0.2.38 Received: from smtpclient.apple (Havok.dons.net.au [10.0.2.38]) by ns.dons.net.au (envelope-sender ) (MIMEDefang) with ESMTP id 2299u5jc001484; Wed, 09 Mar 2022 20:26:05 +1030 Content-Type: text/plain; charset=us-ascii 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 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Subject: Re: Understanding USB callback + assertion panic From: "Daniel O'Connor" In-Reply-To: <69696561-822a-4808-b142-4a22d3f6b6b2@farhan.codes> Date: Wed, 9 Mar 2022 20:26:05 +1030 Cc: freebsd-usb@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <69696561-822a-4808-b142-4a22d3f6b6b2@farhan.codes> To: Farhan Khan X-Mailer: Apple Mail (2.3693.40.0.1.81) X-Spam-Score: -1 () No, score=-1.0 required=5.0 tests=ALL_TRUSTED, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.5 X-Scanned-By: MIMEDefang 2.83 on 10.0.2.1 X-Rspamd-Queue-Id: 4KD6zm6Pz4z4pBF X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=dons.net.au header.s=default header.b="D3Ke1AJ/"; dmarc=pass (policy=quarantine) header.from=dons.net.au; spf=pass (mx1.freebsd.org: domain of darius@dons.net.au designates 61.245.145.238 as permitted sender) smtp.mailfrom=darius@dons.net.au X-Spamd-Result: default: False [-3.50 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.995]; R_DKIM_ALLOW(-0.20)[dons.net.au:s=default]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-usb@freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[dons.net.au:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[dons.net.au,quarantine]; NEURAL_HAM_SHORT(-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:4764, ipnet:61.245.145.0/24, country:AU]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Hi Farhan, > On 9 Mar 2022, at 10:29, Farhan Khan wrote: > I am trying to understand how FreeBSD's USB subsystem works and appear = to be running into a kernel panic due to a failed assertion that I do = not understand. the assertion in question is = /usr/src/sys/dev/usb/usb_transfer.c:1954. This one? USB_XFER_LOCK_ASSERT(xfer, MA_OWNED); > My understanding is that you first configure usbd_transfer_setup(9). = To start a bulk transfer, you populate the appropriate list (typically = an STAIL_* list), then initiate a transfer by calling = usbd_transfer_start(9) with the correct transfer. In my case, my = callback is a simple printf(). >=20 > Upon the usbd_transfer_start(9) call, I am hitting the assertion = error. I have looked at other device drivers and have not identified = what they are doing differently. >=20 > Any suggestions? I think that assertion is saying you have to have acquired the USB = transfer lock USB_XFER_LOCK() et al, although I am not entirely sure how = you do that 'bare'. I have only called usbd_transfer_start in the USB = FIFO setup routines. -- Daniel O'Connor "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum