提交 78b86e57 编写于 作者: B Benjamin Herrenschmidt 提交者: Linus Torvalds

[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: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 6d09bb62
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/prom.h> #include <asm/prom.h>
...@@ -546,6 +547,7 @@ struct pmf_device { ...@@ -546,6 +547,7 @@ struct pmf_device {
static LIST_HEAD(pmf_devices); static LIST_HEAD(pmf_devices);
static spinlock_t pmf_lock = SPIN_LOCK_UNLOCKED; static spinlock_t pmf_lock = SPIN_LOCK_UNLOCKED;
static DEFINE_MUTEX(pmf_irq_mutex);
static void pmf_release_device(struct kref *kref) static void pmf_release_device(struct kref *kref)
{ {
...@@ -864,15 +866,17 @@ int pmf_register_irq_client(struct device_node *target, ...@@ -864,15 +866,17 @@ int pmf_register_irq_client(struct device_node *target,
spin_lock_irqsave(&pmf_lock, flags); spin_lock_irqsave(&pmf_lock, flags);
func = __pmf_find_function(target, name, PMF_FLAGS_INT_GEN); func = __pmf_find_function(target, name, PMF_FLAGS_INT_GEN);
if (func == NULL) { if (func)
spin_unlock_irqrestore(&pmf_lock, flags); func = pmf_get_function(func);
spin_unlock_irqrestore(&pmf_lock, flags);
if (func == NULL)
return -ENODEV; return -ENODEV;
} mutex_lock(&pmf_irq_mutex);
if (list_empty(&func->irq_clients)) if (list_empty(&func->irq_clients))
func->dev->handlers->irq_enable(func); func->dev->handlers->irq_enable(func);
list_add(&client->link, &func->irq_clients); list_add(&client->link, &func->irq_clients);
client->func = func; client->func = func;
spin_unlock_irqrestore(&pmf_lock, flags); mutex_unlock(&pmf_irq_mutex);
return 0; return 0;
} }
...@@ -881,16 +885,16 @@ EXPORT_SYMBOL_GPL(pmf_register_irq_client); ...@@ -881,16 +885,16 @@ EXPORT_SYMBOL_GPL(pmf_register_irq_client);
void pmf_unregister_irq_client(struct pmf_irq_client *client) void pmf_unregister_irq_client(struct pmf_irq_client *client)
{ {
struct pmf_function *func = client->func; struct pmf_function *func = client->func;
unsigned long flags;
BUG_ON(func == NULL); BUG_ON(func == NULL);
spin_lock_irqsave(&pmf_lock, flags); mutex_lock(&pmf_irq_mutex);
client->func = NULL; client->func = NULL;
list_del(&client->link); list_del(&client->link);
if (list_empty(&func->irq_clients)) if (list_empty(&func->irq_clients))
func->dev->handlers->irq_disable(func); func->dev->handlers->irq_disable(func);
spin_unlock_irqrestore(&pmf_lock, flags); mutex_unlock(&pmf_irq_mutex);
pmf_put_function(func);
} }
EXPORT_SYMBOL_GPL(pmf_unregister_irq_client); EXPORT_SYMBOL_GPL(pmf_unregister_irq_client);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册