From owner-freebsd-multimedia@FreeBSD.ORG Thu Sep 23 12:01:39 2004 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C6CA516A4CE; Thu, 23 Sep 2004 12:01:39 +0000 (GMT) Received: from ns.kt-is.co.kr (ns.kt-is.co.kr [211.218.149.125]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0EDC443D2D; Thu, 23 Sep 2004 12:01:39 +0000 (GMT) (envelope-from yongari@kt-is.co.kr) Received: from michelle.kt-is.co.kr (ns2.kt-is.co.kr [220.76.118.193]) (authenticated bits=128) by ns.kt-is.co.kr (8.12.10/8.12.10) with ESMTP id i8NBxtAh052313 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 23 Sep 2004 20:59:55 +0900 (KST) Received: from michelle.kt-is.co.kr (localhost.kt-is.co.kr [127.0.0.1]) by michelle.kt-is.co.kr (8.12.10/8.12.10) with ESMTP id i8NC1634013351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Sep 2004 21:01:07 +0900 (KST) (envelope-from yongari@kt-is.co.kr) Received: (from yongari@localhost) by michelle.kt-is.co.kr (8.12.10/8.12.10/Submit) id i8NC15ET013350; Thu, 23 Sep 2004 21:01:05 +0900 (KST) (envelope-from yongari@kt-is.co.kr) Date: Thu, 23 Sep 2004 21:01:05 +0900 From: Pyun YongHyeon To: Norikatsu Shigemura Message-ID: <20040923120105.GC13003@kt-is.co.kr> References: <20040923024038.GA11717@kt-is.co.kr> <200409231137.i8NBbDjt051259@sakura.ninth-nine.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="fUYQa+Pmc3FrFX/N" Content-Disposition: inline In-Reply-To: <200409231137.i8NBbDjt051259@sakura.ninth-nine.com> User-Agent: Mutt/1.4.1i X-Filter-Version: 1.11a (ns.kt-is.co.kr) cc: freebsd-multimedia@FreeBSD.org cc: gabor@zahemszky.hu Subject: Re: Maestro3 and 5.3-beta5 X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: yongari@kt-is.co.kr List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2004 12:01:40 -0000 --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 23, 2004 at 08:37:13PM +0900, Norikatsu Shigemura wrote: > On Thu, 23 Sep 2004 11:40:38 +0900 > Pyun YongHyeon wrote: > > Since it worked before, it sounds like DMA buffer allocation issue. > > Can you try attached patch? It doesn't fix your issue but it checks > > return code correctly and we can know whether DMA buffer allocation > > was successful or not. > > I was in trouble with this problem, too. So I tested your > patch. It looks good with Onkyo SE-120PCI(Maestro3). > Would you plase commit to CURRENT and RELENG_5? > Yes, I have plans to do it. But it's just part of other commits pending which would be committed after 5.3R. The reason I didn't commit it was lack of time. If you want to commit it please go ahead. Almost all audio drivers's code for sndbuf_alloc() call should be corrected. And possible memory leak in sound(4) should be fixed too. I have attached patch file and it was reviewed by truckman, mat.(Since the patch was tested on sparc64, you may have to add cast (unsigned long) in sndbuf_setmap() patch.) I'll not be reachable until Oct 1. Regards, Pyun YongHyeon -- Pyun YongHyeon --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pcm.patch" --- sys/dev/sound/pcm/buffer.c.orig Thu Apr 29 11:51:59 2004 +++ sys/dev/sound/pcm/buffer.c Mon Aug 30 20:21:10 2004 @@ -61,11 +61,12 @@ struct snd_dbuf *b = (struct snd_dbuf *)arg; if (bootverbose) { - device_printf(b->dev, "sndbuf_setmap %lx, %lx; ", (unsigned long)segs->ds_addr, - (unsigned long)segs->ds_len); - printf("%p -> %lx\n", b->buf, (unsigned long)vtophys(b->buf)); + device_printf(b->dev, "sndbuf_setmap %lx, %lx; ", + segs[0].ds_addr, segs[0].ds_len); + printf("%p -> %lx\n", b->buf, segs[0].ds_addr); } - b->buf_addr = segs->ds_addr; + if ((b->map_error = error) == 0) + b->buf_addr = segs[0].ds_addr; } /* @@ -76,14 +77,26 @@ int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, unsigned int size) { + int ret; + b->dmatag = dmatag; b->maxsize = size; b->bufsize = b->maxsize; - if (bus_dmamem_alloc(b->dmatag, (void **)&b->buf, BUS_DMA_NOWAIT, &b->dmamap)) - return ENOSPC; - if (bus_dmamap_load(b->dmatag, b->dmamap, b->buf, b->maxsize, sndbuf_setmap, b, 0)) - return ENOSPC; - return sndbuf_resize(b, 2, b->maxsize / 2); + b->map_error = 0; + if (bus_dmamem_alloc(b->dmatag, (void **)&b->buf, BUS_DMA_NOWAIT, + &b->dmamap)) + return (ENOMEM); + if (bus_dmamap_load(b->dmatag, b->dmamap, b->buf, b->maxsize, + sndbuf_setmap, b, 0) != 0 || b->map_error != 0) { + bus_dmamem_free(b->dmatag, b->buf, b->dmamap); + b->dmamap = NULL; + return (ENOMEM); + } + + ret = sndbuf_resize(b, 2, b->maxsize / 2); + if (ret != 0) + sndbuf_free(b); + return (ret); } int @@ -92,6 +105,7 @@ b->buf = buf; b->maxsize = size; b->bufsize = b->maxsize; + b->map_error = 0; return sndbuf_resize(b, 2, b->maxsize / 2); } --- sys/dev/sound/pcm/buffer.h.orig Wed Jan 28 17:02:15 2004 +++ sys/dev/sound/pcm/buffer.h Sat Aug 28 17:35:46 2004 @@ -52,6 +52,7 @@ bus_dmamap_t dmamap; bus_dma_tag_t dmatag; u_int32_t buf_addr; + int map_error; struct selinfo sel; struct pcm_channel *channel; char name[SNDBUF_NAMELEN]; --fUYQa+Pmc3FrFX/N--