dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] dmaengine: sh: usb-dmac: set tx_result parameters
@ 2020-06-18 12:07 Yoshihiro Shimoda
  2020-06-24  6:05 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Yoshihiro Shimoda @ 2020-06-18 12:07 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

A client driver (renesas_usbhs) assumed that
dmaengine_tx_status() could return the residue even if
the transfer was completed. However, this was not correct
usage [1] and this caused to break getting the residue after
the commit 24461d9792c2 ("dmaengine: virt-dma: Fix access after
free in vchan_complete()") actually. So, this is possible to get
wrong received size if the usb controller gets a short packet.
For example, g_zero driver causes "bad OUT byte" errors.

To use the tx_result from the renesas_usbhs driver when
the transfer is completed, set the tx_result parameters.

Notes that the renesas_usbhs driver needs to update for it.

[1]
https://lore.kernel.org/dmaengine/20200616165550.GP2324254@vkoul-mobl/

Reported-by: Hien Dang <hien.dang.eb@renesas.com>
Fixes: 24461d9792c2 ("dmaengine: virt-dma: Fix access after free in vchan_complete()")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 Changes from v1:
 - Set tx_result parameters, not change the dmaengine_tx_status behavior.
 https://patchwork.kernel.org/patch/11562783/

 drivers/dma/sh/usb-dmac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
index b218a01..8f7ceb6 100644
--- a/drivers/dma/sh/usb-dmac.c
+++ b/drivers/dma/sh/usb-dmac.c
@@ -586,6 +586,8 @@ static void usb_dmac_isr_transfer_end(struct usb_dmac_chan *chan)
 		desc->residue = usb_dmac_get_current_residue(chan, desc,
 							desc->sg_index - 1);
 		desc->done_cookie = desc->vd.tx.cookie;
+		desc->vd.tx_result.result = DMA_TRANS_NOERROR;
+		desc->vd.tx_result.residue = desc->residue;
 		vchan_cookie_complete(&desc->vd);
 
 		/* Restart the next transfer if this driver has a next desc */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] dmaengine: sh: usb-dmac: set tx_result parameters
  2020-06-18 12:07 [PATCH v2] dmaengine: sh: usb-dmac: set tx_result parameters Yoshihiro Shimoda
@ 2020-06-24  6:05 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2020-06-24  6:05 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: dmaengine, linux-renesas-soc

On 18-06-20, 21:07, Yoshihiro Shimoda wrote:
> A client driver (renesas_usbhs) assumed that
> dmaengine_tx_status() could return the residue even if
> the transfer was completed. However, this was not correct
> usage [1] and this caused to break getting the residue after
> the commit 24461d9792c2 ("dmaengine: virt-dma: Fix access after
> free in vchan_complete()") actually. So, this is possible to get
> wrong received size if the usb controller gets a short packet.
> For example, g_zero driver causes "bad OUT byte" errors.
> 
> To use the tx_result from the renesas_usbhs driver when
> the transfer is completed, set the tx_result parameters.
> 
> Notes that the renesas_usbhs driver needs to update for it.
> 
> [1]
> https://lore.kernel.org/dmaengine/20200616165550.GP2324254@vkoul-mobl/

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-24  6:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 12:07 [PATCH v2] dmaengine: sh: usb-dmac: set tx_result parameters Yoshihiro Shimoda
2020-06-24  6:05 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).