Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/hdaudio Avoid setting up bus_dma w/ BUS_DMA_WAIT...



details:   https://anonhg.NetBSD.org/src/rev/30d162736a89
branches:  trunk
changeset: 747264:30d162736a89
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Sep 07 16:35:02 2009 +0000

description:
Avoid setting up bus_dma w/ BUS_DMA_WAITOK while sc_stream_mtx is held.

diffstat:

 sys/dev/pci/hdaudio/hdaudio.c |  25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diffs (61 lines):

diff -r 76712235c81d -r 30d162736a89 sys/dev/pci/hdaudio/hdaudio.c
--- a/sys/dev/pci/hdaudio/hdaudio.c     Mon Sep 07 16:22:46 2009 +0000
+++ b/sys/dev/pci/hdaudio/hdaudio.c     Mon Sep 07 16:35:02 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.3 2009/09/07 16:21:08 jmcneill Exp $ */
+/* $NetBSD: hdaudio.c,v 1.4 2009/09/07 16:35:02 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.3 2009/09/07 16:21:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.4 2009/09/07 16:35:02 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -901,8 +901,14 @@
     void *cookie)
 {
        struct hdaudio_stream *st;
+       struct hdaudio_dma dma;
        int i, err;
 
+       dma.dma_size = sizeof(struct hdaudio_bdl_entry) * HDAUDIO_BDL_MAX;
+       err = hdaudio_dma_alloc(sc, &dma, BUS_DMA_COHERENT | BUS_DMA_NOCACHE);
+       if (err)
+               return NULL;
+
        mutex_enter(&sc->sc_stream_mtx);
        for (i = 0; i < HDAUDIO_MAX_STREAMS; i++) {
                st = &sc->sc_stream[i];
@@ -914,22 +920,17 @@
                        continue;
 
                /* Allocate stream */
-               st->st_bdl.dma_size = sizeof(struct hdaudio_bdl_entry) *
-                   HDAUDIO_BDL_MAX;
-               err = hdaudio_dma_alloc(sc, &st->st_bdl,
-                   BUS_DMA_COHERENT | BUS_DMA_NOCACHE);
-               if (!err) {
-                       st->st_intr = intr;
-                       st->st_cookie = cookie;
-                       sc->sc_stream_mask |= (1 << i);
-               } else
-                       st = NULL;
+               st->st_bdl = dma;
+               st->st_intr = intr;
+               st->st_cookie = cookie;
+               sc->sc_stream_mask |= (1 << i);
                mutex_exit(&sc->sc_stream_mtx);
                return st;
        }
        mutex_exit(&sc->sc_stream_mtx);
 
        /* No streams of requested type available */
+       hdaudio_dma_free(sc, &dma);
        return NULL;
 }
 



Home | Main Index | Thread Index | Old Index