Date: Sat, 15 Dec 2007 17:37:45 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 130963 for review Message-ID: <200712151737.lBFHbjan084845@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=130963 Change 130963 by hselasky@hselasky_laptop001 on 2007/12/15 17:37:43 Reintroduce support for non-kernel virtual memory after advice from Julian Elischer. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#71 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#76 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.c#71 (text+ko) ==== @@ -1968,22 +1968,19 @@ { struct usbd_page *page; - res->buffer = USBD_ADD_BYTES(pc->buffer, offset); + if (pc->page_start) { + + /* Case 1 - something has been loaded into DMA */ - offset += pc->page_offset_buf; + if (pc->buffer) { - /* range check */ + /* Case 1a - Kernel Virtual Address */ - if ((offset >= pc->page_offset_end) || - (offset < pc->page_offset_buf)) { + res->buffer = USBD_ADD_BYTES(pc->buffer, offset); + } - /* we've reached the end */ + offset += pc->page_offset_buf; - res->length = 0; - res->buffer = NULL; - res->physaddr = 0; - return; - } /* compute destination page */ page = pc->page_start; @@ -1994,20 +1991,24 @@ res->length = USB_PAGE_SIZE - offset; res->physaddr = page->physaddr + offset; + if (!pc->buffer) { + /* Case 1b - Non Kernel Virtual Address */ + + res->buffer = USBD_ADD_BYTES(page->buffer, offset); + } + } else { + + /* Case 2 - Plain PIO */ + + res->buffer = USBD_ADD_BYTES(pc->buffer, offset); + res->length = 0-1; + res->physaddr = 0; + } return; } /*------------------------------------------------------------------------* - * usbd_get_buffer - *------------------------------------------------------------------------*/ -void * -usbd_get_buffer(struct usbd_page_cache *pc, uint32_t offset) -{ - return (USBD_ADD_BYTES(pc->buffer, offset)); -} - -/*------------------------------------------------------------------------* * usbd_copy_in - copy directly to DMA-able memory *------------------------------------------------------------------------*/ void ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#76 (text+ko) ==== @@ -219,6 +219,7 @@ struct usbd_page { bus_size_t physaddr; + void *buffer; /* non Kernel Virtual Address */ }; struct usbd_page_search { @@ -798,7 +799,6 @@ void usbd_set_desc(device_t dev, struct usbd_device *udev); void *usbd_alloc_mbufs(struct malloc_type *type, struct usbd_ifqueue *ifq, uint32_t block_size, uint16_t block_number); void usbd_get_page(struct usbd_page_cache *cache, uint32_t offset, struct usbd_page_search *res); -void *usbd_get_buffer(struct usbd_page_cache *pc, uint32_t offset); void usbd_copy_in(struct usbd_page_cache *cache, uint32_t offset, const void *ptr, uint32_t len); void usbd_m_copy_in(struct usbd_page_cache *cache, uint32_t dst_offset, struct mbuf *m, uint32_t src_offset, uint32_t src_len); int usbd_uiomove(struct usbd_page_cache *pc, struct uio *uio, uint32_t pc_offset, uint32_t len);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712151737.lBFHbjan084845>