Date: Sun, 25 Nov 2007 12:09:40 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 129498 for review Message-ID: <200711251209.lAPC9eva085100@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=129498 Change 129498 by hselasky@hselasky_laptop001 on 2007/11/25 12:09:11 Final step into adding support for loading of virtual buffers into DMA. Add code that allocates and frees BUS-DMA maps. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#55 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#60 edit .. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#53 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.c#55 (text+ko) ==== @@ -2244,6 +2244,51 @@ } /*------------------------------------------------------------------------* + * usbd_dma_load_setup - allocate BUS-DMA maps + *------------------------------------------------------------------------*/ +void +usbd_dma_load_setup(struct usbd_setup_params *parm) +{ + struct usbd_xfer *xfer; + + if (parm->buf == NULL) { + return; + } + xfer = parm->curr_xfer; + + if (bus_dmamap_create(xfer->udev->bus->dma_tag_1b, 0, + &(xfer->dma_tx_map))) { + xfer->dma_tx_map = NULL; + parm->err = USBD_NOMEM; + return; + } + if (bus_dmamap_create(xfer->udev->bus->dma_tag_1b, 0, + &(xfer->dma_rx_map))) { + xfer->dma_rx_map = NULL; + parm->err = USBD_NOMEM; + return; + } + return; +} + +/*------------------------------------------------------------------------* + * usbd_dma_load_unsetup - release BUS-DMA maps + *------------------------------------------------------------------------*/ +void +usbd_dma_load_unsetup(struct usbd_xfer *xfer) +{ + if (xfer->dma_tx_map) { + bus_dmamap_destroy(xfer->udev->bus->dma_tag_1b, + xfer->dma_tx_map); + } + if (xfer->dma_rx_map) { + bus_dmamap_destroy(xfer->udev->bus->dma_tag_1b, + xfer->dma_rx_map); + } + return; +} + +/*------------------------------------------------------------------------* * usbd_dma_load_pre_sync - flush CPU cache, if any *------------------------------------------------------------------------*/ void ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#60 (text+ko) ==== @@ -710,6 +710,8 @@ void usbd_dma_tag_free(bus_dma_tag_t tag); void *usbd_mem_alloc_sub(bus_dma_tag_t tag, struct usbd_page *page, uint32_t size, uint32_t alignment); void usbd_mem_free_sub(struct usbd_page *page); +void usbd_dma_load_setup(struct usbd_setup_params *parm); +void usbd_dma_load_unsetup(struct usbd_xfer *xfer); void usbd_dma_load_pre_sync(struct usbd_xfer *xfer); void usbd_dma_load_post_sync(struct usbd_xfer *xfer); void usbd_page_cpu_invalidate(struct usbd_page *page); ==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#53 (text+ko) ==== @@ -678,12 +678,9 @@ *------------------------------------------------------------------------*/ usbd_status usbd_transfer_setup(struct usbd_device *udev, - uint8_t iface_index, - struct usbd_xfer **ppxfer, - const struct usbd_config *setup_start, - uint16_t n_setup, - void *priv_sc, - struct mtx *priv_mtx) + uint8_t iface_index, struct usbd_xfer **ppxfer, + const struct usbd_config *setup_start, uint16_t n_setup, + void *priv_sc, struct mtx *priv_mtx) { struct usbd_xfer dummy; struct usbd_setup_params parm; @@ -813,6 +810,10 @@ (udev->bus->methods->xfer_setup) (&parm); + if (xfer->flags.bdma_enable && + xfer->flags_int.bdma_enable) { + usbd_dma_load_setup(&parm); + } if (parm.err) { goto done; } @@ -959,6 +960,8 @@ usb_callout_drain(&(xfer->timeout_handle)); + usbd_dma_load_unsetup(xfer); + if (xfer->usb_root) { info = xfer->usb_root;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711251209.lAPC9eva085100>