Re: Faking usb autosuspend out for uvc and cdc_acm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 25 Nov 2009, Greg KH wrote:

> Hi Matthew,
> 
> A few months ago, you posted a patch that added a function,
> usb_device_autosuspend_enable(), to the usb core code, and then modified
> the uvc driver to call this at probe time.
> 
> I've been using this patch for a while on a platform that a few of us
> are trying to optimize the power usage on.  It was thought that this was
> needed in order to put the uvc video driver to sleep while it was not
> being used, which is the majority of the time.  This was the equalivant
> of echoing "auto" to the power/level file in sysfs.

Does the uvcvideo driver already include autosuspend support?  If it 
doesn't then setting power/level to "auto" won't have any effect, 
unless you unbind the driver from the device.

> Well, when someone actually got around to measuring the power usage, it
> turned out that the kernel patch was not equalvant to echoing the value
> in sysfs.  I tracked this down to the fact that your function only did
> the following:
> 
> 	void usb_device_autosuspend_enable(struct usb_device *udev)
> 	{
> 		udev->autosuspend_disabled = 0;
> 		udev->autoresume_disabled = 0;
> 	}
> 
> The usb or power core was never told that the device needed to go into
> "sleep".  So I tried to fix this by doing adding one line to the
> function:
> 
> 	void usb_device_autosuspend_enable(struct usb_device *udev)
> 	{
> 		udev->autosuspend_disabled = 0;
> 		udev->autoresume_disabled = 0;
> 		usb_external_suspend_device(udev, PMSG_USER_SUSPEND);
> 	}

As a matter of fact, writing "auto" to the sysfs attribute is exactly 
equivalent to doing what Matthew wrote plus

		usb_external_resume_device(udev, PMSG_USER_RESUME);

However this should not make any difference, provided you call it from 
within uvcvideo's probe routine.

> But, again, in testing, this didn't seem to actually make any
> difference.  Well, it did for about 50% of the time the machine was
> tested, but not the other 50%.  The other 50% always worked when echoing
> "auto" to the power/level file.

Did you look at the contents of the power/level file before writing 
"auto" to it?

> So, in summary:
> 	- echoing "auto" to the sysfs file always seemed to work
> 	- the above change to your function seemed to work 50% of the
> 	  time.
> 
> Any ideas?

This doesn't make sense; it should have worked just as you thought.

Have you tried adding printk statements to uvcvideo's suspend and 
resume routines, so you can see when the actual power transitions take 
place?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux