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



Reply via email to