Bug 7220

Summary: saa7134: no sound after suspend to disk
Product: Drivers Reporter: Adrian Bunk (bunk)
Component: Video(Other)Assignee: Rafael J. Wysocki (rjwysocki)
Status: CLOSED CODE_FIX    
Severity: normal CC: akpm, mchehab, protasnb, rjwysocki
Priority: P2    
Hardware: i386   
OS: Linux   
Kernel Version: all Subsystem:
Regression: --- Bisected commit-id:
Bug Depends on:    
Bug Blocks: 7216    
Attachments: syslog

Description Adrian Bunk 2006-09-27 17:26:24 UTC
I have observed the following problem with all kernels I tried
(up to 2.6.18-rc6-mm2):

After suspend-from-disk, everything works fine except for my saa7134 
card: The picture is still fine, but there is no sound.

It seems saa7134 needs some initialization after resume?
Comment 1 Pavel Machek 2006-10-08 13:26:45 UTC
Try unloading/reloading saa7134 around resume. If that helps, port insmod/rmmod
parts of the driver into suspend/resume and you are done.
Comment 2 Adrian Bunk 2006-10-09 21:29:02 UTC
It does help, but I failed to get this "porting" done in a working way when I
tried it.
Comment 3 Mauro Carvalho Chehab 2006-10-10 06:44:44 UTC
To initialize the board after resume, you will need parts of saa7134_initdev, like:

        /* initialize hardware #1 */
        saa7134_board_init1(dev);
        saa7134_hwinit1(dev);

        /* initialize hardware #2 */
        saa7134_board_init2(dev);
        saa7134_hwinit2(dev);

Taking a closer look at the code, I suspect we will need to split some hardware
initialization code there from the subsystem initializations taken in place by
those init stuff.

For unregister, it calls:
        saa7134_hwfini(dev);

You should notice, however, that some of the code called by fini will unregister
some devices (like input). So, you will need to do a better check on that. At a
first glance, i would just call, at suspend:
    saa7134_tvaudio_fini()
to disable audio output.
Comment 4 Andrew Morton 2007-01-31 02:09:58 UTC
fixed?
Comment 5 Rafael J. Wysocki 2007-05-30 10:48:06 UTC
Is the bug still present in 2.6.22-rc3 and/or in the latest -git ?
Comment 6 Natalie Protasevich 2007-06-21 21:12:01 UTC
The code is in (I see it in 2.6.22-rc4), just needs some testing and the bug can be closed.
Adrian, can you please try it and confirm the code works now?
Thanks.
Comment 7 Rafael J. Wysocki 2007-08-09 09:18:18 UTC
Any progress?
Comment 8 Adrian Bunk 2007-08-11 17:55:07 UTC
Sorry, I somehow didn't get around to test this one.

I tested with 2.6.23-rc2:

The good news is:
Sound works after resuming when I'm not watching TV when suspending.

The bad news is:

I wanted to know whether it also works when watching TV while suspending, so I tried watching analog TV with tvtime and DVB-T with kaffeine (the card supports doing both at the same time) when suspending.

During suspend I got kernel BUG at drivers/media/video/video-buf-dvb.c:59.

After resume:
Bad page state in process 'tvtime'
page:c15b0e40 flags:0x40000000 mapping:00000000 mapcount:0 count:-1
Trying to fix it up, but a reboot is needed

After resuming processes randomly (but quickly) segfaulted.

After typing in a console "shutdown -h now" the kernel panic'ed.
Comment 9 Adrian Bunk 2007-08-11 18:00:54 UTC
Created attachment 12355 [details]
syslog
Comment 10 Rafael J. Wysocki 2007-08-20 10:22:55 UTC
Hm, the bug was triggered during the freezing of tasks.

I think this patch will help:
http://www.sisk.pl/kernel/hibernation_and_suspend/2.6.23-rc3/patches/11-freezer-do-not-send-signals-to-kernel-threads.patch

[You'll need to apply the previous patches from the series before it.]
Comment 11 Mauro Carvalho Chehab 2007-08-20 11:51:42 UTC
There are also another fix removing the BUG_ON() on video-buf-dvb that may help:

http://git.kernel.org/?p=linux/kernel/git/mchehab/v4l-dvb.git;a=commit;h=b396f1e8ff2de4d9db15ce6b8d7748c542364a60
Comment 12 Adrian Bunk 2007-08-26 20:03:37 UTC
I just tried 2.6.23-rc3-mm1 that contains both patches, and except for some minor issues it's now working fine:  :-)

When only running tvtime (analog TV) when suspending tvtime continues running after resuming (perfect!).

When only running kaffeine (DVB-T) when suspending, kaffeine only shows a freeze frame after resuming. After closing and restarting kaffeine it works again.
 Most likely the tuning of the device wasn't restored when resuming?

When running both tvtime and kaffeine when suspending, kaffeine has the problem described above plus tvtime doesn't has sound. After closing both applications and restarting them it works again.
Comment 13 Adrian Bunk 2007-10-12 03:18:03 UTC
After the latest v4l-dvb merge into Linus' tree everything is working fine.  :-)

I don't even have to restart kaffeine anymore (only the channel needs to be reselected).

tvtime also continues to work when both were running (but this might also have improved due to me switching to saa7134-alsa).

Thanks a lot for these improvements!