From owner-freebsd-multimedia@FreeBSD.ORG Sun Jun 14 18:47:55 2009 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C54021065672 for ; Sun, 14 Jun 2009 18:47:55 +0000 (UTC) (envelope-from rick@kiwi-computer.com) Received: from hamlet.setfilepointer.com (hamlet.SetFilePointer.com [63.224.10.2]) by mx1.freebsd.org (Postfix) with SMTP id 4B8448FC16 for ; Sun, 14 Jun 2009 18:47:55 +0000 (UTC) (envelope-from rick@kiwi-computer.com) Received: (qmail 5407 invoked from network); 14 Jun 2009 13:47:54 -0500 Received: from keira.kiwi-computer.com (HELO kiwi-computer.com) (63.224.10.3) by hamlet.setfilepointer.com with SMTP; 14 Jun 2009 13:47:54 -0500 Received: (qmail 73185 invoked by uid 2001); 14 Jun 2009 18:47:54 -0000 Date: Sun, 14 Jun 2009 13:47:54 -0500 From: "Rick C. Petty" To: Alexander Motin Message-ID: <20090614184754.GA72664@keira.kiwi-computer.com> References: <1242609781.00113421.1242598202@10.7.7.3> <4A122B72.80206@FreeBSD.org> <20090519184150.GA990@keira.kiwi-computer.com> <20090605020054.GA67365@keira.kiwi-computer.com> <4A28D79C.6070406@FreeBSD.org> <20090614050211.GA67556@keira.kiwi-computer.com> <20090614062157.GA67705@keira.kiwi-computer.com> <4A34A663.2010503@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A34A663.2010503@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: freebsd-multimedia@freebsd.org Subject: Re: snd_hda works on i386, fails on amd64 (RELENG_7) X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rick-freebsd2008@kiwi-computer.com List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jun 2009 18:47:56 -0000 On Sun, Jun 14, 2009 at 10:27:31AM +0300, Alexander Motin wrote: > Rick C. Petty wrote: > > > >Hmm, I looked at the place that queries support_64bit, in hdac_dma_alloc as > >part of the lowaddr to the bus_dma_tag_create(9) call: > > > > lowaddr = (sc->support_64bit) ? BUS_SPACE_MAXADDR : > > BUS_SPACE_MAXADDR_32BIT; > > ... > > > >On a whim, I tried manually setting lowaddr to BUS_SPACE_MAXADDR_24BIT and > >it worked! A binary search revealed that it breaks for me when > >lowaddr > 0x7FFFFFFF ... perhaps a 32-bit overflow bug related to DMA? > > You are right. There is definitely overflow. Try this: > > --- hdac.c.prev 2009-04-01 21:55:08.000000000 +0300 > +++ hdac.c 2009-06-14 10:24:18.000000000 +0300 > @@ -1589,9 +1589,9 @@ hdac_dma_cb(void *callback_arg, bus_dma_ > static int > hdac_dma_alloc(struct hdac_softc *sc, struct hdac_dma *dma, bus_size_t > size) > { > + bus_addr_t lowaddr; > bus_size_t roundsz; > int result; > - int lowaddr; > > roundsz = roundup2(size, HDAC_DMA_ALIGNMENT); > lowaddr = (sc->support_64bit) ? BUS_SPACE_MAXADDR : That helped. I still need to set sc->support_64bit to 0 in hdac_get_capabilities(). I added code so I can override this setting using device.hints. Could you maybe see about getting the following code committed? Feel free to fix it up as necessary. Thank you, -- Rick C. Petty --- src/sys/dev/sound/pci/hda/hdac.c.orig 2009-03-30 05:18:43.000000000 -0500 +++ src/sys/dev/sound/pci/hda/hdac.c 2009-06-14 13:15:14.000000000 -0500 @@ -1510,6 +1510,7 @@ static int hdac_get_capabilities(struct hdac_softc *sc) { + uint32_t flags; uint16_t gcap; uint8_t corbsize, rirbsize; @@ -1519,6 +1520,9 @@ sc->num_bss = HDAC_GCAP_BSS(gcap); sc->support_64bit = HDA_FLAG_MATCH(gcap, HDAC_GCAP_64OK); + flags = device_get_flags(sc->dev); + if (flags & 32) + sc->support_64bit = 0; corbsize = HDAC_READ_1(&sc->mem, HDAC_CORBSIZE); if ((corbsize & HDAC_CORBSIZE_CORBSZCAP_256) == @@ -1591,9 +1595,9 @@ static int hdac_dma_alloc(struct hdac_softc *sc, struct hdac_dma *dma, bus_size_t size) { + bus_addr_t lowaddr; bus_size_t roundsz; int result; - int lowaddr; roundsz = roundup2(size, HDAC_DMA_ALIGNMENT); lowaddr = (sc->support_64bit) ? BUS_SPACE_MAXADDR : --- /usr/src/share/man/man4/snd_hda.4.orig 2009-01-11 09:43:13.000000000 -0600 +++ /usr/src/share/man/man4/snd_hda.4 2009-06-14 13:44:38.000000000 -0500 @@ -145,6 +145,16 @@ or as a set of space-separated .Dq Ar option Ns = Ns Ar value pairs. +.It Va hint.hdac.%d.flags +Additional configuration settings. +.El +.Pp +Meaning of +.Ar flags : +.Bl -tag -width "0x00" -offset indent -compact +.It 0x20 +Force device to use 32-bit DMA address (under 4GB), even if the device +capabilities states that the device supports 64-bit operation. .El .Pp Pin configuration is the UAA driver's main source of information about codec