From 0e3416b72785504753b31a508157a1133fc694f5 Mon Sep 17 00:00:00 2001 From: skrll Date: Sun, 23 Aug 2015 11:15:08 +0000 Subject: [PATCH] Do BUS_DMASYNC_POST{READ,WRITE} on transfer buffers appropriately --- sys/external/bsd/dwc2/dwc2.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/external/bsd/dwc2/dwc2.c b/sys/external/bsd/dwc2/dwc2.c index 205a340c7d2c..7dadc8c25474 100644 --- a/sys/external/bsd/dwc2/dwc2.c +++ b/sys/external/bsd/dwc2/dwc2.c @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2.c,v 1.33 2015/08/18 12:01:16 skrll Exp $ */ +/* $NetBSD: dwc2.c,v 1.34 2015/08/23 11:15:08 skrll Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.33 2015/08/18 12:01:16 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.34 2015/08/23 11:15:08 skrll Exp $"); #include "opt_usb.h" @@ -1754,6 +1754,20 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, printf("%s: unknown error status %d\n", __func__, status); } + if (xfer->status == USBD_NORMAL_COMPLETION) { + int rd = usbd_xfer_isread(xfer); + + /* + * control transfers with no data phase don't touch dmabuf, but + * everything else does. + */ + if (!(xfertype == UE_CONTROL && + UGETW(xfer->request.wLength) == 0)) { + usb_syncmem(&xfer->dmabuf, 0, xfer->actlen, + rd ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); + } + } + if (xfertype == UE_ISOCHRONOUS || xfertype == UE_INTERRUPT) { struct dwc2_pipe *dpipe = DWC2_XFER2DPIPE(xfer);