From owner-svn-src-head@FreeBSD.ORG Fri Dec 21 14:17:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3E483BE8; Fri, 21 Dec 2012 14:17:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 095268FC0A; Fri, 21 Dec 2012 14:17:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBLEHdOK076224; Fri, 21 Dec 2012 14:17:39 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBLEHdP0076223; Fri, 21 Dec 2012 14:17:39 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201212211417.qBLEHdP0076223@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 21 Dec 2012 14:17:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244535 - head/sys/dev/usb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Dec 2012 14:17:40 -0000 Author: hselasky Date: Fri Dec 21 14:17:39 2012 New Revision: 244535 URL: http://svnweb.freebsd.org/changeset/base/244535 Log: Regression issue: Use a boundary of zero, hence a PAGE_SIZE boundary is implied by all memory allocations. Background: Busdma has problems to allocate more than PAGE_SIZE bytes when the boundary is PAGE_SIZE bytes too. Initially it was thought that a boundary of PAGE_SIZE bytes will only affect loading of DMA memory, so that segments get split correctly, but it also affects allocation of DMA'able memory. Solution: USB can detect big segments and split them as required by the USB code. MFC after: 1 week Reported by: gonzo Modified: head/sys/dev/usb/usb_busdma.c Modified: head/sys/dev/usb/usb_busdma.c ============================================================================== --- head/sys/dev/usb/usb_busdma.c Fri Dec 21 13:14:12 2012 (r244534) +++ head/sys/dev/usb/usb_busdma.c Fri Dec 21 14:17:39 2012 (r244535) @@ -358,8 +358,7 @@ usb_dma_tag_create(struct usb_dma_tag *u if (bus_dma_tag_create ( /* parent */ udt->tag_parent->tag, /* alignment */ align, - /* boundary */ (align == 1) ? - USB_PAGE_SIZE : 0, + /* boundary */ 0, /* lowaddr */ (2ULL << (udt->tag_parent->dma_bits - 1)) - 1, /* highaddr */ BUS_SPACE_MAXADDR, /* filter */ NULL, @@ -418,6 +417,7 @@ usb_pc_common_mem_cb(void *arg, bus_dma_ struct usb_page_cache *pc; struct usb_page *pg; usb_size_t rem; + bus_size_t off; uint8_t owned; pc = arg; @@ -433,6 +433,8 @@ usb_pc_common_mem_cb(void *arg, bus_dma_ if (error) { goto done; } + + off = 0; pg = pc->page_start; pg->physaddr = segs->ds_addr & ~(USB_PAGE_SIZE - 1); rem = segs->ds_addr & (USB_PAGE_SIZE - 1); @@ -450,10 +452,16 @@ usb_pc_common_mem_cb(void *arg, bus_dma_ } #endif while (nseg > 0) { - nseg--; - segs++; + off += USB_PAGE_SIZE; + if (off >= (segs->ds_len + rem)) { + /* page crossing */ + nseg--; + segs++; + off = 0; + rem = 0; + } pg++; - pg->physaddr = segs->ds_addr & ~(USB_PAGE_SIZE - 1); + pg->physaddr = (segs->ds_addr + off) & ~(USB_PAGE_SIZE - 1); } done: