From: nicolas.ferre@atmel.com (Nicolas Ferre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] dmaengine: at_xdmac: double FIFO flush needed to compute residue
Date: Fri, 13 May 2016 14:28:22 +0200 [thread overview]
Message-ID: <5735C866.70800@atmel.com> (raw)
In-Reply-To: <1463064854-6719-3-git-send-email-ludovic.desroches@atmel.com>
Le 12/05/2016 16:54, Ludovic Desroches a ?crit :
> Due to the way CUBC register is updated, a double flush is needed to
> compute an accurate residue. First flush aim is to get data from the DMA
> FIFO and second one ensures that we won't report data which are not in
> memory.
>
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel
> eXtended DMA Controller driver")
> Cc: stable at vger.kernel.org #v4.1 and later
Reviewed-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/dma/at_xdmac.c | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index b02494e..75bd662 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -1425,7 +1425,16 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
> residue = desc->xfer_size;
> /*
> * Flush FIFO: only relevant when the transfer is source peripheral
> - * synchronized.
> + * synchronized. Flush is needed before reading CUBC because data in
> + * the FIFO are not reported by CUBC. Reporting a residue of the
> + * transfer length while we have data in FIFO can cause issue.
> + * Usecase: atmel USART has a timeout which means I have received
> + * characters but there is no more character received for a while. On
> + * timeout, it requests the residue. If the data are in the DMA FIFO,
> + * we will return a residue of the transfer length. It means no data
> + * received. If an application is waiting for these data, it will hang
> + * since we won't have another USART timeout without receiving new
> + * data.
> */
> mask = AT_XDMAC_CC_TYPE | AT_XDMAC_CC_DSYNC;
> value = AT_XDMAC_CC_TYPE_PER_TRAN | AT_XDMAC_CC_DSYNC_PER2MEM;
> @@ -1481,6 +1490,19 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
> }
>
> /*
> + * Flush FIFO: only relevant when the transfer is source peripheral
> + * synchronized. Another flush is needed here because CUBC is updated
> + * when the controller sends the data write command. It can lead to
> + * report data that are not written in the memory or the device. The
> + * FIFO flush ensures that data are really written.
> + */
> + if ((desc->lld.mbr_cfg & mask) == value) {
> + at_xdmac_write(atxdmac, AT_XDMAC_GSWF, atchan->mask);
> + while (!(at_xdmac_chan_read(atchan, AT_XDMAC_CIS) & AT_XDMAC_CIS_FIS))
> + cpu_relax();
> + }
> +
> + /*
> * Remove size of all microblocks already transferred and the current
> * one. Then add the remaining size to transfer of the current
> * microblock.
>
--
Nicolas Ferre
WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: Ludovic Desroches <ludovic.desroches@atmel.com>, <vinod.koul@intel.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
<dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] dmaengine: at_xdmac: double FIFO flush needed to compute residue
Date: Fri, 13 May 2016 14:28:22 +0200 [thread overview]
Message-ID: <5735C866.70800@atmel.com> (raw)
In-Reply-To: <1463064854-6719-3-git-send-email-ludovic.desroches@atmel.com>
Le 12/05/2016 16:54, Ludovic Desroches a écrit :
> Due to the way CUBC register is updated, a double flush is needed to
> compute an accurate residue. First flush aim is to get data from the DMA
> FIFO and second one ensures that we won't report data which are not in
> memory.
>
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel
> eXtended DMA Controller driver")
> Cc: stable@vger.kernel.org #v4.1 and later
Reviewed-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/dma/at_xdmac.c | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index b02494e..75bd662 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -1425,7 +1425,16 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
> residue = desc->xfer_size;
> /*
> * Flush FIFO: only relevant when the transfer is source peripheral
> - * synchronized.
> + * synchronized. Flush is needed before reading CUBC because data in
> + * the FIFO are not reported by CUBC. Reporting a residue of the
> + * transfer length while we have data in FIFO can cause issue.
> + * Usecase: atmel USART has a timeout which means I have received
> + * characters but there is no more character received for a while. On
> + * timeout, it requests the residue. If the data are in the DMA FIFO,
> + * we will return a residue of the transfer length. It means no data
> + * received. If an application is waiting for these data, it will hang
> + * since we won't have another USART timeout without receiving new
> + * data.
> */
> mask = AT_XDMAC_CC_TYPE | AT_XDMAC_CC_DSYNC;
> value = AT_XDMAC_CC_TYPE_PER_TRAN | AT_XDMAC_CC_DSYNC_PER2MEM;
> @@ -1481,6 +1490,19 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
> }
>
> /*
> + * Flush FIFO: only relevant when the transfer is source peripheral
> + * synchronized. Another flush is needed here because CUBC is updated
> + * when the controller sends the data write command. It can lead to
> + * report data that are not written in the memory or the device. The
> + * FIFO flush ensures that data are really written.
> + */
> + if ((desc->lld.mbr_cfg & mask) == value) {
> + at_xdmac_write(atxdmac, AT_XDMAC_GSWF, atchan->mask);
> + while (!(at_xdmac_chan_read(atchan, AT_XDMAC_CIS) & AT_XDMAC_CIS_FIS))
> + cpu_relax();
> + }
> +
> + /*
> * Remove size of all microblocks already transferred and the current
> * one. Then add the remaining size to transfer of the current
> * microblock.
>
--
Nicolas Ferre
next prev parent reply other threads:[~2016-05-13 12:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 14:54 [PATCH 1/3] dmaengine: at_xdmac: align descriptors on 64 bits Ludovic Desroches
2016-05-12 14:54 ` Ludovic Desroches
2016-05-12 14:54 ` [PATCH 2/3] dmaengine: at_xdmac: fix residue corruption Ludovic Desroches
2016-05-12 14:54 ` Ludovic Desroches
2016-05-13 12:27 ` Nicolas Ferre
2016-05-13 12:27 ` Nicolas Ferre
2016-05-12 14:54 ` [PATCH 3/3] dmaengine: at_xdmac: double FIFO flush needed to compute residue Ludovic Desroches
2016-05-12 14:54 ` Ludovic Desroches
2016-05-13 12:28 ` Nicolas Ferre [this message]
2016-05-13 12:28 ` Nicolas Ferre
2016-05-13 12:27 ` [PATCH 1/3] dmaengine: at_xdmac: align descriptors on 64 bits Nicolas Ferre
2016-05-13 12:27 ` Nicolas Ferre
2016-05-30 5:18 ` Vinod Koul
2016-05-30 5:18 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5735C866.70800@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.