2010-04-01 16:56:23

by Pavel Machek

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

Hi!

> Do you mean the dmesg output ?
> A full dmesg is included in this address :
> http://pastebin.com/8XU619Uk
> Not in all suspend/hibernate the problem comes, only in some of them
> and this included dmesg output is just after a non working case of
> webcam fault.
>
>
> I also have found this in `/var/log/messages | grep uvcvideo`
> Mar 31 00:31:16 linux-l365 kernel: [399905.714743] usbcore:
> deregistering interface driver uvcvideo
> Mar 31 00:31:24 linux-l365 kernel: [399914.121386] uvcvideo: Found UVC
> 1.00 device LG Webcam (0c45:62c0)
> Mar 31 00:31:24 linux-l365 kernel: [399914.135661] usbcore: registered
> new interface driver uvcvideo

Also try unloading uvcvideo before suspend and reloading it after
resume...

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


2010-04-01 17:22:06

by Philippe Troin

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

Pavel Machek <[email protected]> writes:

> > Do you mean the dmesg output ?
> > A full dmesg is included in this address :
> > http://pastebin.com/8XU619Uk
> > Not in all suspend/hibernate the problem comes, only in some of them
> > and this included dmesg output is just after a non working case of
> > webcam fault.
> >
> >
> > I also have found this in `/var/log/messages | grep uvcvideo`
> > Mar 31 00:31:16 linux-l365 kernel: [399905.714743] usbcore:
> > deregistering interface driver uvcvideo
> > Mar 31 00:31:24 linux-l365 kernel: [399914.121386] uvcvideo: Found UVC
> > 1.00 device LG Webcam (0c45:62c0)
> > Mar 31 00:31:24 linux-l365 kernel: [399914.135661] usbcore: registered
> > new interface driver uvcvideo
>
> Also try unloading uvcvideo before suspend and reloading it after
> resume...

I have a similar problem with a Creative Optia webcam.

I have found that removing the ehci_hcd module and reinserting it
fixes the problem.

If your kernel ships with ehci_hcd built-in (F11 and later), the
script included also fixes the problem (it rebind the device).

Of course, I'd love to see this issue fixed.

Phil.

Script: /etc/pm/sleep.d/50kickuvc

#!/bin/sh

case "$1" in
resume|thaw)
cd /sys/bus/usb/drivers/uvcvideo || exit 1
devices=''
for i in [0-9]*-[0-9]*:*
do
[ -L "$i" ] || break
saved_IFS="$IFS"
IFS=:
set -- $i
IFS="$saved_IFS"
found=no
for j in $devices
do
if [ "$j" = "$1" ]
then
found=yes
fi
done
if [ "$found" = no ]
then
devices="$devices $1"
fi
done
if [ "$devices" != "" ]
then
cd /sys/bus/usb/drivers/usb || exit 1
for i in $devices
do
echo $i > unbind
sleep 1
echo $i > bind
done
fi
;;
esac

2010-04-04 13:22:40

by Pavel Machek

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

Hi!

> > > Do you mean the dmesg output ?
> > > A full dmesg is included in this address :
> > > http://pastebin.com/8XU619Uk
> > > Not in all suspend/hibernate the problem comes, only in some of them
> > > and this included dmesg output is just after a non working case of
> > > webcam fault.
> > >
> > >
> > > I also have found this in `/var/log/messages | grep uvcvideo`
> > > Mar 31 00:31:16 linux-l365 kernel: [399905.714743] usbcore:
> > > deregistering interface driver uvcvideo
> > > Mar 31 00:31:24 linux-l365 kernel: [399914.121386] uvcvideo: Found UVC
> > > 1.00 device LG Webcam (0c45:62c0)
> > > Mar 31 00:31:24 linux-l365 kernel: [399914.135661] usbcore: registered
> > > new interface driver uvcvideo
> >
> > Also try unloading uvcvideo before suspend and reloading it after
> > resume...
>
> I have a similar problem with a Creative Optia webcam.
>
> I have found that removing the ehci_hcd module and reinserting it
> fixes the problem.
>
> If your kernel ships with ehci_hcd built-in (F11 and later), the
> script included also fixes the problem (it rebind the device).
>
> Of course, I'd love to see this issue fixed.

If unload/reload of uvcvideo helps, it is most likely problem in that.

If unload/reload of ehci_hcd is needed, it is most likely ehci problem.

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2010-04-04 18:58:59

by Philippe Troin

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

Pavel Machek <[email protected]> writes:

> Hi!
>
> > > > Do you mean the dmesg output ?
> > > > A full dmesg is included in this address :
> > > > http://pastebin.com/8XU619Uk
> > > > Not in all suspend/hibernate the problem comes, only in some of them
> > > > and this included dmesg output is just after a non working case of
> > > > webcam fault.
> > > >
> > > >
> > > > I also have found this in `/var/log/messages | grep uvcvideo`
> > > > Mar 31 00:31:16 linux-l365 kernel: [399905.714743] usbcore:
> > > > deregistering interface driver uvcvideo
> > > > Mar 31 00:31:24 linux-l365 kernel: [399914.121386] uvcvideo: Found UVC
> > > > 1.00 device LG Webcam (0c45:62c0)
> > > > Mar 31 00:31:24 linux-l365 kernel: [399914.135661] usbcore: registered
> > > > new interface driver uvcvideo
> > >
> > > Also try unloading uvcvideo before suspend and reloading it after
> > > resume...
> >
> > I have a similar problem with a Creative Optia webcam.
> >
> > I have found that removing the ehci_hcd module and reinserting it
> > fixes the problem.
> >
> > If your kernel ships with ehci_hcd built-in (F11 and later), the
> > script included also fixes the problem (it rebind the device).
> >
> > Of course, I'd love to see this issue fixed.
>
> If unload/reload of uvcvideo helps, it is most likely problem in that.
>
> If unload/reload of ehci_hcd is needed, it is most likely ehci problem.

My testing shows that:

1. If I remove uvcvideo BEFORE suspend and reinsert it after resume,
it works. However, I cannot always rmmod uvcvideo before suspend
as it may be in use.

2. As a work around, removing ehci_hcd and reinserting ehci_hcd upon
resume works as well.

3. Since my distribution's kernels come with ehci_hcd built into the
kernel, and I cannot do #2 any more, I also found that unbinding
and rebinding the device (with the script I sent earlier on) works
as well.

I think uvcvideo is failing to reinitialize the camera on resume, and
forcing an uvcvideo "reset" with either of these three methods kicks
uvcvideo into working again.

Phil.

2010-04-04 19:33:45

by Pavel Machek

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

Hi!

> > If unload/reload of uvcvideo helps, it is most likely problem in that.
> >
> > If unload/reload of ehci_hcd is needed, it is most likely ehci problem.
>
> My testing shows that:
>
> 1. If I remove uvcvideo BEFORE suspend and reinsert it after resume,
> it works. However, I cannot always rmmod uvcvideo before suspend
> as it may be in use.
>
> 2. As a work around, removing ehci_hcd and reinserting ehci_hcd upon
> resume works as well.
>
> 3. Since my distribution's kernels come with ehci_hcd built into the
> kernel, and I cannot do #2 any more, I also found that unbinding
> and rebinding the device (with the script I sent earlier on) works
> as well.
>
> I think uvcvideo is failing to reinitialize the camera on resume, and
> forcing an uvcvideo "reset" with either of these three methods kicks
> uvcvideo into working again.

Ok, that puts the problem firmly into uvcvideo area.

Try changing its _resume routine to whatever is done on device
unplug... it should be rather easy, and is quite close to "correct"
solution.


Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2010-04-06 09:33:20

by Mohamed Ikbel Boulabiar

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

Hi !

> Ok, that puts the problem firmly into uvcvideo area.
>
> Try changing its _resume routine to whatever is done on device
> unplug... it should be rather easy, and is quite close to "correct"
> solution.

I am waiting to try that.

If I always need to rmmod/modprobe everytime, that is meaning that
something is kept messed somewhere in memory and should be cleaned by
restart (reinitialize ?) the device.


Mohamed-Ikbel

2010-04-06 13:30:47

by Pavel Machek

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

On Tue 2010-04-06 11:32:46, Mohamed Ikbel Boulabiar wrote:
> Hi !
>
> > Ok, that puts the problem firmly into uvcvideo area.
> >
> > Try changing its _resume routine to whatever is done on device
> > unplug... it should be rather easy, and is quite close to "correct"
> > solution.
>
> I am waiting to try that.
>
> If I always need to rmmod/modprobe everytime, that is meaning that
> something is kept messed somewhere in memory and should be cleaned by
> restart (reinitialize ?) the device.

Yes. And it also means that problem is within the stuff being rmmoded/insmoded.

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2010-04-11 10:52:57

by Laurent Pinchart

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

On Sunday 04 April 2010 21:34:06 Pavel Machek wrote:
> Hi!
>
> > > If unload/reload of uvcvideo helps, it is most likely problem in that.
> > >
> > > If unload/reload of ehci_hcd is needed, it is most likely ehci problem.
> >
> > My testing shows that:
> > 1. If I remove uvcvideo BEFORE suspend and reinsert it after resume,
> >
> > it works. However, I cannot always rmmod uvcvideo before suspend
> > as it may be in use.
> >
> > 2. As a work around, removing ehci_hcd and reinserting ehci_hcd upon
> >
> > resume works as well.
> >
> > 3. Since my distribution's kernels come with ehci_hcd built into the
> >
> > kernel, and I cannot do #2 any more, I also found that unbinding
> > and rebinding the device (with the script I sent earlier on) works
> > as well.
> >
> > I think uvcvideo is failing to reinitialize the camera on resume, and
> > forcing an uvcvideo "reset" with either of these three methods kicks
> > uvcvideo into working again.
>
> Ok, that puts the problem firmly into uvcvideo area.

No, it doesn't.

First of all, the dmesg output available on pastebin.com is difficult to
understand. As it seems you perform several suspend/resume cycles there.
Mohamed, could you please

- clear the kernel log ('dmesg -c' as root)
- suspend and resume your system
- post the kernel log content ('dmesg')
- clear the kernel log
- try to use your webcam with whatever test software your prefer
- describe the failure (application error messages, ...)
- post the kernel log content

> Try changing its _resume routine to whatever is done on device
> unplug... it should be rather easy, and is quite close to "correct"
> solution.

That's not a solution. Devices are supposed to resume properly without being
reset. The camera might be crashing, or the USB core might be doing something
wrong, requiring some kind of reset. I'd like to diagnose the problem
correctly before trying to fix it.

--
Regards,

Laurent Pinchart

2010-04-11 15:44:46

by Pavel Machek

[permalink] [raw]
Subject: Re: webcam problem after suspend/hibernate

Hi!

> > > My testing shows that:
> > > 1. If I remove uvcvideo BEFORE suspend and reinsert it after resume,
> > >
> > > it works. However, I cannot always rmmod uvcvideo before suspend
> > > as it may be in use.
...
> > > I think uvcvideo is failing to reinitialize the camera on resume, and
> > > forcing an uvcvideo "reset" with either of these three methods kicks
> > > uvcvideo into working again.
> >
> > Ok, that puts the problem firmly into uvcvideo area.
>
> No, it doesn't.

I believe that the fact that rmmod/insmod fixes it means that problem
is in the driver (and not in ehci or something like that).

> First of all, the dmesg output available on pastebin.com is difficult to
> understand. As it seems you perform several suspend/resume cycles there.
> Mohamed, could you please
>
> - clear the kernel log ('dmesg -c' as root)
> - suspend and resume your system
> - post the kernel log content ('dmesg')
> - clear the kernel log
> - try to use your webcam with whatever test software your prefer
> - describe the failure (application error messages, ...)
> - post the kernel log content

Good idea.

> > Try changing its _resume routine to whatever is done on device
> > unplug... it should be rather easy, and is quite close to "correct"
> > solution.
>
> That's not a solution. Devices are supposed to resume properly without being
> reset. The camera might be crashing, or the USB core might be doing something
> wrong, requiring some kind of reset. I'd like to diagnose the problem
> correctly before trying to fix it.

Ok. (You are right that simulating rmmod/insmod is not the same as
proper suspend/resume support, but I still guess it would help with
debugging.)
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html