Greg and everyone else:

The following patches form a general clean-up and reorganization of the
suspend/resume support in usbcore.  I developed them in the course of
working on autosuspend and autoresume.  That work isn't finished yet, but
it still seemed like a good idea to submit these first because they are
fairly substantial and it wouldn't hurt to get some feedback on them.

Although several of these changes are of interest, only two of them (7 and
9) should cause any noticeable difference in the core's behavior.  The
rest are more along the lines of bug fixes and code re-arrangement.  

Here's what the individual patches do:

     1. Change the disconnect checking in devio.c (the usbfs code) so
        that it will detect cases where the device has been unregistered
        from usbfs, even if the device is still connected.  Although this 
        can't happen now, it will be able to occur after patch 4.

     2. Fix usb-skeleton so that it won't try to submit URBs after its 
        disconnect method has returned.  It's quite likely that there
        are drivers based on usb-skeleton in need of the same fix, but
        I don't know which ones they are.

     3. Move some driver-related code from usb.c to driver.c.  These
        routines (concerned with uevent generation and claiming/releasing
        interfaces as well as suspend/resume handling) should have gone 
        into driver.c when it was first split off, but they got left 
        behind somehow.

     4. Make usb_generic into a genuine device driver.  This involves
        adding a mechanism to tell apart USB interface drivers from USB
        device drivers -- of which usb_generic is currently the only one.
        Doing this opens the possibility of having alternate USB device 
        drivers.  For example, when a USB device is exported over the
        network or to a guest (virtual) operating system, it should be 
        driven by the other system.  The host to which the device is 
        actually connected would bind a stub driver in place of 
        usb_generic.

     5. Rename usb_suspend_device to usb_port_suspend (and likewise for
        _resume).  Originally I did this because I wanted to name a
        different routine "usb_suspend_device".  In the end I chose a 
        separate name, but it still seemed worthwhile to keep the
        "usb_port_suspend" name, for two reasons: The routine isn't any 
        longer a main entry into the suspend pathway, and it isn't much 
        more than a wrapper around hub_port_suspend.

     6. Split the core suspend and resume routines into two pieces, one
        for handling USB devices and the other for handling USB 
        interfaces.  This is cleaner than doing them both in one routine.

     7. Remove the recursion in suspend and resume.  This has been overdue
        for some time.  It won't affect system suspends, since the PM core
        does its own recursion through the entire device tree.  It will
        affect only runtime PM done by userspace writing to power/state
        attribute files in sysfs.  (That whole mechanism is slated to
        be overhauled anyway.)

     8. General cleanup of the suspend/resume code.  Duplicated code,
        unnecessary checks, that sort of thing.

     9. Tie together suspend/resume operations on a device and on its
        interfaces.  There doesn't seem to be much need for the peculiar
        intermediate state where a USB device is awake but some of its
        interfaces are suspended.  The patch effectively rules them out;
        attempts to suspend or resume an interface won't do anything,
        and attempts to suspend or resume a device will affect all its
        interfaces as well as the device as a whole.

This stuff works okay in preliminary light testing, but it could use some 
more, especially with different sorts of host controllers.  I expect a 
certain amount of adjustment/cleanup will be needed.  Not much, hopefully.

The actual autosuspend changes should require only a pair of additional 
patches: one to add the core mechanisms, and one to start using it in
usbfs and the hub driver.  They will appear in due course.

Alan Stern



_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to