diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2006-06-04 05:51:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-05 15:29:16 -0400 |
commit | 78b86e579f11e7d7bd45acd90b6a87cd4b7c5a54 (patch) | |
tree | 2515fd95638aa037a68ed080adfe6759cf28625b | |
parent | 6d09bb627d2470299dfb1af0e6d27fb4aece9196 (diff) |
[PATCH] pmf_register_irq_client() gives sleep with locks held warning
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This fixes request_irq() potentially called from atomic context.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/powerpc/platforms/powermac/pfunc_core.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c index 4baa75b1d36f..f08173b0f065 100644 --- a/arch/powerpc/platforms/powermac/pfunc_core.c +++ b/arch/powerpc/platforms/powermac/pfunc_core.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/spinlock.h> | 12 | #include <linux/spinlock.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/mutex.h> | ||
14 | 15 | ||
15 | #include <asm/semaphore.h> | 16 | #include <asm/semaphore.h> |
16 | #include <asm/prom.h> | 17 | #include <asm/prom.h> |
@@ -546,6 +547,7 @@ struct pmf_device { | |||
546 | 547 | ||
547 | static LIST_HEAD(pmf_devices); | 548 | static LIST_HEAD(pmf_devices); |
548 | static spinlock_t pmf_lock = SPIN_LOCK_UNLOCKED; | 549 | static spinlock_t pmf_lock = SPIN_LOCK_UNLOCKED; |
550 | static DEFINE_MUTEX(pmf_irq_mutex); | ||
549 | 551 | ||
550 | static void pmf_release_device(struct kref *kref) | 552 | static void pmf_release_device(struct kref *kref) |
551 | { | 553 | { |
@@ -864,15 +866,17 @@ int pmf_register_irq_client(struct device_node *target, | |||
864 | 866 | ||
865 | spin_lock_irqsave(&pmf_lock, flags); | 867 | spin_lock_irqsave(&pmf_lock, flags); |
866 | func = __pmf_find_function(target, name, PMF_FLAGS_INT_GEN); | 868 | func = __pmf_find_function(target, name, PMF_FLAGS_INT_GEN); |
867 | if (func == NULL) { | 869 | if (func) |
868 | spin_unlock_irqrestore(&pmf_lock, flags); | 870 | func = pmf_get_function(func); |
871 | spin_unlock_irqrestore(&pmf_lock, flags); | ||
872 | if (func == NULL) | ||
869 | return -ENODEV; | 873 | return -ENODEV; |
870 | } | 874 | mutex_lock(&pmf_irq_mutex); |
871 | if (list_empty(&func->irq_clients)) | 875 | if (list_empty(&func->irq_clients)) |
872 | func->dev->handlers->irq_enable(func); | 876 | func->dev->handlers->irq_enable(func); |
873 | list_add(&client->link, &func->irq_clients); | 877 | list_add(&client->link, &func->irq_clients); |
874 | client->func = func; | 878 | client->func = func; |
875 | spin_unlock_irqrestore(&pmf_lock, flags); | 879 | mutex_unlock(&pmf_irq_mutex); |
876 | 880 | ||
877 | return 0; | 881 | return 0; |
878 | } | 882 | } |
@@ -881,16 +885,16 @@ EXPORT_SYMBOL_GPL(pmf_register_irq_client); | |||
881 | void pmf_unregister_irq_client(struct pmf_irq_client *client) | 885 | void pmf_unregister_irq_client(struct pmf_irq_client *client) |
882 | { | 886 | { |
883 | struct pmf_function *func = client->func; | 887 | struct pmf_function *func = client->func; |
884 | unsigned long flags; | ||
885 | 888 | ||
886 | BUG_ON(func == NULL); | 889 | BUG_ON(func == NULL); |
887 | 890 | ||
888 | spin_lock_irqsave(&pmf_lock, flags); | 891 | mutex_lock(&pmf_irq_mutex); |
889 | client->func = NULL; | 892 | client->func = NULL; |
890 | list_del(&client->link); | 893 | list_del(&client->link); |
891 | if (list_empty(&func->irq_clients)) | 894 | if (list_empty(&func->irq_clients)) |
892 | func->dev->handlers->irq_disable(func); | 895 | func->dev->handlers->irq_disable(func); |
893 | spin_unlock_irqrestore(&pmf_lock, flags); | 896 | mutex_unlock(&pmf_irq_mutex); |
897 | pmf_put_function(func); | ||
894 | } | 898 | } |
895 | EXPORT_SYMBOL_GPL(pmf_unregister_irq_client); | 899 | EXPORT_SYMBOL_GPL(pmf_unregister_irq_client); |
896 | 900 | ||