[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>
This commit is contained in:
Benjamin Herrenschmidt 2006-06-04 02:51:38 -07:00 committed by Linus Torvalds
parent 6d09bb627d
commit 78b86e579f

View File

@ -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 {
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,
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);
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);