Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ti-st: use worker instead of calling st_int_write in wake up

The wake up method is called with the port lock held. The st_int_write
method calls port->ops->write with tries to acquire the lock again,
causing CPU to wait infinitely. Right way to do is to write data to port
in worker thread.

Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Muhammad Hamza Farooq and committed by
Greg Kroah-Hartman
b05b7c7c f97ef759

+17 -2
+16 -2
drivers/misc/ti-st/st_core.c
··· 460 460 * - TTY layer when write's finished 461 461 * - st_write (in context of the protocol stack) 462 462 */ 463 + static void work_fn_write_wakeup(struct work_struct *work) 464 + { 465 + struct st_data_s *st_gdata = container_of(work, struct st_data_s, 466 + work_write_wakeup); 467 + 468 + st_tx_wakeup((void *)st_gdata); 469 + } 463 470 void st_tx_wakeup(struct st_data_s *st_data) 464 471 { 465 472 struct sk_buff *skb; ··· 819 812 /* don't do an wakeup for now */ 820 813 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 821 814 822 - /* call our internal wakeup */ 823 - st_tx_wakeup((void *)st_gdata); 815 + /* 816 + * schedule the internal wakeup instead of calling directly to 817 + * avoid lockup (port->lock needed in tty->ops->write is 818 + * already taken here 819 + */ 820 + schedule_work(&st_gdata->work_write_wakeup); 824 821 } 825 822 826 823 static void st_tty_flush_buffer(struct tty_struct *tty) ··· 892 881 pr_err("unable to un-register ldisc"); 893 882 return err; 894 883 } 884 + 885 + INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup); 886 + 895 887 *core_data = st_gdata; 896 888 return 0; 897 889 }