ALSA: hda - Continue probe in work context to avoid request_module deadlock
PATCH v2 4/4 ALSA: hda - Continue probe in work context to avoid request_module deadlock
There's deadlock when request_module(i915) in azx_probe.
It looks like:device_lock(audio pci device) -> azx_probe -> module_request (or symbol_request) -> modprobe (userspace) -> i915 init -> drm_pci_init -> pci_register_driver -> bus_add_driver -> driver_attach -> which in turn tries all locks on pci bus, and when it tries the one on the audio device, it will deadlock.
This patch introduce a work to store remaining probe stuff, and let request_module run in safe work context.
--- sound/pci/hda/hda_i915.c | 13 ++++-- sound/pci/hda/hda_intel.c | 105 +++++++++++++++++++++++++++------------------- 2 files changed, 71 insertions(+), 47 deletions(-)
sound/pci/hda/hda_i915.c +9 -4
@@ -42,13 +42,18 @@ int hda_i915_init(void) {int err =0 ; - get_power =symbol_request (i915_request_power_well); + get_power =symbol_get (i915_request_power_well);if (!get_power) { -snd_printk (KERN_WARNING "hda-i915: get_power symbol get fail\n" ); -return -ENODEV ; +request_module ("i915" ); + get_power =symbol_get (i915_request_power_well); +if (!get_power) { +snd_printk (KERN_WARNING "hda-i915: get_power symbol get fail\n" ); +return -ENODEV ; + } +snd_printdd ("hda-i915: get_power symbol get successful\n" ); } - put_power =symbol_request (i915_release_power_well); + put_power =symbol_get (i915_release_power_well);if (!put_power) {symbol_put (i915_request_power_well); get_power =NULL ;
sound/pci/hda/hda_intel.c +62 -43
145 lines not on this page · raw message
Signature · 1 line
1.8.1.2
At Thu, 23 May 2013 09:51:07 +0800,
Quoted 28 lines · Wang Xingchao
There's deadlock when
request_module(i915)inazx_probe.
It looks like:device_lock(audio pci device)->azx_probe->module_request(orsymbol_request) -> modprobe (userspace) -> i915 init ->drm_pci_init->pci_register_driver->bus_add_driver->driver_attach-> which in turn tries all locks on pci bus, and when it tries the one on the audio device, it will deadlock.This patch introduce a work to store remaining probe stuff, and let
request_modulerun in safe work context.Signed-off-by Wang Xingchao <[email protected]>--- sound/pci/hda/hda_i915.c | 13 ++++-- sound/pci/hda/hda_intel.c | 105 +++++++++++++++++++++++++++------------------- 2 files changed, 71 insertions(+), 47 deletions(-)sound/pci/hda/hda_i915.c +1
-1@@ -42,13 +42,18 @@ int hda_i915_init(void) {int err =0 ; - get_power =symbol_request (i915_request_power_well); + get_power =symbol_get (i915_request_power_well);
sound/pci/hda/hda_i915.c int hda_i915_init(void) · line 53
Quoted 10 lines
sound/pci/hda/hda_i915.c +7
-2if (!get_power) { -snd_printk (KERN_WARNING "hda-i915: get_power symbol get fail\n" ); -return -ENODEV ; +request_module ("i915" ); + get_power =symbol_get (i915_request_power_well); +if (!get_power) { +snd_printk (KERN_WARNING "hda-i915: get_power symbol get fail\n" ); +return -ENODEV ; + } +snd_printdd ("hda-i915: get_power symbol get successful\n" );
Why do you need this change?
Takashi
Hi Takashi,
Quoted 48 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, May 23, 2013 2:49 PM
To: Wang Xingchao
Cc: [email protected]; [email protected]; [email protected]; Girdwood, Liam R; Li, Jocelyn; Wang, Xingchao; Lin, Mengdong
Subject: Re: [PATCH 4/4 V2] ALSA: hda - Continue probe in work context to avoidrequest_moduledeadlockAt Thu, 23 May 2013 09:51:07 +0800,
Quoted 23 lines · Wang Xingchao
There's deadlock when
request_module(i915)inazx_probe. It looks like:device_lock(audio pci device)->azx_probe->module_request(orsymbol_request) -> modprobe (userspace) -> i915 init ->drm_pci_init->pci_register_driver->bus_add_driver->driver_attach-> which in turn tries all locks on pci bus, and when it tries the one on the audio device, it will deadlock.This patch introduce a work to store remaining probe stuff, and let
request_modulerun in safe work context.Signed-off-by Wang Xingchao <[email protected]>---
sound/pci/hda/hda_i915.c| 13 ++++--sound/pci/hda/hda_intel.c|
105 +++++++++++++++++++++++++++-------------------2 files changed, 71 insertions(+), 47 deletions(-)sound/pci/hda/hda_i915.c index renamed from sound/pci/hda/hda_i915.c +0
-076c13d5..7547b20 100644
sound/pci/hda/hda_i915.c int hda_i915_init(void) { · line 46
Quoted 6 lines
sound/pci/hda/hda_i915.c +1
-2@@ -42,13 +42,18 @@ int hda_i915_init(void) {int err =0 ; - get_power =symbol_request (i915_request_power_well); + get_power =symbol_get (i915_request_power_well);if (!get_power) { - snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
sound/pci/hda/hda_i915.c int hda_i915_init(void)
Quoted 5 lines
sound/pci/hda/hda_i915.c +4
-1-return -ENODEV ; +request_module ("i915" ); + get_power =symbol_get (i915_request_power_well); + if (!get_power) { + snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
Quoted 6 lines
sound/pci/hda/hda_i915.c int hda_i915_init(void) · line 53
Quoted 3 lines
sound/pci/hda/hda_i915.c +3
-0+return -ENODEV ; + } +snd_printdd ("hda-i915: get_power symbol get successful\n" );Why do you need this change?
symbol_request() should be the better API in such case but in my test it doesnot really load i915 module, that's why I call request_module(i915) directly here.
Please note there's parameter difference:request_module("i915") symbol_request(i915_reauest_power_well)-->request_module("symbol:i915_request_power_well")
I donot know why the second one did not really load the module.
Thanks
--xingchao
At Thu, 23 May 2013 10:19:27 +0000,
Quoted 58 lines · Xingchao
Hi Takashi,
Quoted 48 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, May 23, 2013 2:49 PM
To: Wang Xingchao
Cc: [email protected]; [email protected]; [email protected]; Girdwood, Liam R; Li, Jocelyn; Wang, Xingchao; Lin, Mengdong
Subject: Re: [PATCH 4/4 V2] ALSA: hda - Continue probe in work context to avoidrequest_moduledeadlockAt Thu, 23 May 2013 09:51:07 +0800,
Quoted 23 lines · Wang Xingchao
There's deadlock when
request_module(i915)inazx_probe. It looks like:device_lock(audio pci device)->azx_probe->module_request(orsymbol_request) -> modprobe (userspace) -> i915 init ->drm_pci_init->pci_register_driver->bus_add_driver->driver_attach-> which in turn tries all locks on pci bus, and when it tries the one on the audio device, it will deadlock.This patch introduce a work to store remaining probe stuff, and let
request_modulerun in safe work context.Signed-off-by Wang Xingchao <[email protected]>---
sound/pci/hda/hda_i915.c| 13 ++++--sound/pci/hda/hda_intel.c|
105 +++++++++++++++++++++++++++-------------------2 files changed, 71 insertions(+), 47 deletions(-)sound/pci/hda/hda_i915.c index renamed from sound/pci/hda/hda_i915.c +0
-076c13d5..7547b20 100644
sound/pci/hda/hda_i915.c int hda_i915_init(void) { · line 46
Quoted 6 lines
sound/pci/hda/hda_i915.c +1
-2@@ -42,13 +42,18 @@ int hda_i915_init(void) {int err =0 ; - get_power =symbol_request (i915_request_power_well); + get_power =symbol_get (i915_request_power_well);if (!get_power) { - snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
sound/pci/hda/hda_i915.c int hda_i915_init(void)
Quoted 5 lines
sound/pci/hda/hda_i915.c +4
-1-return -ENODEV ; +request_module ("i915" ); + get_power =symbol_get (i915_request_power_well); + if (!get_power) { + snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
Quoted 6 lines
sound/pci/hda/hda_i915.c int hda_i915_init(void) · line 53
Quoted 3 lines
sound/pci/hda/hda_i915.c +3
-0+return -ENODEV ; + } +snd_printdd ("hda-i915: get_power symbol get successful\n" );Why do you need this change?
Quoted 8 lines
symbol_request()should be the better API in such case but in my test it doesnot really load i915 module, that's why I callrequest_module(i915)directly here.Please note there's parameter difference:
request_module("i915")symbol_request(i915_reauest_power_well)-->request_module("symbol:i915_request_power_well")I donot know why the second one did not really load the module.
Well, something is really fishy. The patch can't be accepted only because it just works by moon phase...
Takashi
Quoted 84 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, May 23, 2013 6:27 PM
To: Wang, Xingchao
Cc: Wang Xingchao; [email protected]; [email protected]; [email protected]; Girdwood, Liam R; Li, Jocelyn; Lin, Mengdong
Subject: Re: [PATCH 4/4 V2] ALSA: hda - Continue probe in work context to avoidrequest_moduledeadlockAt Thu, 23 May 2013 10:19:27 +0000,
Quoted 49 lines · Xingchao
Hi Takashi,
Quoted 46 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, May 23, 2013 2:49 PM
To: Wang Xingchao
Cc: [email protected]; [email protected]; [email protected]; Girdwood, Liam R; Li, Jocelyn; Wang, Xingchao; Lin, Mengdong
Subject: Re: [PATCH 4/4 V2] ALSA: hda - Continue probe in work context to avoidrequest_moduledeadlockAt Thu, 23 May 2013 09:51:07 +0800,
Quoted 27 lines · Wang Xingchao
There's deadlock when
request_module(i915)inazx_probe. It looks like:device_lock(audio pci device)->azx_probe->module_request(orsymbol_request) -> modprobe (userspace) -> i915 init ->drm_pci_init
->pci_register_driver->bus_add_driver->driver_attach-> which -> in
turn tries all locks on pci bus, and when it tries the one on the audio device, it will deadlock.This patch introduce a work to store remaining probe stuff, and let
request_modulerun in safe work context.Signed-off-by Wang Xingchao <[email protected]>---
sound/pci/hda/hda_i915.c| 13 ++++--sound/pci/hda/hda_intel.c
|
105 +++++++++++++++++++++++++++-------------------2 files changed, 71 insertions(+), 47 deletions(-)sound/pci/hda/hda_i915.c +0
-0index
76c13d5..7547b20 100644sound/pci/hda/hda_i915.c int hda_i915_init(void) { · line 46
Quoted 6 lines
sound/pci/hda/hda_i915.c +1
-2@@ -42,13 +42,18 @@ int hda_i915_init(void) {int err =0 ; - get_power =symbol_request (i915_request_power_well); + get_power =symbol_get (i915_request_power_well);if (!get_power) { - snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
Quoted 5 lines
Quoted 5 lines
sound/pci/hda/hda_i915.c int hda_i915_init(void)
Quoted 5 lines
sound/pci/hda/hda_i915.c +4
-1-return -ENODEV ; +request_module ("i915" ); + get_power =symbol_get (i915_request_power_well); + if (!get_power) { + snd_printk(KERN_WARNING "hda-i915: get_power symbolget
Quoted 10 lines
Quoted 7 lines
fail\n");
sound/pci/hda/hda_i915.c int hda_i915_init(void) · line 53
Quoted 3 lines
sound/pci/hda/hda_i915.c +3
-0+return -ENODEV ; + } +snd_printdd ("hda-i915: get_power symbol get successful\n" );Why do you need this change?
symbol_request()should be the better API in such case but in my test it doesnot really load i915 module, that's why I callrequest_module(i915)directly here.
Quoted 4 lines
Please note there's parameter difference:
request_module("i915")
Quoted 8 lines
symbol_request(i915_reauest_power_well)-->request_module("symbol:i915_
Quoted 3 lines
request_power_well")I donot know why the second one did not really load the module.
Well, something is really fishy. The patch can't be accepted only because it just works by moon phase...
I will continue to figure out the reason it doesnot work. :(
--xingchao
Quoted 85 lines · Xingchao
Quoted 85 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, May 23, 2013 6:27 PM
To: Wang, Xingchao
Cc: Wang Xingchao; [email protected]; [email protected]; [email protected]; Girdwood, Liam R; Li, Jocelyn; Lin, Mengdong
Subject: Re: [PATCH 4/4 V2] ALSA: hda - Continue probe in work context to avoidrequest_moduledeadlockAt Thu, 23 May 2013 10:19:27 +0000,
Quoted 49 lines · Xingchao
Hi Takashi,
Quoted 46 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, May 23, 2013 2:49 PM
To: Wang Xingchao
Cc: [email protected]; [email protected]; [email protected]; Girdwood, Liam R; Li, Jocelyn; Wang, Xingchao; Lin, Mengdong
Subject: Re: [PATCH 4/4 V2] ALSA: hda - Continue probe in work context to avoidrequest_moduledeadlockAt Thu, 23 May 2013 09:51:07 +0800,
Quoted 27 lines · Wang Xingchao
There's deadlock when
request_module(i915)inazx_probe. It looks like:device_lock(audio pci device)->azx_probe->module_request(orsymbol_request) -> modprobe (userspace) -> i915 init ->drm_pci_init
->pci_register_driver->bus_add_driver->driver_attach-> which -> in
turn tries all locks on pci bus, and when it tries the one on the audio device, it will deadlock.This patch introduce a work to store remaining probe stuff, and let
request_modulerun in safe work context.Signed-off-by Wang Xingchao <[email protected]>---
sound/pci/hda/hda_i915.c| 13 ++++--sound/pci/hda/hda_intel.c
|
105 +++++++++++++++++++++++++++-------------------2 files changed, 71 insertions(+), 47 deletions(-)sound/pci/hda/hda_i915.c +0
-0index
76c13d5..7547b20 100644sound/pci/hda/hda_i915.c int hda_i915_init(void) { · line 46
Quoted 6 lines
sound/pci/hda/hda_i915.c +1
-2@@ -42,13 +42,18 @@ int hda_i915_init(void) {int err =0 ; - get_power =symbol_request (i915_request_power_well); + get_power =symbol_get (i915_request_power_well);if (!get_power) { - snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
Quoted 5 lines
Quoted 5 lines
sound/pci/hda/hda_i915.c int hda_i915_init(void)
Quoted 5 lines
sound/pci/hda/hda_i915.c +4
-1-return -ENODEV ; +request_module ("i915" ); + get_power =symbol_get (i915_request_power_well); + if (!get_power) { + snd_printk(KERN_WARNING "hda-i915: get_power symbolget
Quoted 10 lines
Quoted 7 lines
fail\n");
sound/pci/hda/hda_i915.c int hda_i915_init(void) · line 53
Quoted 3 lines
sound/pci/hda/hda_i915.c +3
-0+return -ENODEV ; + } +snd_printdd ("hda-i915: get_power symbol get successful\n" );Why do you need this change?
symbol_request()should be the better API in such case but in my test it doesnot really load i915 module, that's why I callrequest_module(i915)directly here.
Quoted 4 lines
Please note there's parameter difference:
request_module("i915")symbol_request(i915_reauest_power_well)-->request_module("symbol:i915_
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
request_power_well")I donot know why the second one did not really load the module.
Well, something is really fishy. The patch can't be accepted only because it just works by moon phase...
I will continue to figure out the reason it doesnot work. :(
To the rescue!
I've tried to track this down, and I think this is a problem in modprobe with blacklisted modules. I've just emailed the kmod maintainer (with Wang Xingchao in cc) and asked for clarification.
Signature · 2 lines
David Henningsson, Canonical Ltd. https://launchpad.net/~diwic
At Thu, 23 May 2013 19:41:58 +0200,
Quoted 94 lines · David Henningsson
Quoted 92 lines · Xingchao
Quoted 92 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, May 23, 2013 6:27 PM
To: Wang, Xingchao
Cc: Wang Xingchao; [email protected]; [email protected]; [email protected]; Girdwood, Liam R; Li, Jocelyn; Lin, Mengdong
Subject: Re: [PATCH 4/4 V2] ALSA: hda - Continue probe in work context to avoidrequest_moduledeadlockAt Thu, 23 May 2013 10:19:27 +0000,
Quoted 49 lines · Xingchao
Hi Takashi,
Quoted 46 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, May 23, 2013 2:49 PM
To: Wang Xingchao
Cc: [email protected]; [email protected]; [email protected]; Girdwood, Liam R; Li, Jocelyn; Wang, Xingchao; Lin, Mengdong
Subject: Re: [PATCH 4/4 V2] ALSA: hda - Continue probe in work context to avoidrequest_moduledeadlockAt Thu, 23 May 2013 09:51:07 +0800,
Quoted 27 lines · Wang Xingchao
There's deadlock when
request_module(i915)inazx_probe. It looks like:device_lock(audio pci device)->azx_probe->module_request(orsymbol_request) -> modprobe (userspace) -> i915 init ->drm_pci_init
->pci_register_driver->bus_add_driver->driver_attach-> which -> in
turn tries all locks on pci bus, and when it tries the one on the audio device, it will deadlock.This patch introduce a work to store remaining probe stuff, and let
request_modulerun in safe work context.Signed-off-by Wang Xingchao <[email protected]>---
sound/pci/hda/hda_i915.c| 13 ++++--sound/pci/hda/hda_intel.c
|
105 +++++++++++++++++++++++++++-------------------2 files changed, 71 insertions(+), 47 deletions(-)sound/pci/hda/hda_i915.c +0
-0index
76c13d5..7547b20 100644sound/pci/hda/hda_i915.c int hda_i915_init(void) { · line 46
Quoted 6 lines
sound/pci/hda/hda_i915.c +1
-2@@ -42,13 +42,18 @@ int hda_i915_init(void) {int err =0 ; - get_power =symbol_request (i915_request_power_well); + get_power =symbol_get (i915_request_power_well);if (!get_power) { - snd_printk(KERN_WARNING "hda-i915: get_power symbol getfail\n");
Quoted 5 lines
Quoted 5 lines
sound/pci/hda/hda_i915.c int hda_i915_init(void)
Quoted 5 lines
sound/pci/hda/hda_i915.c +4
-1-return -ENODEV ; +request_module ("i915" ); + get_power =symbol_get (i915_request_power_well); + if (!get_power) { + snd_printk(KERN_WARNING "hda-i915: get_power symbolget
Quoted 10 lines
Quoted 7 lines
fail\n");
sound/pci/hda/hda_i915.c int hda_i915_init(void) · line 53
Quoted 3 lines
sound/pci/hda/hda_i915.c +3
-0+return -ENODEV ; + } +snd_printdd ("hda-i915: get_power symbol get successful\n" );Why do you need this change?
symbol_request()should be the better API in such case but in my test it doesnot really load i915 module, that's why I callrequest_module(i915)directly here.
Quoted 4 lines
Please note there's parameter difference:
request_module("i915")symbol_request(i915_reauest_power_well)-->request_module("symbol:i915_
Quoted 3 lines
request_power_well")I donot know why the second one did not really load the module.
Well, something is really fishy. The patch can't be accepted only because it just works by moon phase...
Quoted 7 lines
Quoted 1 line
I will continue to figure out the reason it doesnot work. :(
To the rescue!
I've tried to track this down, and I think this is a problem in modprobe with blacklisted modules. I've just emailed the kmod maintainer (with Wang Xingchao in cc) and asked for clarification.
Thanks for figuring out!
Takashi