提交 4312dc76 编写于 作者: J Johannes Berg 提交者: Paul Mackerras

[POWERPC] make pmf irq_client functions safe against pmf interrupts coming in

This fixes the pmf irq_client functions to be safe against pmf interrupts coming
in while a client is registered/unregistered.
Signed-off-by: NJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: NPaul Mackerras <paulus@samba.org>
上级 368a6ba5
...@@ -871,10 +871,17 @@ int pmf_register_irq_client(struct device_node *target, ...@@ -871,10 +871,17 @@ int pmf_register_irq_client(struct device_node *target,
spin_unlock_irqrestore(&pmf_lock, flags); spin_unlock_irqrestore(&pmf_lock, flags);
if (func == NULL) if (func == NULL)
return -ENODEV; return -ENODEV;
/* guard against manipulations of list */
mutex_lock(&pmf_irq_mutex); 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);
/* guard against pmf_do_irq while changing list */
spin_lock_irqsave(&pmf_lock, flags);
list_add(&client->link, &func->irq_clients); list_add(&client->link, &func->irq_clients);
spin_unlock_irqrestore(&pmf_lock, flags);
client->func = func; client->func = func;
mutex_unlock(&pmf_irq_mutex); mutex_unlock(&pmf_irq_mutex);
...@@ -885,12 +892,19 @@ EXPORT_SYMBOL_GPL(pmf_register_irq_client); ...@@ -885,12 +892,19 @@ 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);
/* guard against manipulations of list */
mutex_lock(&pmf_irq_mutex); mutex_lock(&pmf_irq_mutex);
client->func = NULL; client->func = NULL;
/* guard against pmf_do_irq while changing list */
spin_lock_irqsave(&pmf_lock, flags);
list_del(&client->link); list_del(&client->link);
spin_unlock_irqrestore(&pmf_lock, flags);
if (list_empty(&func->irq_clients)) if (list_empty(&func->irq_clients))
func->dev->handlers->irq_disable(func); func->dev->handlers->irq_disable(func);
mutex_unlock(&pmf_irq_mutex); mutex_unlock(&pmf_irq_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册