diff mbox series

[02/10] dmaengine: bcm2835: Allow cyclic transactions without interrupt

Message ID 037b83d2ae8aa92448b9d647436012c06f4c0561.1564825752.git.lukas@wunner.de (mailing list archive)
State Not Applicable
Headers show
Series Raspberry Pi SPI speedups | expand

Commit Message

Lukas Wunner Aug. 3, 2019, 10:10 a.m. UTC
The BCM2835 DMA driver currently requests an interrupt from the
controller regardless whether or not the client has passed in the
DMA_PREP_INTERRUPT flag. This causes unnecessary overhead for cyclic
transactions which do not need an interrupt after each period.

We're about to add such a use case, namely cyclic clearing of the SPI
controller's RX FIFO, so amend the DMA driver to request an interrupt
only if DMA_PREP_INTERRUPT was passed in. Ignore the period_len for
such transactions and set it to the buffer length to make the driver's
calculations work.

Tested-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Martin Sperl <kernel@martin.sperl.org>
Cc: Florian Kauer <florian.kauer@koalo.de>
---
 drivers/dma/bcm2835-dma.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Vinod Koul Aug. 8, 2019, 12:30 p.m. UTC | #1
On 03-08-19, 12:10, Lukas Wunner wrote:
> The BCM2835 DMA driver currently requests an interrupt from the
> controller regardless whether or not the client has passed in the
> DMA_PREP_INTERRUPT flag. This causes unnecessary overhead for cyclic
> transactions which do not need an interrupt after each period.
> 
> We're about to add such a use case, namely cyclic clearing of the SPI
> controller's RX FIFO, so amend the DMA driver to request an interrupt
> only if DMA_PREP_INTERRUPT was passed in. Ignore the period_len for
> such transactions and set it to the buffer length to make the driver's
> calculations work.

Acked-by: Vinod Koul <vkoul@kernel.org>

> 
> Tested-by: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Cc: Martin Sperl <kernel@martin.sperl.org>
> Cc: Florian Kauer <florian.kauer@koalo.de>
> ---
>  drivers/dma/bcm2835-dma.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index 523c507ad69e..a65514fcb7f2 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
> @@ -691,7 +691,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
>  	struct bcm2835_desc *d;
>  	dma_addr_t src, dst;
>  	u32 info = BCM2835_DMA_WAIT_RESP;
> -	u32 extra = BCM2835_DMA_INT_EN;
> +	u32 extra = 0;
>  	size_t max_len = bcm2835_dma_max_frame_length(c);
>  	size_t frames;
>  
> @@ -707,6 +707,11 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
>  		return NULL;
>  	}
>  
> +	if (flags & DMA_PREP_INTERRUPT)
> +		extra |= BCM2835_DMA_INT_EN;
> +	else
> +		period_len = buf_len;
> +
>  	/*
>  	 * warn if buf_len is not a multiple of period_len - this may leed
>  	 * to unexpected latencies for interrupts and thus audiable clicks
> @@ -778,7 +783,10 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan)
>  
>  	/* stop DMA activity */
>  	if (c->desc) {
> -		vchan_terminate_vdesc(&c->desc->vd);
> +		if (c->desc->vd.tx.flags & DMA_PREP_INTERRUPT)
> +			vchan_terminate_vdesc(&c->desc->vd);
> +		else
> +			vchan_vdesc_fini(&c->desc->vd);
>  		c->desc = NULL;
>  		bcm2835_dma_abort(c);
>  	}
> -- 
> 2.20.1
diff mbox series

Patch

diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 523c507ad69e..a65514fcb7f2 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -691,7 +691,7 @@  static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
 	struct bcm2835_desc *d;
 	dma_addr_t src, dst;
 	u32 info = BCM2835_DMA_WAIT_RESP;
-	u32 extra = BCM2835_DMA_INT_EN;
+	u32 extra = 0;
 	size_t max_len = bcm2835_dma_max_frame_length(c);
 	size_t frames;
 
@@ -707,6 +707,11 @@  static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
 		return NULL;
 	}
 
+	if (flags & DMA_PREP_INTERRUPT)
+		extra |= BCM2835_DMA_INT_EN;
+	else
+		period_len = buf_len;
+
 	/*
 	 * warn if buf_len is not a multiple of period_len - this may leed
 	 * to unexpected latencies for interrupts and thus audiable clicks
@@ -778,7 +783,10 @@  static int bcm2835_dma_terminate_all(struct dma_chan *chan)
 
 	/* stop DMA activity */
 	if (c->desc) {
-		vchan_terminate_vdesc(&c->desc->vd);
+		if (c->desc->vd.tx.flags & DMA_PREP_INTERRUPT)
+			vchan_terminate_vdesc(&c->desc->vd);
+		else
+			vchan_vdesc_fini(&c->desc->vd);
 		c->desc = NULL;
 		bcm2835_dma_abort(c);
 	}