From owner-freebsd-current Thu Jan 16 14:52:37 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2453B37B401; Thu, 16 Jan 2003 14:52:34 -0800 (PST) Received: from angelica.unixdaemons.com (angelica.unixdaemons.com [209.148.64.135]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1874243EB2; Thu, 16 Jan 2003 14:52:33 -0800 (PST) (envelope-from hiten@angelica.unixdaemons.com) Received: from angelica.unixdaemons.com (hiten@localhost.unixdaemons.com [127.0.0.1]) by angelica.unixdaemons.com (8.12.7/8.12.1) with ESMTP id h0GMqOa6049289; Thu, 16 Jan 2003 17:52:24 -0500 (EST) Received: (from hiten@localhost) by angelica.unixdaemons.com (8.12.7/8.12.1/Submit) id h0GMqMP0049288; Thu, 16 Jan 2003 17:52:22 -0500 (EST) (envelope-from hiten) Date: Thu, 16 Jan 2003 17:52:22 -0500 From: Hiten Pandya To: Thomas Moestl Cc: Josef Karthauser , Maxime Henrion , current@FreeBSD.ORG Subject: Re: Bus DMA for USB - compilation problems. Message-ID: <20030116225222.GB24866@unixdaemons.com> References: <20030115195607.GA13076@genius.tao.org.uk> <20030115200519.GH16775@elvis.mu.org> <20030115202033.GA13368@genius.tao.org.uk> <20030115215804.GA286@crow.dom2ip.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030115215804.GA286@crow.dom2ip.de> User-Agent: Mutt/1.4i X-Operating-System: FreeBSD i386 X-Public-Key: http://www.pittgoth.com/~hiten/pubkey.asc X-URL: http://www.unixdaemons.com/~hiten X-PGP: http://pgp.mit.edu:11371/pks/lookup?search=Hiten+Pandya&op=index Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Jan 15, 2003 at 10:58:04PM +0100, Thomas Moestl wrote the words in effect of: > On Wed, 2003/01/15 at 20:20:33 +0000, Josef Karthauser wrote: > > On Wed, Jan 15, 2003 at 12:05:20PM -0800, Maxime Henrion wrote: > > > Josef Karthauser wrote: > > > > I've partially ported the NetBSD busdma code for USB to FreeBSD, but > > > > it doesn't compile, probably for a trivial reason. > > > > > > > > Anyone fancy helping me out? > > > > > > I didn't look at the patches yet, but could you give me the compilation > > > error you are getting ? > > > > > > > cc -c -O -pipe -march=pentium3 -Wall -Wredundant-decls -Wnested-externs > > -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline > > -Wcast-qual -fformat-extensions -ansi -g -nostdinc -I- -I. > > -I/usr/src/sys -I/usr/src/sys/dev -I/usr/src/sys/contrib/dev/acpica > > -I/usr/src/sys/contrib/ipfilter -D_KERNEL -include opt_global.h > > -fno-common -mno-align-long-strings -mpreferred-stack-boundary=2 > > -ffreestanding -Werror /usr/src/sys/dev/usb/uhci.c > > /usr/src/sys/dev/usb/uhci.c: In function `uhci_init': > > /usr/src/sys/dev/usb/uhci.c:425: dereferencing pointer to incomplete type > > /usr/src/sys/dev/usb/uhci.c: In function `uhci_power': > > /usr/src/sys/dev/usb/uhci.c:714: dereferencing pointer to incomplete type > > /usr/src/sys/dev/usb/uhci.c: In function `uhci_alloc_std': > > > > It's failing at lines like: > > > > UWRITE4(sc, UHCI_FLBASEADDR, DMAADDR(&sc->sc_dma, 0)); /* set frame list */ > > > > The problematic is DMAADDR, and it's because the sc->sc_dma, which is > > defined as usb_dma_t. This is defined in usb_port.h, and it uses > > usb_dma_block which is defined in usb_mem.h. I think that it's the > > usb_dma_block that is coming up as incomplete, but I'm not sure. > > DMAADDR is: > > #define DMAADDR(dma, o) ((dma)->block->map->dm_segs[0].ds_addr + (dma)->offs + (o)) > > struct usb_dma_block starts like: > > typedef struct usb_dma_block { > bus_dma_tag_t tag; > bus_dmamap_t map; > > However, bus_dmamap_t (like bus_dma_tag_t) is supposed to be opaque to > users of the busdma interface on FreeBSD. Our implementations enforce > this by defining it as: > > typedef struct bus_dmamap *bus_dmamap_t; > > , and by not exporting struct bus_dmamap in public headers. > > The DMA addresses are obtained by writing an appropriate callback > routine to process them and passing it to bus_dmamap_load(). > The usb_mem.c will need some other changes to work on FreeBSD, since > our busdma code has diverged from NetBSD's quite a bit. Hiya Joe! The caller has to specify a routine to receive the DMA segment list, and for processing any errors occured during this period. If the operation is delayed, than EINPROGRESS is returned. If you specify BUS_DMA_NOWAIT, then the bus dma interface allows you to fail the request rather the delay (no sleep) it. Neccessary prep. must be done if you don't want bus_dmamap_load_*() to block, by setting the BUS_DMA_ALLOCNOW flag at dma tag and map creation time. You must also note, that the lifetime of the callback routine, should be about the same as that of the bus_dma_segment_t array passed. As defered from the NetBSD bus_dma interface, you can provide a filter routine, at dma tag creation time (bus_dma_tag_create) to DMA to an address range not accesilbe to the interface -- i.e. if such thing happens, the routine is asked to take over the task. The BusLogic driver is a very good driver to read for bus_dma related things. I personally found it good, as it covers many cases. JFYI. HTH. Cheers. -- Hiten Pandya (hiten@unixdaemons.com, hiten@uk.FreeBSD.org) http://www.unixdaemons.com/~hiten/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message