[mythtv-users] Kernel Crash when starting up in au0828-video.c line 895

Larry Finger Larry.Finger at lwfinger.net
Sun Apr 8 22:53:13 UTC 2012

On 04/08/2012 04:38 PM, jrh wrote:
> On Apr 8, 2012, at 5:09 PM, Larry Finger wrote:
>> On 04/08/2012 03:43 PM, jrh wrote:
>>> On Apr 8, 2012, at 4:03 PM, Mark Lord wrote:
>>>> On 12-04-08 04:01 PM, Mark Lord wrote:
>>>>> On 12-04-08 02:34 AM, f-myth-users at media.mit.edu wrote:
>>>>>>> Date: Sat, 07 Apr 2012 20:56:23 -0400
>>>>>>> From: Mark Lord<mythtv at rtr.ca>
>>>>>>> I should add that, even with the above workarounds, there is STILL an issue
>>>>>>> when mythbackend starts up:  If you have "multi-rec" enabled (more than one
>>>>>>> virtual tuner per physical HVR-950Q), then the backend will have several
>>>>>>> near-simultaneous "tune to initial channel" calls into the drivers.
>>>>>>> This will cause tuner failure.
>>>>>> I haven't been following this thread closely (not my hardware), but
>>>>>> would it be possible to tune using an external tuner script that uses
>>>>>> a mutex and some sleeps to avoid simultaneous tunes?  I have no idea
>>>>>> if the way multirec tunes this hardware is amenable to breaking it
>>>>>> out externally like that.
>>>>> Mythtv doesn't offer external channel change scripts for all digital tuners,
>>>>> dunno if it has the option for the 950Q or not.
>>>>> But the place for the mutex is somewhere in one of the drivers that manages
>>>>> the 950Q, probably in the au0828 driver.  At some point I suspect I'll go in
>>>>> there and just fix the danged thing myself.  But for now, disabling multirec
>>>>> keeps it working well enough.
>>>> Another related thing might be to fix mythbackend to NOT issue channel tuning
>>>> requests to virtual tuners when the physical tuner is already tuned appropriately.
>>> The way I was set up, I never enabled the digital side of the 950Q. I was only using the analog side. Also, I am using the 64 bit version.
>>> I did try the 32 bit version, but had the same errors as below.. again only using the analog side, never adding the DVB ATSC tuner:
>>> Apr  7 15:47:51 myth1204 mythbackend[1590]: I CoreContext v4lchannel.cpp:661 (SetInputAndFormat) V4LChannel(/dev/video0): SetInputAndFormat(1, NTSC) (v4l v2) input_switch: 0 mode_switch: 1
>>> The messages below lead me to believe that maybe one of the ioctl calls in the v4l stuff may have had a null pointer passed to it.
>>> Apr  7 15:47:50 myth1204 kernel: [   18.216226] ------------[ cut here ]------------
>>> Apr  7 15:47:50 myth1204 kernel: [   18.216284] kernel BUG at /build/buildd/linux-3.2.0/drivers/media/video/au0828/au0828-video.c:895!
>>> Apr  7 15:47:50 myth1204 kernel: [   18.216357] invalid opcode: 0000 [#1] SMP
>>> Apr  7 15:47:50 myth1204 kernel: [   18.216394] CPU 0
>>> Apr  7 15:47:50 myth1204 kernel: [   18.216412] Modules linked in: xc5000 tuner au8522 ppdev snd_usb_audio snd_atiixp snd_ac97_codec ac97_bus snd_pcm snd_hwdep snd_usbmidi_lib snd_seq_midi snd_rawmidi snd_seq_midi_event au0828 psmouse dvb_core snd_seq videobuf_vmalloc videobuf_core tveeprom v4l2_common snd_timer snd_seq_device videodev serio_raw v4l2_compat_ioctl32 radeon edac_core snd k8temp edac_mce_amd soundcore ttm snd_page_alloc drm_kms_helper i2c_piix4 drm i2c_algo_bit nfsd nfs lockd fscache auth_rpcgss nfs_acl sunrpc parport_pc mac_hid shpchp lp parport hid_apple usbhid hid 8139too usb_storage 8139cp pata_atiixp sata_sil floppy
>> Please supply the rest of the bug message that tells what called res_free(). The bug is because there has been an attempt to free something that seems not to have been reserved.
>> Do you build your own kernels, or could you? If so, it will be easy to provide a patch that prints a warning, but does not crash the kernel.
>> Larry
> I haven't built a kernel since the 1.2 days. The kernel involved below is the stock kernel as of yesterday's ubuntu 12.04 updates.
> Linux myth1204 3.2.0-22-generic #35-Ubuntu SMP Tue Apr 3 18:33:15 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
> If I had a howto for building it, I could probably work out how. I do software development, just not at the kernel level.

It is pretty straight-forward. I do not use Ubuntu, but I have a Powerbook G4 
that runs Mint 9, which is also Debian based and uses the same kind of setup. 
The detailed description is at https://help.ubuntu.com/community/Kernel/Compile. 
That page has not been updated recently, but the instructions for 10.04 look 
correct for 12.04.

If you apply the attached patch, the system will echo some diagnostics, but will 
not crash. All frees are for a single bit, thus it is safe to turn res_free() 
into a no-op.

FYI, the crash comes from the statement 'res_free(fh, AU0828_RESOURCE_VIDEO);' 
at roughly line 1700 of file drivers/media/video/au0828/au0828-video.c. I do not 
understand why that bit is not being set.

This is clearly a kernel bug. Even if devices do not respond in the way the 
driver expects, the driver should never crash the kernel with a BUG statement. 
That action should be reserved for conditions that might cause irreparable 
damage to the file system.

Good luck with this issue. I will submit a patch to the kernel and reference 
this thread.

-------------- next part --------------
Index: linux-3.1.9-1.4/drivers/media/video/au0828/au0828-video.c
--- linux-3.1.9-1.4.orig/drivers/media/video/au0828/au0828-video.c
+++ linux-3.1.9-1.4/drivers/media/video/au0828/au0828-video.c
@@ -891,8 +891,13 @@ static int res_locked(struct au0828_dev
 static void res_free(struct au0828_fh *fh, unsigned int bits)
 	struct au0828_dev    *dev = fh->dev;
+	unsigned int bits2 = fh->resources & bits;
-	BUG_ON((fh->resources & bits) != bits);
+	if (bits2 != bits) {
+		WARN_ONCE(true, "au0828: Trying to free resource 0x%x"
+			  " without reserving it\n", bits);
+		return;
+	}
 	fh->resources  &= ~bits;

More information about the mythtv-users mailing list