linux-stable/drivers/serial
Atsushi Nemoto 27c0c8e511 atmel_serial might lose modem status change
I found a problem of handling of modem status of atmel_serial driver.

With the commit 1ecc26 ("atmel_serial: split the interrupt handler"),
handling of modem status signal was splitted into two parts.  The
atmel_tasklet_func() compares new status with irq_status_prev, but
irq_status_prev is not correct if signal status was changed while the port
is closed.

Here is a sequence to cause problem:

1. Remote side sets CTS (and DSR).
2. Local side close the port.
3. Local side clears RTS and DTR.
4. Remote side clears CTS and DSR.
5. Local side reopen the port.  hw_stopped becomes 1.
6. Local side sets RTS and DTR.
7. Remote side sets CTS and DSR.

Then CTS change interrupt can be received, but since CTS bit in
irq_status_prev and new status is same, uart_handle_cts_change() will not
be called (so hw_stopped will not be cleared, i.e.  cannot send any data).

I suppose irq_status_prev should be initialized at somewhere in open
sequence.

Itai Levi pointed out that we need to initialize atmel_port->irq_status
as well here. His analysis is as follows:

> Regarding the second part of the patch (which resets irq_status_prev),
> it turns out that both versions of the patch (mine and Atsushi's)
> still leave enough room for faulty behavior when opening the port.
>
> This is because we are not resetting both irq_status_prev and
> irq_status in atmel_startup() to CSR, which leads faulty behavior in
> the following sequences:
>
> First case:
> 1. closing the port while CTS line = 1 (TX not allowed)
> 2. setting CTS line = 0 (TX allowed)
> 3. opening the port
> 4. transmitting one char
> 5. Cannot transmit more chars, although CTS line is 0
>
> Second case:
> 1. closing the port while CTS line = 0 (TX allowed)
> 2. setting CTS line = 1 (TX not allowed)
> 3. opening the port
> 4. receiving some chars
> 5. Now we can transmit, although CTS line is 1
>
> This reason for this is that the tasklet is scheduled as a result of
> TX or RX interrupts (not a status change!), in steps 4 above. Inside
> the tasklet, the atmel_port->irq_status (which holds the value from
> the previous session) is compared to atmel_port->irq_status_prev.
> Hence, a status-change of the CTS line is faultily detected.
>
> Both cases were verified on 9260 hardware.

[haavard.skinnemoen@atmel.com: folded with patch from Itai Levi]
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Cc: Remy Bohmer <linux@bohmer.net>
Cc: Marc Pignat <marc.pignat@hevs.ch>
Cc: Itai Levi <itai.levi.devel@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-02-18 15:37:55 -08:00
..
cpm_uart Merge branch 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-20 13:23:01 -07:00
jsm Add enable_ms to jsm driver 2009-01-30 08:40:54 -08:00
8250.c fix early_serial_setup() regression 2009-01-13 14:03:43 -08:00
8250.h 8250: improve workaround for UARTs that don't re-assert THRE correctly 2008-09-02 19:21:38 -07:00
8250_accent.c
8250_acorn.c
8250_boca.c
8250_early.c
8250_exar_st16c554.c
8250_fourport.c
8250_gsc.c make probe_serial_gsc() static 2008-10-20 08:52:36 -07:00
8250_hp300.c
8250_hub6.c
8250_mca.c
8250_pci.c Add support for '8-port RS-232 MIC-3620 from advantech' 2009-01-27 07:37:15 -08:00
8250_pnp.c serial: Add SupraExpress 336i PnP Voice Modem 2009-01-15 12:48:36 -08:00
21285.c [ARM] Move include/asm-arm/arch-* to arch/arm/*/include/mach 2008-08-07 09:55:48 +01:00
68328serial.c serial, 8250: remove NR_IRQ usage 2008-10-16 16:52:02 +02:00
68328serial.h
68360serial.c Fix compile errors in SGI console drivers (linux-next tree) 2008-07-20 17:12:36 -07:00
amba-pl010.c [ARM] amba drivers: don't pass a consumer clock name for devices with unique clocks 2008-11-30 17:38:14 +00:00
amba-pl011.c [ARM] amba drivers: don't pass a consumer clock name for devices with unique clocks 2008-11-30 17:38:14 +00:00
atmel_serial.c atmel_serial might lose modem status change 2009-02-18 15:37:55 -08:00
bfin_5xx.c Blackfin Serial Driver: Remove BI status for known_good_char 2009-01-02 10:19:35 -08:00
bfin_sport_uart.c __FUNCTION__ is gcc-specific, use __func__ 2009-01-02 10:19:42 -08:00
bfin_sport_uart.h
clps711x.c [ARM] Move include/asm-arm/arch-* to arch/arm/*/include/mach 2008-08-07 09:55:48 +01:00
crisv10.c trivial: fix then -> than typos in comments and documentation 2009-01-06 11:28:06 +01:00
crisv10.h [CRIS] Move header files from include to arch/cris/include. 2008-10-29 17:29:44 +01:00
dz.c serial: DZ11: avoid a hang at console switch-over 2008-07-24 10:47:29 -07:00
dz.h
icom.c ttydev: Fix up compile failures in the PPC build 2008-07-22 13:03:22 -07:00
icom.h
imx.c [ARM] MXC: remove dependency to other include files from irqs.h 2008-12-18 16:40:11 +01:00
ioc3_serial.c [IA64] Fix section mismatch ioc3uart_init()/ioc3uart_submodule 2008-12-09 10:08:51 -08:00
ioc4_serial.c Fix compile errors in SGI console drivers (linux-next tree) 2008-07-20 17:12:36 -07:00
ip22zilog.c Fix compile errors in SGI console drivers (linux-next tree) 2008-07-20 17:12:36 -07:00
ip22zilog.h
Kconfig MIPS: enable serial UART support on PNX833X devices. 2009-01-27 07:37:15 -08:00
kgdboc.c
m32r_sio.c drivers/serial: use nr_irqs 2008-10-16 16:52:06 +02:00
m32r_sio.h
m32r_sio_reg.h
Makefile serial: Add driver for the Cell Network Processor serial port NWP device 2009-01-08 16:25:18 +11:00
mcf.c m68knommu: fix ColdFire 5272 serial baud rates in mcf.c 2009-01-27 16:42:00 +10:00
mpc52xx_uart.c powerpc/mpc5200: fix error paths in PSC UART probe function 2008-12-21 02:54:32 -07:00
mpsc.c kgdb: kgdboc console poll hooks for mpsc uart 2008-07-23 11:30:16 -05:00
mux.c Fix compile errors in SGI console drivers (linux-next tree) 2008-07-20 17:12:36 -07:00
netx-serial.c [ARM] build fixes for netX serial driver 2008-10-30 09:41:59 +01:00
nwpserial.c serial: Add driver for the Cell Network Processor serial port NWP device 2009-01-08 16:25:18 +11:00
of_serial.c serial: Add 16850 uart type support to OF uart driver 2009-01-16 16:15:17 +11:00
pmac_zilog.c serial/pmac_zilog: Add console polling support 2008-11-19 16:04:23 +11:00
pmac_zilog.h
pnx8xxx_uart.c When a break signal is detected, the next character should be ignored. 2009-01-15 12:48:36 -08:00
pxa.c Merge branch 'for-rmk' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa-linux-2.6 into devel 2008-12-02 22:07:40 +00:00
s3c24a0.c [ARM] S3C24A0: Serial port definitions and driver support. 2008-12-15 21:46:36 +00:00
s3c2400.c [ARM] S3C24XX: Move files out of include/asm-arm/plat-s3c* 2008-10-07 22:26:09 +01:00
s3c2410.c [ARM] S3C24XX: Move files out of include/asm-arm/plat-s3c* 2008-10-07 22:26:09 +01:00
s3c2412.c [ARM] S3C24XX: Move files out of include/asm-arm/plat-s3c* 2008-10-07 22:26:09 +01:00
s3c2440.c drivers/serial/s3c2440.c: fix typo in MODULE_LICENSE 2008-12-10 08:01:53 -08:00
s3c6400.c [ARM] S3C6400: serial support for S3C6400 and S3C6410 SoCs 2008-12-15 21:58:11 +00:00
sa1100.c [ARM] Move include/asm-arm/arch-* to arch/arm/*/include/mach 2008-08-07 09:55:48 +01:00
samsung.c [ARM] S3C: Remove cpufreq warnings for unset serial information 2008-12-18 16:35:56 +00:00
samsung.h [ARM] S3C: Update serial driver IRQ handling 2008-12-15 23:02:39 +00:00
sb1250-duart.c Fix compile errors in SGI console drivers (linux-next tree) 2008-07-20 17:12:36 -07:00
sc26xx.c Fix compile errors in SGI console drivers (linux-next tree) 2008-07-20 17:12:36 -07:00
serial_core.c serial: struct device - replace bus_id with dev_name(), dev_set_name() 2009-01-06 10:44:37 -08:00
serial_cs.c pcmcia: remove unused argument to pcmcia_parse_tuple() 2008-08-31 15:50:33 +02:00
serial_ks8695.c [ARM] 5250/1: unbalanced enable_irq() for serial_ks8695.c fix 2008-10-01 22:41:43 +01:00
serial_lh7a40x.c [ARM] lh7a40x: avoid polluting the kernel's namespace 2008-11-28 16:39:04 +00:00
serial_txx9.c serial_txx9: use %lx for iobase 2008-10-20 08:50:24 -07:00
sh-sci.c serial: sh-sci: Fix up port pinmux for SH7366. 2008-12-22 18:44:49 +09:00
sh-sci.h sh: fix sh-sci / early printk build on sh7723 2009-01-21 17:44:32 +09:00
sn_console.c Altix serial: fix 2008-10-20 08:52:36 -07:00
suncore.c
suncore.h
sunhv.c sparc: Annotate of_device_id arrays with const or __initdata. 2008-08-31 01:23:17 -07:00
sunsab.c sparc: Annotate of_device_id arrays with const or __initdata. 2008-08-31 01:23:17 -07:00
sunsab.h
sunsu.c sparc: Annotate of_device_id arrays with const or __initdata. 2008-08-31 01:23:17 -07:00
sunzilog.c sparc: Annotate of_device_id arrays with const or __initdata. 2008-08-31 01:23:17 -07:00
sunzilog.h
uartlite.c powerpc/virtex: fix various format/casting printk mismatches 2008-11-14 09:59:48 -07:00
ucc_uart.c Merge branch 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-20 13:23:01 -07:00
vr41xx_siu.c Fix compile errors in SGI console drivers (linux-next tree) 2008-07-20 17:12:36 -07:00
zs.c serial: Z85C30: avoid a hang at console switch-over 2008-07-24 10:47:29 -07:00
zs.h