Changeset 5f94a0c in mainline


Ignore:
Timestamp:
2011-05-17T10:46:00Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
28d9c95
Parents:
2aaf804
Message:

Add timeouts to the enumeration routine

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-rhd/port.c

    r2aaf804 r5f94a0c  
    227227                while (uhci_port_read_status(port) & STATUS_IN_RESET);
    228228        }
     229        /* PIO delay, should not be longer than 3ms as the device might
     230         * enter suspend state. */
    229231        udelay(10);
    230232        /* Enable the port. */
    231233        uhci_port_set_enabled(port, true);
    232 
    233         /* Reset recovery period,
    234          * devices do not have to respond during this period
    235          */
    236         async_usleep(10000);
    237234        return EOK;
    238235}
  • uspace/lib/usbdev/src/hub.c

    r2aaf804 r5f94a0c  
    4141#include <assert.h>
    4242#include <usb/debug.h>
     43#include <time.h>
    4344
    4445/** How much time to wait between attempts to register endpoint 0:0.
     
    218219
    219220        int rc;
     221        struct timeval start_time;
     222
     223        rc = gettimeofday(&start_time, NULL);
     224        if (rc != EOK) {
     225                return rc;
     226        }
    220227
    221228        rc = usb_hc_connection_open(&hc_conn);
     
    264271                }
    265272        } while (rc != EOK);
     273        struct timeval end_time;
     274
     275        rc = gettimeofday(&end_time, NULL);
     276        if (rc != EOK) {
     277                goto leave_release_default_address;
     278        }
     279
     280        /* According to the USB spec part 9.1.2 host allows 100ms time for
     281         * the insertion process to complete. According to 7.1.7.1 this is the
     282         * time between attach detected and port reset. However, the setup done
     283         * above might use much of this time so we should only wait to fill
     284         * up the 100ms quota*/
     285        suseconds_t elapsed = tv_sub(&end_time, &start_time);
     286        if (elapsed < 100000) {
     287                async_usleep(100000 - elapsed);
     288        }
    266289
    267290        /*
     
    273296                goto leave_release_default_address;
    274297        }
     298        /* USB spec 7.1.7.1: The USB System Software guarantees a minimum of
     299         * 10ms for reset recovery. Device response to any bus transactions
     300         * addressed to the default device address during the reset recovery
     301         * time is undefined.
     302         */
     303        async_usleep(10000);
    275304
    276305        rc = usb_pipe_probe_default_control(&ctrl_pipe);
Note: See TracChangeset for help on using the changeset viewer.