]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
tty: release BTM while sleeping in block_til_ready
authorArnd Bergmann <arnd@arndb.de>
Tue, 1 Jun 2010 20:53:10 +0000 (22:53 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 10 Aug 2010 20:47:44 +0000 (13:47 -0700)
Most tty drivers may block while opening a device.
Since this possibly depends on another thread
closing it first and both threads may need the BTM,
we need to release it here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/char/amiserial.c
drivers/char/ip2/ip2main.c
drivers/char/serial167.c
drivers/char/specialix.c
drivers/char/synclink.c
drivers/char/synclink_gt.c
drivers/char/synclinkmp.c
drivers/char/tty_port.c
drivers/serial/68328serial.c
drivers/serial/68360serial.c
drivers/serial/crisv10.c

index 8228e61bb54df1cf84fa3f452ba0deddcd0307ba..a11c8c9ca3d4b858029205f9a265b6ee96b04fdb 100644 (file)
@@ -1710,7 +1710,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
                printk("block_til_ready blocking: ttys%d, count = %d\n",
                       info->line, state->count);
 #endif
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        __set_current_state(TASK_RUNNING);
        remove_wait_queue(&info->open_wait, &wait);
index 911e1da6def225af3163809bd2eeaec394931ab4..07f3ea38b5828eda0a16ceed8b23fdbdee891d79 100644 (file)
@@ -1486,7 +1486,9 @@ ip2_open( PTTY tty, struct file *pFile )
 
        if ( tty_hung_up_p(pFile) || ( pCh->flags & ASYNC_CLOSING )) {
                if ( pCh->flags & ASYNC_CLOSING ) {
+                       tty_unlock();
                        schedule();
+                       tty_lock();
                }
                if ( tty_hung_up_p(pFile) ) {
                        set_current_state( TASK_RUNNING );
@@ -1548,7 +1550,9 @@ ip2_open( PTTY tty, struct file *pFile )
                        rc = (( pCh->flags & ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS);
                        break;
                }
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        set_current_state( TASK_RUNNING );
        remove_wait_queue(&pCh->open_wait, &wait);
index 90b3ec0aabdd691f1efaac7d3f76492a9292ac53..f646725bd567ec279541dd968e9a1653746035fe 100644 (file)
@@ -1786,7 +1786,9 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
                       tty->name, info->count);
                /**/
 #endif
-                   schedule();
+               tty_unlock();
+               schedule();
+               tty_lock();
        }
        __set_current_state(TASK_RUNNING);
        remove_wait_queue(&info->open_wait, &wait);
index 7be456f760c927e77a0062b5064fe87c2596402b..9f8495b4fc8f5d648529d9c57950718bf11e8fd0 100644 (file)
@@ -1365,7 +1365,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
                        retval = -ERESTARTSYS;
                        break;
                }
+               tty_unlock();
                schedule();
+               tty_lock();
        }
 
        set_current_state(TASK_RUNNING);
index 2b03d4d473505a6808612598007fd6cb2ac77871..a2a58004e188eaf2a3be13909c735b7b2a8b39d1 100644 (file)
@@ -3349,7 +3349,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
                        printk("%s(%d):block_til_ready blocking on %s count=%d\n",
                                 __FILE__,__LINE__, tty->driver->name, port->count );
                                 
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        
        set_current_state(TASK_RUNNING);
index 5a602eb7cd2d9c8a5789f5bae59ad147b1dcd873..fef80cfcab5c8caf231b4435d423095dfb90815e 100644 (file)
@@ -3244,7 +3244,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
                }
 
                DBGINFO(("%s block_til_ready wait\n", tty->driver->name));
+               tty_unlock();
                schedule();
+               tty_lock();
        }
 
        set_current_state(TASK_RUNNING);
index ac447c7eb572a4f20bbdf51d82f27377fa3cb1e4..e56caf7d82aaaa5e679e6835784ac7714f1cf864 100644 (file)
@@ -3365,7 +3365,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
                        printk("%s(%d):%s block_til_ready() count=%d\n",
                                 __FILE__,__LINE__, tty->driver->name, port->count );
 
+               tty_unlock();
                schedule();
+               tty_lock();
        }
 
        set_current_state(TASK_RUNNING);
index 35eb30402f1889c4e7778e50c96463c652976075..33d37d230f8f4335ee9d85336bcb3816c6e968f0 100644 (file)
@@ -294,7 +294,9 @@ int tty_port_block_til_ready(struct tty_port *port,
                        retval = -ERESTARTSYS;
                        break;
                }
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        finish_wait(&port->open_wait, &wait);
 
index 9330edb323e2475bf26bcddb17ca893be58da771..d8204f4ebbb40d05bd2ab7a921206a70856af6c3 100644 (file)
@@ -1235,7 +1235,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
                        retval = -ERESTARTSYS;
                        break;
                }
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        current->state = TASK_RUNNING;
        remove_wait_queue(&info->open_wait, &wait);
index edcf1cc089d11edccbd1f4e82d40617db3b570ff..0dff3bbddc8b34eb98136380ba909f8009fd3f24 100644 (file)
@@ -1860,7 +1860,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
                printk("block_til_ready blocking: ttys%d, count = %d\n",
                       info->line, state->count);
 #endif
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        current->state = TASK_RUNNING;
        remove_wait_queue(&info->open_wait, &wait);
index 8e356c5eeae0e826b569e188ab1fa0f50b2efeb4..5696710b6f2dd133e69fc42f1ad0e117d48a9af5 100644 (file)
@@ -4066,7 +4066,9 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
                printk("block_til_ready blocking: ttyS%d, count = %d\n",
                       info->line, info->count);
 #endif
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&info->open_wait, &wait);