From: mglocker Date: Sat, 10 Sep 2022 08:13:16 +0000 (+0000) Subject: Finally, only allocate the number of frames for isoc transfers which we X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f6fab45d8293b2d8052ea1356b4b9fa4f042aa51;p=openbsd Finally, only allocate the number of frames for isoc transfers which we really need. The static allocation workaround in the code (DWC2_MAXISOCPACKETS) was required because the NetBSD allocx USB method has a second argument to pass nframes already there, which we don't have. Regression tested with video play, audio play, audio record. ok mpi@ --- diff --git a/sys/dev/usb/dwc2/dwc2.c b/sys/dev/usb/dwc2/dwc2.c index a75bdf20360..cc19484cb1b 100644 --- a/sys/dev/usb/dwc2/dwc2.c +++ b/sys/dev/usb/dwc2/dwc2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2.c,v 1.66 2022/09/09 21:16:54 mglocker Exp $ */ +/* $OpenBSD: dwc2.c,v 1.67 2022/09/10 08:13:16 mglocker Exp $ */ /* $NetBSD: dwc2.c,v 1.32 2014/09/02 23:26:20 macallan Exp $ */ /*- @@ -232,8 +232,6 @@ dwc2_allocx(struct usbd_bus *bus) DWC2_EVCNT_INCR(sc->sc_ev_xferpoolget); dxfer = pool_get(&sc->sc_xferpool, PR_NOWAIT | PR_ZERO); if (dxfer != NULL) { - dxfer->urb = dwc2_hcd_urb_alloc(sc->sc_hsotg, - DWC2_MAXISOCPACKETS, M_NOWAIT); #ifdef DIAGNOSTIC dxfer->xfer.busy_free = XFER_ONQU; #endif @@ -257,7 +255,7 @@ dwc2_freex(struct usbd_bus *bus, struct usbd_xfer *xfer) xfer->busy_free = XFER_FREE; #endif DWC2_EVCNT_INCR(sc->sc_ev_xferpoolput); - dwc2_hcd_urb_free(sc->sc_hsotg, dxfer->urb, DWC2_MAXISOCPACKETS); + dwc2_hcd_urb_free(sc->sc_hsotg, dxfer->urb, xfer->nframes); pool_put(&sc->sc_xferpool, xfer); } @@ -1103,13 +1101,13 @@ dwc2_device_start(struct usbd_xfer *xfer) len = xfer->length; } + dxfer->urb = dwc2_hcd_urb_alloc(sc->sc_hsotg, xfer->nframes, M_NOWAIT); dwc2_urb = dxfer->urb; if (!dwc2_urb) return USBD_NOMEM; -// KASSERT(dwc2_urb->packet_count == xfer->nframes); memset(dwc2_urb, 0, sizeof(*dwc2_urb) + - sizeof(dwc2_urb->iso_descs[0]) * DWC2_MAXISOCPACKETS); + sizeof(dwc2_urb->iso_descs[0]) * xfer->nframes); dwc2_urb->priv = xfer; dwc2_urb->packet_count = xfer->nframes; @@ -1181,8 +1179,6 @@ dwc2_device_start(struct usbd_xfer *xfer) xfer->actlen = 0; - KASSERT(xfertype != UE_ISOCHRONOUS || - xfer->nframes <= DWC2_MAXISOCPACKETS); KASSERTMSG(xfer->nframes == 0 || xfertype == UE_ISOCHRONOUS, "nframes %d xfertype %d\n", xfer->nframes, xfertype); diff --git a/sys/dev/usb/dwc2/dwc2var.h b/sys/dev/usb/dwc2/dwc2var.h index b9a9d953cd3..438f08b618d 100644 --- a/sys/dev/usb/dwc2/dwc2var.h +++ b/sys/dev/usb/dwc2/dwc2var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2var.h,v 1.23 2022/09/04 08:42:40 mglocker Exp $ */ +/* $OpenBSD: dwc2var.h,v 1.24 2022/09/10 08:13:16 mglocker Exp $ */ /* $NetBSD: dwc2var.h,v 1.3 2013/10/22 12:57:40 skrll Exp $ */ /*- @@ -126,7 +126,6 @@ dwc2_root_intr(dwc2_softc_t *sc) * XXX Compat */ #define USB_MAXCHILDREN 31 /* XXX: Include in to our USB stack */ -#define DWC2_MAXISOCPACKETS 40 /* XXX: Fix nframes handling */ #define ENOSR 90 #define device_xname(d) ((d)->dv_xname) #define jiffies hardclock_ticks