diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2020-03-21 12:08:32 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2020-03-21 12:08:32 +0000 |
commit | 7881b97f2527c018391cd5e2d5059d83e1714f79 (patch) | |
tree | ce75a2c8554d3457bfde0584ece3a705330d5d1d /sys | |
parent | d6938517352a49d61af7fea437ee011aee95cfea (diff) |
Instead of passing the flags as part of a struct that's supposed to be
filled by the callee, change the usb_allocmem() API to take another
argument for the flags.
ok mpi@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/dwc2/dwc2.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_hcd.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/dwc2/dwc2_hcdddma.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/ehci.c | 17 | ||||
-rw-r--r-- | sys/dev/usb/ohci.c | 20 | ||||
-rw-r--r-- | sys/dev/usb/uhci.c | 15 | ||||
-rw-r--r-- | sys/dev/usb/usb_mem.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/usb_mem.h | 5 | ||||
-rw-r--r-- | sys/dev/usb/usbdi.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/usbdivar.h | 3 |
10 files changed, 39 insertions, 54 deletions
diff --git a/sys/dev/usb/dwc2/dwc2.c b/sys/dev/usb/dwc2/dwc2.c index 9f795500b02..6ca3cc658e5 100644 --- a/sys/dev/usb/dwc2/dwc2.c +++ b/sys/dev/usb/dwc2/dwc2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2.c,v 1.50 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: dwc2.c,v 1.51 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: dwc2.c,v 1.32 2014/09/02 23:26:20 macallan Exp $ */ /*- @@ -473,9 +473,8 @@ dwc2_open(struct usbd_pipe *pipe) switch (xfertype) { case UE_CONTROL: pipe->methods = &dwc2_device_ctrl_methods; - dpipe->req_dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, sizeof(usb_device_request_t), - 0, &dpipe->req_dma); + 0, USB_DMA_COHERENT, &dpipe->req_dma); if (err) return err; break; diff --git a/sys/dev/usb/dwc2/dwc2_hcd.c b/sys/dev/usb/dwc2/dwc2_hcd.c index 04018d6b67e..ab76de7d766 100644 --- a/sys/dev/usb/dwc2/dwc2_hcd.c +++ b/sys/dev/usb/dwc2/dwc2_hcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_hcd.c,v 1.21 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: dwc2_hcd.c,v 1.22 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: dwc2_hcd.c,v 1.15 2014/11/24 10:14:14 skrll Exp $ */ /* @@ -679,9 +679,8 @@ STATIC int dwc2_hc_setup_align_buf(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, qh->dw_align_buf = NULL; qh->dw_align_buf_dma = 0; - qh->dw_align_buf_usbdma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&hsotg->hsotg_sc->sc_bus, buf_size, buf_size, - &qh->dw_align_buf_usbdma); + USB_DMA_COHERENT, &qh->dw_align_buf_usbdma); if (!err) { struct usb_dma *ud = &qh->dw_align_buf_usbdma; @@ -2268,9 +2267,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, */ hsotg->status_buf = NULL; if (hsotg->core_params->dma_enable > 0) { - hsotg->status_buf_usbdma.flags |= USB_DMA_COHERENT; retval = usb_allocmem(&hsotg->hsotg_sc->sc_bus, DWC2_HCD_STATUS_BUF_SIZE, 0, + USB_DMA_COHERENT, &hsotg->status_buf_usbdma); if (!retval) { hsotg->status_buf = KERNADDR(&hsotg->status_buf_usbdma, 0); diff --git a/sys/dev/usb/dwc2/dwc2_hcdddma.c b/sys/dev/usb/dwc2/dwc2_hcdddma.c index 3077517154a..4355fd2d30a 100644 --- a/sys/dev/usb/dwc2/dwc2_hcdddma.c +++ b/sys/dev/usb/dwc2/dwc2_hcdddma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwc2_hcdddma.c,v 1.15 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: dwc2_hcdddma.c,v 1.16 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: dwc2_hcdddma.c,v 1.6 2014/04/03 06:34:58 skrll Exp $ */ /* @@ -102,10 +102,9 @@ STATIC int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, //KASSERT(!cpu_intr_p() && !cpu_softintr_p()); qh->desc_list = NULL; - qh->desc_list_usbdma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&hsotg->hsotg_sc->sc_bus, sizeof(struct dwc2_hcd_dma_desc) * dwc2_max_desc_num(qh), 0, - &qh->desc_list_usbdma); + USB_DMA_COHERENT, &qh->desc_list_usbdma); if (!err) { qh->desc_list = KERNADDR(&qh->desc_list_usbdma, 0); @@ -144,9 +143,8 @@ STATIC int dwc2_frame_list_alloc(struct dwc2_hsotg *hsotg, gfp_t mem_flags) /* XXXNH - struct pool */ hsotg->frame_list = NULL; - hsotg->frame_list_usbdma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&hsotg->hsotg_sc->sc_bus, 4 * FRLISTEN_64_SIZE, - 0, &hsotg->frame_list_usbdma); + 0, USB_DMA_COHERENT, &hsotg->frame_list_usbdma); if (!err) { hsotg->frame_list = KERNADDR(&hsotg->frame_list_usbdma, 0); diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index c0db91ac106..269a7675a4b 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci.c,v 1.207 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: ehci.c,v 1.208 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */ /* @@ -355,9 +355,8 @@ ehci_init(struct ehci_softc *sc) case 3: return (USBD_IOERROR); } - sc->sc_fldma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, sc->sc_flsize * sizeof(ehci_link_t), - EHCI_FLALIGN_ALIGN, &sc->sc_fldma); + EHCI_FLALIGN_ALIGN, USB_DMA_COHERENT, &sc->sc_fldma); if (err) return (err); DPRINTF(("%s: flsize=%d\n", sc->sc_bus.bdev.dv_xname,sc->sc_flsize)); @@ -1470,9 +1469,8 @@ ehci_open(struct usbd_pipe *pipe) switch (xfertype) { case UE_CONTROL: - epipe->u.ctl.reqdma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, sizeof(usb_device_request_t), - 0, &epipe->u.ctl.reqdma); + 0, USB_DMA_COHERENT, &epipe->u.ctl.reqdma); if (err) { ehci_free_sqh(sc, sqh); return (err); @@ -2259,9 +2257,8 @@ ehci_alloc_sqh(struct ehci_softc *sc) s = splusb(); if (sc->sc_freeqhs == NULL) { DPRINTFN(2, ("ehci_alloc_sqh: allocating chunk\n")); - dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, EHCI_SQH_SIZE * EHCI_SQH_CHUNK, - EHCI_PAGE_SIZE, &dma); + EHCI_PAGE_SIZE, USB_DMA_COHERENT, &dma); if (err) goto out; for (i = 0; i < EHCI_SQH_CHUNK; i++) { @@ -2308,9 +2305,8 @@ ehci_alloc_sqtd(struct ehci_softc *sc) s = splusb(); if (sc->sc_freeqtds == NULL) { DPRINTFN(2, ("ehci_alloc_sqtd: allocating chunk\n")); - dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, EHCI_SQTD_SIZE*EHCI_SQTD_CHUNK, - EHCI_PAGE_SIZE, &dma); + EHCI_PAGE_SIZE, USB_DMA_COHERENT, &dma); if (err) goto out; for(i = 0; i < EHCI_SQTD_CHUNK; i++) { @@ -2537,9 +2533,8 @@ ehci_alloc_itd(struct ehci_softc *sc) } if (freeitd == NULL) { - dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, EHCI_ITD_SIZE * EHCI_ITD_CHUNK, - EHCI_PAGE_SIZE, &dma); + EHCI_PAGE_SIZE, USB_DMA_COHERENT, &dma); if (err) { splx(s); return (NULL); diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index ed11da7bfb4..7aa2303eabd 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci.c,v 1.159 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: ohci.c,v 1.160 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ @@ -394,9 +394,8 @@ ohci_alloc_sed(struct ohci_softc *sc) s = splusb(); if (sc->sc_freeeds == NULL) { DPRINTFN(2, ("ohci_alloc_sed: allocating chunk\n")); - dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, OHCI_SED_SIZE * OHCI_SED_CHUNK, - OHCI_ED_ALIGN, &dma); + OHCI_ED_ALIGN, USB_DMA_COHERENT, &dma); if (err) goto out; for (i = 0; i < OHCI_SED_CHUNK; i++) { @@ -440,9 +439,8 @@ ohci_alloc_std(struct ohci_softc *sc) s = splusb(); if (sc->sc_freetds == NULL) { DPRINTFN(2, ("ohci_alloc_std: allocating chunk\n")); - dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK, - OHCI_TD_ALIGN, &dma); + OHCI_TD_ALIGN, USB_DMA_COHERENT, &dma); if (err) goto out; for (i = 0; i < OHCI_STD_CHUNK; i++) { @@ -599,9 +597,8 @@ ohci_alloc_sitd(struct ohci_softc *sc) if (sc->sc_freeitds == NULL) { DPRINTFN(2, ("ohci_alloc_sitd: allocating chunk\n")); - dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, OHCI_SITD_SIZE * OHCI_SITD_CHUNK, - OHCI_ITD_ALIGN, &dma); + OHCI_ITD_ALIGN, USB_DMA_COHERENT, &dma); if (err) return (NULL); s = splusb(); @@ -731,9 +728,8 @@ ohci_init(struct ohci_softc *sc) /* XXX determine alignment by R/W */ /* Allocate the HCCA area. */ - sc->sc_hccadma.flags |= USB_DMA_COHERENT; - err = usb_allocmem(&sc->sc_bus, OHCI_HCCA_SIZE, - OHCI_HCCA_ALIGN, &sc->sc_hccadma); + err = usb_allocmem(&sc->sc_bus, OHCI_HCCA_SIZE, OHCI_HCCA_ALIGN, + USB_DMA_COHERENT, &sc->sc_hccadma); if (err) return (err); sc->sc_hcca = KERNADDR(&sc->sc_hccadma, 0); @@ -1935,10 +1931,10 @@ ohci_open(struct usbd_pipe *pipe) switch (xfertype) { case UE_CONTROL: pipe->methods = &ohci_device_ctrl_methods; - opipe->u.ctl.reqdma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, sizeof(usb_device_request_t), - 0, &opipe->u.ctl.reqdma); + 0, USB_DMA_COHERENT, + &opipe->u.ctl.reqdma); if (err) goto bad; s = splusb(); diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index db05f3c2ccc..bae6c1b81a9 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.150 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: uhci.c,v 1.151 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -377,10 +377,9 @@ uhci_init(struct uhci_softc *sc) UWRITE1(sc, UHCI_SOF, sc->sc_saved_sof); /* Allocate and initialize real frame array. */ - sc->sc_dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, UHCI_FRAMELIST_COUNT * sizeof(uhci_physaddr_t), - UHCI_FRAMELIST_ALIGN, &sc->sc_dma); + UHCI_FRAMELIST_ALIGN, USB_DMA_COHERENT, &sc->sc_dma); if (err) return (err); sc->sc_pframes = KERNADDR(&sc->sc_dma, 0); @@ -1415,9 +1414,8 @@ uhci_alloc_std(struct uhci_softc *sc) s = splusb(); if (sc->sc_freetds == NULL) { DPRINTFN(2,("uhci_alloc_std: allocating chunk\n")); - dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, UHCI_STD_SIZE * UHCI_STD_CHUNK, - UHCI_TD_ALIGN, &dma); + UHCI_TD_ALIGN, USB_DMA_COHERENT, &dma); if (err) goto out; for(i = 0; i < UHCI_STD_CHUNK; i++) { @@ -1470,9 +1468,8 @@ uhci_alloc_sqh(struct uhci_softc *sc) s = splusb(); if (sc->sc_freeqhs == NULL) { DPRINTFN(2, ("uhci_alloc_sqh: allocating chunk\n")); - dma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, UHCI_SQH_SIZE * UHCI_SQH_CHUNK, - UHCI_QH_ALIGN, &dma); + UHCI_QH_ALIGN, USB_DMA_COHERENT, &dma); if (err) goto out; for (i = 0; i < UHCI_SQH_CHUNK; i++) { @@ -2653,10 +2650,10 @@ uhci_open(struct usbd_pipe *pipe) uhci_free_std(sc, upipe->u.ctl.setup); goto bad; } - upipe->u.ctl.reqdma.flags |= USB_DMA_COHERENT; err = usb_allocmem(&sc->sc_bus, sizeof(usb_device_request_t), - 0, &upipe->u.ctl.reqdma); + 0, USB_DMA_COHERENT, + &upipe->u.ctl.reqdma); if (err) { uhci_free_sqh(sc, upipe->u.ctl.sqh); uhci_free_std(sc, upipe->u.ctl.setup); diff --git a/sys/dev/usb/usb_mem.c b/sys/dev/usb/usb_mem.c index d1e51e868ad..d0b37e54766 100644 --- a/sys/dev/usb/usb_mem.c +++ b/sys/dev/usb/usb_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_mem.c,v 1.33 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: usb_mem.c,v 1.34 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: usb_mem.c,v 1.26 2003/02/01 06:23:40 thorpej Exp $ */ /* @@ -184,7 +184,8 @@ usb_block_freemem(struct usb_dma_block *p) } usbd_status -usb_allocmem(struct usbd_bus *bus, size_t size, size_t align, struct usb_dma *p) +usb_allocmem(struct usbd_bus *bus, size_t size, size_t align, int flags, + struct usb_dma *p) { bus_dma_tag_t tag = bus->dmatag; usbd_status err; @@ -194,7 +195,7 @@ usb_allocmem(struct usbd_bus *bus, size_t size, size_t align, struct usb_dma *p) int i; int s; - coherent = !!(p->flags & USB_DMA_COHERENT); + coherent = !!(flags & USB_DMA_COHERENT); /* If the request is large then just use a full block. */ if (size > USB_MEM_SMALL || align > USB_MEM_SMALL) { diff --git a/sys/dev/usb/usb_mem.h b/sys/dev/usb/usb_mem.h index f0e0d1c217d..98a221eae9a 100644 --- a/sys/dev/usb/usb_mem.h +++ b/sys/dev/usb/usb_mem.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_mem.h,v 1.16 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: usb_mem.h,v 1.17 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: usb_mem.h,v 1.20 2003/05/03 18:11:42 wiz Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.9 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -51,6 +51,7 @@ struct usb_dma_block { #define KERNADDR(dma, o) \ ((void *)((char *)((dma)->block->kaddr + (dma)->offs) + (o))) -usbd_status usb_allocmem(struct usbd_bus *,size_t,size_t, struct usb_dma *); +usbd_status usb_allocmem(struct usbd_bus *, size_t, size_t, int, + struct usb_dma *); void usb_freemem(struct usbd_bus *, struct usb_dma *); void usb_syncmem(struct usb_dma *, bus_addr_t, bus_size_t, int); diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index aba1220103f..5161afc21e5 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.c,v 1.103 2020/02/22 14:01:35 jasper Exp $ */ +/* $OpenBSD: usbdi.c,v 1.104 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: usbdi.c,v 1.103 2002/09/27 15:37:38 provos Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -305,7 +305,7 @@ usbd_transfer(struct usbd_xfer *xfer) if (xfer->rqflags & URQ_AUTO_DMABUF) printf("usbd_transfer: has old buffer!\n"); #endif - err = usb_allocmem(bus, xfer->length, 0, &xfer->dmabuf); + err = usb_allocmem(bus, xfer->length, 0, 0, &xfer->dmabuf); if (err) return (err); xfer->rqflags |= URQ_AUTO_DMABUF; @@ -389,7 +389,7 @@ usbd_alloc_buffer(struct usbd_xfer *xfer, u_int32_t size) if (xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF)) printf("usbd_alloc_buffer: xfer already has a buffer\n"); #endif - err = usb_allocmem(bus, size, 0, &xfer->dmabuf); + err = usb_allocmem(bus, size, 0, 0, &xfer->dmabuf); if (err) return (NULL); xfer->rqflags |= URQ_DEV_DMABUF; diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h index 448aab4dcb8..5aa207818f7 100644 --- a/sys/dev/usb/usbdivar.h +++ b/sys/dev/usb/usbdivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdivar.h,v 1.80 2020/03/19 14:18:38 patrick Exp $ */ +/* $OpenBSD: usbdivar.h,v 1.81 2020/03/21 12:08:31 patrick Exp $ */ /* $NetBSD: usbdivar.h,v 1.70 2002/07/11 21:14:36 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */ @@ -47,7 +47,6 @@ struct usb_dma_block; struct usb_dma { struct usb_dma_block *block; u_int offs; - int flags; #define USB_DMA_COHERENT (1 << 0) }; |