Re: handling failure in suspend() during autosuspend

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Fri, 5 Oct 2007, Oliver Neukum wrote:

> Hi,
> 
> this code tries to handle suspend() returning errors (usb_suspend_both):
> 
> 	/* If the suspend failed, resume interfaces that did get suspended */
> 	if (status != 0) {
> 		while (--i >= 0) {
> 			intf = udev->actconfig->interface[i];
> 			usb_resume_interface(intf, 0);
> 		}
> 
> 		/* Try another autosuspend when the interfaces aren't busy */
> 		if (udev->auto_pm)
> 			autosuspend_check(udev);
> 
> It uses autosuspend_check() to resubmit the work if the problem isn't
> permanent. It in turn schedules the retry only if last_busy
> is recent enough. A failure to set it if you refuse to autosuspend will
> kill autosuspend on the devices that use exclusively last_busy.

Right.  If a driver refuses to autosuspend, it should update last_busy.  
In most cases the refusal will be because an I/O event just happened, 
which means last_busy should already be (almost) equal to the current 
time.

> However, even if a driver uses it, it still is a race condition.
> The clean solution would be to split autosuspend_check(), with
> check really only checking, and a new function to schedule another
> attempt.

Do you really want to schedule another attempt at this point?  What 
if the drivers's suspend method incremented the pm_usage_count?  I 
don't see anything wrong with doing both a check and a reschedule.

As far as the race is concerned...  In practice it shouldn't matter
unless autosuspend_delay is set to 0.  I suppose autosuspend_check()  
could take an extra "reschedule" flag.  If the flag was set, the
routine would schedule another autosuspend attempt (with a 1-second
delay) if the idle-time period had already expired.

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.