* dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
@ 2018-02-02 10:05 ` Yoshihiro Shimoda
0 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2018-02-02 10:05 UTC (permalink / raw)
To: vinod.koul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda
This patch fixes an issue that a race condition happens between a client
driver and the rcar-dmac driver:
- The rcar_dmac_isr_transfer_end() is called.
- The done list appears, and desc.running is the next active list.
- rcar_dmac_chan_get_residue() is called by a client driver before
rcar_dmac_isr_channel_thread() is called.
- The rcar_dmac_chan_get_residue() will not find any descriptors.
- And, the following WARNING happens:
WARN(1, "No descriptor for cookie!");
The sh-sci driver with HSCIF (921,600bps) on R-Car H3 can cause this
situation.
So, this patch checks the done lists in rcar_dmac_chan_get_residue()
and returns zero if the done lists has the argument cookie.
Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/dma/sh/rcar-dmac.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 2b2c7db..f748be6 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1264,8 +1264,17 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
* If the cookie doesn't correspond to the currently running transfer
* then the descriptor hasn't been processed yet, and the residue is
* equal to the full descriptor size.
+ * Also, a client driver is possible to call this function before
+ * rcar_dmac_isr_channel_thread() runs. In this case, the "desc.running"
+ * will be the next descriptor, and the done list will appear. So, if
+ * the argument cookie matches the done list's cookie, we can assume
+ * the residue is zero.
*/
if (cookie != desc->async_tx.cookie) {
+ list_for_each_entry(desc, &chan->desc.done, node) {
+ if (cookie == desc->async_tx.cookie)
+ return 0;
+ }
list_for_each_entry(desc, &chan->desc.pending, node) {
if (cookie == desc->async_tx.cookie)
return desc->size;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
@ 2018-02-02 10:05 ` Yoshihiro Shimoda
0 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2018-02-02 10:05 UTC (permalink / raw)
To: vinod.koul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda
This patch fixes an issue that a race condition happens between a client
driver and the rcar-dmac driver:
- The rcar_dmac_isr_transfer_end() is called.
- The done list appears, and desc.running is the next active list.
- rcar_dmac_chan_get_residue() is called by a client driver before
rcar_dmac_isr_channel_thread() is called.
- The rcar_dmac_chan_get_residue() will not find any descriptors.
- And, the following WARNING happens:
WARN(1, "No descriptor for cookie!");
The sh-sci driver with HSCIF (921,600bps) on R-Car H3 can cause this
situation.
So, this patch checks the done lists in rcar_dmac_chan_get_residue()
and returns zero if the done lists has the argument cookie.
Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/dma/sh/rcar-dmac.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 2b2c7db..f748be6 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1264,8 +1264,17 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
* If the cookie doesn't correspond to the currently running transfer
* then the descriptor hasn't been processed yet, and the residue is
* equal to the full descriptor size.
+ * Also, a client driver is possible to call this function before
+ * rcar_dmac_isr_channel_thread() runs. In this case, the "desc.running"
+ * will be the next descriptor, and the done list will appear. So, if
+ * the argument cookie matches the done list's cookie, we can assume
+ * the residue is zero.
*/
if (cookie != desc->async_tx.cookie) {
+ list_for_each_entry(desc, &chan->desc.done, node) {
+ if (cookie == desc->async_tx.cookie)
+ return 0;
+ }
list_for_each_entry(desc, &chan->desc.pending, node) {
if (cookie == desc->async_tx.cookie)
return desc->size;
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
2018-02-02 10:05 ` [PATCH] " Yoshihiro Shimoda
@ 2018-03-01 5:39 ` Yoshihiro Shimoda
-1 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2018-03-01 5:39 UTC (permalink / raw)
To: vinod.koul; +Cc: dmaengine, linux-renesas-soc
Hi Vinod,
Would you review this patch?
Or, should I rebase this on the latest your repo?
Best regards,
Yoshihiro Shimoda
> -----Original Message-----
> From: Yoshihiro Shimoda
> Sent: Friday, February 2, 2018 7:05 PM
> To: vinod.koul@intel.com
> Cc: dmaengine@vger.kernel.org; linux-renesas-soc@vger.kernel.org; Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Subject: [PATCH] dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
>
> This patch fixes an issue that a race condition happens between a client
> driver and the rcar-dmac driver:
>
> - The rcar_dmac_isr_transfer_end() is called.
> - The done list appears, and desc.running is the next active list.
> - rcar_dmac_chan_get_residue() is called by a client driver before
> rcar_dmac_isr_channel_thread() is called.
> - The rcar_dmac_chan_get_residue() will not find any descriptors.
> - And, the following WARNING happens:
> WARN(1, "No descriptor for cookie!");
>
> The sh-sci driver with HSCIF (921,600bps) on R-Car H3 can cause this
> situation.
> So, this patch checks the done lists in rcar_dmac_chan_get_residue()
> and returns zero if the done lists has the argument cookie.
>
> Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> drivers/dma/sh/rcar-dmac.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 2b2c7db..f748be6 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1264,8 +1264,17 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
> * If the cookie doesn't correspond to the currently running transfer
> * then the descriptor hasn't been processed yet, and the residue is
> * equal to the full descriptor size.
> + * Also, a client driver is possible to call this function before
> + * rcar_dmac_isr_channel_thread() runs. In this case, the "desc.running"
> + * will be the next descriptor, and the done list will appear. So, if
> + * the argument cookie matches the done list's cookie, we can assume
> + * the residue is zero.
> */
> if (cookie != desc->async_tx.cookie) {
> + list_for_each_entry(desc, &chan->desc.done, node) {
> + if (cookie == desc->async_tx.cookie)
> + return 0;
> + }
> list_for_each_entry(desc, &chan->desc.pending, node) {
> if (cookie == desc->async_tx.cookie)
> return desc->size;
> --
> 1.9.1
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
@ 2018-03-01 5:39 ` Yoshihiro Shimoda
0 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2018-03-01 5:39 UTC (permalink / raw)
To: vinod.koul; +Cc: dmaengine, linux-renesas-soc
Hi Vinod,
Would you review this patch?
Or, should I rebase this on the latest your repo?
Best regards,
Yoshihiro Shimoda
> -----Original Message-----
> From: Yoshihiro Shimoda
> Sent: Friday, February 2, 2018 7:05 PM
> To: vinod.koul@intel.com
> Cc: dmaengine@vger.kernel.org; linux-renesas-soc@vger.kernel.org; Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Subject: [PATCH] dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
>
> This patch fixes an issue that a race condition happens between a client
> driver and the rcar-dmac driver:
>
> - The rcar_dmac_isr_transfer_end() is called.
> - The done list appears, and desc.running is the next active list.
> - rcar_dmac_chan_get_residue() is called by a client driver before
> rcar_dmac_isr_channel_thread() is called.
> - The rcar_dmac_chan_get_residue() will not find any descriptors.
> - And, the following WARNING happens:
> WARN(1, "No descriptor for cookie!");
>
> The sh-sci driver with HSCIF (921,600bps) on R-Car H3 can cause this
> situation.
> So, this patch checks the done lists in rcar_dmac_chan_get_residue()
> and returns zero if the done lists has the argument cookie.
>
> Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> drivers/dma/sh/rcar-dmac.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 2b2c7db..f748be6 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1264,8 +1264,17 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
> * If the cookie doesn't correspond to the currently running transfer
> * then the descriptor hasn't been processed yet, and the residue is
> * equal to the full descriptor size.
> + * Also, a client driver is possible to call this function before
> + * rcar_dmac_isr_channel_thread() runs. In this case, the "desc.running"
> + * will be the next descriptor, and the done list will appear. So, if
> + * the argument cookie matches the done list's cookie, we can assume
> + * the residue is zero.
> */
> if (cookie != desc->async_tx.cookie) {
> + list_for_each_entry(desc, &chan->desc.done, node) {
> + if (cookie == desc->async_tx.cookie)
> + return 0;
> + }
> list_for_each_entry(desc, &chan->desc.pending, node) {
> if (cookie == desc->async_tx.cookie)
> return desc->size;
> --
> 1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
2018-02-02 10:05 ` [PATCH] " Yoshihiro Shimoda
@ 2018-03-05 11:29 ` Vinod Koul
-1 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2018-03-05 11:29 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: dmaengine, linux-renesas-soc
On Fri, Feb 02, 2018 at 07:05:15PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that a race condition happens between a client
> driver and the rcar-dmac driver:
>
> - The rcar_dmac_isr_transfer_end() is called.
> - The done list appears, and desc.running is the next active list.
> - rcar_dmac_chan_get_residue() is called by a client driver before
> rcar_dmac_isr_channel_thread() is called.
> - The rcar_dmac_chan_get_residue() will not find any descriptors.
> - And, the following WARNING happens:
> WARN(1, "No descriptor for cookie!");
>
> The sh-sci driver with HSCIF (921,600bps) on R-Car H3 can cause this
> situation.
> So, this patch checks the done lists in rcar_dmac_chan_get_residue()
> and returns zero if the done lists has the argument cookie.
Applied, thanks
>
> Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> drivers/dma/sh/rcar-dmac.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 2b2c7db..f748be6 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1264,8 +1264,17 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
> * If the cookie doesn't correspond to the currently running transfer
> * then the descriptor hasn't been processed yet, and the residue is
> * equal to the full descriptor size.
> + * Also, a client driver is possible to call this function before
> + * rcar_dmac_isr_channel_thread() runs. In this case, the "desc.running"
> + * will be the next descriptor, and the done list will appear. So, if
> + * the argument cookie matches the done list's cookie, we can assume
> + * the residue is zero.
> */
> if (cookie != desc->async_tx.cookie) {
> + list_for_each_entry(desc, &chan->desc.done, node) {
> + if (cookie == desc->async_tx.cookie)
> + return 0;
> + }
> list_for_each_entry(desc, &chan->desc.pending, node) {
> if (cookie == desc->async_tx.cookie)
> return desc->size;
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
@ 2018-03-05 11:29 ` Vinod Koul
0 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2018-03-05 11:29 UTC (permalink / raw)
To: Yoshihiro Shimoda; +Cc: dmaengine, linux-renesas-soc
On Fri, Feb 02, 2018 at 07:05:15PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that a race condition happens between a client
> driver and the rcar-dmac driver:
>
> - The rcar_dmac_isr_transfer_end() is called.
> - The done list appears, and desc.running is the next active list.
> - rcar_dmac_chan_get_residue() is called by a client driver before
> rcar_dmac_isr_channel_thread() is called.
> - The rcar_dmac_chan_get_residue() will not find any descriptors.
> - And, the following WARNING happens:
> WARN(1, "No descriptor for cookie!");
>
> The sh-sci driver with HSCIF (921,600bps) on R-Car H3 can cause this
> situation.
> So, this patch checks the done lists in rcar_dmac_chan_get_residue()
> and returns zero if the done lists has the argument cookie.
Applied, thanks
>
> Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> drivers/dma/sh/rcar-dmac.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 2b2c7db..f748be6 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1264,8 +1264,17 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
> * If the cookie doesn't correspond to the currently running transfer
> * then the descriptor hasn't been processed yet, and the residue is
> * equal to the full descriptor size.
> + * Also, a client driver is possible to call this function before
> + * rcar_dmac_isr_channel_thread() runs. In this case, the "desc.running"
> + * will be the next descriptor, and the done list will appear. So, if
> + * the argument cookie matches the done list's cookie, we can assume
> + * the residue is zero.
> */
> if (cookie != desc->async_tx.cookie) {
> + list_for_each_entry(desc, &chan->desc.done, node) {
> + if (cookie == desc->async_tx.cookie)
> + return 0;
> + }
> list_for_each_entry(desc, &chan->desc.pending, node) {
> if (cookie == desc->async_tx.cookie)
> return desc->size;
> --
> 1.9.1
>
--
~Vinod
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-05 11:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01 5:39 dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue() Yoshihiro Shimoda
2018-03-01 5:39 ` [PATCH] " Yoshihiro Shimoda
-- strict thread matches above, loose matches on Subject: below --
2018-03-05 11:29 Vinod Koul
2018-03-05 11:29 ` [PATCH] " Vinod Koul
2018-02-02 10:05 Yoshihiro Shimoda
2018-02-02 10:05 ` [PATCH] " Yoshihiro Shimoda
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.