Date: Mon, 18 Apr 2022 23:51:10 -0400 From: Farhan Khan <farhan@farhan.codes> To: Hans Petter Selasky <hps@selasky.org>, freebsd-usb@freebsd.org Subject: Re: Trouble loading firmware to USB device Message-ID: <9315bf6d-b9a9-89a2-9a32-aca9fd9cc015@farhan.codes> In-Reply-To: <d27787a2-eb6b-25dc-2d0d-56af4184032b@selasky.org> References: <f47b9415c262267d5c2505463b54f58ceaf76315.camel@farhan.codes> <d27787a2-eb6b-25dc-2d0d-56af4184032b@selasky.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 4/18/22 14:57, Hans Petter Selasky wrote: > Hi, > > error = tsleep(&usc->wait_msg_id, 0, "athnfw", 5); > > This means wait 5 ticks which is typically 5ms before timing out, > which is probably too short! > > This code is wrong for FreeBSD. > > The lock should cover the whole section and you should use msleep > instead. > > ATHN_LOCK(sc); > error = usbd_do_request(usc->sc_udev, &sc->sc_mtx, &req, NULL); > if (error == 0 && usc->wait_msg_id != 0) { > printf("Error is %d\n", error); > error = msleep(&usc->wait_msg_id, 0, "athnfw", hz); /* wait 1 > second at most */ > if (error) { > ATHN_UNLOCK(sc); > printf("Exiting condition %d\n", error); > return error; > } > } > ATHN_UNLOCK(sc); > > --HPS Thank you! I made the changes, but the problem remains, namely the athn_usb_intr INTR RX callback is never called. ----- ATHN_LOCK(sc); error = usbd_do_request(usc->sc_udev, &sc->sc_mtx, &req, NULL); if (error == 0 && usc->wait_msg_id != 0) { printf("Error is %d\n", error); error = msleep(&usc->wait_msg_id, &sc->sc_mtx, 0, "athnfw", hz); /* Wait 1 second at most */ if (error) { ATHN_UNLOCK(sc); printf("Exiting condition %d\n", error); return error; } } ATHN_UNLOCK(sc); ----- Is this something I need to call manually? We spoke earlier about how the RX INTR callbacks are not automatically done and must be done by the driver. The only time the athn_usb_intr RX Intr is called is when I manually do so at initialization. - Farhan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9315bf6d-b9a9-89a2-9a32-aca9fd9cc015>