]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'tty/tty-next'
authorThierry Reding <treding@nvidia.com>
Thu, 24 Oct 2013 12:59:14 +0000 (14:59 +0200)
committerThierry Reding <treding@nvidia.com>
Thu, 24 Oct 2013 12:59:14 +0000 (14:59 +0200)
Conflicts:
drivers/tty/serial/atmel_serial.c
drivers/tty/serial/imx.c

1  2 
drivers/tty/serial/imx.c
drivers/tty/serial/pmac_zilog.c
drivers/tty/serial/ucc_uart.c
include/linux/tty.h
kernel/sysctl.c

diff --combined drivers/tty/serial/imx.c
index 042aa077b5b3e166a8453ac0684da1dd024f6785,bb84f8d4c54e3a6d1e810692c85065bd060434fa..b2cfdb661947ec2690fc4840e089688151749a68
@@@ -223,8 -223,7 +223,7 @@@ struct imx_port 
        struct dma_chan         *dma_chan_rx, *dma_chan_tx;
        struct scatterlist      rx_sgl, tx_sgl[2];
        void                    *rx_buf;
-       unsigned int            rx_bytes, tx_bytes;
-       struct work_struct      tsk_dma_rx, tsk_dma_tx;
+       unsigned int            tx_bytes;
        unsigned int            dma_tx_nents;
        wait_queue_head_t       dma_wait;
  };
@@@ -505,34 -504,25 +504,25 @@@ static void dma_tx_callback(void *data
                dev_dbg(sport->port.dev, "exit in %s.\n", __func__);
                return;
        }
-       schedule_work(&sport->tsk_dma_tx);
  }
  
- static void dma_tx_work(struct work_struct *w)
+ static void imx_dma_tx(struct imx_port *sport)
  {
-       struct imx_port *sport = container_of(w, struct imx_port, tsk_dma_tx);
        struct circ_buf *xmit = &sport->port.state->xmit;
        struct scatterlist *sgl = sport->tx_sgl;
        struct dma_async_tx_descriptor *desc;
        struct dma_chan *chan = sport->dma_chan_tx;
        struct device *dev = sport->port.dev;
        enum dma_status status;
-       unsigned long flags;
        int ret;
  
-       status = chan->device->device_tx_status(chan, (dma_cookie_t)0, NULL);
+       status = dmaengine_tx_status(chan, (dma_cookie_t)0, NULL);
        if (DMA_IN_PROGRESS == status)
                return;
  
-       spin_lock_irqsave(&sport->port.lock, flags);
        sport->tx_bytes = uart_circ_chars_pending(xmit);
-       if (sport->tx_bytes == 0) {
-               spin_unlock_irqrestore(&sport->port.lock, flags);
-               return;
-       }
  
-       if (xmit->tail > xmit->head) {
+       if (xmit->tail > xmit->head && xmit->head > 0) {
                sport->dma_tx_nents = 2;
                sg_init_table(sgl, 2);
                sg_set_buf(sgl, xmit->buf + xmit->tail,
                sport->dma_tx_nents = 1;
                sg_init_one(sgl, xmit->buf + xmit->tail, sport->tx_bytes);
        }
-       spin_unlock_irqrestore(&sport->port.lock, flags);
  
        ret = dma_map_sg(dev, sgl, sport->dma_tx_nents, DMA_TO_DEVICE);
        if (ret == 0) {
@@@ -609,11 -598,7 +598,7 @@@ static void imx_start_tx(struct uart_po
        }
  
        if (sport->dma_is_enabled) {
-               /*
-                * We may in the interrupt context, so arise a work_struct to
-                * do the real job.
-                */
-               schedule_work(&sport->tsk_dma_tx);
+               imx_dma_tx(sport);
                return;
        }
  
@@@ -732,6 -717,7 +717,7 @@@ out
        return IRQ_HANDLED;
  }
  
+ static int start_rx_dma(struct imx_port *sport);
  /*
   * If the RXFIFO is filled with some data, and then we
   * arise a DMA operation to receive them.
@@@ -750,7 -736,7 +736,7 @@@ static void imx_dma_rxint(struct imx_po
                writel(temp, sport->port.membase + UCR1);
  
                /* tell the DMA to receive the data. */
-               schedule_work(&sport->tsk_dma_rx);
+               start_rx_dma(sport);
        }
  }
  
@@@ -795,8 -781,15 +781,15 @@@ static irqreturn_t imx_int(int irq, voi
  static unsigned int imx_tx_empty(struct uart_port *port)
  {
        struct imx_port *sport = (struct imx_port *)port;
+       unsigned int ret;
+       ret = (readl(sport->port.membase + USR2) & USR2_TXDC) ?  TIOCSER_TEMT : 0;
  
-       return (readl(sport->port.membase + USR2) & USR2_TXDC) ?  TIOCSER_TEMT : 0;
+       /* If the TX DMA is working, return 0. */
+       if (sport->dma_is_enabled && sport->dma_is_txing)
+               ret = 0;
+       return ret;
  }
  
  /*
@@@ -865,22 -858,6 +858,6 @@@ static int imx_setup_ufcr(struct imx_po
  }
  
  #define RX_BUF_SIZE   (PAGE_SIZE)
- static int start_rx_dma(struct imx_port *sport);
- static void dma_rx_work(struct work_struct *w)
- {
-       struct imx_port *sport = container_of(w, struct imx_port, tsk_dma_rx);
-       struct tty_port *port = &sport->port.state->port;
-       if (sport->rx_bytes) {
-               tty_insert_flip_string(port, sport->rx_buf, sport->rx_bytes);
-               tty_flip_buffer_push(port);
-               sport->rx_bytes = 0;
-       }
-       if (sport->dma_is_rxing)
-               start_rx_dma(sport);
- }
  static void imx_rx_dma_done(struct imx_port *sport)
  {
        unsigned long temp;
@@@ -912,6 -889,7 +889,7 @@@ static void dma_rx_callback(void *data
        struct imx_port *sport = data;
        struct dma_chan *chan = sport->dma_chan_rx;
        struct scatterlist *sgl = &sport->rx_sgl;
+       struct tty_port *port = &sport->port.state->port;
        struct dma_tx_state state;
        enum dma_status status;
        unsigned int count;
        /* unmap it first */
        dma_unmap_sg(sport->port.dev, sgl, 1, DMA_FROM_DEVICE);
  
-       status = chan->device->device_tx_status(chan, (dma_cookie_t)0, &state);
+       status = dmaengine_tx_status(chan, (dma_cookie_t)0, &state);
        count = RX_BUF_SIZE - state.residue;
        dev_dbg(sport->port.dev, "We get %d bytes.\n", count);
  
        if (count) {
-               sport->rx_bytes = count;
-               schedule_work(&sport->tsk_dma_rx);
+               tty_insert_flip_string(port, sport->rx_buf, count);
+               tty_flip_buffer_push(port);
+               start_rx_dma(sport);
        } else
                imx_rx_dma_done(sport);
  }
@@@ -1007,7 -987,6 +987,6 @@@ static int imx_uart_dma_init(struct imx
                ret = -ENOMEM;
                goto err;
        }
-       sport->rx_bytes = 0;
  
        /* Prepare for TX : */
        sport->dma_chan_tx = dma_request_slave_channel(dev, "tx");
@@@ -1038,11 -1017,7 +1017,7 @@@ err
  static void imx_enable_dma(struct imx_port *sport)
  {
        unsigned long temp;
-       struct tty_port *port = &sport->port.state->port;
  
-       port->low_latency = 1;
-       INIT_WORK(&sport->tsk_dma_tx, dma_tx_work);
-       INIT_WORK(&sport->tsk_dma_rx, dma_rx_work);
        init_waitqueue_head(&sport->dma_wait);
  
        /* set UCR1 */
  static void imx_disable_dma(struct imx_port *sport)
  {
        unsigned long temp;
-       struct tty_port *port = &sport->port.state->port;
  
        /* clear UCR1 */
        temp = readl(sport->port.membase + UCR1);
        writel(temp, sport->port.membase + UCR4);
  
        sport->dma_is_enabled = 0;
-       port->low_latency = 0;
  }
  
  /* half the RX buffer size */
@@@ -1303,6 -1276,16 +1276,16 @@@ static void imx_shutdown(struct uart_po
        clk_disable_unprepare(sport->clk_ipg);
  }
  
+ static void imx_flush_buffer(struct uart_port *port)
+ {
+       struct imx_port *sport = (struct imx_port *)port;
+       if (sport->dma_is_enabled) {
+               sport->tx_bytes = 0;
+               dmaengine_terminate_all(sport->dma_chan_tx);
+       }
+ }
  static void
  imx_set_termios(struct uart_port *port, struct ktermios *termios,
                   struct ktermios *old)
@@@ -1539,7 -1522,7 +1522,7 @@@ imx_verify_port(struct uart_port *port
                ret = -EINVAL;
        if (sport->port.uartclk / 16 != ser->baud_base)
                ret = -EINVAL;
-       if ((void *)sport->port.mapbase != ser->iomem_base)
+       if (sport->port.mapbase != (unsigned long)ser->iomem_base)
                ret = -EINVAL;
        if (sport->port.iobase != ser->port)
                ret = -EINVAL;
@@@ -1623,6 -1606,7 +1606,7 @@@ static struct uart_ops imx_pops = 
        .break_ctl      = imx_break_ctl,
        .startup        = imx_startup,
        .shutdown       = imx_shutdown,
+       .flush_buffer   = imx_flush_buffer,
        .set_termios    = imx_set_termios,
        .type           = imx_type,
        .release_port   = imx_release_port,
@@@ -1912,6 -1896,10 +1896,6 @@@ static int serial_imx_probe_dt(struct i
  
        sport->devdata = of_id->data;
  
 -      if (of_device_is_stdout_path(np))
 -              add_preferred_console(imx_reg.cons->name, sport->port.line,
 -                                    NULL);
 -
        return 0;
  }
  #else
index 246b4c327a543a3ec2d2a6742b9c051b2782887b,95917cefe14f53e3a03bf099844d8351647cce31..481b781b26e370e23fea8d2088311562c15cde87
@@@ -57,8 -57,6 +57,8 @@@
  #include <linux/bitops.h>
  #include <linux/sysrq.h>
  #include <linux/mutex.h>
 +#include <linux/of_address.h>
 +#include <linux/of_irq.h>
  #include <asm/sections.h>
  #include <asm/io.h>
  #include <asm/irq.h>
@@@ -1074,7 -1072,7 +1074,7 @@@ static void pmz_convert_to_zs(struct ua
                uap->curregs[5] |= Tx8;
                uap->parity_mask = 0xff;
                break;
-       };
+       }
        uap->curregs[4] &= ~(SB_MASK);
        if (cflag & CSTOPB)
                uap->curregs[4] |= SB2;
index 9de1da0c9d891fddf6eb155f897ba54f341a0591,2fd1e1789811941aea3c2d8de3611e916440e0a7..d569ca58bab6cd9f092361b2656105a57dc11846
@@@ -25,8 -25,6 +25,8 @@@
  #include <linux/tty.h>
  #include <linux/tty_flip.h>
  #include <linux/io.h>
 +#include <linux/of_address.h>
 +#include <linux/of_irq.h>
  #include <linux/of_platform.h>
  #include <linux/dma-mapping.h>
  
@@@ -271,7 -269,7 +271,7 @@@ static unsigned int qe_uart_tx_empty(st
                        return 1;
  
                bdp++;
-       };
+       }
  }
  
  /*
diff --combined include/linux/tty.h
index 633cac77f9f97b56155bf5a005aa2899591425ac,2f47989d8288b2fce1c0e000a1020cecb9b73f54..97d660ed70c1901407dac9ea49bd1036840e649c
@@@ -180,7 -180,6 +180,6 @@@ struct tty_port_operations 
           IFF the port was initialized. Do not use to free resources. Called
           under the port mutex to serialize against activate/shutdowns */
        void (*shutdown)(struct tty_port *port);
-       void (*drop)(struct tty_port *port);
        /* Called under the port mutex from tty_port_open, serialized using
           the port mutex */
          /* FIXME: long term getting the tty argument *out* of this would be
@@@ -672,17 -671,31 +671,17 @@@ static inline void tty_wait_until_sent_
  #define wait_event_interruptible_tty(tty, wq, condition)              \
  ({                                                                    \
        int __ret = 0;                                                  \
 -      if (!(condition)) {                                             \
 -              __wait_event_interruptible_tty(tty, wq, condition, __ret);      \
 -      }                                                               \
 +      if (!(condition))                                               \
 +              __ret = __wait_event_interruptible_tty(tty, wq,         \
 +                                                     condition);      \
        __ret;                                                          \
  })
  
 -#define __wait_event_interruptible_tty(tty, wq, condition, ret)               \
 -do {                                                                  \
 -      DEFINE_WAIT(__wait);                                            \
 -                                                                      \
 -      for (;;) {                                                      \
 -              prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);      \
 -              if (condition)                                          \
 -                      break;                                          \
 -              if (!signal_pending(current)) {                         \
 -                      tty_unlock(tty);                                        \
 +#define __wait_event_interruptible_tty(tty, wq, condition)            \
 +      ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0,          \
 +                      tty_unlock(tty);                                \
                        schedule();                                     \
 -                      tty_lock(tty);                                  \
 -                      continue;                                       \
 -              }                                                       \
 -              ret = -ERESTARTSYS;                                     \
 -              break;                                                  \
 -      }                                                               \
 -      finish_wait(&wq, &__wait);                                      \
 -} while (0)
 +                      tty_lock(tty))
  
  #ifdef CONFIG_PROC_FS
  extern void proc_tty_register_driver(struct tty_driver *);
diff --combined kernel/sysctl.c
index 5c704dbf6d45c2196a460d640a508a643cb7f03a,8b80f1bae21a56de33b18ce198d1df5272fbce0f..9aa71cec9e0e57246b64fdcdf094b672a9185044
@@@ -190,7 -190,7 +190,7 @@@ static int proc_dostring_coredump(struc
  
  #ifdef CONFIG_MAGIC_SYSRQ
  /* Note: sysrq code uses it's own private copy */
- static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
+ static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
  
  static int sysrq_sysctl_handler(ctl_table *table, int write,
                                void __user *buffer, size_t *lenp,
@@@ -370,6 -370,13 +370,6 @@@ static struct ctl_table kern_table[] = 
                .mode           = 0644,
                .proc_handler   = proc_dointvec,
        },
 -      {
 -              .procname       = "numa_balancing_scan_period_reset",
 -              .data           = &sysctl_numa_balancing_scan_period_reset,
 -              .maxlen         = sizeof(unsigned int),
 -              .mode           = 0644,
 -              .proc_handler   = proc_dointvec,
 -      },
        {
                .procname       = "numa_balancing_scan_period_max_ms",
                .data           = &sysctl_numa_balancing_scan_period_max,
                .mode           = 0644,
                .proc_handler   = proc_dointvec,
        },
 +      {
 +              .procname       = "numa_balancing_settle_count",
 +              .data           = &sysctl_numa_balancing_settle_count,
 +              .maxlen         = sizeof(unsigned int),
 +              .mode           = 0644,
 +              .proc_handler   = proc_dointvec,
 +      },
 +      {
 +              .procname       = "numa_balancing_migrate_deferred",
 +              .data           = &sysctl_numa_balancing_migrate_deferred,
 +              .maxlen         = sizeof(unsigned int),
 +              .mode           = 0644,
 +              .proc_handler   = proc_dointvec,
 +      },
  #endif /* CONFIG_NUMA_BALANCING */
  #endif /* CONFIG_SCHED_DEBUG */
        {
        {
                .procname       = "hung_task_check_count",
                .data           = &sysctl_hung_task_check_count,
 -              .maxlen         = sizeof(unsigned long),
 +              .maxlen         = sizeof(int),
                .mode           = 0644,
 -              .proc_handler   = proc_doulongvec_minmax,
 +              .proc_handler   = proc_dointvec_minmax,
 +              .extra1         = &zero,
        },
        {
                .procname       = "hung_task_timeout_secs",
                .maxlen         = sizeof(sysctl_perf_event_sample_rate),
                .mode           = 0644,
                .proc_handler   = perf_proc_update_handler,
 +              .extra1         = &one,
        },
        {
                .procname       = "perf_cpu_time_max_percent",