From owner-freebsd-current@FreeBSD.ORG Sun Dec 7 09:23:49 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71163106567B; Sun, 7 Dec 2008 09:23:49 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe12.swipnet.se [212.247.155.97]) by mx1.freebsd.org (Postfix) with ESMTP id 8F7578FC23; Sun, 7 Dec 2008 09:23:47 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=OxQIQV-UnBUA:10 a=OldrGD9YyLYA:10 a=P3SC899gXHkOLDnkTYxLZw==:17 a=6I5d2MoRAAAA:8 a=XWMPSL2NCp9O6ptO02YA:9 a=-m65pplqKBvUwPkz_OsA:7 a=rQWlRaZadRbjHd-41yFsA6_yBIcA:4 a=LY0hPdMaydYA:10 Received: from [62.113.133.240] (account mc467741@c2i.net [62.113.133.240] verified) by mailfe12.swip.net (CommuniGate Pro SMTP 5.2.6) with ESMTPA id 989066876; Sun, 07 Dec 2008 10:23:45 +0100 From: Hans Petter Selasky To: freebsd-current@freebsd.org Date: Sun, 7 Dec 2008 10:25:58 +0100 User-Agent: KMail/1.9.7 References: <20081107082740.GA1334@icarus.home.lan> <200812061334.55365.hselasky@c2i.net> <031DE609-3E5B-4508-BAB0-95800B7F02F4@mac.com> In-Reply-To: <031DE609-3E5B-4508-BAB0-95800B7F02F4@mac.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812071026.00497.hselasky@c2i.net> Cc: Marcel Moolenaar , freebsd-usb@freebsd.org, Alfred Perlstein Subject: Re: [Serious] busdma bug in -current in relation to USB hardware - review wanted X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Dec 2008 09:23:49 -0000 On Saturday 06 December 2008, Marcel Moolenaar wrote: > On Dec 6, 2008, at 4:34 AM, Hans Petter Selasky wrote: > > Hi, > > > > After various feedback from several people I have made a new patch > > proposal > > that will fix the busdma problem. > > > > See: > > > > http://perforce.freebsd.org/chv.cgi?CH=154181 > > > > Review wanted! > > The USB stack has a fixed page size of 4K. On our 64-bit platforms > PAGE_SIZE is at least 8K. Your change is sloppy in that respect > and doesn't make the distinction. That makes the patch a kluge. > The definition of BUS_DMA_NO_REALIGN is based on circumstantial > evidence only and as such, works as a side-effect. I don't think > that's a good design. > > I don't think there's any reason not to preserve the page offset > in all cases. So far all hardware worked whether or not their > DMA pages were bounced and the non-bounced pages would have a > possible non-zero page offset, whereas the bounced pages would > always have a zero page offset. In short: it works either way. > In particular, it works with the page offset preserved. Why not > preserve it always? What's the downside? Hi Marcel, I think you might be right there. There is one case in which I don't understand what is the correct busdma behaviour. If the DMA tag has an alignment of 4 bytes, and the memory loaded is not aligned to four bytes, then should a bounce page be used? If yes, then you will need to clear the page offset. Else not. NOTE: We are not talking about allocating DMA memory, only loading it. --HPS