Date: Sat, 15 Dec 2007 18:05:14 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 130965 for review Message-ID: <200712151805.lBFI5Eao093889@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=130965 Change 130965 by hselasky@hselasky_laptop001 on 2007/12/15 18:04:21 Revert parts of change 130054 to "usb_subr.c". We now support non-kernel virtual addresses again. NOTE: usbd_copy_in, usbd_copy_out, usbd_uiomove, usbd_bzero "struct usbd_page_cache" and "struct usbd_page" are very generic and should be factored out one day using some kind of system provided function and structures. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#73 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.c#73 (text+ko) ==== @@ -2014,10 +2014,21 @@ usbd_copy_in(struct usbd_page_cache *cache, uint32_t offset, const void *ptr, uint32_t len) { - void *dst; + struct usbd_page_search buf_res; + + while (len != 0) { + + usbd_get_page(cache, offset, &buf_res); + + if (buf_res.length > len) { + buf_res.length = len; + } + bcopy(ptr, buf_res.buffer, buf_res.length); - dst = USBD_ADD_BYTES(cache->buffer, offset); - bcopy(ptr, dst, len); + offset += buf_res.length; + len -= buf_res.length; + ptr = USBD_ADD_BYTES(ptr, buf_res.length); + } return; } @@ -2061,10 +2072,29 @@ usbd_uiomove(struct usbd_page_cache *pc, struct uio *uio, uint32_t pc_offset, uint32_t len) { - void *ptr; + struct usbd_page_search res; + int error = 0; + + while (len != 0) { + + usbd_get_page(pc, pc_offset, &res); + + if (res.length > len) { + res.length = len; + } + /* + * "uiomove()" can sleep so one needs to make a wrapper, + * exiting the mutex and checking things + */ + error = uiomove(res.buffer, res.length, uio); - ptr = USBD_ADD_BYTES(pc->buffer, pc_offset); - return (uiomove(ptr, len, uio)); + if (error) { + break; + } + pc_offset += res.length; + len -= res.length; + } + return (error); } /*------------------------------------------------------------------------* @@ -2074,10 +2104,21 @@ usbd_copy_out(struct usbd_page_cache *cache, uint32_t offset, void *ptr, uint32_t len) { - void *src; + struct usbd_page_search res; + + while (len != 0) { + + usbd_get_page(cache, offset, &res); + + if (res.length > len) { + res.length = len; + } + bcopy(res.buffer, ptr, res.length); - src = USBD_ADD_BYTES(cache->buffer, offset); - bcopy(src, ptr, len); + offset += res.length; + len -= res.length; + ptr = USBD_ADD_BYTES(ptr, res.length); + } return; } @@ -2087,10 +2128,20 @@ void usbd_bzero(struct usbd_page_cache *cache, uint32_t offset, uint32_t len) { - void *ptr; + struct usbd_page_search res; + + while (len != 0) { + + usbd_get_page(cache, offset, &res); + + if (res.length > len) { + res.length = len; + } + bzero(res.buffer, res.length); - ptr = USBD_ADD_BYTES(cache->buffer, offset); - bzero(ptr, len); + offset += res.length; + len -= res.length; + } return; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712151805.lBFI5Eao093889>