Merge branches 'aaci', 'mmci-dma', 'pl' and 'pl011' into drivers

This commit is contained in:
Russell King 2011-03-17 11:04:51 +00:00
1461 changed files with 19547 additions and 10879 deletions

View file

@ -10,4 +10,3 @@ obj-$(CONFIG_HVC_XEN) += hvc_xen.o
obj-$(CONFIG_HVC_IUCV) += hvc_iucv.o
obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o
obj-$(CONFIG_HVCS) += hvcs.o
obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o

File diff suppressed because it is too large Load diff

View file

@ -2414,6 +2414,7 @@ static int gsmld_config(struct tty_struct *tty, struct gsm_mux *gsm,
gsm->initiator = c->initiator;
gsm->mru = c->mru;
gsm->mtu = c->mtu;
gsm->encoding = c->encapsulation;
gsm->adaption = c->adaption;
gsm->n2 = c->n2;

View file

@ -581,8 +581,9 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
__u8 __user *buf, size_t nr)
{
struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
int ret;
int ret = 0;
struct n_hdlc_buf *rbuf;
DECLARE_WAITQUEUE(wait, current);
if (debuglevel >= DEBUG_LEVEL_INFO)
printk("%s(%d)n_hdlc_tty_read() called\n",__FILE__,__LINE__);
@ -598,57 +599,55 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
return -EFAULT;
}
tty_lock();
add_wait_queue(&tty->read_wait, &wait);
for (;;) {
if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
tty_unlock();
return -EIO;
ret = -EIO;
break;
}
if (tty_hung_up_p(file))
break;
n_hdlc = tty2n_hdlc (tty);
if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC ||
tty != n_hdlc->tty) {
tty_unlock();
return 0;
}
set_current_state(TASK_INTERRUPTIBLE);
rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list);
if (rbuf)
if (rbuf) {
if (rbuf->count > nr) {
/* too large for caller's buffer */
ret = -EOVERFLOW;
} else {
if (copy_to_user(buf, rbuf->buf, rbuf->count))
ret = -EFAULT;
else
ret = rbuf->count;
}
if (n_hdlc->rx_free_buf_list.count >
DEFAULT_RX_BUF_COUNT)
kfree(rbuf);
else
n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, rbuf);
break;
}
/* no data */
if (file->f_flags & O_NONBLOCK) {
tty_unlock();
return -EAGAIN;
ret = -EAGAIN;
break;
}
interruptible_sleep_on (&tty->read_wait);
schedule();
if (signal_pending(current)) {
tty_unlock();
return -EINTR;
ret = -EINTR;
break;
}
}
if (rbuf->count > nr)
/* frame too large for caller's buffer (discard frame) */
ret = -EOVERFLOW;
else {
/* Copy the data to the caller's buffer */
if (copy_to_user(buf, rbuf->buf, rbuf->count))
ret = -EFAULT;
else
ret = rbuf->count;
}
/* return HDLC buffer to free list unless the free list */
/* count has exceeded the default value, in which case the */
/* buffer is freed back to the OS to conserve memory */
if (n_hdlc->rx_free_buf_list.count > DEFAULT_RX_BUF_COUNT)
kfree(rbuf);
else
n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf);
tty_unlock();
remove_wait_queue(&tty->read_wait, &wait);
__set_current_state(TASK_RUNNING);
return ret;
} /* end of n_hdlc_tty_read() */
@ -691,14 +690,15 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
count = maxframe;
}
tty_lock();
add_wait_queue(&tty->write_wait, &wait);
set_current_state(TASK_INTERRUPTIBLE);
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
/* Allocate transmit buffer */
/* sleep until transmit buffer available */
while (!(tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list))) {
tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list);
if (tbuf)
break;
if (file->f_flags & O_NONBLOCK) {
error = -EAGAIN;
break;
@ -719,7 +719,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
}
}
set_current_state(TASK_RUNNING);
__set_current_state(TASK_RUNNING);
remove_wait_queue(&tty->write_wait, &wait);
if (!error) {
@ -731,7 +731,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
n_hdlc_send_frames(n_hdlc,tty);
}
tty_unlock();
return error;
} /* end of n_hdlc_tty_write() */

View file

@ -262,7 +262,7 @@ static void status_handle(struct m68k_serial *info, unsigned short status)
static void receive_chars(struct m68k_serial *info, unsigned short rx)
{
struct tty_struct *tty = info->port.tty;
struct tty_struct *tty = info->tty;
m68328_uart *uart = &uart_addr[info->line];
unsigned char ch, flag;
@ -329,7 +329,7 @@ static void transmit_chars(struct m68k_serial *info)
goto clear_and_return;
}
if((info->xmit_cnt <= 0) || info->port.tty->stopped) {
if((info->xmit_cnt <= 0) || info->tty->stopped) {
/* That's peculiar... TX ints off */
uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
goto clear_and_return;
@ -383,7 +383,7 @@ static void do_softint(struct work_struct *work)
struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue);
struct tty_struct *tty;
tty = info->port.tty;
tty = info->tty;
if (!tty)
return;
#if 0
@ -407,7 +407,7 @@ static void do_serial_hangup(struct work_struct *work)
struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue_hangup);
struct tty_struct *tty;
tty = info->port.tty;
tty = info->tty;
if (!tty)
return;
@ -451,8 +451,8 @@ static int startup(struct m68k_serial * info)
uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
#endif
if (info->port.tty)
clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
if (info->tty)
clear_bit(TTY_IO_ERROR, &info->tty->flags);
info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
/*
@ -486,8 +486,8 @@ static void shutdown(struct m68k_serial * info)
info->xmit_buf = 0;
}
if (info->port.tty)
set_bit(TTY_IO_ERROR, &info->port.tty->flags);
if (info->tty)
set_bit(TTY_IO_ERROR, &info->tty->flags);
info->flags &= ~S_INITIALIZED;
local_irq_restore(flags);
@ -553,9 +553,9 @@ static void change_speed(struct m68k_serial *info)
unsigned cflag;
int i;
if (!info->port.tty || !info->port.tty->termios)
if (!info->tty || !info->tty->termios)
return;
cflag = info->port.tty->termios->c_cflag;
cflag = info->tty->termios->c_cflag;
if (!(port = info->port))
return;
@ -970,7 +970,6 @@ static void send_break(struct m68k_serial * info, unsigned int duration)
static int rs_ioctl(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg)
{
int error;
struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
int retval;
@ -1104,7 +1103,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
tty_ldisc_flush(tty);
tty->closing = 0;
info->event = 0;
info->port.tty = NULL;
info->tty = NULL;
#warning "This is not and has never been valid so fix it"
#if 0
if (tty->ldisc.num != ldiscs[N_TTY].num) {
@ -1142,7 +1141,7 @@ void rs_hangup(struct tty_struct *tty)
info->event = 0;
info->count = 0;
info->flags &= ~S_NORMAL_ACTIVE;
info->port.tty = NULL;
info->tty = NULL;
wake_up_interruptible(&info->open_wait);
}
@ -1261,7 +1260,7 @@ int rs_open(struct tty_struct *tty, struct file * filp)
info->count++;
tty->driver_data = info;
info->port.tty = tty;
info->tty = tty;
/*
* Start up serial port
@ -1338,7 +1337,7 @@ rs68328_init(void)
info = &m68k_soft[i];
info->magic = SERIAL_MAGIC;
info->port = (int) &uart_addr[i];
info->port.tty = NULL;
info->tty = NULL;
info->irq = uart_irqs[i];
info->custom_divisor = 16;
info->close_delay = 50;

View file

@ -2428,6 +2428,7 @@ static const struct tty_operations rs_360_ops = {
/* .read_proc = rs_360_read_proc, */
.tiocmget = rs_360_tiocmget,
.tiocmset = rs_360_tiocmset,
.get_icount = rs_360_get_icount,
};
static int __init rs_360_init(void)

View file

@ -236,7 +236,8 @@ static const struct serial8250_config uart_config[] = {
.fifo_size = 128,
.tx_loadsz = 128,
.fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
.flags = UART_CAP_FIFO | UART_CAP_EFR | UART_CAP_SLEEP,
/* UART_CAP_EFR breaks billionon CF bluetooth card. */
.flags = UART_CAP_FIFO | UART_CAP_SLEEP,
},
[PORT_16654] = {
.name = "ST16654",

View file

@ -1518,6 +1518,7 @@ config SERIAL_BCM63XX_CONSOLE
config SERIAL_GRLIB_GAISLER_APBUART
tristate "GRLIB APBUART serial support"
depends on OF
select SERIAL_CORE
---help---
Add support for the GRLIB APBUART serial port.

View file

@ -676,7 +676,7 @@ static struct uart_driver amba_reg = {
.cons = AMBA_CONSOLE,
};
static int pl010_probe(struct amba_device *dev, struct amba_id *id)
static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
{
struct uart_amba_port *uap;
void __iomem *base;

View file

@ -96,6 +96,22 @@ static struct vendor_data vendor_st = {
};
/* Deals with DMA transactions */
struct pl011_sgbuf {
struct scatterlist sg;
char *buf;
};
struct pl011_dmarx_data {
struct dma_chan *chan;
struct completion complete;
bool use_buf_b;
struct pl011_sgbuf sgbuf_a;
struct pl011_sgbuf sgbuf_b;
dma_cookie_t cookie;
bool running;
};
struct pl011_dmatx_data {
struct dma_chan *chan;
struct scatterlist sg;
@ -120,11 +136,69 @@ struct uart_amba_port {
char type[12];
#ifdef CONFIG_DMA_ENGINE
/* DMA stuff */
bool using_dma;
bool using_tx_dma;
bool using_rx_dma;
struct pl011_dmarx_data dmarx;
struct pl011_dmatx_data dmatx;
#endif
};
/*
* Reads up to 256 characters from the FIFO or until it's empty and
* inserts them into the TTY layer. Returns the number of characters
* read from the FIFO.
*/
static int pl011_fifo_to_tty(struct uart_amba_port *uap)
{
u16 status, ch;
unsigned int flag, max_count = 256;
int fifotaken = 0;
while (max_count--) {
status = readw(uap->port.membase + UART01x_FR);
if (status & UART01x_FR_RXFE)
break;
/* Take chars from the FIFO and update status */
ch = readw(uap->port.membase + UART01x_DR) |
UART_DUMMY_DR_RX;
flag = TTY_NORMAL;
uap->port.icount.rx++;
fifotaken++;
if (unlikely(ch & UART_DR_ERROR)) {
if (ch & UART011_DR_BE) {
ch &= ~(UART011_DR_FE | UART011_DR_PE);
uap->port.icount.brk++;
if (uart_handle_break(&uap->port))
continue;
} else if (ch & UART011_DR_PE)
uap->port.icount.parity++;
else if (ch & UART011_DR_FE)
uap->port.icount.frame++;
if (ch & UART011_DR_OE)
uap->port.icount.overrun++;
ch &= uap->port.read_status_mask;
if (ch & UART011_DR_BE)
flag = TTY_BREAK;
else if (ch & UART011_DR_PE)
flag = TTY_PARITY;
else if (ch & UART011_DR_FE)
flag = TTY_FRAME;
}
if (uart_handle_sysrq_char(&uap->port, ch & 255))
continue;
uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag);
}
return fifotaken;
}
/*
* All the DMA operation mode stuff goes inside this ifdef.
* This assumes that you have a generic DMA device interface,
@ -134,6 +208,31 @@ struct uart_amba_port {
#define PL011_DMA_BUFFER_SIZE PAGE_SIZE
static int pl011_sgbuf_init(struct dma_chan *chan, struct pl011_sgbuf *sg,
enum dma_data_direction dir)
{
sg->buf = kmalloc(PL011_DMA_BUFFER_SIZE, GFP_KERNEL);
if (!sg->buf)
return -ENOMEM;
sg_init_one(&sg->sg, sg->buf, PL011_DMA_BUFFER_SIZE);
if (dma_map_sg(chan->device->dev, &sg->sg, 1, dir) != 1) {
kfree(sg->buf);
return -EINVAL;
}
return 0;
}
static void pl011_sgbuf_free(struct dma_chan *chan, struct pl011_sgbuf *sg,
enum dma_data_direction dir)
{
if (sg->buf) {
dma_unmap_sg(chan->device->dev, &sg->sg, 1, dir);
kfree(sg->buf);
}
}
static void pl011_dma_probe_initcall(struct uart_amba_port *uap)
{
/* DMA is the sole user of the platform data right now */
@ -153,7 +252,7 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap)
return;
}
/* Try to acquire a generic DMA engine slave channel */
/* Try to acquire a generic DMA engine slave TX channel */
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
@ -168,6 +267,28 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap)
dev_info(uap->port.dev, "DMA channel TX %s\n",
dma_chan_name(uap->dmatx.chan));
/* Optionally make use of an RX channel as well */
if (plat->dma_rx_param) {
struct dma_slave_config rx_conf = {
.src_addr = uap->port.mapbase + UART01x_DR,
.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE,
.direction = DMA_FROM_DEVICE,
.src_maxburst = uap->fifosize >> 1,
};
chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param);
if (!chan) {
dev_err(uap->port.dev, "no RX DMA channel!\n");
return;
}
dmaengine_slave_config(chan, &rx_conf);
uap->dmarx.chan = chan;
dev_info(uap->port.dev, "DMA channel RX %s\n",
dma_chan_name(uap->dmarx.chan));
}
}
#ifndef MODULE
@ -219,9 +340,10 @@ static void pl011_dma_remove(struct uart_amba_port *uap)
/* TODO: remove the initcall if it has not yet executed */
if (uap->dmatx.chan)
dma_release_channel(uap->dmatx.chan);
if (uap->dmarx.chan)
dma_release_channel(uap->dmarx.chan);
}
/* Forward declare this for the refill routine */
static int pl011_dma_tx_refill(struct uart_amba_port *uap);
@ -380,7 +502,7 @@ static int pl011_dma_tx_refill(struct uart_amba_port *uap)
*/
static bool pl011_dma_tx_irq(struct uart_amba_port *uap)
{
if (!uap->using_dma)
if (!uap->using_tx_dma)
return false;
/*
@ -432,7 +554,7 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
{
u16 dmacr;
if (!uap->using_dma)
if (!uap->using_tx_dma)
return false;
if (!uap->port.x_char) {
@ -492,7 +614,7 @@ static void pl011_dma_flush_buffer(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
if (!uap->using_dma)
if (!uap->using_tx_dma)
return;
/* Avoid deadlock with the DMA engine callback */
@ -508,9 +630,219 @@ static void pl011_dma_flush_buffer(struct uart_port *port)
}
}
static void pl011_dma_rx_callback(void *data);
static int pl011_dma_rx_trigger_dma(struct uart_amba_port *uap)
{
struct dma_chan *rxchan = uap->dmarx.chan;
struct dma_device *dma_dev;
struct pl011_dmarx_data *dmarx = &uap->dmarx;
struct dma_async_tx_descriptor *desc;
struct pl011_sgbuf *sgbuf;
if (!rxchan)
return -EIO;
/* Start the RX DMA job */
sgbuf = uap->dmarx.use_buf_b ?
&uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a;
dma_dev = rxchan->device;
desc = rxchan->device->device_prep_slave_sg(rxchan, &sgbuf->sg, 1,
DMA_FROM_DEVICE,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
/*
* If the DMA engine is busy and cannot prepare a
* channel, no big deal, the driver will fall back
* to interrupt mode as a result of this error code.
*/
if (!desc) {
uap->dmarx.running = false;
dmaengine_terminate_all(rxchan);
return -EBUSY;
}
/* Some data to go along to the callback */
desc->callback = pl011_dma_rx_callback;
desc->callback_param = uap;
dmarx->cookie = dmaengine_submit(desc);
dma_async_issue_pending(rxchan);
uap->dmacr |= UART011_RXDMAE;
writew(uap->dmacr, uap->port.membase + UART011_DMACR);
uap->dmarx.running = true;
uap->im &= ~UART011_RXIM;
writew(uap->im, uap->port.membase + UART011_IMSC);
return 0;
}
/*
* This is called when either the DMA job is complete, or
* the FIFO timeout interrupt occurred. This must be called
* with the port spinlock uap->port.lock held.
*/
static void pl011_dma_rx_chars(struct uart_amba_port *uap,
u32 pending, bool use_buf_b,
bool readfifo)
{
struct tty_struct *tty = uap->port.state->port.tty;
struct pl011_sgbuf *sgbuf = use_buf_b ?
&uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a;
struct device *dev = uap->dmarx.chan->device->dev;
int dma_count = 0;
u32 fifotaken = 0; /* only used for vdbg() */
/* Pick everything from the DMA first */
if (pending) {
/* Sync in buffer */
dma_sync_sg_for_cpu(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
/*
* First take all chars in the DMA pipe, then look in the FIFO.
* Note that tty_insert_flip_buf() tries to take as many chars
* as it can.
*/
dma_count = tty_insert_flip_string(uap->port.state->port.tty,
sgbuf->buf, pending);
/* Return buffer to device */
dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
uap->port.icount.rx += dma_count;
if (dma_count < pending)
dev_warn(uap->port.dev,
"couldn't insert all characters (TTY is full?)\n");
}
/*
* Only continue with trying to read the FIFO if all DMA chars have
* been taken first.
*/
if (dma_count == pending && readfifo) {
/* Clear any error flags */
writew(UART011_OEIS | UART011_BEIS | UART011_PEIS | UART011_FEIS,
uap->port.membase + UART011_ICR);
/*
* If we read all the DMA'd characters, and we had an
* incomplete buffer, that could be due to an rx error, or
* maybe we just timed out. Read any pending chars and check
* the error status.
*
* Error conditions will only occur in the FIFO, these will
* trigger an immediate interrupt and stop the DMA job, so we
* will always find the error in the FIFO, never in the DMA
* buffer.
*/
fifotaken = pl011_fifo_to_tty(uap);
}
spin_unlock(&uap->port.lock);
dev_vdbg(uap->port.dev,
"Took %d chars from DMA buffer and %d chars from the FIFO\n",
dma_count, fifotaken);
tty_flip_buffer_push(tty);
spin_lock(&uap->port.lock);
}
static void pl011_dma_rx_irq(struct uart_amba_port *uap)
{
struct pl011_dmarx_data *dmarx = &uap->dmarx;
struct dma_chan *rxchan = dmarx->chan;
struct pl011_sgbuf *sgbuf = dmarx->use_buf_b ?
&dmarx->sgbuf_b : &dmarx->sgbuf_a;
size_t pending;
struct dma_tx_state state;
enum dma_status dmastat;
/*
* Pause the transfer so we can trust the current counter,
* do this before we pause the PL011 block, else we may
* overflow the FIFO.
*/
if (dmaengine_pause(rxchan))
dev_err(uap->port.dev, "unable to pause DMA transfer\n");
dmastat = rxchan->device->device_tx_status(rxchan,
dmarx->cookie, &state);
if (dmastat != DMA_PAUSED)
dev_err(uap->port.dev, "unable to pause DMA transfer\n");
/* Disable RX DMA - incoming data will wait in the FIFO */
uap->dmacr &= ~UART011_RXDMAE;
writew(uap->dmacr, uap->port.membase + UART011_DMACR);
uap->dmarx.running = false;
pending = sgbuf->sg.length - state.residue;
BUG_ON(pending > PL011_DMA_BUFFER_SIZE);
/* Then we terminate the transfer - we now know our residue */
dmaengine_terminate_all(rxchan);
/*
* This will take the chars we have so far and insert
* into the framework.
*/
pl011_dma_rx_chars(uap, pending, dmarx->use_buf_b, true);
/* Switch buffer & re-trigger DMA job */
dmarx->use_buf_b = !dmarx->use_buf_b;
if (pl011_dma_rx_trigger_dma(uap)) {
dev_dbg(uap->port.dev, "could not retrigger RX DMA job "
"fall back to interrupt mode\n");
uap->im |= UART011_RXIM;
writew(uap->im, uap->port.membase + UART011_IMSC);
}
}
static void pl011_dma_rx_callback(void *data)
{
struct uart_amba_port *uap = data;
struct pl011_dmarx_data *dmarx = &uap->dmarx;
bool lastbuf = dmarx->use_buf_b;
int ret;
/*
* This completion interrupt occurs typically when the
* RX buffer is totally stuffed but no timeout has yet
* occurred. When that happens, we just want the RX
* routine to flush out the secondary DMA buffer while
* we immediately trigger the next DMA job.
*/
spin_lock_irq(&uap->port.lock);
uap->dmarx.running = false;
dmarx->use_buf_b = !lastbuf;
ret = pl011_dma_rx_trigger_dma(uap);
pl011_dma_rx_chars(uap, PL011_DMA_BUFFER_SIZE, lastbuf, false);
spin_unlock_irq(&uap->port.lock);
/*
* Do this check after we picked the DMA chars so we don't
* get some IRQ immediately from RX.
*/
if (ret) {
dev_dbg(uap->port.dev, "could not retrigger RX DMA job "
"fall back to interrupt mode\n");
uap->im |= UART011_RXIM;
writew(uap->im, uap->port.membase + UART011_IMSC);
}
}
/*
* Stop accepting received characters, when we're shutting down or
* suspending this port.
* Locking: called with port lock held and IRQs disabled.
*/
static inline void pl011_dma_rx_stop(struct uart_amba_port *uap)
{
/* FIXME. Just disable the DMA enable */
uap->dmacr &= ~UART011_RXDMAE;
writew(uap->dmacr, uap->port.membase + UART011_DMACR);
}
static void pl011_dma_startup(struct uart_amba_port *uap)
{
int ret;
if (!uap->dmatx.chan)
return;
@ -525,8 +857,33 @@ static void pl011_dma_startup(struct uart_amba_port *uap)
/* The DMA buffer is now the FIFO the TTY subsystem can use */
uap->port.fifosize = PL011_DMA_BUFFER_SIZE;
uap->using_dma = true;
uap->using_tx_dma = true;
if (!uap->dmarx.chan)
goto skip_rx;
/* Allocate and map DMA RX buffers */
ret = pl011_sgbuf_init(uap->dmarx.chan, &uap->dmarx.sgbuf_a,
DMA_FROM_DEVICE);
if (ret) {
dev_err(uap->port.dev, "failed to init DMA %s: %d\n",
"RX buffer A", ret);
goto skip_rx;
}
ret = pl011_sgbuf_init(uap->dmarx.chan, &uap->dmarx.sgbuf_b,
DMA_FROM_DEVICE);
if (ret) {
dev_err(uap->port.dev, "failed to init DMA %s: %d\n",
"RX buffer B", ret);
pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_a,
DMA_FROM_DEVICE);
goto skip_rx;
}
uap->using_rx_dma = true;
skip_rx:
/* Turn on DMA error (RX/TX will be enabled on demand) */
uap->dmacr |= UART011_DMAONERR;
writew(uap->dmacr, uap->port.membase + UART011_DMACR);
@ -539,11 +896,17 @@ static void pl011_dma_startup(struct uart_amba_port *uap)
if (uap->vendor->dma_threshold)
writew(ST_UART011_DMAWM_RX_16 | ST_UART011_DMAWM_TX_16,
uap->port.membase + ST_UART011_DMAWM);
if (uap->using_rx_dma) {
if (pl011_dma_rx_trigger_dma(uap))
dev_dbg(uap->port.dev, "could not trigger initial "
"RX DMA job, fall back to interrupt mode\n");
}
}
static void pl011_dma_shutdown(struct uart_amba_port *uap)
{
if (!uap->using_dma)
if (!(uap->using_tx_dma || uap->using_rx_dma))
return;
/* Disable RX and TX DMA */
@ -555,19 +918,39 @@ static void pl011_dma_shutdown(struct uart_amba_port *uap)
writew(uap->dmacr, uap->port.membase + UART011_DMACR);
spin_unlock_irq(&uap->port.lock);
/* In theory, this should already be done by pl011_dma_flush_buffer */
dmaengine_terminate_all(uap->dmatx.chan);
if (uap->dmatx.queued) {
dma_unmap_sg(uap->dmatx.chan->device->dev, &uap->dmatx.sg, 1,
DMA_TO_DEVICE);
uap->dmatx.queued = false;
if (uap->using_tx_dma) {
/* In theory, this should already be done by pl011_dma_flush_buffer */
dmaengine_terminate_all(uap->dmatx.chan);
if (uap->dmatx.queued) {
dma_unmap_sg(uap->dmatx.chan->device->dev, &uap->dmatx.sg, 1,
DMA_TO_DEVICE);
uap->dmatx.queued = false;
}
kfree(uap->dmatx.buf);
uap->using_tx_dma = false;
}
kfree(uap->dmatx.buf);
uap->using_dma = false;
if (uap->using_rx_dma) {
dmaengine_terminate_all(uap->dmarx.chan);
/* Clean up the RX DMA */
pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_a, DMA_FROM_DEVICE);
pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_b, DMA_FROM_DEVICE);
uap->using_rx_dma = false;
}
}
static inline bool pl011_dma_rx_available(struct uart_amba_port *uap)
{
return uap->using_rx_dma;
}
static inline bool pl011_dma_rx_running(struct uart_amba_port *uap)
{
return uap->using_rx_dma && uap->dmarx.running;
}
#else
/* Blank functions if the DMA engine is not available */
static inline void pl011_dma_probe(struct uart_amba_port *uap)
@ -600,6 +983,29 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
return false;
}
static inline void pl011_dma_rx_irq(struct uart_amba_port *uap)
{
}
static inline void pl011_dma_rx_stop(struct uart_amba_port *uap)
{
}
static inline int pl011_dma_rx_trigger_dma(struct uart_amba_port *uap)
{
return -EIO;
}
static inline bool pl011_dma_rx_available(struct uart_amba_port *uap)
{
return false;
}
static inline bool pl011_dma_rx_running(struct uart_amba_port *uap)
{
return false;
}
#define pl011_dma_flush_buffer NULL
#endif
@ -630,6 +1036,8 @@ static void pl011_stop_rx(struct uart_port *port)
uap->im &= ~(UART011_RXIM|UART011_RTIM|UART011_FEIM|
UART011_PEIM|UART011_BEIM|UART011_OEIM);
writew(uap->im, uap->port.membase + UART011_IMSC);
pl011_dma_rx_stop(uap);
}
static void pl011_enable_ms(struct uart_port *port)
@ -643,51 +1051,24 @@ static void pl011_enable_ms(struct uart_port *port)
static void pl011_rx_chars(struct uart_amba_port *uap)
{
struct tty_struct *tty = uap->port.state->port.tty;
unsigned int status, ch, flag, max_count = 256;
status = readw(uap->port.membase + UART01x_FR);
while ((status & UART01x_FR_RXFE) == 0 && max_count--) {
ch = readw(uap->port.membase + UART01x_DR) | UART_DUMMY_DR_RX;
flag = TTY_NORMAL;
uap->port.icount.rx++;
pl011_fifo_to_tty(uap);
/*
* Note that the error handling code is
* out of the main execution path
*/
if (unlikely(ch & UART_DR_ERROR)) {
if (ch & UART011_DR_BE) {
ch &= ~(UART011_DR_FE | UART011_DR_PE);
uap->port.icount.brk++;
if (uart_handle_break(&uap->port))
goto ignore_char;
} else if (ch & UART011_DR_PE)
uap->port.icount.parity++;
else if (ch & UART011_DR_FE)
uap->port.icount.frame++;
if (ch & UART011_DR_OE)
uap->port.icount.overrun++;
ch &= uap->port.read_status_mask;
if (ch & UART011_DR_BE)
flag = TTY_BREAK;
else if (ch & UART011_DR_PE)
flag = TTY_PARITY;
else if (ch & UART011_DR_FE)
flag = TTY_FRAME;
}
if (uart_handle_sysrq_char(&uap->port, ch & 255))
goto ignore_char;
uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag);
ignore_char:
status = readw(uap->port.membase + UART01x_FR);
}
spin_unlock(&uap->port.lock);
tty_flip_buffer_push(tty);
/*
* If we were temporarily out of DMA mode for a while,
* attempt to switch back to DMA mode again.
*/
if (pl011_dma_rx_available(uap)) {
if (pl011_dma_rx_trigger_dma(uap)) {
dev_dbg(uap->port.dev, "could not trigger RX DMA job "
"fall back to interrupt mode again\n");
uap->im |= UART011_RXIM;
} else
uap->im &= ~UART011_RXIM;
writew(uap->im, uap->port.membase + UART011_IMSC);
}
spin_lock(&uap->port.lock);
}
@ -767,8 +1148,12 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
UART011_RXIS),
uap->port.membase + UART011_ICR);
if (status & (UART011_RTIS|UART011_RXIS))
pl011_rx_chars(uap);
if (status & (UART011_RTIS|UART011_RXIS)) {
if (pl011_dma_rx_running(uap))
pl011_dma_rx_irq(uap);
else
pl011_rx_chars(uap);
}
if (status & (UART011_DSRMIS|UART011_DCDMIS|
UART011_CTSMIS|UART011_RIMIS))
pl011_modem_status(uap);
@ -945,10 +1330,14 @@ static int pl011_startup(struct uart_port *port)
pl011_dma_startup(uap);
/*
* Finally, enable interrupts
* Finally, enable interrupts, only timeouts when using DMA
* if initial RX DMA job failed, start in interrupt mode
* as well.
*/
spin_lock_irq(&uap->port.lock);
uap->im = UART011_RXIM | UART011_RTIM;
uap->im = UART011_RTIM;
if (!pl011_dma_rx_running(uap))
uap->im |= UART011_RXIM;
writew(uap->im, uap->port.membase + UART011_IMSC);
spin_unlock_irq(&uap->port.lock);
@ -1349,7 +1738,7 @@ static struct uart_driver amba_reg = {
.cons = AMBA_CONSOLE,
};
static int pl011_probe(struct amba_device *dev, struct amba_id *id)
static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
{
struct uart_amba_port *uap;
struct vendor_data *vendor = id->data;

View file

@ -370,10 +370,8 @@ static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id)
{
struct bfin_serial_port *uart = dev_id;
spin_lock(&uart->port.lock);
while (UART_GET_LSR(uart) & DR)
bfin_serial_rx_chars(uart);
spin_unlock(&uart->port.lock);
return IRQ_HANDLED;
}
@ -490,9 +488,8 @@ void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
{
int x_pos, pos;
dma_disable_irq(uart->tx_dma_channel);
dma_disable_irq(uart->rx_dma_channel);
spin_lock_bh(&uart->port.lock);
dma_disable_irq_nosync(uart->rx_dma_channel);
spin_lock_bh(&uart->rx_lock);
/* 2D DMA RX buffer ring is used. Because curr_y_count and
* curr_x_count can't be read as an atomic operation,
@ -523,8 +520,7 @@ void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
uart->rx_dma_buf.tail = uart->rx_dma_buf.head;
}
spin_unlock_bh(&uart->port.lock);
dma_enable_irq(uart->tx_dma_channel);
spin_unlock_bh(&uart->rx_lock);
dma_enable_irq(uart->rx_dma_channel);
mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES);
@ -571,7 +567,7 @@ static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id)
unsigned short irqstat;
int x_pos, pos;
spin_lock(&uart->port.lock);
spin_lock(&uart->rx_lock);
irqstat = get_dma_curr_irqstat(uart->rx_dma_channel);
clear_dma_irqstat(uart->rx_dma_channel);
@ -589,7 +585,7 @@ static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id)
uart->rx_dma_buf.tail = uart->rx_dma_buf.head;
}
spin_unlock(&uart->port.lock);
spin_unlock(&uart->rx_lock);
return IRQ_HANDLED;
}
@ -1332,6 +1328,7 @@ static int bfin_serial_probe(struct platform_device *pdev)
}
#ifdef CONFIG_SERIAL_BFIN_DMA
spin_lock_init(&uart->rx_lock);
uart->tx_done = 1;
uart->tx_count = 0;

View file

@ -601,7 +601,7 @@ static int max3100_startup(struct uart_port *port)
s->rts = 0;
sprintf(b, "max3100-%d", s->minor);
s->workqueue = create_freezeable_workqueue(b);
s->workqueue = create_freezable_workqueue(b);
if (!s->workqueue) {
dev_warn(&s->spi->dev, "cannot create workqueue\n");
return -EBUSY;

View file

@ -833,7 +833,7 @@ static int max3107_startup(struct uart_port *port)
struct max3107_port *s = container_of(port, struct max3107_port, port);
/* Initialize work queue */
s->workqueue = create_freezeable_workqueue("max3107");
s->workqueue = create_freezable_workqueue("max3107");
if (!s->workqueue) {
dev_err(&s->spi->dev, "Workqueue creation failed\n");
return -EBUSY;

View file

@ -829,7 +829,7 @@ static void __init sbd_probe_duarts(void)
#ifdef CONFIG_SERIAL_SB1250_DUART_CONSOLE
/*
* Serial console stuff. Very basic, polling driver for doing serial
* console output. The console_sem is held by the caller, so we
* console output. The console_lock is held by the caller, so we
* shouldn't be interrupted for more console activity.
*/
static void sbd_console_putchar(struct uart_port *uport, int ch)

View file

@ -712,6 +712,7 @@ static struct pcmcia_device_id serial_ids[] = {
PCMCIA_PFC_DEVICE_PROD_ID12(1, "Xircom", "CreditCard Ethernet+Modem II", 0x2e3ee845, 0xeca401bf),
PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0032, 0x0e01),
PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0032, 0x0a05),
PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0032, 0x0b05),
PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0032, 0x1101),
PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0104, 0x0070),
PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0101, 0x0562),

View file

@ -46,7 +46,7 @@
#include <asm/irq_regs.h>
/* Whether we react on sysrq keys or just ignore them */
static int __read_mostly sysrq_enabled = 1;
static int __read_mostly sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
static bool __read_mostly sysrq_always_enabled;
static bool sysrq_on(void)
@ -571,6 +571,7 @@ struct sysrq_state {
unsigned int alt_use;
bool active;
bool need_reinject;
bool reinjecting;
};
static void sysrq_reinject_alt_sysrq(struct work_struct *work)
@ -581,6 +582,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
unsigned int alt_code = sysrq->alt_use;
if (sysrq->need_reinject) {
/* we do not want the assignment to be reordered */
sysrq->reinjecting = true;
mb();
/* Simulate press and release of Alt + SysRq */
input_inject_event(handle, EV_KEY, alt_code, 1);
input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
@ -589,6 +594,9 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
input_inject_event(handle, EV_KEY, alt_code, 0);
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
mb();
sysrq->reinjecting = false;
}
}
@ -599,6 +607,13 @@ static bool sysrq_filter(struct input_handle *handle,
bool was_active = sysrq->active;
bool suppress;
/*
* Do not filter anything if we are in the process of re-injecting
* Alt+SysRq combination.
*/
if (sysrq->reinjecting)
return false;
switch (type) {
case EV_SYN:
@ -629,7 +644,7 @@ static bool sysrq_filter(struct input_handle *handle,
sysrq->alt_use = sysrq->alt;
/*
* If nothing else will be pressed we'll need
* to * re-inject Alt-SysRq keysroke.
* to re-inject Alt-SysRq keysroke.
*/
sysrq->need_reinject = true;
}

View file

@ -3256,8 +3256,8 @@ static ssize_t show_cons_active(struct device *dev,
struct console *c;
ssize_t count = 0;
acquire_console_sem();
for (c = console_drivers; c; c = c->next) {
console_lock();
for_each_console(c) {
if (!c->device)
continue;
if (!c->write)
@ -3271,7 +3271,7 @@ static ssize_t show_cons_active(struct device *dev,
while (i--)
count += sprintf(buf + count, "%s%d%c",
cs[i]->name, cs[i]->index, i ? ' ':'\n');
release_console_sem();
console_unlock();
return count;
}
@ -3306,7 +3306,7 @@ int __init tty_init(void)
if (IS_ERR(consdev))
consdev = NULL;
else
device_create_file(consdev, &dev_attr_active);
WARN_ON(device_create_file(consdev, &dev_attr_active) < 0);
#ifdef CONFIG_VT
vty_init(&console_fops);

View file

@ -316,9 +316,9 @@ int paste_selection(struct tty_struct *tty)
/* always called with BTM from vt_ioctl */
WARN_ON(!tty_locked());
acquire_console_sem();
console_lock();
poke_blanked_console();
release_console_sem();
console_unlock();
ld = tty_ldisc_ref(tty);
if (!ld) {

View file

@ -202,7 +202,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
/* Select the proper current console and verify
* sanity of the situation under the console lock.
*/
acquire_console_sem();
console_lock();
attr = (currcons & 128);
currcons = (currcons & 127);
@ -336,9 +336,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
* the pagefault handling code may want to call printk().
*/
release_console_sem();
console_unlock();
ret = copy_to_user(buf, con_buf_start, orig_count);
acquire_console_sem();
console_lock();
if (ret) {
read += (orig_count - ret);
@ -354,7 +354,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
if (read)
ret = read;
unlock_out:
release_console_sem();
console_unlock();
mutex_unlock(&con_buf_mtx);
return ret;
}
@ -379,7 +379,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
/* Select the proper current console and verify
* sanity of the situation under the console lock.
*/
acquire_console_sem();
console_lock();
attr = (currcons & 128);
currcons = (currcons & 127);
@ -414,9 +414,9 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
/* Temporarily drop the console lock so that we can read
* in the write data from userspace safely.
*/
release_console_sem();
console_unlock();
ret = copy_from_user(con_buf, buf, this_round);
acquire_console_sem();
console_lock();
if (ret) {
this_round -= ret;
@ -542,7 +542,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
vcs_scr_updated(vc);
unlock_out:
release_console_sem();
console_unlock();
mutex_unlock(&con_buf_mtx);

View file

@ -1003,9 +1003,9 @@ static int vt_resize(struct tty_struct *tty, struct winsize *ws)
struct vc_data *vc = tty->driver_data;
int ret;
acquire_console_sem();
console_lock();
ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row);
release_console_sem();
console_unlock();
return ret;
}
@ -1271,7 +1271,7 @@ static void default_attr(struct vc_data *vc)
vc->vc_color = vc->vc_def_color;
}
/* console_sem is held */
/* console_lock is held */
static void csi_m(struct vc_data *vc)
{
int i;
@ -1415,7 +1415,7 @@ int mouse_reporting(void)
return vc_cons[fg_console].d->vc_report_mouse;
}
/* console_sem is held */
/* console_lock is held */
static void set_mode(struct vc_data *vc, int on_off)
{
int i;
@ -1485,7 +1485,7 @@ static void set_mode(struct vc_data *vc, int on_off)
}
}
/* console_sem is held */
/* console_lock is held */
static void setterm_command(struct vc_data *vc)
{
switch(vc->vc_par[0]) {
@ -1545,7 +1545,7 @@ static void setterm_command(struct vc_data *vc)
}
}
/* console_sem is held */
/* console_lock is held */
static void csi_at(struct vc_data *vc, unsigned int nr)
{
if (nr > vc->vc_cols - vc->vc_x)
@ -1555,7 +1555,7 @@ static void csi_at(struct vc_data *vc, unsigned int nr)
insert_char(vc, nr);
}
/* console_sem is held */
/* console_lock is held */
static void csi_L(struct vc_data *vc, unsigned int nr)
{
if (nr > vc->vc_rows - vc->vc_y)
@ -1566,7 +1566,7 @@ static void csi_L(struct vc_data *vc, unsigned int nr)
vc->vc_need_wrap = 0;
}
/* console_sem is held */
/* console_lock is held */
static void csi_P(struct vc_data *vc, unsigned int nr)
{
if (nr > vc->vc_cols - vc->vc_x)
@ -1576,7 +1576,7 @@ static void csi_P(struct vc_data *vc, unsigned int nr)
delete_char(vc, nr);
}
/* console_sem is held */
/* console_lock is held */
static void csi_M(struct vc_data *vc, unsigned int nr)
{
if (nr > vc->vc_rows - vc->vc_y)
@ -1587,7 +1587,7 @@ static void csi_M(struct vc_data *vc, unsigned int nr)
vc->vc_need_wrap = 0;
}
/* console_sem is held (except via vc_init->reset_terminal */
/* console_lock is held (except via vc_init->reset_terminal */
static void save_cur(struct vc_data *vc)
{
vc->vc_saved_x = vc->vc_x;
@ -1603,7 +1603,7 @@ static void save_cur(struct vc_data *vc)
vc->vc_saved_G1 = vc->vc_G1_charset;
}
/* console_sem is held */
/* console_lock is held */
static void restore_cur(struct vc_data *vc)
{
gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y);
@ -1625,7 +1625,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
ESpalette };
/* console_sem is held (except via vc_init()) */
/* console_lock is held (except via vc_init()) */
static void reset_terminal(struct vc_data *vc, int do_clear)
{
vc->vc_top = 0;
@ -1685,7 +1685,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
csi_J(vc, 2);
}
/* console_sem is held */
/* console_lock is held */
static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
{
/*
@ -2119,7 +2119,7 @@ static int is_double_width(uint32_t ucs)
return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1);
}
/* acquires console_sem */
/* acquires console_lock */
static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count)
{
#ifdef VT_BUF_VRAM_ONLY
@ -2147,11 +2147,11 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
might_sleep();
acquire_console_sem();
console_lock();
vc = tty->driver_data;
if (vc == NULL) {
printk(KERN_ERR "vt: argh, driver_data is NULL !\n");
release_console_sem();
console_unlock();
return 0;
}
@ -2159,7 +2159,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
if (!vc_cons_allocated(currcons)) {
/* could this happen? */
printk_once("con_write: tty %d not allocated\n", currcons+1);
release_console_sem();
console_unlock();
return 0;
}
@ -2375,7 +2375,7 @@ rescan_last_byte:
}
FLUSH
console_conditional_schedule();
release_console_sem();
console_unlock();
notify_update(vc);
return n;
#undef FLUSH
@ -2388,11 +2388,11 @@ rescan_last_byte:
* us to do the switches asynchronously (needed when we want
* to switch due to a keyboard interrupt). Synchronization
* with other console code and prevention of re-entrancy is
* ensured with console_sem.
* ensured with console_lock.
*/
static void console_callback(struct work_struct *ignored)
{
acquire_console_sem();
console_lock();
if (want_console >= 0) {
if (want_console != fg_console &&
@ -2422,7 +2422,7 @@ static void console_callback(struct work_struct *ignored)
}
notify_update(vc_cons[fg_console].d);
release_console_sem();
console_unlock();
}
int set_console(int nr)
@ -2603,7 +2603,7 @@ static struct console vt_console_driver = {
*/
/*
* Generally a bit racy with respect to console_sem().
* Generally a bit racy with respect to console_lock();.
*
* There are some functions which don't need it.
*
@ -2629,17 +2629,17 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
switch (type)
{
case TIOCL_SETSEL:
acquire_console_sem();
console_lock();
ret = set_selection((struct tiocl_selection __user *)(p+1), tty);
release_console_sem();
console_unlock();
break;
case TIOCL_PASTESEL:
ret = paste_selection(tty);
break;
case TIOCL_UNBLANKSCREEN:
acquire_console_sem();
console_lock();
unblank_screen();
release_console_sem();
console_unlock();
break;
case TIOCL_SELLOADLUT:
ret = sel_loadlut(p);
@ -2688,10 +2688,10 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
}
break;
case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
acquire_console_sem();
console_lock();
ignore_poke = 1;
do_blank_screen(0);
release_console_sem();
console_unlock();
break;
case TIOCL_BLANKEDSCREEN:
ret = console_blanked;
@ -2790,11 +2790,11 @@ static void con_flush_chars(struct tty_struct *tty)
return;
/* if we race with con_close(), vt may be null */
acquire_console_sem();
console_lock();
vc = tty->driver_data;
if (vc)
set_cursor(vc);
release_console_sem();
console_unlock();
}
/*
@ -2805,7 +2805,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
unsigned int currcons = tty->index;
int ret = 0;
acquire_console_sem();
console_lock();
if (tty->driver_data == NULL) {
ret = vc_allocate(currcons);
if (ret == 0) {
@ -2813,7 +2813,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
/* Still being freed */
if (vc->port.tty) {
release_console_sem();
console_unlock();
return -ERESTARTSYS;
}
tty->driver_data = vc;
@ -2827,11 +2827,11 @@ static int con_open(struct tty_struct *tty, struct file *filp)
tty->termios->c_iflag |= IUTF8;
else
tty->termios->c_iflag &= ~IUTF8;
release_console_sem();
console_unlock();
return ret;
}
}
release_console_sem();
console_unlock();
return ret;
}
@ -2844,9 +2844,9 @@ static void con_shutdown(struct tty_struct *tty)
{
struct vc_data *vc = tty->driver_data;
BUG_ON(vc == NULL);
acquire_console_sem();
console_lock();
vc->port.tty = NULL;
release_console_sem();
console_unlock();
tty_shutdown(tty);
}
@ -2893,13 +2893,13 @@ static int __init con_init(void)
struct vc_data *vc;
unsigned int currcons = 0, i;
acquire_console_sem();
console_lock();
if (conswitchp)
display_desc = conswitchp->con_startup();
if (!display_desc) {
fg_console = 0;
release_console_sem();
console_unlock();
return 0;
}
@ -2946,7 +2946,7 @@ static int __init con_init(void)
printable = 1;
printk("\n");
release_console_sem();
console_unlock();
#ifdef CONFIG_VT_CONSOLE
register_console(&vt_console_driver);
@ -2994,7 +2994,7 @@ int __init vty_init(const struct file_operations *console_fops)
if (IS_ERR(tty0dev))
tty0dev = NULL;
else
device_create_file(tty0dev, &dev_attr_active);
WARN_ON(device_create_file(tty0dev, &dev_attr_active) < 0);
vcs_init();
@ -3037,7 +3037,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
if (!try_module_get(owner))
return -ENODEV;
acquire_console_sem();
console_lock();
/* check if driver is registered */
for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@ -3122,7 +3122,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
retval = 0;
err:
release_console_sem();
console_unlock();
module_put(owner);
return retval;
};
@ -3171,7 +3171,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
if (!try_module_get(owner))
return -ENODEV;
acquire_console_sem();
console_lock();
/* check if driver is registered and if it is unbindable */
for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@ -3185,7 +3185,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
}
if (retval) {
release_console_sem();
console_unlock();
goto err;
}
@ -3204,12 +3204,12 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
}
if (retval) {
release_console_sem();
console_unlock();
goto err;
}
if (!con_is_bound(csw)) {
release_console_sem();
console_unlock();
goto err;
}
@ -3238,7 +3238,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
if (!con_is_bound(csw))
con_driver->flag &= ~CON_DRIVER_FLAG_INIT;
release_console_sem();
console_unlock();
/* ignore return value, binding should not fail */
bind_con_driver(defcsw, first, last, deflt);
err:
@ -3538,14 +3538,14 @@ int register_con_driver(const struct consw *csw, int first, int last)
if (!try_module_get(owner))
return -ENODEV;
acquire_console_sem();
console_lock();
for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
con_driver = &registered_con_driver[i];
/* already registered */
if (con_driver->con == csw)
retval = -EINVAL;
retval = -EBUSY;
}
if (retval)
@ -3592,7 +3592,7 @@ int register_con_driver(const struct consw *csw, int first, int last)
}
err:
release_console_sem();
console_unlock();
module_put(owner);
return retval;
}
@ -3613,7 +3613,7 @@ int unregister_con_driver(const struct consw *csw)
{
int i, retval = -ENODEV;
acquire_console_sem();
console_lock();
/* cannot unregister a bound driver */
if (con_is_bound(csw))
@ -3639,7 +3639,7 @@ int unregister_con_driver(const struct consw *csw)
}
}
err:
release_console_sem();
console_unlock();
return retval;
}
EXPORT_SYMBOL(unregister_con_driver);
@ -3656,7 +3656,12 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt)
int err;
err = register_con_driver(csw, first, last);
/* if we get an busy error we still want to bind the console driver
* and return success, as we may have unbound the console driver
 * but not unregistered it.
*/
if (err == -EBUSY)
err = 0;
if (!err)
bind_con_driver(csw, first, last, deflt);
@ -3934,9 +3939,9 @@ int con_set_cmap(unsigned char __user *arg)
{
int rc;
acquire_console_sem();
console_lock();
rc = set_get_cmap (arg,1);
release_console_sem();
console_unlock();
return rc;
}
@ -3945,9 +3950,9 @@ int con_get_cmap(unsigned char __user *arg)
{
int rc;
acquire_console_sem();
console_lock();
rc = set_get_cmap (arg,0);
release_console_sem();
console_unlock();
return rc;
}
@ -3994,12 +3999,12 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
} else
font.data = NULL;
acquire_console_sem();
console_lock();
if (vc->vc_sw->con_font_get)
rc = vc->vc_sw->con_font_get(vc, &font);
else
rc = -ENOSYS;
release_console_sem();
console_unlock();
if (rc)
goto out;
@ -4076,12 +4081,12 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
font.data = memdup_user(op->data, size);
if (IS_ERR(font.data))
return PTR_ERR(font.data);
acquire_console_sem();
console_lock();
if (vc->vc_sw->con_font_set)
rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
else
rc = -ENOSYS;
release_console_sem();
console_unlock();
kfree(font.data);
return rc;
}
@ -4103,12 +4108,12 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
else
name[MAX_FONT_NAME - 1] = 0;
acquire_console_sem();
console_lock();
if (vc->vc_sw->con_font_default)
rc = vc->vc_sw->con_font_default(vc, &font, s);
else
rc = -ENOSYS;
release_console_sem();
console_unlock();
if (!rc) {
op->width = font.width;
op->height = font.height;
@ -4124,7 +4129,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
if (vc->vc_mode != KD_TEXT)
return -EINVAL;
acquire_console_sem();
console_lock();
if (!vc->vc_sw->con_font_copy)
rc = -ENOSYS;
else if (con < 0 || !vc_cons_allocated(con))
@ -4133,7 +4138,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
rc = 0;
else
rc = vc->vc_sw->con_font_copy(vc, con);
release_console_sem();
console_unlock();
return rc;
}

View file

@ -649,12 +649,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
/*
* explicitly blank/unblank the screen if switching modes
*/
acquire_console_sem();
console_lock();
if (arg == KD_TEXT)
do_unblank_screen(1);
else
do_blank_screen(1);
release_console_sem();
console_unlock();
break;
case KDGETMODE:
@ -893,7 +893,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
ret = -EINVAL;
goto out;
}
acquire_console_sem();
console_lock();
vc->vt_mode = tmp;
/* the frsig is ignored, so we set it to 0 */
vc->vt_mode.frsig = 0;
@ -901,7 +901,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
vc->vt_pid = get_pid(task_pid(current));
/* no switch is required -- [email protected] */
vc->vt_newvt = -1;
release_console_sem();
console_unlock();
break;
}
@ -910,9 +910,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
struct vt_mode tmp;
int rc;
acquire_console_sem();
console_lock();
memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode));
release_console_sem();
console_unlock();
rc = copy_to_user(up, &tmp, sizeof(struct vt_mode));
if (rc)
@ -965,9 +965,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
ret = -ENXIO;
else {
arg--;
acquire_console_sem();
console_lock();
ret = vc_allocate(arg);
release_console_sem();
console_unlock();
if (ret)
break;
set_console(arg);
@ -990,7 +990,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
ret = -ENXIO;
else {
vsa.console--;
acquire_console_sem();
console_lock();
ret = vc_allocate(vsa.console);
if (ret == 0) {
struct vc_data *nvc;
@ -1003,7 +1003,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
put_pid(nvc->vt_pid);
nvc->vt_pid = get_pid(task_pid(current));
}
release_console_sem();
console_unlock();
if (ret)
break;
/* Commence switch and lock */
@ -1044,7 +1044,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
/*
* Switching-from response
*/
acquire_console_sem();
console_lock();
if (vc->vt_newvt >= 0) {
if (arg == 0)
/*
@ -1063,7 +1063,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
vc->vt_newvt = -1;
ret = vc_allocate(newvt);
if (ret) {
release_console_sem();
console_unlock();
break;
}
/*
@ -1083,7 +1083,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
if (arg != VT_ACKACQ)
ret = -EINVAL;
}
release_console_sem();
console_unlock();
break;
/*
@ -1096,20 +1096,20 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
}
if (arg == 0) {
/* deallocate all unused consoles, but leave 0 */
acquire_console_sem();
console_lock();
for (i=1; i<MAX_NR_CONSOLES; i++)
if (! VT_BUSY(i))
vc_deallocate(i);
release_console_sem();
console_unlock();
} else {
/* deallocate a single console, if possible */
arg--;
if (VT_BUSY(arg))
ret = -EBUSY;
else if (arg) { /* leave 0 */
acquire_console_sem();
console_lock();
vc_deallocate(arg);
release_console_sem();
console_unlock();
}
}
break;
@ -1126,7 +1126,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
get_user(cc, &vtsizes->v_cols))
ret = -EFAULT;
else {
acquire_console_sem();
console_lock();
for (i = 0; i < MAX_NR_CONSOLES; i++) {
vc = vc_cons[i].d;
@ -1135,7 +1135,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
vc_resize(vc_cons[i].d, cc, ll);
}
}
release_console_sem();
console_unlock();
}
break;
}
@ -1187,14 +1187,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
for (i = 0; i < MAX_NR_CONSOLES; i++) {
if (!vc_cons[i].d)
continue;
acquire_console_sem();
console_lock();
if (vlin)
vc_cons[i].d->vc_scan_lines = vlin;
if (clin)
vc_cons[i].d->vc_font.height = clin;
vc_cons[i].d->vc_resize_user = 1;
vc_resize(vc_cons[i].d, cc, ll);
release_console_sem();
console_unlock();
}
break;
}
@ -1367,7 +1367,7 @@ void vc_SAK(struct work_struct *work)
struct vc_data *vc;
struct tty_struct *tty;
acquire_console_sem();
console_lock();
vc = vc_con->d;
if (vc) {
tty = vc->port.tty;
@ -1379,7 +1379,7 @@ void vc_SAK(struct work_struct *work)
__do_SAK(tty);
reset_vc(vc);
}
release_console_sem();
console_unlock();
}
#ifdef CONFIG_COMPAT
@ -1737,10 +1737,10 @@ int vt_move_to_console(unsigned int vt, int alloc)
{
int prev;
acquire_console_sem();
console_lock();
/* Graphics mode - up to X */
if (disable_vt_switch) {
release_console_sem();
console_unlock();
return 0;
}
prev = fg_console;
@ -1748,7 +1748,7 @@ int vt_move_to_console(unsigned int vt, int alloc)
if (alloc && vc_allocate(vt)) {
/* we can't have a free VC for now. Too bad,
* we don't want to mess the screen for now. */
release_console_sem();
console_unlock();
return -ENOSPC;
}
@ -1758,10 +1758,10 @@ int vt_move_to_console(unsigned int vt, int alloc)
* Let the calling function know so it can decide
* what to do.
*/
release_console_sem();
console_unlock();
return -EIO;
}
release_console_sem();
console_unlock();
tty_lock();
if (vt_waitactive(vt + 1)) {
pr_debug("Suspend: Can't switch VCs.");
@ -1781,8 +1781,8 @@ int vt_move_to_console(unsigned int vt, int alloc)
*/
void pm_set_vt_switch(int do_switch)
{
acquire_console_sem();
console_lock();
disable_vt_switch = !do_switch;
release_console_sem();
console_unlock();
}
EXPORT_SYMBOL(pm_set_vt_switch);