From owner-freebsd-sparc64@FreeBSD.ORG Sun Sep 12 18:22:26 2010 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA2BD1065673 for ; Sun, 12 Sep 2010 18:22:26 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 3DEBC8FC1B for ; Sun, 12 Sep 2010 18:22:25 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.3/8.14.3/ALCHEMY.FRANKEN.DE) with ESMTP id o8CIMFtk090477; Sun, 12 Sep 2010 20:22:15 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.3/8.14.3/Submit) id o8CIMEAZ090476; Sun, 12 Sep 2010 20:22:14 +0200 (CEST) (envelope-from marius) Date: Sun, 12 Sep 2010 20:22:14 +0200 From: Marius Strobl To: Hans Petter Selasky Message-ID: <20100912182214.GA90233@alchemy.franken.de> References: <20100725143252.GV21929@gradx.cs.jhu.edu> <201007260859.20501.hselasky@c2i.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201007260859.20501.hselasky@c2i.net> User-Agent: Mutt/1.4.2.3i Cc: Nathaniel W Filardo , freebsd-sparc64@freebsd.org Subject: Re: VIMAGE hang, USB panic X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Sep 2010 18:22:26 -0000 On Mon, Jul 26, 2010 at 08:59:20AM +0200, Hans Petter Selasky wrote: > On Sunday 25 July 2010 16:32:52 Nathaniel W Filardo wrote: > > Speaking of USB hotplug, attaching a micro 4-port hub, I get this (both > > with and without VIMAGE): > > > > ugen0.2: at usbus0 > > uhub1: on > > usbus0 > > panic: iommu_dvmamap_create: bogus preallocation size , nsegments = 2, > > maxpre = 2, maxsize = 1 > > cpuid = 0 > > KDB: stack backtrace: > > Hi, > > Looks like the following check fails. The allocation size USB requests is 1- > byte. For the check to not fail, we need to request more bytes then the max- > segments parameter specified. Or decrease the nsegments parameter. I think that the sanity check is right and the parameters supplied are bogus as 1 byte cannot be split across 2 segments. > > maxpre = imin(dt->dt_nsegments, IOMMU_MAX_PRE_SEG); > presz = dt->dt_maxsize / maxpre; > KASSERT(presz != 0, ("%s: bogus preallocation size , nsegments = %d, " > "maxpre = %d, maxsize = %lu", __func__, dt->dt_nsegments, maxpre, > dt->dt_maxsize)); > > Does not look like a problem in the USB stack. I think it is as the maxsize and nsegments parameters supplied in this case make no sense. Moreover, maxsegsz should be <= maxsize, thus I'd like to commit the following change: Index: usb_busdma.c =================================================================== --- usb_busdma.c (revision 212478) +++ usb_busdma.c (working copy) @@ -366,9 +366,9 @@ usb_dma_tag_create(struct usb_dma_tag *udt, /* filter */ NULL, /* filterarg */ NULL, /* maxsize */ size, - /* nsegments */ (align == 1) ? + /* nsegments */ (align == 1 && size > 1) ? (2 + (size / USB_PAGE_SIZE)) : 1, - /* maxsegsz */ (align == 1) ? + /* maxsegsz */ (align == 1 && size > USB_PAGE_SIZE) ? USB_PAGE_SIZE : size, /* flags */ BUS_DMA_KEEP_PG_OFFSET, /* lockfn */ &usb_dma_lock_cb, Why is this using one more segment than splitting size in USB_PAGE_SIZE sized segments btw? If this isn't actually needed then replacing the 2 with a 1 would be the more preferable fix IMO. However, specifying such small allocation sizes together with BUS_SPACE_UNRESTRICTED as nsegments, which unlike what usb(4) currently does the I'd would consider as valid combinations, will also trigger this assertion, so I'll remove it. Marius