svn commit: r212982 - user/weongyo/usb/sys/dev/usb

Weongyo Jeong weongyo at FreeBSD.org
Tue Sep 21 23:25:38 UTC 2010


Author: weongyo
Date: Tue Sep 21 23:25:38 2010
New Revision: 212982
URL: http://svn.freebsd.org/changeset/base/212982

Log:
  Records the length of DMA physical buffer also that it looks handling
  the DMA segments is completely wrong because there are no any places to
  check the DMA buffer length in USB stack.  It means some physical
  address are overwrited by invalid USB transfers.

Modified:
  user/weongyo/usb/sys/dev/usb/usb_busdma.c
  user/weongyo/usb/sys/dev/usb/usb_busdma.h

Modified: user/weongyo/usb/sys/dev/usb/usb_busdma.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_busdma.c	Tue Sep 21 23:08:12 2010	(r212981)
+++ user/weongyo/usb/sys/dev/usb/usb_busdma.c	Tue Sep 21 23:25:38 2010	(r212982)
@@ -434,6 +434,7 @@ usb_pc_common_mem_cb(void *arg, bus_dma_
 
 	pg = pc->pages;
 	pg->physaddr = segs[0].ds_addr & ~(USB_PAGE_SIZE - 1);
+	pg->physlen = segs[0].ds_len;
 	rem = segs[0].ds_addr & (USB_PAGE_SIZE - 1);
 	pc->page_offset_buf = rem;
 	pc->page_offset_end += rem;
@@ -447,8 +448,10 @@ usb_pc_common_mem_cb(void *arg, bus_dma_
 		goto done;
 	}
 #endif
-	for (i = 1; i < nseg; i++)
+	for (i = 1; i < nseg; i++) {
 		pg[i].physaddr = segs[i].ds_addr & ~(USB_PAGE_SIZE - 1);
+		pg[i].physlen = segs[i].ds_len;
+	}
 done:
 	uptag->dma_error = (error ? 1 : 0);
 	if (isload)

Modified: user/weongyo/usb/sys/dev/usb/usb_busdma.h
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_busdma.h	Tue Sep 21 23:08:12 2010	(r212981)
+++ user/weongyo/usb/sys/dev/usb/usb_busdma.h	Tue Sep 21 23:25:38 2010	(r212982)
@@ -61,6 +61,7 @@ typedef void (usb_dma_callback_t)(struct
 struct usb_page {
 #if USB_HAVE_BUSDMA
 	bus_addr_t physaddr;
+	bus_size_t physlen;
 	void   *buffer;			/* non Kernel Virtual Address */
 #endif
 };


More information about the svn-src-user mailing list