From owner-freebsd-current@FreeBSD.ORG Fri Nov 7 17:06:58 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 BD174106568B for ; Fri, 7 Nov 2008 17:06:58 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe12.tele2.se [212.247.155.97]) by mx1.freebsd.org (Postfix) with ESMTP id EA33E8FC1E for ; Fri, 7 Nov 2008 17:06:57 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=BsiE5UjOb94A:10 a=vvzDfkpqIs0A:10 a=d6BVkb5LuPPVEe4iNQMLyA==:17 a=6I5d2MoRAAAA:8 a=6-5ZibYPNPbUPX4ov8YA:9 a=YSydp3P56GSINd-7874A:7 a=XrMi6xJXLwWbUyacIo9TZL_bw1UA:4 a=LY0hPdMaydYA:10 Received: from [62.113.135.6] (account mc467741@c2i.net [62.113.135.6] verified) by mailfe12.swip.net (CommuniGate Pro SMTP 5.2.6) with ESMTPA id 971451562; Fri, 07 Nov 2008 18:06:56 +0100 From: Hans Petter Selasky To: freebsd-current@freebsd.org Date: Fri, 7 Nov 2008 18:09:04 +0100 User-Agent: KMail/1.9.7 References: <20081107075232.GA1608@icarus.home.lan> <4bSZ78p2klKnbZ/rhiyIIUK0VNE@qm7gbYKMPO53E/nl+D5eD8YyL1A> <20081107090719.GA1287@icarus.home.lan> In-Reply-To: <20081107090719.GA1287@icarus.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200811071809.05617.hselasky@c2i.net> Cc: Jeremy Chadwick , Eygene Ryabinkin Subject: Re: USB4BSD (USB2): Microsoft 4000 keyboard unusable 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: Fri, 07 Nov 2008 17:06:58 -0000 On Friday 07 November 2008, Jeremy Chadwick wrote: > On Fri, Nov 07, 2008 at 11:38:49AM +0300, Eygene Ryabinkin wrote: > > Thu, Nov 06, 2008 at 11:52:32PM -0800, Jeremy Chadwick wrote: > > [...] > > > > > Everything built (csup date: 2008/11/06 ~2200 PST) fine, no issues -- > > > until I noticed my USB keyboard didn't function any longer. > > > > > > During boot0/boot2/loader, the keyboard functions (as expected, re: USB > > > Legacy option is enabled in my BIOS), and the keyboard LEDs are lit as > > > expected. The kernel loads, some drivers initialise, and the LEDs go > > > off. Once the USB2 stack loads, the keyboard LEDs turn back up, but as > > > stated, no keypresses are registered. I was forced to hook up a PS/2 > > > keyboard. > > You are using 64-bit architecture - right? Then you need the following patch to usb2_busdma.c: http://perforce.freebsd.org/chv.cgi?CH=152624 Fix some problems related to busdma: Need to unload DMA maps before re-use! Fix a corner case when loading zero bytes. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_busdma.c#10 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_busdma.c#10 (text+ko) ==== @@ -597,6 +597,12 @@ uptag = pc->tag_parent; /* + * We have to unload the previous loaded DMA + * pages before trying to load a new one! + */ + bus_dmamap_unload(pc->tag, pc->map); + + /* * Try to load memory into DMA. */ err = bus_dmamap_load( @@ -612,6 +618,12 @@ } else { /* + * We have to unload the previous loaded DMA + * pages before trying to load a new one! + */ + bus_dmamap_unload(pc->tag, pc->map); + + /* * Try to load memory into DMA. The callback * will be called in all cases: */ @@ -639,6 +651,10 @@ void usb2_pc_cpu_invalidate(struct usb2_page_cache *pc) { + if (pc->page_offset_end == pc->page_offset_buf) { + /* nothing has been loaded into this page cache! */ + return; + } bus_dmamap_sync(pc->tag, pc->map, BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); return; @@ -650,6 +666,10 @@ void usb2_pc_cpu_flush(struct usb2_page_cache *pc) { + if (pc->page_offset_end == pc->page_offset_buf) { + /* nothing has been loaded into this page cache! */ + return; + } bus_dmamap_sync(pc->tag, pc->map, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return; @@ -953,6 +973,12 @@ if (size > 0) { + /* + * We have to unload the previous loaded DMA + * pages before trying to load a new one! + */ + bus_dmamap_unload(pc->tag, pc->map); + /* try to load memory into DMA using using no wait option */ if (bus_dmamap_load(pc->tag, pc->map, pc->buffer, size, NULL, BUS_DMA_NOWAIT)) { @@ -990,6 +1016,10 @@ len = pc->page_offset_end - pc->page_offset_buf; + if (len == 0) { + /* nothing has been loaded into this page cache */ + return; + } bus_dmamap_sync(pc->tag, pc->map, 0, len, BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); return; @@ -1005,6 +1035,10 @@ len = pc->page_offset_end - pc->page_offset_buf; + if (len == 0) { + /* nothing has been loaded into this page cache */ + return; + } bus_dmamap_sync(pc->tag, pc->map, 0, len, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return; Best regards HPS