Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17b11af1 authored by Manu Gautam's avatar Manu Gautam Committed by Steve Kondik
Browse files

Revert "adbd: Don't close/reopen FFS ep0 on disconnect"

This reverts commit b5d385f1ef38ad0c163598c3a4e167d4ae9df3c6.

Commit b5d385f "adbd: Don't close/reopen FFS ep0 on disconnect"
fixes USBCV chapter 9 failures due to re-enumeration as part of
reopening FFS ep0 handle. This was done from usb_kick function
which gets invoked whenever adb read/write fails.
But, not allowing USB re-enumeration on real IO failures results
in adb to go offline and only way to recover is by re-connecting
USB cable.
As ADB function is used for debugging and USBCV tests are not
mandatory, hence, revert original change to allow USB
enumeration on any read/write failures.

CRs-fixed: 689512
Change-Id: Ic0b38223761b7c0eb3e2c54328e88010297318fb
parent 20cf83cb
Loading
Loading
Loading
Loading
+19 −24
Original line number Diff line number Diff line
@@ -313,7 +313,6 @@ static void init_functionfs(struct usb_handle *h)
{
    ssize_t ret;

    if (h->control < 0) { // might have already done this before
    D("OPENING %s\n", USB_FFS_ADB_EP0);
    h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR);
    if (h->control < 0) {
@@ -332,7 +331,6 @@ static void init_functionfs(struct usb_handle *h)
        D("[ %s: writing strings failed: errno=%d]\n", USB_FFS_ADB_EP0, errno);
        goto err;
    }
    }

    h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR);
    if (h->bulk_out < 0) {
@@ -371,14 +369,14 @@ static void *usb_ffs_open_thread(void *x)
    while (1) {
        // wait until the USB device needs opening
        adb_mutex_lock(&usb->lock);
        while (usb->control != -1 && usb->bulk_in != -1 && usb->bulk_out != -1)
        while (usb->control != -1)
            adb_cond_wait(&usb->notify, &usb->lock);
        adb_mutex_unlock(&usb->lock);

        while (1) {
            init_functionfs(usb);

            if (usb->control >= 0 && usb->bulk_in >= 0 && usb->bulk_out >= 0)
            if (usb->control >= 0)
                break;

            adb_sleep_ms(1000);
@@ -475,13 +473,10 @@ static void usb_ffs_kick(usb_handle *h)
        D("[ kick: sink (fd=%d) clear halt failed (%d) ]", h->bulk_out, errno);

    adb_mutex_lock(&h->lock);

    // don't close ep0 here, since we may not need to reinitialize it with
    // the same descriptors again. if however ep1/ep2 fail to re-open in
    // init_functionfs, only then would we close and open ep0 again.
    adb_close(h->control);
    adb_close(h->bulk_out);
    adb_close(h->bulk_in);
    h->bulk_out = h->bulk_in = -1;
    h->control = h->bulk_out = h->bulk_in = -1;

    // notify usb_ffs_open_thread that we are disconnected
    adb_cond_signal(&h->notify);