12 Dec, 2009
40 commits
-
This is overkill and mostly not needed
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
The tty flag can be tested so the shadow flag isn't needed
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
- The open lock is needed to fix up the case of a board reset occuring during
tty open but too early for a sane hangup response.
- The lock can however got for other cases
- Use the port mutex for get/setserial
- Fix up the confused lack of locking on the THROTTLE and other bits in the
private flags. Just use set/test/clear bit and it covers the cases we needSigned-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Introduce a lock for moxafunc() to protect the cases where were get collisions
between two function requests at the same time.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Rework a few bits of this into tty_port format
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Alexander Strakh reported
KERNEL_VERSION: 2.6.31
DESCRIBE:
Driver drivers/char/isicom.c might sleep in atomic context, because it
calls
tty_port_xmit_buf under spin_lock../drivers/char/isicom.c:
1307 static void isicom_hangup(struct tty_struct *tty)
1308 {
...
1315 spin_lock_irqsave(&port->card->card_lock, flags);
1316 isicom_shutdown_port(port);
...Path to might_sleep macro from isicom_hangup:
1. isicom_hangup calls spin_lock_irqsave (drivers/char/isicom.c:1315) and
then
calls isicom_shutdown_port.
2. isiscom_shutdown_port calls tty_port_free_xmit_buf at
drivers/char/isicom.c:906
3. tty_port_free_xmit_buf calls mutex_lock at drivers/char/tty_port:48Found by Linux Driver Verification Project.
Reported-by: Alexander Strakh
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Propogate the init/shutdown mutex through the setserial logic. Use the proper
locks for the various bits still using the BKL. Kill the BKL in this driver.Updated to fix the bug noted by Dan Carpenter
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
At first this looks a fairly trivial conversion but we can't quite push
everything into the right format yet. The open side is easy but care is needed
over the setserial methods. Fix up the locking now that we've adopted the
port->mutex locking rule for the initialization.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Split this into two flags - INIT meaning the board is set up and ACTIVE
meaning the board has ports open. Remove the broken HUPCL casing and push
the counts somewhere sensible.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Trivial conversion in this case so might as well do it while testing the
port_open design is rightSigned-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Users of tty port need a way to refcount ports when hotplugging is
involved.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Slice/dice/repeat as with the stallion driver this is just code shuffling
and removalSigned-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
The driver is already structured this way so just slice and dice
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Some devices want to set IO_ERROR in their activate methods so that you can
be handed a 'dead' port for operations like setserial. Thus we need to
clear the flag before activate so that activate can choose to set the flag
and still return 0.This is fine as the file handle/tty are not accessible to the user yet.
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
To propogate tty_port_open/close to a few other devices we need to start
handling the IO_ERROR flag on the tty. We can do this pretty trivially.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
We want to be able to do this without regard for the activate/own open
method being used which causes a problem using port->mutex. Add another
mutex for now. Once everything uses port_open to do buffer allocs we can
kill it back offSigned-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
The new dtr_rts function didn't take the port->func lock as it should
so add use of the lock there.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Add the POSIX block for carrier
Linux TIOCMIWAIT functionality is still lacking from the driver.
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Running the current code through checkpatch shows a few bits of noise
mostly but not entirely from before the changes.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Switching between two non standard baud rates fails because of the cflag
test. Do as we did elsewhere and just kill the "optimisation".Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Gets us proper tty semantics, removes some code and fixes up a few corner
case races (hangup during open etc)Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
When we move to the tty_port logic the port mutex will protect open v close
v hangup. Move to this first in the existing open code so we have a bisection
point.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
The tty can go away underneath us, so we must refcount it. Do the naïve
implementation initially. We will worry about startup shortly.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Now... testing reveals that the very first patch "sdio_uart: use
tty_port" causes a segmentation fault in sdio_uart_open():Unable to handle kernel NULL pointer dereference at virtual address 00000084
pgd = dfb44000 [00000084] *pgd=1fb99031, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#1] PREEMPT
last sysfs file:
/sys/devices/platform/mvsdio/mmc_host/mmc0/mmc0:f111/uevent
Modules linked in:
CPU: 0 Not tainted (2.6.32-rc5-next-20091102-00001-gb36eae9 #10)
PC is at sdio_uart_open+0x204/0x2cc
[...]Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Add a tty_port object to the sdio uart. For the moment just begin using the
tty field of the port, as this is the critical one to clean up.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Move the HUCPL handling from the end of close_port_start to the beginning
of close_port_end. What this actually does is change the ordering fromport shutdown
port->dtr_rtsto
port->dtr_rts
port shutdownSome hardware drops the physical connection on shutdown so we must perform
the port operations before the shutdown.Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
devpts_get_tty() assumes that the inode passed in is associated with a valid
pty. But if the only reference to the pty is via a bind-mount, the inode
passed to devpts_get_tty() while valid, would refer to a pty that no longer
exists.With a lot of debug effort, Grzegorz Nosek developed a small program (see
below) to reproduce a crash on recent kernels. This crash is a regression
introduced by the commit:commit 527b3e4773628b30d03323a2cb5fb0d84441990f
Author: Sukadev Bhattiprolu
Date: Mon Oct 13 10:43:08 2008 +0100To fix, ensure that the dentry associated with the inode has not yet been
deleted/unhashed by devpts_pty_kill().See also:
https://lists.linux-foundation.org/pipermail/containers/2009-July/019273.htmltty-bug.c:
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
#include#include
void dummy(int sig)
{
}static int child(void *unused)
{
int fd;signal(SIGINT, dummy); signal(SIGHUP, dummy);
pause(); /* cheesy synchronisation to wait for /dev/pts/0 to appear */mount("/dev/pts/0", "/dev/console", NULL, MS_BIND, NULL);
sleep(2);fd = open("/dev/console", O_RDWR);
dup(0); dup(0);
write(1, "Hello world!\n", sizeof("Hello world!\n")-1);
return 0;
}int main(void)
{
pid_t pid;
char *stack;stack = malloc(16384);
pid = clone(child, stack+16384, CLONE_NEWNS|SIGCHLD, NULL);open("/dev/ptmx", O_RDWR|O_NOCTTY|O_NONBLOCK);
unlockpt(fd); grantpt(fd);
sleep(2);
kill(pid, SIGHUP);
sleep(1);
return 0; /* exit before child opens /dev/console */
}Reported-by: Grzegorz Nosek
Signed-off-by: Sukadev Bhattiprolu
Tested-by: Serge Hallyn
Cc: stable
Signed-off-by: Greg Kroah-Hartman -
Do not read IIR in serial8250_start_tx when UART_BUG_TXEN
Reading the IIR clears some oustanding interrupts so it is not safe.
Instead, simply transmit immediately if the buffer is empty without
regard to IIR.Signed-off-by: Ian Jackson
Reviewed-by: Markus Armbruster
Reviewed-by: Jiri Kosina
Cc: Alan Cox
Cc: stable
Signed-off-by: Greg Kroah-Hartman -
A small addition to the ldisc method descriptions.
Signed-off-by: Tilman Schmidt
Signed-off-by: Randy Dunlap
Acked-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman -
Intel(R) PXA27x Processor Family Specification Update (Nov 2005)
says:E75. UART: Baud rate may not be programmed correctly on
back-to-back writes.Problem:
When programming the Divisor Latch registers, Low and High (DLL and
DLH), with back-to-back writes, the second register write may not
take effect. The result is an incorrect baud rate.Workaround:
After programming the first Divisor Latch register, read and verify
it before programming the second Divisor Latch register.This was hit when changing the baud rate from 115200 to 9600 while
receiving characters at 9600 Bd.And fixed indention of some comments nearby.
Signed-off-by: Uwe Kleine-König
Acked-by: Wolfram Sang
Acked-by: Marc Kleine-Budde
Cc: Eric Miao
Cc: Alan Cox
Cc: Mike Rapoport
Signed-off-by: Greg Kroah-Hartman -
Signed-off-by: André Goddard Rosa
Signed-off-by: Greg Kroah-Hartman -
Signed-off-by: André Goddard Rosa
Signed-off-by: Greg Kroah-Hartman -
If kzalloc() or alloc_tty_driver() fails, we call:
put_tty_driver(normal = NULL).Then:
put_tty_driver -> tty_driver_kref_put -> kref_put(&NULL->kref, ...)Signed-off-by: André Goddard Rosa
Signed-off-by: Greg Kroah-Hartman -
Opticon now takes the right mutex to check the port status but the status
check is done wrongly for the modern serial code, so fix it.Signed-off-by: Alan Cox
Cc: Alan Stern
Cc: Oliver Neukum
Signed-off-by: Greg Kroah-Hartman -
The tty port has a port mutex used for all the port related locking so we
don't need the one in the USB serial layer any more.Signed-off-by: Alan Cox
Cc: Alan Stern
Cc: Oliver Neukum
Signed-off-by: Greg Kroah-Hartman -
As Alan Stern pointed out - now we have tty_port_open the shutdown method
and locking allow us to whack the other bits into the full helper methods
and provide a shutdown op which the tty port code will synchronize with
setup for us.Signed-off-by: Alan Cox
Cc: Alan Stern
Cc: Oliver Neukum
Signed-off-by: Greg Kroah-Hartman -
Mind the hoover wire...
Signed-off-by: Alan Cox
Cc: Alan Stern
Cc: Oliver Neukum
Signed-off-by: Greg Kroah-Hartman -
For the moment this just moves the USB logic over and fixes the 'what if
we open and hangup at the same time' race noticed by Oliver Neukum.Signed-off-by: Alan Cox
Cc: Alan Stern
Cc: Oliver Neukum
Signed-off-by: Greg Kroah-Hartman -
Signed-off-by: Alan Cox
Signed-off-by: Greg Kroah-Hartman