8250_dw and 8250_dma fixes
Subsystems (3)
cover 8250_dw and 8250_dma fixes
Hi,
The 8250_dma.c needs to be converted to use tty_port since the tty buffer functions are now changes. The 8250_dw.c needs to have ifdef wrapping the ACPI code as there are no stubs for ACPI functions.
There is also an optimisation for 8250_dw.c and an optimisation for 8250_dma.c in this set.
Heikki Krogerus (4):
serial: 8250_dma: Switch to using tty_port
serial: 8250_dma: TX optimisation
serial: 8250_dw: Use ifdef with ACPI
serial: 8250_dw: Set maxburst size
drivers/tty/serial/8250/8250_dma.c | 17 ++++++++++------- drivers/tty/serial/8250/8250_dw.c | 13 +++++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/4 serial: 8250_dma: Switch to using tty_port
The tty buffer functions are converted to using tty_port structure instead of struct tty, so we must do the same.
--- drivers/tty/serial/8250/8250_dma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_dma.c +7 -4
@@ -43,8 +43,9 @@ static void __dma_rx_complete(void *param) {struct uart_8250_port *p = param;struct uart_8250_dma *dma = p->dma; -struct tty_struct *tty = p->port.state->port.tty; +struct tty_port *tty_port = &p->port.state->port;struct dma_tx_state state; +int count;dma_sync_single_for_cpu (dma->rxchan->device->dev, dma->rx_addr, dma->rx_size,DMA_FROM_DEVICE );
@@ -52,10 +53,12 @@ static void __dma_rx_complete(void *param)dmaengine_tx_status (dma->rxchan, dma->rx_cookie, &state);dmaengine_terminate_all (dma->rxchan); -tty_insert_flip_string (tty, dma->rx_buf, dma->rx_size - state.residue); - p->port.icount.rx += dma->rx_size - state.residue; + count = dma->rx_size - state.residue; -tty_flip_buffer_push (tty); +tty_insert_flip_string (tty_port, dma->rx_buf, count); + p->port.icount.rx += count; + +tty_flip_buffer_push (tty_port); }int serial8250_tx_dma (struct uart_8250_port *p)
Signature · 1 line
1.7.10.4
PATCH 2/4 serial: 8250_dma: TX optimisation
In reply to Heikki KrogerusRemove one useless wakeup, and do not use DMA with zero byte transfers.
--- drivers/tty/serial/8250/8250_dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_dma.c +3 -3
@@ -67,12 +67,12 @@ int serial8250_tx_dma(struct uart_8250_port *p)struct circ_buf *xmit = &p->port.state->xmit;struct dma_async_tx_descriptor *desc; -if (dma->tx_running) { -uart_write_wakeup (&p->port); +if (dma->tx_running)return -EBUSY ; - } dma->tx_size =CIRC_CNT_TO_END (xmit->head, xmit->tail,UART_XMIT_SIZE ); +if (!dma->tx_size) +return -EINVAL ; desc = dmaengine_prep_slave_single(dma->txchan, dma->tx_addr + xmit->tail,
Signature · 1 line
1.7.10.4
PATCH 3/4 serial: 8250_dw: Use ifdef with ACPI
In reply to Heikki KrogerusThere are no stubs for ACPI functions so the driver needs to have this ifdef or it will not compile without ACPI.
--- drivers/tty/serial/8250/8250_dw.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/tty/serial/8250/8250_dw.c +7 -0
@@ -145,6 +145,7 @@ static int dw8250_probe_of(struct uart_port *p)return 0 ; } +#ifdef CONFIG_ACPI static bool dw8250_acpi_dma_filter (struct dma_chan *chan,void *parm) {return chan->chan_id == *(int *)parm;
@@ -231,6 +232,12 @@ static int dw8250_probe_acpi(struct uart_port *p) return 0; } +#else +static inline int dw8250_probe_acpi (struct uart_port *p) +{ +return -ENODEV ; +} +#endif /* CONFIG_ACPI */ static void dw8250_setup_port (struct uart_8250_port *up) {
Signature · 1 line
1.7.10.4
PATCH 4/4 serial: 8250_dw: Set maxburst size
In reply to Heikki KrogerusThe default burst is often 1 byte which is not very optimal. The ideal burst size when using 16550A type port would be 1/2 of fifosize, but this does not work with all Designware implementations. Setting it to 1/4 fifosize.
--- drivers/tty/serial/8250/8250_dw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_dw.c +4 -2
@@ -178,6 +178,7 @@ dw8250_acpi_walk_resource(struct acpi_resource *res, void *data) slave->direction =DMA_MEM_TO_DEV ; slave->dst_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ; slave->slave_id = fixed_dma->request_lines; + slave->dst_maxburst = port->tx_loadsz /4 ; dma->tx_chan_id = fixed_dma->channels; dma->tx_param = &dma->tx_chan_id;
@@ -189,6 +190,7 @@ dw8250_acpi_walk_resource(struct acpi_resource *res, void *data) slave->direction =DMA_DEV_TO_MEM ; slave->src_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ; slave->slave_id = fixed_dma->request_lines; + slave->src_maxburst = p->fifosize /4 ; dma->rx_chan_id = fixed_dma->channels; dma->rx_param = &dma->rx_chan_id;
@@ -296,6 +298,8 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.serial_in = dw8250_serial_in; uart.port.serial_out = dw8250_serial_out; +dw8250_setup_port (&uart); +if (pdev->dev.of_node) { err =dw8250_probe_of (&uart.port);if (err)
@@ -308,8 +312,6 @@ static int dw8250_probe(struct platform_device *pdev)return -ENODEV ; } -dw8250_setup_port (&uart); - data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ;
Signature · 1 line
1.7.10.4