tty: release BTM while sleeping in block_til_ready

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>
This commit is contained in:
Arnd Bergmann 2010-06-01 22:53:10 +02:00 committed by Greg Kroah-Hartman
parent b07471fa51
commit e142a31da3
11 changed files with 25 additions and 1 deletions

View 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", printk("block_til_ready blocking: ttys%d, count = %d\n",
info->line, state->count); info->line, state->count);
#endif #endif
tty_unlock();
schedule(); schedule();
tty_lock();
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
remove_wait_queue(&info->open_wait, &wait); remove_wait_queue(&info->open_wait, &wait);

View File

@ -1486,7 +1486,9 @@ ip2_open( PTTY tty, struct file *pFile )
if ( tty_hung_up_p(pFile) || ( pCh->flags & ASYNC_CLOSING )) { if ( tty_hung_up_p(pFile) || ( pCh->flags & ASYNC_CLOSING )) {
if ( pCh->flags & ASYNC_CLOSING ) { if ( pCh->flags & ASYNC_CLOSING ) {
tty_unlock();
schedule(); schedule();
tty_lock();
} }
if ( tty_hung_up_p(pFile) ) { if ( tty_hung_up_p(pFile) ) {
set_current_state( TASK_RUNNING ); set_current_state( TASK_RUNNING );
@ -1548,7 +1550,9 @@ ip2_open( PTTY tty, struct file *pFile )
rc = (( pCh->flags & ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS); rc = (( pCh->flags & ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS);
break; break;
} }
tty_unlock();
schedule(); schedule();
tty_lock();
} }
set_current_state( TASK_RUNNING ); set_current_state( TASK_RUNNING );
remove_wait_queue(&pCh->open_wait, &wait); remove_wait_queue(&pCh->open_wait, &wait);

View File

@ -1786,7 +1786,9 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
tty->name, info->count); tty->name, info->count);
/**/ /**/
#endif #endif
tty_unlock();
schedule(); schedule();
tty_lock();
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
remove_wait_queue(&info->open_wait, &wait); remove_wait_queue(&info->open_wait, &wait);

View File

@ -1365,7 +1365,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
break; break;
} }
tty_unlock();
schedule(); schedule();
tty_lock();
} }
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);

View 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", printk("%s(%d):block_til_ready blocking on %s count=%d\n",
__FILE__,__LINE__, tty->driver->name, port->count ); __FILE__,__LINE__, tty->driver->name, port->count );
tty_unlock();
schedule(); schedule();
tty_lock();
} }
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);

View 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)); DBGINFO(("%s block_til_ready wait\n", tty->driver->name));
tty_unlock();
schedule(); schedule();
tty_lock();
} }
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);

View 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", printk("%s(%d):%s block_til_ready() count=%d\n",
__FILE__,__LINE__, tty->driver->name, port->count ); __FILE__,__LINE__, tty->driver->name, port->count );
tty_unlock();
schedule(); schedule();
tty_lock();
} }
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);

View File

@ -294,7 +294,9 @@ int tty_port_block_til_ready(struct tty_port *port,
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
break; break;
} }
tty_unlock();
schedule(); schedule();
tty_lock();
} }
finish_wait(&port->open_wait, &wait); finish_wait(&port->open_wait, &wait);

View File

@ -1235,7 +1235,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
break; break;
} }
tty_unlock();
schedule(); schedule();
tty_lock();
} }
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(&info->open_wait, &wait); remove_wait_queue(&info->open_wait, &wait);

View 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", printk("block_til_ready blocking: ttys%d, count = %d\n",
info->line, state->count); info->line, state->count);
#endif #endif
tty_unlock();
schedule(); schedule();
tty_lock();
} }
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(&info->open_wait, &wait); remove_wait_queue(&info->open_wait, &wait);

View 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", printk("block_til_ready blocking: ttyS%d, count = %d\n",
info->line, info->count); info->line, info->count);
#endif #endif
tty_unlock();
schedule(); schedule();
tty_lock();
} }
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&info->open_wait, &wait); remove_wait_queue(&info->open_wait, &wait);