summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pcm/feeder.c
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>1999-12-05 19:09:13 +0000
committercg <cg@FreeBSD.org>1999-12-05 19:09:13 +0000
commit06117a91591c5f63a2ef74fca50d798533c06554 (patch)
tree3ba5e966b221c21899684d947e044cc0606b1654 /sys/dev/sound/pcm/feeder.c
parente1102a476ce640b1758e3f3152c8c8c9c7caa6c6 (diff)
downloadFreeBSD-src-06117a91591c5f63a2ef74fca50d798533c06554.zip
FreeBSD-src-06117a91591c5f63a2ef74fca50d798533c06554.tar.gz
fix dma underrun issues
mutate some panics to kasserts add more spl protection PR: kern/14990 Partially Submitted by: Vladimir N.Silyaev <vns@delta.odessa.ua> Reviewed by: dfr
Diffstat (limited to 'sys/dev/sound/pcm/feeder.c')
-rw-r--r--sys/dev/sound/pcm/feeder.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/sys/dev/sound/pcm/feeder.c b/sys/dev/sound/pcm/feeder.c
index a545c1f..cc45a5c 100644
--- a/sys/dev/sound/pcm/feeder.c
+++ b/sys/dev/sound/pcm/feeder.c
@@ -108,24 +108,23 @@ static unsigned char u8_to_ulaw[] = {
static int
feed_root(pcm_feeder *feeder, pcm_channel *ch, u_int8_t *buffer, u_int32_t count, struct uio *stream)
{
- int ret, tmp = 0, c = 0;
- if (!count) panic("feed_root: count == 0");
+ int ret, c = 0, s;
+ KASSERT(count, ("feed_root: count == 0"));
count &= ~((1 << ch->align) - 1);
- if (!count) panic("feed_root: aligned count == 0");
+ KASSERT(count, ("feed_root: aligned count == 0"));
+ s = spltty();
if (ch->smegcnt > 0) {
c = min(ch->smegcnt, count);
bcopy(ch->smegbuf, buffer, c);
ch->smegcnt -= c;
}
- while ((stream->uio_resid > 0) && (c < count)) {
- tmp = stream->uio_resid;
- ret = uiomove(buffer + c, count - c, stream);
- if (ret) panic("feed_root: uiomove failed");
- tmp -= stream->uio_resid;
- c += tmp;
+ count = min(count, stream->uio_resid);
+ if (count) {
+ ret = uiomove(buffer, count, stream);
+ KASSERT(ret == 0, ("feed_root: uiomove failed"));
}
- if (!c) panic("feed_root: uiomove didn't");
- return c;
+ splx(s);
+ return c + count;
}
pcm_feeder feeder_root = { "root", 0, NULL, NULL, feed_root };
OpenPOWER on IntegriCloud