possible recursive locking: find_ref_lock() / v4l2_ctrl_add_handler()

2013-02-10 Thread Knut Petersen

Maybe somebody could have at that old locking warning:

[9.761427] cx88/2: cx2388x MPEG-TS Driver Manager version 0.0.9 loaded
[9.782848] cx88/0: cx2388x v4l2 driver version 0.0.9 loaded
[9.794205] input: HDA Digital PCBeep as 
/devices/pci:00/:00:1b.0/input/input5
[9.879194] cx88[0]: subsystem: 0070:6906, board: Hauppauge 
WinTV-HVR4000(Lite) DVB-S/S2 [card=69,autodetected], frontend(s): 1
[9.914871] input: HDA Intel Line as 
/devices/pci:00/:00:1b.0/sound/card0/input6
[9.932037] cx88[0]: TV tuner type -1, Radio tuner type -1
[9.953646] input: HDA Intel Front Mic as 
/devices/pci:00/:00:1b.0/sound/card0/input7
[9.981718] input: HDA Intel Rear Mic as 
/devices/pci:00/:00:1b.0/sound/card0/input8
[9.996493] input: HDA Intel Line Out CLFE as 
/devices/pci:00/:00:1b.0/sound/card0/input9
[   10.003354] input: HDA Intel Line Out Surround as 
/devices/pci:00/:00:1b.0/sound/card0/input10
[   10.007987] input: HDA Intel Line Out Front as 
/devices/pci:00/:00:1b.0/sound/card0/input11
[   10.450310] tveeprom 9-0050: Hauppauge model 69100, rev B4C3, serial# 7900937
[   10.453751] tveeprom 9-0050: MAC address is 00:0d:fe:78:8f:09
[   10.457134] tveeprom 9-0050: tuner model is Conexant CX24118A (idx 123, type 
4)
[   10.460547] tveeprom 9-0050: TV standards ATSC/DVB Digital (eeprom 0x80)
[   10.463936] tveeprom 9-0050: audio processor is None (idx 0)
[   10.467320] tveeprom 9-0050: decoder processor is CX880 (idx 20)
[   10.470648] tveeprom 9-0050: has no radio, has IR receiver, has no IR 
transmitter
[   10.474038] cx88[0]: hauppauge eeprom: model=69100
[   10.508060] Registered IR keymap rc-hauppauge
[   10.518107] input: cx88 IR (Hauppauge WinTV-HVR400 as 
/devices/pci:00/:00:1e.0/:05:05.2/rc/rc0/input12
[   10.526485] rc0: cx88 IR (Hauppauge WinTV-HVR400 as 
/devices/pci:00/:00:1e.0/:05:05.2/rc/rc0
[   10.530869] cx88[0]/2: cx2388x 8802 Driver Manager
[   10.534533] cx88[0]/2: found at :05:05.2, rev: 5, irq: 17, latency: 32, 
mmio: 0xd200
[   10.541221] cx88[0]/0: found at :05:05.0, rev: 5, irq: 17, latency: 32, 
mmio: 0xd000
[   10.545197] IR RC5(x) protocol handler initialized
[   10.557935]
[   10.560012] =
[   10.560012] [ INFO: possible recursive locking detected ]
[   10.560012] 3.8.0-rc7-main #20 Not tainted
[   10.560012] -
[   10.560012] modprobe/469 is trying to acquire lock:
[   10.560012]  (hdl-lock){+.+...}, at: [f85604f6] find_ref_lock+0x1f/0x39 
[videodev]
[   10.560012]
[   10.560012] but task is already holding lock:
[   10.560012]  (hdl-lock){+.+...}, at: [f85622d3] 
v4l2_ctrl_add_handler+0x35/0x91 [videodev]
[   10.560012]
[   10.560012] other info that might help us debug this:
[   10.560012]  Possible unsafe locking scenario:
[   10.560012]
[   10.560012]CPU0
[   10.560012]
[   10.560012]   lock(hdl-lock);
[   10.560012]   lock(hdl-lock);
[   10.560012]
[   10.560012]  *** DEADLOCK ***
[   10.560012]
[   10.560012]  May be due to missing lock nesting notation
[   10.560012]
[   10.560012] 3 locks held by modprobe/469:
[   10.560012]  #0:  (__lockdep_no_validate__){..}, at: [c03cbcfc] 
__driver_attach+0x31/0x6b
[   10.560012]  #1:  (__lockdep_no_validate__){..}, at: [c03cbd08] 
__driver_attach+0x3d/0x6b
[   10.560012]  #2:  (hdl-lock){+.+...}, at: [f85622d3] 
v4l2_ctrl_add_handler+0x35/0x91 [videodev]
[   10.560012]
[   10.560012] stack backtrace:
[   10.560012] Pid: 469, comm: modprobe Not tainted 3.8.0-rc7-main #20
[   10.560012] Call Trace:
[   10.560012]  [c01272cb] ? console_unlock+0x34b/0x374
[   10.560012]  [c015b25a] __lock_acquire+0x1314/0x138a
[   10.560012]  [c015bc94] ? mark_held_locks+0xa1/0xc8
[   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
[   10.560012]  [c015b703] lock_acquire+0xaf/0xcd
[   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
[   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
[   10.560012]  [c04f8ae0] mutex_lock_nested+0x3a/0x266
[   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
[   10.560012]  [c04f8cc8] ? mutex_lock_nested+0x222/0x266
[   10.560012]  [c04f8cf1] ? mutex_lock_nested+0x24b/0x266
[   10.560012]  [f85604f6] find_ref_lock+0x1f/0x39 [videodev]
[   10.560012]  [f8560db7] handler_new_ref+0x38/0x143 [videodev]
[   10.560012]  [f856230b] v4l2_ctrl_add_handler+0x6d/0x91 [videodev]
[   10.560012]  [f85c2961] cx8800_initdev+0x329/0x673 [cx8800]
[   10.560012]  [c04fd581] ? sub_preempt_count+0x90/0x9d
[   10.560012]  [c04faa54] ? _raw_spin_unlock_irqrestore+0x44/0x5b
[   10.560012]  [c03d0acd] ? __pm_runtime_resume+0x40/0x48
[   10.560012]  [c02e6ca4] pci_device_probe+0x5f/0x96
[   10.560012]  [c03cbbe7] driver_probe_device+0x8f/0x173
[   10.560012]  [c03cbd1a] __driver_attach+0x4f/0x6b
[   10.560012]  [c03ca895] bus_for_each_dev+0x44/0x66
[   10.560012]  

Re: possible recursive locking: find_ref_lock() / v4l2_ctrl_add_handler()

2013-02-10 Thread Hans Verkuil
On Sun February 10 2013 11:34:11 Knut Petersen wrote:
 Maybe somebody could have at that old locking warning:

It's a false warning. If someone can point me to some documentation on how to
tell lockdep that it isn't a deadlock, then that would be appreciated.

Regards,

Hans

 
 [9.761427] cx88/2: cx2388x MPEG-TS Driver Manager version 0.0.9 loaded
 [9.782848] cx88/0: cx2388x v4l2 driver version 0.0.9 loaded
 [9.794205] input: HDA Digital PCBeep as 
 /devices/pci:00/:00:1b.0/input/input5
 [9.879194] cx88[0]: subsystem: 0070:6906, board: Hauppauge 
 WinTV-HVR4000(Lite) DVB-S/S2 [card=69,autodetected], frontend(s): 1
 [9.914871] input: HDA Intel Line as 
 /devices/pci:00/:00:1b.0/sound/card0/input6
 [9.932037] cx88[0]: TV tuner type -1, Radio tuner type -1
 [9.953646] input: HDA Intel Front Mic as 
 /devices/pci:00/:00:1b.0/sound/card0/input7
 [9.981718] input: HDA Intel Rear Mic as 
 /devices/pci:00/:00:1b.0/sound/card0/input8
 [9.996493] input: HDA Intel Line Out CLFE as 
 /devices/pci:00/:00:1b.0/sound/card0/input9
 [   10.003354] input: HDA Intel Line Out Surround as 
 /devices/pci:00/:00:1b.0/sound/card0/input10
 [   10.007987] input: HDA Intel Line Out Front as 
 /devices/pci:00/:00:1b.0/sound/card0/input11
 [   10.450310] tveeprom 9-0050: Hauppauge model 69100, rev B4C3, serial# 
 7900937
 [   10.453751] tveeprom 9-0050: MAC address is 00:0d:fe:78:8f:09
 [   10.457134] tveeprom 9-0050: tuner model is Conexant CX24118A (idx 123, 
 type 4)
 [   10.460547] tveeprom 9-0050: TV standards ATSC/DVB Digital (eeprom 0x80)
 [   10.463936] tveeprom 9-0050: audio processor is None (idx 0)
 [   10.467320] tveeprom 9-0050: decoder processor is CX880 (idx 20)
 [   10.470648] tveeprom 9-0050: has no radio, has IR receiver, has no IR 
 transmitter
 [   10.474038] cx88[0]: hauppauge eeprom: model=69100
 [   10.508060] Registered IR keymap rc-hauppauge
 [   10.518107] input: cx88 IR (Hauppauge WinTV-HVR400 as 
 /devices/pci:00/:00:1e.0/:05:05.2/rc/rc0/input12
 [   10.526485] rc0: cx88 IR (Hauppauge WinTV-HVR400 as 
 /devices/pci:00/:00:1e.0/:05:05.2/rc/rc0
 [   10.530869] cx88[0]/2: cx2388x 8802 Driver Manager
 [   10.534533] cx88[0]/2: found at :05:05.2, rev: 5, irq: 17, latency: 
 32, mmio: 0xd200
 [   10.541221] cx88[0]/0: found at :05:05.0, rev: 5, irq: 17, latency: 
 32, mmio: 0xd000
 [   10.545197] IR RC5(x) protocol handler initialized
 [   10.557935]
 [   10.560012] =
 [   10.560012] [ INFO: possible recursive locking detected ]
 [   10.560012] 3.8.0-rc7-main #20 Not tainted
 [   10.560012] -
 [   10.560012] modprobe/469 is trying to acquire lock:
 [   10.560012]  (hdl-lock){+.+...}, at: [f85604f6] find_ref_lock+0x1f/0x39 
 [videodev]
 [   10.560012]
 [   10.560012] but task is already holding lock:
 [   10.560012]  (hdl-lock){+.+...}, at: [f85622d3] 
 v4l2_ctrl_add_handler+0x35/0x91 [videodev]
 [   10.560012]
 [   10.560012] other info that might help us debug this:
 [   10.560012]  Possible unsafe locking scenario:
 [   10.560012]
 [   10.560012]CPU0
 [   10.560012]
 [   10.560012]   lock(hdl-lock);
 [   10.560012]   lock(hdl-lock);
 [   10.560012]
 [   10.560012]  *** DEADLOCK ***
 [   10.560012]
 [   10.560012]  May be due to missing lock nesting notation
 [   10.560012]
 [   10.560012] 3 locks held by modprobe/469:
 [   10.560012]  #0:  (__lockdep_no_validate__){..}, at: [c03cbcfc] 
 __driver_attach+0x31/0x6b
 [   10.560012]  #1:  (__lockdep_no_validate__){..}, at: [c03cbd08] 
 __driver_attach+0x3d/0x6b
 [   10.560012]  #2:  (hdl-lock){+.+...}, at: [f85622d3] 
 v4l2_ctrl_add_handler+0x35/0x91 [videodev]
 [   10.560012]
 [   10.560012] stack backtrace:
 [   10.560012] Pid: 469, comm: modprobe Not tainted 3.8.0-rc7-main #20
 [   10.560012] Call Trace:
 [   10.560012]  [c01272cb] ? console_unlock+0x34b/0x374
 [   10.560012]  [c015b25a] __lock_acquire+0x1314/0x138a
 [   10.560012]  [c015bc94] ? mark_held_locks+0xa1/0xc8
 [   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
 [   10.560012]  [c015b703] lock_acquire+0xaf/0xcd
 [   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
 [   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
 [   10.560012]  [c04f8ae0] mutex_lock_nested+0x3a/0x266
 [   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
 [   10.560012]  [c04f8cc8] ? mutex_lock_nested+0x222/0x266
 [   10.560012]  [c04f8cf1] ? mutex_lock_nested+0x24b/0x266
 [   10.560012]  [f85604f6] find_ref_lock+0x1f/0x39 [videodev]
 [   10.560012]  [f8560db7] handler_new_ref+0x38/0x143 [videodev]
 [   10.560012]  [f856230b] v4l2_ctrl_add_handler+0x6d/0x91 [videodev]
 [   10.560012]  [f85c2961] cx8800_initdev+0x329/0x673 [cx8800]
 [   10.560012]  [c04fd581] ? sub_preempt_count+0x90/0x9d
 [   10.560012]  [c04faa54] ? 

Re: possible recursive locking: find_ref_lock() / v4l2_ctrl_add_handler()

2013-02-10 Thread Andy Walls
On Sun, 2013-02-10 at 11:54 +0100, Hans Verkuil wrote:
 On Sun February 10 2013 11:34:11 Knut Petersen wrote:
  Maybe somebody could have at that old locking warning:
 
 It's a false warning. If someone can point me to some documentation on how to
 tell lockdep that it isn't a deadlock, then that would be appreciated.

Hi Hans,

Here you go, an old patch for you:
http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/27027

Be warned, if lockdep has a limit on the number of classes it can
handle, then my patch could be a problem with a large number of drivers
with v4l2_ctrl_handlers loaded. I must emphasize, that is a new lock
classes per driver instance, not per hardware device instance ... IIRC.

FYI, here's some context that led up to me making the patch:
http://www.gossamer-threads.com/lists/ivtv/devel/41525#41525

Regards,
Andy

 Regards,
 
   Hans
 
  
  [9.761427] cx88/2: cx2388x MPEG-TS Driver Manager version 0.0.9 loaded
  [9.782848] cx88/0: cx2388x v4l2 driver version 0.0.9 loaded
  [9.794205] input: HDA Digital PCBeep as 
  /devices/pci:00/:00:1b.0/input/input5
  [9.879194] cx88[0]: subsystem: 0070:6906, board: Hauppauge 
  WinTV-HVR4000(Lite) DVB-S/S2 [card=69,autodetected], frontend(s): 1
  [9.914871] input: HDA Intel Line as 
  /devices/pci:00/:00:1b.0/sound/card0/input6
  [9.932037] cx88[0]: TV tuner type -1, Radio tuner type -1
  [9.953646] input: HDA Intel Front Mic as 
  /devices/pci:00/:00:1b.0/sound/card0/input7
  [9.981718] input: HDA Intel Rear Mic as 
  /devices/pci:00/:00:1b.0/sound/card0/input8
  [9.996493] input: HDA Intel Line Out CLFE as 
  /devices/pci:00/:00:1b.0/sound/card0/input9
  [   10.003354] input: HDA Intel Line Out Surround as 
  /devices/pci:00/:00:1b.0/sound/card0/input10
  [   10.007987] input: HDA Intel Line Out Front as 
  /devices/pci:00/:00:1b.0/sound/card0/input11
  [   10.450310] tveeprom 9-0050: Hauppauge model 69100, rev B4C3, serial# 
  7900937
  [   10.453751] tveeprom 9-0050: MAC address is 00:0d:fe:78:8f:09
  [   10.457134] tveeprom 9-0050: tuner model is Conexant CX24118A (idx 123, 
  type 4)
  [   10.460547] tveeprom 9-0050: TV standards ATSC/DVB Digital (eeprom 0x80)
  [   10.463936] tveeprom 9-0050: audio processor is None (idx 0)
  [   10.467320] tveeprom 9-0050: decoder processor is CX880 (idx 20)
  [   10.470648] tveeprom 9-0050: has no radio, has IR receiver, has no IR 
  transmitter
  [   10.474038] cx88[0]: hauppauge eeprom: model=69100
  [   10.508060] Registered IR keymap rc-hauppauge
  [   10.518107] input: cx88 IR (Hauppauge WinTV-HVR400 as 
  /devices/pci:00/:00:1e.0/:05:05.2/rc/rc0/input12
  [   10.526485] rc0: cx88 IR (Hauppauge WinTV-HVR400 as 
  /devices/pci:00/:00:1e.0/:05:05.2/rc/rc0
  [   10.530869] cx88[0]/2: cx2388x 8802 Driver Manager
  [   10.534533] cx88[0]/2: found at :05:05.2, rev: 5, irq: 17, latency: 
  32, mmio: 0xd200
  [   10.541221] cx88[0]/0: found at :05:05.0, rev: 5, irq: 17, latency: 
  32, mmio: 0xd000
  [   10.545197] IR RC5(x) protocol handler initialized
  [   10.557935]
  [   10.560012] =
  [   10.560012] [ INFO: possible recursive locking detected ]
  [   10.560012] 3.8.0-rc7-main #20 Not tainted
  [   10.560012] -
  [   10.560012] modprobe/469 is trying to acquire lock:
  [   10.560012]  (hdl-lock){+.+...}, at: [f85604f6] 
  find_ref_lock+0x1f/0x39 [videodev]
  [   10.560012]
  [   10.560012] but task is already holding lock:
  [   10.560012]  (hdl-lock){+.+...}, at: [f85622d3] 
  v4l2_ctrl_add_handler+0x35/0x91 [videodev]
  [   10.560012]
  [   10.560012] other info that might help us debug this:
  [   10.560012]  Possible unsafe locking scenario:
  [   10.560012]
  [   10.560012]CPU0
  [   10.560012]
  [   10.560012]   lock(hdl-lock);
  [   10.560012]   lock(hdl-lock);
  [   10.560012]
  [   10.560012]  *** DEADLOCK ***
  [   10.560012]
  [   10.560012]  May be due to missing lock nesting notation
  [   10.560012]
  [   10.560012] 3 locks held by modprobe/469:
  [   10.560012]  #0:  (__lockdep_no_validate__){..}, at: [c03cbcfc] 
  __driver_attach+0x31/0x6b
  [   10.560012]  #1:  (__lockdep_no_validate__){..}, at: [c03cbd08] 
  __driver_attach+0x3d/0x6b
  [   10.560012]  #2:  (hdl-lock){+.+...}, at: [f85622d3] 
  v4l2_ctrl_add_handler+0x35/0x91 [videodev]
  [   10.560012]
  [   10.560012] stack backtrace:
  [   10.560012] Pid: 469, comm: modprobe Not tainted 3.8.0-rc7-main #20
  [   10.560012] Call Trace:
  [   10.560012]  [c01272cb] ? console_unlock+0x34b/0x374
  [   10.560012]  [c015b25a] __lock_acquire+0x1314/0x138a
  [   10.560012]  [c015bc94] ? mark_held_locks+0xa1/0xc8
  [   10.560012]  [f85604f6] ? find_ref_lock+0x1f/0x39 [videodev]
  [   10.560012]  [c015b703] lock_acquire+0xaf/0xcd
  [   10.560012]  [f85604f6] ?