Date: Thu, 10 Jan 2008 23:45:45 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 132998 for review Message-ID: <200801102345.m0ANjjJ7039197@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=132998 Change 132998 by hselasky@hselasky_laptop001 on 2008/01/10 23:45:24 To be able to fully support the BUS-DMA system on NetBSD we need to make some small changes which are about returning "struct usbd_dma_tag *" instead of "bus_dma_tag_t" so that we get access to the elements of "struct usbd_dma_tag" and can store some temporary stuff there. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#84 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#95 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.c#84 (text+ko) ==== @@ -2219,8 +2219,9 @@ * NOTE: If the "align" parameter has a value of 1 the DMA-tag will * allow multi-segment mappings. Else all mappings are single-segment. *------------------------------------------------------------------------*/ -bus_dma_tag_t -usbd_dma_tag_create(bus_dma_tag_t tag_parent, uint32_t size, uint32_t align) +void +usbd_dma_tag_create(bus_dma_tag_t tag_parent, struct usbd_dma_tag *udt, + uint32_t size, uint32_t align) { bus_dma_tag_t tag; @@ -2242,16 +2243,17 @@ &tag)) { tag = NULL; } - return (tag); + udt->tag = tag; + return; } /*------------------------------------------------------------------------* * usbd_dma_tag_free - free a DMA tag *------------------------------------------------------------------------*/ void -usbd_dma_tag_destroy(bus_dma_tag_t tag) +usbd_dma_tag_destroy(struct usbd_dma_tag *udt) { - bus_dma_tag_destroy(tag); + bus_dma_tag_destroy(udt->tag); return; } @@ -2345,10 +2347,13 @@ } } /* get the correct DMA tag */ - tag = usbd_dma_tag_setup(parent_tag, utag, size, align, utag_max); - if (tag == NULL) { + utag = usbd_dma_tag_setup(parent_tag, utag, size, align, utag_max); + if (utag == NULL) { goto error; } + /* get the DMA tag */ + tag = utag->tag; + /* allocate memory */ if (bus_dmamem_alloc (tag, &ptr, (BUS_DMA_WAITOK | BUS_DMA_COHERENT), &map)) { @@ -2466,6 +2471,7 @@ usbd_pc_dmamap_create(struct usbd_page_cache *pc, uint32_t size) { struct usbd_memory_info *info; + struct usbd_dma_tag *utag; bus_dma_tag_t tag; /* sanity check */ @@ -2475,11 +2481,15 @@ info = pc->xfer->usb_root; tag = pc->xfer->udev->bus->dma_tag_parent; - tag = usbd_dma_tag_setup(tag, info->dma_tag_p, + utag = usbd_dma_tag_setup(tag, info->dma_tag_p, size, 1, info->dma_tag_max); - if (tag == NULL) { + if (utag == NULL) { goto error; } + /* get the DMA tag */ + tag = utag->tag; + + /* create DMA map */ if (bus_dmamap_create(tag, 0, &(pc->map))) { goto error; } @@ -3145,7 +3155,7 @@ /*------------------------------------------------------------------------* * usbd_bus_tag_setup - factored out code *------------------------------------------------------------------------*/ -bus_dma_tag_t +struct usbd_dma_tag * usbd_dma_tag_setup(bus_dma_tag_t tag_parent, struct usbd_dma_tag *udt, uint32_t size, uint32_t align, uint8_t nudt) { @@ -3155,17 +3165,16 @@ while (nudt--) { if (udt->align == 0) { - udt->tag = - usbd_dma_tag_create(tag_parent, size, align); + usbd_dma_tag_create(tag_parent, udt, size, align); if (udt->tag == NULL) { return (NULL); } udt->align = align; udt->size = size; - return (udt->tag); + return (udt); } if ((udt->align == align) && (udt->size == size)) { - return (udt->tag); + return (udt); } udt++; } @@ -3181,7 +3190,7 @@ while (nudt--) { if (udt->align) { - usbd_dma_tag_destroy(udt->tag); + usbd_dma_tag_destroy(udt); udt->align = 0; } udt++; ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#95 (text+ko) ==== @@ -248,16 +248,17 @@ bus_dma_tag_t tag; bus_dmamap_t map; #endif - #ifdef __NetBSD__ - bus_dma_segment_t seg; bus_dma_tag_t tag; bus_dmamap_t map; - int32_t seg_count; + bus_dma_segment_t *p_seg; #endif struct usbd_page *page_start; struct usbd_xfer *xfer; /* if set, backpointer to USB transfer */ void *buffer; /* virtual buffer pointer */ +#ifdef __NetBSD__ + int n_seg; +#endif uint32_t page_offset_buf; uint32_t page_offset_end; uint8_t isread:1; @@ -323,9 +324,15 @@ }; struct usbd_dma_tag { +#ifdef __NetBSD__ + bus_dma_segment_t *p_seg; +#endif bus_dma_tag_t tag; uint32_t align; uint32_t size; +#ifdef __NetBSD__ + uint32_t n_seg; +#endif }; /* USB BUS explore commands */ @@ -856,8 +863,8 @@ int usbd_uiomove(struct usbd_page_cache *pc, struct uio *uio, uint32_t pc_offset, uint32_t len); void usbd_copy_out(struct usbd_page_cache *cache, uint32_t offset, void *ptr, uint32_t len); void usbd_bzero(struct usbd_page_cache *cache, uint32_t offset, uint32_t len); -bus_dma_tag_t usbd_dma_tag_create(bus_dma_tag_t tag_parent, uint32_t size, uint32_t align); -void usbd_dma_tag_destroy(bus_dma_tag_t tag); +void usbd_dma_tag_create(bus_dma_tag_t tag_parent, struct usbd_dma_tag *udt, uint32_t size, uint32_t align); +void usbd_dma_tag_destroy(struct usbd_dma_tag *udt); uint8_t usbd_pc_alloc_mem(bus_dma_tag_t parent_tag, struct usbd_dma_tag *utag, struct usbd_page_cache *pc, struct usbd_page *pg, uint32_t size, uint32_t align, uint8_t utag_max); void usbd_pc_free_mem(struct usbd_page_cache *pc); void usbd_pc_load_mem(struct usbd_page_cache *pc, uint32_t size); @@ -877,7 +884,7 @@ struct mbuf *usbd_ether_get_mbuf(void); int32_t device_delete_all_children(device_t dev); uint16_t usbd_isoc_time_expand(struct usbd_bus *bus, uint16_t isoc_time_curr); -bus_dma_tag_t usbd_dma_tag_setup(bus_dma_tag_t tag_parent, struct usbd_dma_tag *udt, uint32_t size, uint32_t align, uint8_t nudt); +struct usbd_dma_tag *usbd_dma_tag_setup(bus_dma_tag_t tag_parent, struct usbd_dma_tag *udt, uint32_t size, uint32_t align, uint8_t nudt); void usbd_dma_tag_unsetup(struct usbd_dma_tag *udt, uint8_t nudt); void usbd_bus_mem_flush_all(struct usbd_bus *bus, usbd_bus_mem_cb_t *cb); uint8_t usbd_bus_mem_alloc_all(struct usbd_bus *bus, usbd_bus_mem_cb_t *cb);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801102345.m0ANjjJ7039197>