Patchwork [RFC,1/3] hvc_console: rework setup to replace irq functions with callbacks

login
register
mail settings
Submitter Christian Borntraeger
Date Oct. 13, 2008, 7:51 a.m.
Message ID <200810130951.31733.borntraeger@de.ibm.com>
Download mbox | patch
Permalink /patch/4387/
State Accepted
Commit eef2622a9fcfa964073333ea72c7c9cd20ad45e6
Headers show

Comments

Christian Borntraeger - Oct. 13, 2008, 7:51 a.m.
Am Montag, 13. Oktober 2008 schrieb Benjamin Herrenschmidt:
>   ... key      at: [<c000000000939018>] proc_subdir_lock+0x18/0x38
>  ... acquired at:
>    [<c0000000000832e8>] .__lock_acquire+0x814/0x8ec
>    [<c000000000083464>] .lock_acquire+0xa4/0xec
>    [<c0000000004e713c>] ._spin_lock+0x44/0xa0
>    [<c000000000139144>] .xlate_proc_name+0x50/0xf8
>    [<c0000000001392f4>] .remove_proc_entry+0x44/0x298
>    [<c0000000000a1e74>] .unregister_handler_proc+0x40/0x58
>    [<c00000000009fc58>] .free_irq+0x124/0x18c
>    [<c0000000002e6634>] .notifier_del_irq+0x28/0x48
>    [<c0000000002e5ddc>] .hvc_close+0xa0/0x110
>    [<c0000000002cc328>] .release_dev+0x244/0x580
>    [<c0000000002cc688>] .tty_release+0x24/0x44
>    [<c0000000000e5384>] .__fput+0xf8/0x1dc
>    [<c0000000000e1bec>] .filp_close+0xb4/0xdc
>    [<c0000000000e33a4>] .sys_close+0xac/0x100
>    [<c0000000000084d4>] syscall_exit+0x0/0x40


Hmmm. 
Can you try if this patch fixes the lockdep trace?

This would be analog to
commit b1b135c8d619cb2c7045d6ee4e48375882518bb5
Author: Christian Borntraeger <borntraeger@de.ibm.com>
Date:   Thu Aug 7 09:18:34 2008 +0200

    fix spinlock recursion in hvc_console

    commit 611e097d7707741a336a0677d9d69bec40f29f3d
    Author: Christian Borntraeger <borntraeger@de.ibm.com>
    hvc_console: rework setup to replace irq functions with callbacks
    introduced a spinlock recursion problem.


Signed-off-by: Christian Borntraeger<borntraeger@de.ibm.com>
---
 drivers/char/hvc_console.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Christian Borntraeger - Oct. 14, 2008, 6:42 a.m.
Am Dienstag, 14. Oktober 2008 schrieb Benjamin Herrenschmidt:
> 
> > Hmmm. 
> > Can you try if this patch fixes the lockdep trace?
> 
> Yup, the patch fixes it, I'll commit it via the powerpc.git tree if you
> don't have any objection.

Sure, go ahead.
Benjamin Herrenschmidt - Oct. 14, 2008, 8:18 a.m.
On Tue, 2008-10-14 at 08:42 +0200, Christian Borntraeger wrote:
> Am Dienstag, 14. Oktober 2008 schrieb Benjamin Herrenschmidt:
> > 
> > > Hmmm. 
> > > Can you try if this patch fixes the lockdep trace?
> > 
> > Yup, the patch fixes it, I'll commit it via the powerpc.git tree if you
> > don't have any objection.
> 
> Sure, go ahead.

Allright, I have a batch about ready to go to Linus, so I'll add that
and ask him to pull tomorrow.

Thanks,
Ben.

Patch

Index: linux-2.6/drivers/char/hvc_console.c
===================================================================
--- linux-2.6.orig/drivers/char/hvc_console.c
+++ linux-2.6/drivers/char/hvc_console.c
@@ -367,13 +367,13 @@  static void hvc_close(struct tty_struct 
 	spin_lock_irqsave(&hp->lock, flags);
 
 	if (--hp->count == 0) {
-		if (hp->ops->notifier_del)
-			hp->ops->notifier_del(hp, hp->data);
-
 		/* We are done with the tty pointer now. */
 		hp->tty = NULL;
 		spin_unlock_irqrestore(&hp->lock, flags);
 
+		if (hp->ops->notifier_del)
+			hp->ops->notifier_del(hp, hp->data);
+
 		/*
 		 * Chain calls chars_in_buffer() and returns immediately if
 		 * there is no buffered data otherwise sleeps on a wait queue
@@ -416,11 +416,11 @@  static void hvc_hangup(struct tty_struct
 	hp->n_outbuf = 0;
 	hp->tty = NULL;
 
+	spin_unlock_irqrestore(&hp->lock, flags);
+
 	if (hp->ops->notifier_del)
 			hp->ops->notifier_del(hp, hp->data);
 
-	spin_unlock_irqrestore(&hp->lock, flags);
-
 	while(temp_open_count) {
 		--temp_open_count;
 		kref_put(&hp->kref, destroy_hvc_struct);