Skip to content

Commit

Permalink
s32k3xx:Serial refactor out tx dma semaphore
Browse files Browse the repository at this point in the history
    Fixes stuttering output.

    The use of the semaphore was causing blocking
    on non blocking callers. This ensured that
    the TX DAM would be restated, but when it
    was switched to trywait in 8362e31, it left
    data in the xmit queue unsent.

    This solution removes the semaphore and restart
    the DMA on completion if there is more data in
    the xmit queue to be sent.
  • Loading branch information
davids5 committed Dec 5, 2023
1 parent d40ce1b commit 7efbc08
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions arch/arm/src/s32k3xx/s32k3xx_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,6 @@ struct s32k3xx_uart_s
#ifdef SERIAL_HAVE_TXDMA
const unsigned int dma_txreqsrc; /* DMAMUX source of TX DMA request */
DMACH_HANDLE txdma; /* currently-open transmit DMA stream */
sem_t txdmasem; /* Indicate TX DMA completion */
#endif

/* RX DMA state */
Expand Down Expand Up @@ -2913,9 +2912,6 @@ static int s32k3xx_dma_setup(struct uart_dev_s *dev)
{
return -EBUSY;
}

nxsem_init(&priv->txdmasem, 0, 1);
nxsem_set_protocol(&priv->txdmasem, SEM_PRIO_NONE);
}

/* Enable Tx DMA for the UART */
Expand Down Expand Up @@ -3120,7 +3116,6 @@ static void s32k3xx_dma_shutdown(struct uart_dev_s *dev)

s32k3xx_dmach_free(priv->txdma);
priv->txdma = NULL;
nxsem_destroy(&priv->txdmasem);
}
#endif
}
Expand Down Expand Up @@ -3988,9 +3983,9 @@ static void s32k3xx_dma_txcallback(DMACH_HANDLE handle, void *arg, bool done,

uart_xmitchars_done(&priv->dev);

/* Release waiter */
/* Send more data if available */

nxsem_post(&priv->txdmasem);
s32k3xx_dma_txavailable(&priv->dev);
}
#endif

Expand All @@ -4009,9 +4004,7 @@ static void s32k3xx_dma_txavailable(struct uart_dev_s *dev)

/* Only send when the DMA is idle */

int rv = nxsem_trywait(&priv->txdmasem);

if (rv == OK)
if (s32k3xx_dmach_idle(priv->txdma) == 0)
{
uart_xmitchars_dma(dev);
}
Expand Down

0 comments on commit 7efbc08

Please sign in to comment.