diff options
author | hselasky <hselasky@FreeBSD.org> | 2013-01-27 18:01:03 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2013-01-27 18:01:03 +0000 |
commit | 43f43dc8e94902f8e1bc244b4b7829250c8d2bc2 (patch) | |
tree | 2fb764bf337b4b43a5a1428902dc4335f82b9794 /sys/dev/usb/usb_busdma.c | |
parent | 0f7cb9fb6754a229de2f21ea0062775b645a26c4 (diff) | |
download | FreeBSD-src-43f43dc8e94902f8e1bc244b4b7829250c8d2bc2.zip FreeBSD-src-43f43dc8e94902f8e1bc244b4b7829250c8d2bc2.tar.gz |
Fix regression issue after r244500 and r244503:
If a BUSDMA load operation results in a single segment which
is greater than the PAGE_SIZE, the USB computed physical
addresses will not be correct. Make sure that the first
segment is unfolded like the sub-sequent segments are into
USB_PAGE_SIZE big ranges.
Found by: Alexander Nedotsukov
MFC after: 1 week
Diffstat (limited to 'sys/dev/usb/usb_busdma.c')
-rw-r--r-- | sys/dev/usb/usb_busdma.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/dev/usb/usb_busdma.c b/sys/dev/usb/usb_busdma.c index f3c4833..47fb4d5 100644 --- a/sys/dev/usb/usb_busdma.c +++ b/sys/dev/usb/usb_busdma.c @@ -440,7 +440,6 @@ usb_pc_common_mem_cb(void *arg, bus_dma_segment_t *segs, rem = segs->ds_addr & (USB_PAGE_SIZE - 1); pc->page_offset_buf = rem; pc->page_offset_end += rem; - nseg--; #ifdef USB_DEBUG if (rem != (USB_P2U(pc->buffer) & (USB_PAGE_SIZE - 1))) { /* @@ -451,7 +450,7 @@ usb_pc_common_mem_cb(void *arg, bus_dma_segment_t *segs, goto done; } #endif - while (nseg > 0) { + while (1) { off += USB_PAGE_SIZE; if (off >= (segs->ds_len + rem)) { /* page crossing */ @@ -459,6 +458,8 @@ usb_pc_common_mem_cb(void *arg, bus_dma_segment_t *segs, segs++; off = 0; rem = 0; + if (nseg == 0) + break; } pg++; pg->physaddr = (segs->ds_addr + off) & ~(USB_PAGE_SIZE - 1); |