Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1516208

Re: [PATCH] serial: sirf: Simplify a test

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [PATCH] serial: sirf: Simplify a test
Date 2016-11-07 15:00 +0100
Message-ID <sASCX-3R8-23@gated-at.bofh.it> (permalink)
References <syBmN-5tE-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tuesday, November 1, 2016 8:03:33 AM CET Christophe JAILLET wrote:
> 'dmaengine_prep_dma_cyclic()' does not return an error pointer, so the test
> can be simplified to be more consistent.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

The change looks correct in principle. It would be good to automate looking
for other instances of this bug. How did you find it? Do you have e.g. a
coccinelle script or did you just stumble over the issue by accident?

There is one problem with your patch:

>  drivers/tty/serial/sirfsoc_uart.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c
> index b186c9c4f850..666ca3156961 100644
> --- a/drivers/tty/serial/sirfsoc_uart.c
> +++ b/drivers/tty/serial/sirfsoc_uart.c
> @@ -609,7 +609,7 @@ static void sirfsoc_uart_start_next_rx_dma(struct uart_port *port)
>                 sirfport->rx_dma_items.dma_addr, SIRFSOC_RX_DMA_BUF_SIZE,
>                 SIRFSOC_RX_DMA_BUF_SIZE / 2,
>                 DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT);
> -       if (IS_ERR_OR_NULL(sirfport->rx_dma_items.desc)) {
> +       if (!sirfport->rx_dma_items.desc) {
>                 dev_err(port->dev, "DMA slave single fail\n");
>                 return;
>         }

The serial driver is for the sirf platform, which uses the sirf-dma
dmaengine driver, and that particular driver has an incorrect
dma_prep_cyclic implementation, so I think we also need this fix:

diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index 8f62edad51be..220c611c89ae 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -775,7 +775,7 @@ sirfsoc_dma_prep_cyclic(struct dma_chan *chan, dma_addr_t addr,
 	 * BUFB
 	 */
 	if (buf_len !=  2 * period_len)
-		return ERR_PTR(-EINVAL);
+		return NULL;
 
 	/* Get free descriptor */
 	spin_lock_irqsave(&schan->lock, iflags);


	Arnd

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] serial: sirf: Simplify a test Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-11-01 08:10 +0100
  Re: [PATCH] serial: sirf: Simplify a test Arnd Bergmann <arnd@arndb.de> - 2016-11-07 15:00 +0100
    Re: [PATCH] serial: sirf: Simplify a test Julia Lawall <julia.lawall@lip6.fr> - 2016-11-07 18:30 +0100
    Re: [PATCH] serial: sirf: Simplify a test Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-11-08 08:20 +0100
      Re: [PATCH] serial: sirf: Simplify a test Arnd Bergmann <arnd@arndb.de> - 2016-11-08 12:50 +0100
      Re: [PATCH] serial: sirf: Simplify a test Julia Lawall <julia.lawall@lip6.fr> - 2016-11-10 22:20 +0100

csiph-web