From owner-svn-src-head@FreeBSD.ORG Sun Jan 27 18:01:03 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BE730A1E; Sun, 27 Jan 2013 18:01:03 +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 AF798E63; Sun, 27 Jan 2013 18:01:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0RI13RR031845; Sun, 27 Jan 2013 18:01:03 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0RI13rU031844; Sun, 27 Jan 2013 18:01:03 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201301271801.r0RI13rU031844@svn.freebsd.org> From: Hans Petter Selasky Date: Sun, 27 Jan 2013 18:01:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r245995 - 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: Sun, 27 Jan 2013 18:01:03 -0000 Author: hselasky Date: Sun Jan 27 18:01:03 2013 New Revision: 245995 URL: http://svnweb.freebsd.org/changeset/base/245995 Log: 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 Modified: head/sys/dev/usb/usb_busdma.c Modified: head/sys/dev/usb/usb_busdma.c ============================================================================== --- head/sys/dev/usb/usb_busdma.c Sun Jan 27 17:41:29 2013 (r245994) +++ head/sys/dev/usb/usb_busdma.c Sun Jan 27 18:01:03 2013 (r245995) @@ -440,7 +440,6 @@ usb_pc_common_mem_cb(void *arg, bus_dma_ 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_ 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_ segs++; off = 0; rem = 0; + if (nseg == 0) + break; } pg++; pg->physaddr = (segs->ds_addr + off) & ~(USB_PAGE_SIZE - 1);