From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 2 13:23:56 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 20C9516A403 for ; Sun, 2 Jul 2006 13:23:56 +0000 (UTC) (envelope-from iedowse@iedowse.com) Received: from nowhere.iedowse.com (nowhere.iedowse.com [82.195.144.75]) by mx1.FreeBSD.org (Postfix) with SMTP id 1143943D45 for ; Sun, 2 Jul 2006 13:23:54 +0000 (GMT) (envelope-from iedowse@iedowse.com) Received: from localhost ([127.0.0.1] helo=iedowse.com) by nowhere.iedowse.com via local-iedowse id ; 2 Jul 2006 14:23:53 +0100 (IST) To: Hans Petter Selasky In-Reply-To: Your message of "Sun, 02 Jul 2006 14:33:30 +0200." <200607021433.32278.hselasky@c2i.net> Date: Sun, 02 Jul 2006 14:23:53 +0100 From: Ian Dowse Message-ID: <200607021423.aa76796@nowhere.iedowse.com> Cc: David Malone , freebsd-hackers@freebsd.org Subject: Re: contiguous memory allocation problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jul 2006 13:23:56 -0000 In message <200607021433.32278.hselasky@c2i.net>, Hans Petter Selasky writes: >On Sunday 02 July 2006 14:05, Ian Dowse wrote: >> This data structure requires the associated data buffer to be >> contiguous (relative to virtual memory), but allows the physical >> memory pages to be non-contiguous. Seven page pointers are provided >> to support the expression of 8 isochronous transfers. The seven >> pointers allow for 3 (transactions) * 1024 (maximum packet size) >> * 8 (transaction records) (24576 bytes) to be moved with this >> data structure, regardless of the alignment offset of the first >> page. > >3 * 1024 bytes = 0xC00 bytes > >8 * 0xC00 = 0x6000 bytes maximum > >According to this you need "6" "EHCI pages", because "6 * 0x1000 = 0x6000". >The seventh "EHCI page" is just there to allow one to start at any page >offset. There is no eight "EHCI page". > >The only solution I see, is to have a double layer ITD. The first layer have >the 4 first transfers activated, and the second layer have the 4 last >transfers activated. > >A little more complicated, but not impossible. The trick is that if the 0x6000 bytes are contiguous in virtual memory then they never span more than 6 pages so one iTD is enough. i.e. you can just do malloc(0x6000) and you don't need multi-page physically contiguous buffers or extra memory-memory copies regardless of how the virtual buffer maps to physical pages. This seems to be the general extent of scatter-gather support offered by the various USB host controllers (modulo various caveats such as assuming pages are >= 4k, handling physical addresses > 4GB on non-IOMMU hardware and UHCI's lack of support for mid-packet non-contiguous page boundaries). Ian