Skip to content

Commit 2c7baf6

Browse files
pcercueinunojsa
authored andcommitted
usb: gadget: functionfs: Fix inverted DMA fence direction
A "read" fence was installed when the DMABUF was to be written to, and a "write" fence was installed when the DMABUF was to be read from. Besides, dma_resv_usage_rw() should only be used when waiting for fences. Fixes: 7b07a2a ("usb: gadget: functionfs: Add DMABUF import interface") Signed-off-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20240402110951.16376-2-paul@crapouillou.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bf80872 commit 2c7baf6

File tree

1 file changed

+4
-2
lines changed
  • drivers/usb/gadget/function

1 file changed

+4
-2
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,7 @@ static int ffs_dmabuf_transfer(struct file *file,
15781578
struct ffs_dmabuf_priv *priv;
15791579
struct ffs_dma_fence *fence;
15801580
struct usb_request *usb_req;
1581+
enum dma_resv_usage resv_dir;
15811582
struct dma_buf *dmabuf;
15821583
struct ffs_ep *ep;
15831584
bool cookie;
@@ -1665,8 +1666,9 @@ static int ffs_dmabuf_transfer(struct file *file,
16651666
dma_fence_init(&fence->base, &ffs_dmabuf_fence_ops,
16661667
&priv->lock, priv->context, seqno);
16671668

1668-
dma_resv_add_fence(dmabuf->resv, &fence->base,
1669-
dma_resv_usage_rw(epfile->in));
1669+
resv_dir = epfile->in ? DMA_RESV_USAGE_WRITE : DMA_RESV_USAGE_READ;
1670+
1671+
dma_resv_add_fence(dmabuf->resv, &fence->base, resv_dir);
16701672
dma_resv_unlock(dmabuf->resv);
16711673

16721674
/* Now that the dma_fence is in place, queue the transfer. */

0 commit comments

Comments
 (0)