Maestro3 and 5.3-beta5
Pyun YongHyeon
yongari at kt-is.co.kr
Thu Sep 23 05:01:40 PDT 2004
On Thu, Sep 23, 2004 at 08:37:13PM +0900, Norikatsu Shigemura wrote:
> On Thu, 23 Sep 2004 11:40:38 +0900
> Pyun YongHyeon <yongari at kt-is.co.kr> 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 <http://www.kr.freebsd.org/~yongari>
-------------- next part --------------
--- 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];
More information about the freebsd-multimedia
mailing list