Commit 466257d9 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Vinod Koul

dmaengine: sh: usb-dmac: set tx_result parameters

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 24461d97 ("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: default avatarHien Dang <hien.dang.eb@renesas.com>
Fixes: 24461d97 ("dmaengine: virt-dma: Fix access after free in vchan_complete()")
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/1592482053-19433-1-git-send-email-yoshihiro.shimoda.uh@renesas.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent d964d5ff
...@@ -586,6 +586,8 @@ static void usb_dmac_isr_transfer_end(struct usb_dmac_chan *chan) ...@@ -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->residue = usb_dmac_get_current_residue(chan, desc,
desc->sg_index - 1); desc->sg_index - 1);
desc->done_cookie = desc->vd.tx.cookie; 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); vchan_cookie_complete(&desc->vd);
/* Restart the next transfer if this driver has a next desc */ /* Restart the next transfer if this driver has a next desc */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment