Author: hselasky
Date: Tue Mar 29 10:47:14 2016
New Revision: 297381
URL: https://svnweb.freebsd.org/changeset/base/297381

Log:
  Verify that all segments in the loaded segment list are back to back
  with regard to the page offset, and not only the two first ones.

Modified:
  head/sys/dev/usb/usb_busdma.c

Modified: head/sys/dev/usb/usb_busdma.c
==============================================================================
--- head/sys/dev/usb/usb_busdma.c       Tue Mar 29 10:27:25 2016        
(r297380)
+++ head/sys/dev/usb/usb_busdma.c       Tue Mar 29 10:47:14 2016        
(r297381)
@@ -472,17 +472,22 @@ usb_pc_common_mem_cb(void *arg, bus_dma_
        pc->page_offset_buf = rem;
        pc->page_offset_end += rem;
 #ifdef USB_DEBUG
-       if (nseg > 1 &&
-           ((segs->ds_addr + segs->ds_len) & (USB_PAGE_SIZE - 1)) !=
-           ((segs + 1)->ds_addr & (USB_PAGE_SIZE - 1))) {
-               /*
-                * This check verifies there is no page offset hole
-                * between the first and second segment. See the
-                * BUS_DMA_KEEP_PG_OFFSET flag.
-                */
-               DPRINTFN(0, "Page offset was not preserved\n");
-               error = 1;
-               goto done;
+       if (nseg > 1) {
+               int x;
+
+               for (x = 0; x != nseg - 1; x++) {
+                       if (((segs[x].ds_addr + segs[x].ds_len) & 
(USB_PAGE_SIZE - 1)) ==
+                           ((segs[x + 1].ds_addr & (USB_PAGE_SIZE - 1))))
+                               continue;
+                       /*
+                        * This check verifies there is no page offset
+                        * hole between any of the segments. See the
+                        * BUS_DMA_KEEP_PG_OFFSET flag.
+                        */
+                       DPRINTFN(0, "Page offset was not preserved\n");
+                       error = 1;
+                       goto done;
+               }
        }
 #endif
        while (pc->ismultiseg) {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to