Skip to content

Commit edaa4d6

Browse files
committed
Merge branch 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: n_gsm: Fix length handling n_gsm: Copy n2 over when configuring via ioctl interface serial: bfin_5xx: grab port lock before making port termios changes serial: bfin_5xx: disable CON_PRINTBUFFER for consoles serial: bfin_5xx: remove redundant SSYNC to improve TX speed serial: bfin_5xx: always include DMA headers vcs: make proper usage of the poll flags amiserial: Remove unused variable icount 8250: Fix tcsetattr to avoid ioctl(TIOCMIWAIT) hang tty_ldisc: Fix BUG() on hangup TTY: restore tty_ldisc_wait_idle SERIAL: blacklist si3052 chip drivers/serial/bfin_5xx.c: Fix line continuation defects tty: prevent DOS in the flush_to_ldisc 8250: add support for Kouwell KW-L221N-2 nozomi: Fix warning from the previous TIOCGCOUNT changes tty: fix warning in synclink driver tty: Fix formatting in tty.h tty: the development tree is now done in git
2 parents 891cbd3 + 40e3465 commit edaa4d6

File tree

12 files changed

+94
-30
lines changed

12 files changed

+94
-30
lines changed

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ M: Greg Kroah-Hartman <[email protected]>
161161
162162
W: http://serial.sourceforge.net
163163
S: Maintained
164-
T: quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
164+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6.git
165165
F: drivers/serial/8250*
166166
F: include/linux/serial_8250.h
167167

@@ -5910,7 +5910,7 @@ S: Maintained
59105910
TTY LAYER
59115911
M: Greg Kroah-Hartman <[email protected]>
59125912
S: Maintained
5913-
T: quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
5913+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6.git
59145914
F: drivers/char/tty_*
59155915
F: drivers/serial/serial_core.c
59165916
F: include/linux/serial_core.h

drivers/char/amiserial.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
12991299
{
13001300
struct async_struct * info = tty->driver_data;
13011301
struct async_icount cprev, cnow; /* kernel counter temps */
1302-
struct serial_icounter_struct icount;
13031302
void __user *argp = (void __user *)arg;
13041303
unsigned long flags;
13051304

drivers/char/nozomi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,6 @@ static int ntty_ioctl(struct tty_struct *tty, struct file *file,
18281828
unsigned int cmd, unsigned long arg)
18291829
{
18301830
struct port *port = tty->driver_data;
1831-
void __user *argp = (void __user *)arg;
18321831
int rval = -ENOIOCTLCMD;
18331832

18341833
DBG1("******** IOCTL, cmd: %d", cmd);

drivers/char/pcmcia/synclink_cs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,6 +2796,7 @@ static const struct tty_operations mgslpc_ops = {
27962796
.hangup = mgslpc_hangup,
27972797
.tiocmget = tiocmget,
27982798
.tiocmset = tiocmset,
2799+
.get_icount = mgslpc_get_icount,
27992800
.proc_fops = &mgslpc_proc_fops,
28002801
};
28012802

drivers/serial/8250.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2343,8 +2343,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
23432343

23442344
/*
23452345
* CTS flow control flag and modem status interrupts
2346+
* Only disable MSI if no threads are waiting in
2347+
* serial_core::uart_wait_modem_status
23462348
*/
2347-
up->ier &= ~UART_IER_MSI;
2349+
if (!waitqueue_active(&up->port.state->port.delta_msr_wait))
2350+
up->ier &= ~UART_IER_MSI;
23482351
if (!(up->bugs & UART_BUG_NOMSR) &&
23492352
UART_ENABLE_MS(&up->port, termios->c_cflag))
23502353
up->ier |= UART_IER_MSI;

drivers/serial/8250_pci.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,8 @@ static struct pciserial_board pci_boards[] __devinitdata = {
22852285

22862286
static const struct pci_device_id softmodem_blacklist[] = {
22872287
{ PCI_VDEVICE(AL, 0x5457), }, /* ALi Corporation M5457 AC'97 Modem */
2288+
{ PCI_VDEVICE(MOTOROLA, 0x3052), }, /* Motorola Si3052-based modem */
2289+
{ PCI_DEVICE(0x1543, 0x3052), }, /* Si3052-based modem, default IDs */
22882290
};
22892291

22902292
/*
@@ -2863,6 +2865,9 @@ static struct pci_device_id serial_pci_tbl[] = {
28632865
PCI_SUBVENDOR_ID_SIIG, PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL,
28642866
0, 0,
28652867
pbn_b0_4_1152000 },
2868+
{ PCI_VENDOR_ID_OXSEMI, 0x9505,
2869+
PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2870+
pbn_b0_bt_2_921600 },
28662871

28672872
/*
28682873
* The below card is a little controversial since it is the

drivers/serial/bfin_5xx.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/tty.h>
2424
#include <linux/tty_flip.h>
2525
#include <linux/serial_core.h>
26+
#include <linux/dma-mapping.h>
2627

2728
#if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \
2829
defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE)
@@ -33,12 +34,10 @@
3334
#include <asm/gpio.h>
3435
#include <mach/bfin_serial_5xx.h>
3536

36-
#ifdef CONFIG_SERIAL_BFIN_DMA
37-
#include <linux/dma-mapping.h>
37+
#include <asm/dma.h>
3838
#include <asm/io.h>
3939
#include <asm/irq.h>
4040
#include <asm/cacheflush.h>
41-
#endif
4241

4342
#ifdef CONFIG_SERIAL_BFIN_MODULE
4443
# undef CONFIG_EARLY_PRINTK
@@ -360,7 +359,6 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart)
360359
UART_PUT_CHAR(uart, xmit->buf[xmit->tail]);
361360
xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
362361
uart->port.icount.tx++;
363-
SSYNC();
364362
}
365363

366364
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
@@ -688,6 +686,13 @@ static int bfin_serial_startup(struct uart_port *port)
688686

689687
# ifdef CONFIG_BF54x
690688
{
689+
/*
690+
* UART2 and UART3 on BF548 share interrupt PINs and DMA
691+
* controllers with SPORT2 and SPORT3. UART rx and tx
692+
* interrupts are generated in PIO mode only when configure
693+
* their peripheral mapping registers properly, which means
694+
* request corresponding DMA channels in PIO mode as well.
695+
*/
691696
unsigned uart_dma_ch_rx, uart_dma_ch_tx;
692697

693698
switch (uart->port.irq) {
@@ -734,8 +739,7 @@ static int bfin_serial_startup(struct uart_port *port)
734739
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
735740
IRQF_DISABLED, "BFIN_UART_CTS", uart)) {
736741
uart->cts_pin = -1;
737-
pr_info("Unable to attach BlackFin UART CTS interrupt.\
738-
So, disable it.\n");
742+
pr_info("Unable to attach BlackFin UART CTS interrupt. So, disable it.\n");
739743
}
740744
}
741745
if (uart->rts_pin >= 0) {
@@ -747,8 +751,7 @@ static int bfin_serial_startup(struct uart_port *port)
747751
if (request_irq(uart->status_irq,
748752
bfin_serial_mctrl_cts_int,
749753
IRQF_DISABLED, "BFIN_UART_MODEM_STATUS", uart)) {
750-
pr_info("Unable to attach BlackFin UART Modem \
751-
Status interrupt.\n");
754+
pr_info("Unable to attach BlackFin UART Modem Status interrupt.\n");
752755
}
753756

754757
/* CTS RTS PINs are negative assertive. */
@@ -846,6 +849,8 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
846849
if (termios->c_cflag & CMSPAR)
847850
lcr |= STP;
848851

852+
spin_lock_irqsave(&uart->port.lock, flags);
853+
849854
port->read_status_mask = OE;
850855
if (termios->c_iflag & INPCK)
851856
port->read_status_mask |= (FE | PE);
@@ -875,8 +880,6 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
875880
if (termios->c_line != N_IRDA)
876881
quot -= ANOMALY_05000230;
877882

878-
spin_lock_irqsave(&uart->port.lock, flags);
879-
880883
UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
881884

882885
/* Disable UART */
@@ -1321,6 +1324,14 @@ struct console __init *bfin_earlyserial_init(unsigned int port,
13211324
struct bfin_serial_port *uart;
13221325
struct ktermios t;
13231326

1327+
#ifdef CONFIG_SERIAL_BFIN_CONSOLE
1328+
/*
1329+
* If we are using early serial, don't let the normal console rewind
1330+
* log buffer, since that causes things to be printed multiple times
1331+
*/
1332+
bfin_serial_console.flags &= ~CON_PRINTBUFFER;
1333+
#endif
1334+
13241335
if (port == -1 || port >= nr_active_ports)
13251336
port = 0;
13261337
bfin_serial_init_ports();

drivers/tty/n_gsm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
716716
if (msg->len < 128)
717717
*--dp = (msg->len << 1) | EA;
718718
else {
719-
*--dp = (msg->len >> 6) | EA;
720-
*--dp = (msg->len & 127) << 1;
719+
*--dp = ((msg->len & 127) << 1) | EA;
720+
*--dp = (msg->len >> 6) & 0xfe;
721721
}
722722
}
723723

@@ -2375,6 +2375,7 @@ static int gsmld_config(struct tty_struct *tty, struct gsm_mux *gsm,
23752375
gsm->mru = c->mru;
23762376
gsm->encoding = c->encapsulation;
23772377
gsm->adaption = c->adaption;
2378+
gsm->n2 = c->n2;
23782379

23792380
if (c->i == 1)
23802381
gsm->ftype = UIH;

drivers/tty/tty_buffer.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ static void flush_to_ldisc(struct work_struct *work)
413413
spin_lock_irqsave(&tty->buf.lock, flags);
414414

415415
if (!test_and_set_bit(TTY_FLUSHING, &tty->flags)) {
416-
struct tty_buffer *head;
416+
struct tty_buffer *head, *tail = tty->buf.tail;
417+
int seen_tail = 0;
417418
while ((head = tty->buf.head) != NULL) {
418419
int count;
419420
char *char_buf;
@@ -423,6 +424,15 @@ static void flush_to_ldisc(struct work_struct *work)
423424
if (!count) {
424425
if (head->next == NULL)
425426
break;
427+
/*
428+
There's a possibility tty might get new buffer
429+
added during the unlock window below. We could
430+
end up spinning in here forever hogging the CPU
431+
completely. To avoid this let's have a rest each
432+
time we processed the tail buffer.
433+
*/
434+
if (tail == head)
435+
seen_tail = 1;
426436
tty->buf.head = head->next;
427437
tty_buffer_free(tty, head);
428438
continue;
@@ -432,7 +442,7 @@ static void flush_to_ldisc(struct work_struct *work)
432442
line discipline as we want to empty the queue */
433443
if (test_bit(TTY_FLUSHPENDING, &tty->flags))
434444
break;
435-
if (!tty->receive_room) {
445+
if (!tty->receive_room || seen_tail) {
436446
schedule_delayed_work(&tty->buf.work, 1);
437447
break;
438448
}

drivers/tty/tty_ldisc.c

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
static DEFINE_SPINLOCK(tty_ldisc_lock);
4949
static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait);
50+
static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_idle);
5051
/* Line disc dispatch table */
5152
static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
5253

@@ -83,6 +84,7 @@ static void put_ldisc(struct tty_ldisc *ld)
8384
return;
8485
}
8586
local_irq_restore(flags);
87+
wake_up(&tty_ldisc_idle);
8688
}
8789

8890
/**
@@ -530,6 +532,23 @@ static int tty_ldisc_halt(struct tty_struct *tty)
530532
return cancel_delayed_work_sync(&tty->buf.work);
531533
}
532534

535+
/**
536+
* tty_ldisc_wait_idle - wait for the ldisc to become idle
537+
* @tty: tty to wait for
538+
*
539+
* Wait for the line discipline to become idle. The discipline must
540+
* have been halted for this to guarantee it remains idle.
541+
*/
542+
static int tty_ldisc_wait_idle(struct tty_struct *tty)
543+
{
544+
int ret;
545+
ret = wait_event_interruptible_timeout(tty_ldisc_idle,
546+
atomic_read(&tty->ldisc->users) == 1, 5 * HZ);
547+
if (ret < 0)
548+
return ret;
549+
return ret > 0 ? 0 : -EBUSY;
550+
}
551+
533552
/**
534553
* tty_set_ldisc - set line discipline
535554
* @tty: the terminal to set
@@ -634,8 +653,17 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
634653

635654
flush_scheduled_work();
636655

656+
retval = tty_ldisc_wait_idle(tty);
657+
637658
tty_lock();
638659
mutex_lock(&tty->ldisc_mutex);
660+
661+
/* handle wait idle failure locked */
662+
if (retval) {
663+
tty_ldisc_put(new_ldisc);
664+
goto enable;
665+
}
666+
639667
if (test_bit(TTY_HUPPED, &tty->flags)) {
640668
/* We were raced by the hangup method. It will have stomped
641669
the ldisc data and closed the ldisc down */
@@ -669,6 +697,7 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
669697

670698
tty_ldisc_put(o_ldisc);
671699

700+
enable:
672701
/*
673702
* Allow ldisc referencing to occur again
674703
*/
@@ -714,20 +743,23 @@ static void tty_reset_termios(struct tty_struct *tty)
714743
* state closed
715744
*/
716745

717-
static void tty_ldisc_reinit(struct tty_struct *tty, int ldisc)
746+
static int tty_ldisc_reinit(struct tty_struct *tty, int ldisc)
718747
{
719-
struct tty_ldisc *ld;
748+
struct tty_ldisc *ld = tty_ldisc_get(ldisc);
749+
750+
if (IS_ERR(ld))
751+
return -1;
720752

721753
tty_ldisc_close(tty, tty->ldisc);
722754
tty_ldisc_put(tty->ldisc);
723755
tty->ldisc = NULL;
724756
/*
725757
* Switch the line discipline back
726758
*/
727-
ld = tty_ldisc_get(ldisc);
728-
BUG_ON(IS_ERR(ld));
729759
tty_ldisc_assign(tty, ld);
730760
tty_set_termios_ldisc(tty, ldisc);
761+
762+
return 0;
731763
}
732764

733765
/**
@@ -802,13 +834,16 @@ void tty_ldisc_hangup(struct tty_struct *tty)
802834
a FIXME */
803835
if (tty->ldisc) { /* Not yet closed */
804836
if (reset == 0) {
805-
tty_ldisc_reinit(tty, tty->termios->c_line);
806-
err = tty_ldisc_open(tty, tty->ldisc);
837+
838+
if (!tty_ldisc_reinit(tty, tty->termios->c_line))
839+
err = tty_ldisc_open(tty, tty->ldisc);
840+
else
841+
err = 1;
807842
}
808843
/* If the re-open fails or we reset then go to N_TTY. The
809844
N_TTY open cannot fail */
810845
if (reset || err) {
811-
tty_ldisc_reinit(tty, N_TTY);
846+
BUG_ON(tty_ldisc_reinit(tty, N_TTY));
812847
WARN_ON(tty_ldisc_open(tty, tty->ldisc));
813848
}
814849
tty_ldisc_enable(tty);

0 commit comments

Comments
 (0)