From e54ad26c75102aadac46ba4cbf1c17c8604fd9d3 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 16 Jun 2007 20:07:22 +0000 Subject: [PATCH] Update all sound code to use the snd_*() locking abstraction and sndlock_t. Fix issues with spinlocks being held through blocking conditions (because DragonFly spinlocks aren't FreeBSD mutexes) by replacing the spinlocks with lockmgr locks. --- sys/dev/sound/isa/ad1816.c | 6 ++--- sys/dev/sound/isa/mss.c | 6 ++--- sys/dev/sound/isa/sbc.c | 6 ++--- sys/dev/sound/pci/als4000.c | 6 ++--- sys/dev/sound/pci/atiixp.c | 8 +++---- sys/dev/sound/pci/aureal.c | 6 ++--- sys/dev/sound/pci/cmi.c | 6 ++--- sys/dev/sound/pci/ds1.c | 6 ++--- sys/dev/sound/pci/emu10k1.c | 6 ++--- sys/dev/sound/pci/envy24.c | 6 ++--- sys/dev/sound/pci/envy24ht.c | 6 ++--- sys/dev/sound/pci/es137x.c | 6 ++--- sys/dev/sound/pci/gnu/emu10k1-alsa.h | 20 ++++++++-------- sys/dev/sound/pci/hda/hdac_private.h | 4 ++-- sys/dev/sound/pci/ich.c | 8 ++++--- sys/dev/sound/pci/maestro.c | 8 +++---- sys/dev/sound/pci/maestro3.c | 6 ++--- sys/dev/sound/pci/solo.c | 6 ++--- sys/dev/sound/pci/spicds.c | 4 ++-- sys/dev/sound/pci/t4dwave.c | 6 ++--- sys/dev/sound/pci/via8233.c | 6 ++--- sys/dev/sound/pci/via82c686.c | 6 ++--- sys/dev/sound/pcm/ac97.c | 6 ++--- sys/dev/sound/pcm/channel.c | 6 ++--- sys/dev/sound/pcm/channel.h | 8 +++---- sys/dev/sound/pcm/mixer.c | 6 ++--- sys/dev/sound/pcm/sound.c | 44 ++++++++++++++++++++++++------------ sys/dev/sound/pcm/sound.h | 17 +++++++------- 28 files changed, 126 insertions(+), 109 deletions(-) diff --git a/sys/dev/sound/isa/ad1816.c b/sys/dev/sound/isa/ad1816.c index a0d9677e1d..485c1df6a4 100644 --- a/sys/dev/sound/isa/ad1816.c +++ b/sys/dev/sound/isa/ad1816.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/isa/ad1816.c,v 1.37.2.2 2006/04/04 17:23:24 ariff Exp $ - * $DragonFly: src/sys/dev/sound/isa/ad1816.c,v 1.7 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/isa/ad1816.c,v 1.8 2007/06/16 20:07:18 dillon Exp $ */ #include @@ -36,7 +36,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/isa/ad1816.c,v 1.7 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/isa/ad1816.c,v 1.8 2007/06/16 20:07:18 dillon Exp $"); struct ad1816_info; @@ -58,7 +58,7 @@ struct ad1816_info { int drq2_rid; void *ih; bus_dma_tag_t parent_dmat; - struct spinlock *lock; + sndlock_t lock; unsigned int bufsize; struct ad1816_chinfo pch, rch; diff --git a/sys/dev/sound/isa/mss.c b/sys/dev/sound/isa/mss.c index 8bc9e5176e..f2000f9e9a 100644 --- a/sys/dev/sound/isa/mss.c +++ b/sys/dev/sound/isa/mss.c @@ -27,12 +27,12 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/isa/mss.c,v 1.95.2.3 2006/04/04 17:30:59 ariff Exp $ - * $DragonFly: src/sys/dev/sound/isa/mss.c,v 1.10 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/isa/mss.c,v 1.11 2007/06/16 20:07:18 dillon Exp $ */ #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/isa/mss.c,v 1.10 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/isa/mss.c,v 1.11 2007/06/16 20:07:18 dillon Exp $"); /* board-specific include files */ #include @@ -70,7 +70,7 @@ struct mss_info { int drq2_rid; void *ih; bus_dma_tag_t parent_dmat; - struct spinlock *lock; + sndlock_t lock; char mss_indexed_regs[MSS_INDEXED_REGS]; char opl_indexed_regs[OPL_INDEXED_REGS]; diff --git a/sys/dev/sound/isa/sbc.c b/sys/dev/sound/isa/sbc.c index 54841d0d12..96de2b7ee3 100644 --- a/sys/dev/sound/isa/sbc.c +++ b/sys/dev/sound/isa/sbc.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/isa/sbc.c,v 1.44.2.1 2005/12/30 19:55:53 netchild Exp $ - * $DragonFly: src/sys/dev/sound/isa/sbc.c,v 1.9 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/isa/sbc.c,v 1.10 2007/06/16 20:07:18 dillon Exp $ */ #include @@ -33,7 +33,7 @@ #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/isa/sbc.c,v 1.9 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/isa/sbc.c,v 1.10 2007/06/16 20:07:18 dillon Exp $"); #define IO_MAX 3 #define IRQ_MAX 1 @@ -69,7 +69,7 @@ struct sbc_softc { void *ih[IRQ_MAX]; - struct spinlock *lock; + sndlock_t lock; u_int32_t bd_ver; }; diff --git a/sys/dev/sound/pci/als4000.c b/sys/dev/sound/pci/als4000.c index 738783a1e3..2a11be5134 100644 --- a/sys/dev/sound/pci/als4000.c +++ b/sys/dev/sound/pci/als4000.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/als4000.c,v 1.18.2.1 2005/12/30 19:55:53 netchild Exp $ - * $DragonFly: src/sys/dev/sound/pci/als4000.c,v 1.10 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/als4000.c,v 1.11 2007/06/16 20:07:19 dillon Exp $ */ /* @@ -45,7 +45,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/als4000.c,v 1.10 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/als4000.c,v 1.11 2007/06/16 20:07:19 dillon Exp $"); /* Debugging macro's */ #undef DEB @@ -78,7 +78,7 @@ struct sc_info { struct resource *reg, *irq; int regid, irqid; void *ih; - struct spinlock *lock; + sndlock_t lock; unsigned int bufsz; struct sc_chinfo pch, rch; diff --git a/sys/dev/sound/pci/atiixp.c b/sys/dev/sound/pci/atiixp.c index be387ef896..b0cd1550fe 100644 --- a/sys/dev/sound/pci/atiixp.c +++ b/sys/dev/sound/pci/atiixp.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/atiixp.c,v 1.2.2.7 2007/04/26 08:21:44 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/atiixp.c,v 1.4 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/atiixp.c,v 1.5 2007/06/16 20:07:19 dillon Exp $ */ /* @@ -66,7 +66,7 @@ #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/atiixp.c,v 1.4 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/atiixp.c,v 1.5 2007/06/16 20:07:19 dillon Exp $"); struct atiixp_dma_op { volatile uint32_t addr; @@ -114,7 +114,7 @@ struct atiixp_info { uint32_t dma_segs; int registered_channels; - struct spinlock *lock; + sndlock_t lock; }; #define atiixp_rd(_sc, _reg) \ @@ -747,7 +747,7 @@ atiixp_chip_post_init(void *arg) /* wait for the interrupts to happen */ timeout = 100; while (--timeout) { - msleep(sc, sc->lock, 0, "ixpslp", 1); + snd_mtxsleep(sc, sc->lock, 0, "ixpslp", 1); if (sc->codec_not_ready_bits) break; } diff --git a/sys/dev/sound/pci/aureal.c b/sys/dev/sound/pci/aureal.c index e8a2a5a052..c836324c6e 100644 --- a/sys/dev/sound/pci/aureal.c +++ b/sys/dev/sound/pci/aureal.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/aureal.c,v 1.32 2005/03/01 08:58:05 imp Exp $ - * $DragonFly: src/sys/dev/sound/pci/aureal.c,v 1.10 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/aureal.c,v 1.11 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -34,7 +34,7 @@ #include #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/aureal.c,v 1.10 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/aureal.c,v 1.11 2007/06/16 20:07:19 dillon Exp $"); /* PCI IDs of supported chips */ #define AU8820_PCI_ID 0x000112eb @@ -76,7 +76,7 @@ struct au_info { bus_space_handle_t sh[3]; bus_dma_tag_t parent_dmat; - struct spinlock *lock; + sndlock_t lock; u_int32_t x[32], y[128]; char z[128]; diff --git a/sys/dev/sound/pci/cmi.c b/sys/dev/sound/pci/cmi.c index a37b66a275..47de8f0432 100644 --- a/sys/dev/sound/pci/cmi.c +++ b/sys/dev/sound/pci/cmi.c @@ -40,7 +40,7 @@ * those that don't. * * $FreeBSD: src/sys/dev/sound/pci/cmi.c,v 1.32.2.2 2006/01/24 18:54:22 joel Exp $ - * $DragonFly: src/sys/dev/sound/pci/cmi.c,v 1.9 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/cmi.c,v 1.10 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -54,7 +54,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/cmi.c,v 1.9 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/cmi.c,v 1.10 2007/06/16 20:07:19 dillon Exp $"); /* Supported chip ID's */ #define CMI8338A_PCI_ID 0x010013f6 @@ -110,7 +110,7 @@ struct sc_info { struct resource *reg, *irq; int regid, irqid; void *ih; - struct spinlock *lock; + sndlock_t lock; int spdif_enabled; unsigned int bufsz; diff --git a/sys/dev/sound/pci/ds1.c b/sys/dev/sound/pci/ds1.c index e24d08ec07..042471153e 100644 --- a/sys/dev/sound/pci/ds1.c +++ b/sys/dev/sound/pci/ds1.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/ds1.c,v 1.43.2.1 2006/01/18 01:05:34 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/ds1.c,v 1.8 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/ds1.c,v 1.9 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -36,7 +36,7 @@ #include #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/ds1.c,v 1.8 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/ds1.c,v 1.9 2007/06/16 20:07:19 dillon Exp $"); /* -------------------------------------------------------------------- */ @@ -119,7 +119,7 @@ struct sc_info { struct resource *reg, *irq; int regid, irqid; void *ih; - struct spinlock *lock; + sndlock_t lock; void *regbase; u_int32_t *pbase, pbankbase, pbanksize; diff --git a/sys/dev/sound/pci/emu10k1.c b/sys/dev/sound/pci/emu10k1.c index 6aed0cd7c1..8b3137612b 100644 --- a/sys/dev/sound/pci/emu10k1.c +++ b/sys/dev/sound/pci/emu10k1.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/emu10k1.c,v 1.55.2.1 2005/12/30 19:55:53 netchild Exp $ - * $DragonFly: src/sys/dev/sound/pci/emu10k1.c,v 1.12 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/emu10k1.c,v 1.13 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -38,7 +38,7 @@ #include #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/emu10k1.c,v 1.12 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/emu10k1.c,v 1.13 2007/06/16 20:07:19 dillon Exp $"); /* -------------------------------------------------------------------- */ @@ -130,7 +130,7 @@ struct sc_info { struct resource *reg, *irq; void *ih; - struct spinlock *lock; + sndlock_t lock; unsigned int bufsz; int timer, timerinterval; diff --git a/sys/dev/sound/pci/envy24.c b/sys/dev/sound/pci/envy24.c index 3ede549bd3..035c5be40f 100644 --- a/sys/dev/sound/pci/envy24.c +++ b/sys/dev/sound/pci/envy24.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/envy24.c,v 1.11.2.2 2007/06/11 19:33:27 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/envy24.c,v 1.1 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/envy24.c,v 1.2 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -37,7 +37,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/envy24.c,v 1.1 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/envy24.c,v 1.2 2007/06/16 20:07:19 dillon Exp $"); MALLOC_DEFINE(M_ENVY24, "envy24", "envy24 audio"); @@ -116,7 +116,7 @@ struct cfg_info { /* device private data */ struct sc_info { device_t dev; - struct spinlock *lock; + sndlock_t lock; /* Control/Status registor */ struct resource *cs; diff --git a/sys/dev/sound/pci/envy24ht.c b/sys/dev/sound/pci/envy24ht.c index 2e69b89fa7..b529cdc21d 100644 --- a/sys/dev/sound/pci/envy24ht.c +++ b/sys/dev/sound/pci/envy24ht.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/envy24ht.c,v 1.11.2.2 2007/06/11 19:33:27 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/envy24ht.c,v 1.1 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/envy24ht.c,v 1.2 2007/06/16 20:07:19 dillon Exp $ */ /* @@ -49,7 +49,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/envy24ht.c,v 1.1 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/envy24ht.c,v 1.2 2007/06/16 20:07:19 dillon Exp $"); MALLOC_DEFINE(M_ENVY24HT, "envy24ht", "envy24ht audio"); @@ -125,7 +125,7 @@ struct cfg_info { /* device private data */ struct sc_info { device_t dev; - struct spinlock *lock; + sndlock_t lock; /* Control/Status registor */ struct resource *cs; diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c index 8fbbde99d6..e5f49082df 100644 --- a/sys/dev/sound/pci/es137x.c +++ b/sys/dev/sound/pci/es137x.c @@ -39,7 +39,7 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/es137x.c,v 1.55.2.2 2006/01/16 02:08:56 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/es137x.c,v 1.9 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/es137x.c,v 1.10 2007/06/16 20:07:19 dillon Exp $ */ /* @@ -62,7 +62,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/es137x.c,v 1.9 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/es137x.c,v 1.10 2007/06/16 20:07:19 dillon Exp $"); static int debug = 0; SYSCTL_INT(_debug, OID_AUTO, es_debug, CTLFLAG_RW, &debug, 0, ""); @@ -194,7 +194,7 @@ struct es_info { uint32_t sctrl; uint32_t escfg; struct es_chinfo ch[ES_NCHANS]; - struct spinlock *lock; + sndlock_t lock; }; #define ES_LOCK(sc) snd_mtxlock((sc)->lock) diff --git a/sys/dev/sound/pci/gnu/emu10k1-alsa.h b/sys/dev/sound/pci/gnu/emu10k1-alsa.h index 4f01b63067..b63b7835f6 100644 --- a/sys/dev/sound/pci/gnu/emu10k1-alsa.h +++ b/sys/dev/sound/pci/gnu/emu10k1-alsa.h @@ -24,7 +24,7 @@ */ /* $FreeBSD: src/sys/gnu/dev/sound/pci/emu10k1-alsa.h,v 1.2 2005/01/06 18:26:37 imp Exp $ */ -/* $DragonFly: src/sys/dev/sound/pci/gnu/emu10k1-alsa.h,v 1.1 2007/01/04 22:47:03 corecode Exp $ */ +/* $DragonFly: src/sys/dev/sound/pci/gnu/emu10k1-alsa.h,v 1.2 2007/06/16 20:07:20 dillon Exp $ */ #ifdef __KERNEL__ @@ -910,7 +910,7 @@ typedef struct { struct list_head gpr_ctl; /* GPR controls */ struct semaphore lock; snd_emu10k1_fx8010_pcm_t pcm[8]; - spinlock_t irq_lock; + sndlock_t irq_lock; snd_emu10k1_fx8010_irq_t *irq_handlers; } snd_emu10k1_fx8010_t; @@ -922,9 +922,9 @@ typedef struct { snd_rawmidi_substream_t *substream_input; snd_rawmidi_substream_t *substream_output; unsigned int midi_mode; - spinlock_t input_lock; - spinlock_t output_lock; - spinlock_t open_lock; + sndlock_t input_lock; + sndlock_t output_lock; + sndlock_t open_lock; int tx_enable, rx_enable; int port; int ipr_tx, ipr_rx; @@ -958,7 +958,7 @@ struct _snd_emu10k1 { struct list_head mapped_order_link_head; void **page_ptr_table; unsigned long *page_addr_table; - spinlock_t memblk_lock; + sndlock_t memblk_lock; unsigned int spdif_bits[3]; /* s/pdif out setup */ @@ -974,13 +974,13 @@ struct _snd_emu10k1 { snd_pcm_t *pcm_efx; snd_pcm_t *pcm_fx8010; - spinlock_t synth_lock; + sndlock_t synth_lock; void *synth; int (*get_synth_voice)(emu10k1_t *emu); - spinlock_t reg_lock; - spinlock_t emu_lock; - spinlock_t voice_lock; + sndlock_t reg_lock; + sndlock_t emu_lock; + sndlock_t voice_lock; struct semaphore ptb_lock; emu10k1_voice_t voices[64]; diff --git a/sys/dev/sound/pci/hda/hdac_private.h b/sys/dev/sound/pci/hda/hdac_private.h index 641749d192..9b642f7fcd 100644 --- a/sys/dev/sound/pci/hda/hdac_private.h +++ b/sys/dev/sound/pci/hda/hdac_private.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/hda/hdac_private.h,v 1.6.2.1 2007/05/13 21:09:24 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/hda/hdac_private.h,v 1.3 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/hda/hdac_private.h,v 1.4 2007/06/16 20:07:21 dillon Exp $ */ #ifndef _HDAC_PRIVATE_H_ @@ -287,7 +287,7 @@ struct hdac_chan { struct hdac_softc { device_t dev; device_t hdabus; - struct spinlock *lock; + sndlock_t lock; struct intr_config_hook intrhook; diff --git a/sys/dev/sound/pci/ich.c b/sys/dev/sound/pci/ich.c index 9f6c248df4..71f969ed72 100644 --- a/sys/dev/sound/pci/ich.c +++ b/sys/dev/sound/pci/ich.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/ich.c,v 1.53.2.11 2007/05/28 21:07:41 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/ich.c,v 1.15 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/ich.c,v 1.16 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -35,7 +35,7 @@ #include #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/ich.c,v 1.15 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/ich.c,v 1.16 2007/06/16 20:07:19 dillon Exp $"); /* -------------------------------------------------------------------- */ @@ -208,9 +208,11 @@ struct sc_info { uint16_t vendor; uint16_t devid; uint32_t flags; - struct spinlock *ich_lock; + sndlock_t ich_lock; }; +#define IGNORE_PCR 0x01 + /* -------------------------------------------------------------------- */ static uint32_t ich_fmt[] = { diff --git a/sys/dev/sound/pci/maestro.c b/sys/dev/sound/pci/maestro.c index 029ef79443..a2dccc41dd 100644 --- a/sys/dev/sound/pci/maestro.c +++ b/sys/dev/sound/pci/maestro.c @@ -25,7 +25,7 @@ * * maestro.c,v 1.23.2.1 2003/10/03 18:21:38 taku Exp * $FreeBSD: src/sys/dev/sound/pci/maestro.c,v 1.28.2.3 2006/02/04 11:58:28 netchild Exp $ - * $DragonFly: src/sys/dev/sound/pci/maestro.c,v 1.9 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/maestro.c,v 1.10 2007/06/16 20:07:19 dillon Exp $ */ /* @@ -56,7 +56,7 @@ #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/maestro.c,v 1.9 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/maestro.c,v 1.10 2007/06/16 20:07:19 dillon Exp $"); #define inline __inline @@ -161,7 +161,7 @@ struct agg_info { /* FreeBSD SMPng related */ #ifdef USING_MUTEX - struct spinlock *lock; /* mutual exclusion */ + sndlock_t lock; #endif /* FreeBSD newpcm related */ struct ac97_info *codec; @@ -288,7 +288,7 @@ agg_sleep(struct agg_info *sc, const char *wmesg, int msec) if (timo == 0) timo = 1; #ifdef USING_MUTEX - msleep(sc, sc->lock, 0, wmesg, timo); + snd_mtxsleep(sc, sc->lock, 0, wmesg, timo); #else tsleep(sc, PWAIT, wmesg, timo); #endif diff --git a/sys/dev/sound/pci/maestro3.c b/sys/dev/sound/pci/maestro3.c index 24a1305320..fc3e3b7226 100644 --- a/sys/dev/sound/pci/maestro3.c +++ b/sys/dev/sound/pci/maestro3.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/maestro3.c,v 1.28.2.2 2007/03/12 02:03:25 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/maestro3.c,v 1.11 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/maestro3.c,v 1.12 2007/06/16 20:07:19 dillon Exp $ */ /* @@ -64,7 +64,7 @@ #include #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/maestro3.c,v 1.11 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/maestro3.c,v 1.12 2007/06/16 20:07:19 dillon Exp $"); /* -------------------------------------------------------------------- */ @@ -152,7 +152,7 @@ struct sc_info { unsigned int bufsz; u_int16_t *savemem; - struct spinlock *sc_lock; + sndlock_t sc_lock; }; #define M3_LOCK(_sc) snd_mtxlock((_sc)->sc_lock) diff --git a/sys/dev/sound/pci/solo.c b/sys/dev/sound/pci/solo.c index fb84090592..9e46348e00 100644 --- a/sys/dev/sound/pci/solo.c +++ b/sys/dev/sound/pci/solo.c @@ -23,7 +23,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/solo.c,v 1.35.2.4 2006/07/13 01:53:54 yongari Exp $ - * $DragonFly: src/sys/dev/sound/pci/solo.c,v 1.9 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/solo.c,v 1.10 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -36,7 +36,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/solo.c,v 1.9 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/solo.c,v 1.10 2007/06/16 20:07:19 dillon Exp $"); #define SOLO_DEFAULT_BUFSZ 16384 #define ABS(x) (((x) < 0)? -(x) : (x)) @@ -100,7 +100,7 @@ struct ess_info { struct ess_chinfo pch, rch; #if ESS18XX_MPSAFE == 1 - struct spinlock *lock; + sndlock_t lock; #endif }; diff --git a/sys/dev/sound/pci/spicds.c b/sys/dev/sound/pci/spicds.c index 30a01bcbf0..24da4a4014 100644 --- a/sys/dev/sound/pci/spicds.c +++ b/sys/dev/sound/pci/spicds.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/spicds.c,v 1.5.2.2 2007/06/11 19:33:27 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/spicds.c,v 1.1 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/spicds.c,v 1.2 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -46,7 +46,7 @@ struct spicds_info { unsigned int dvc; /* De-emphasis and Volume Control */ unsigned int left, right; char name[SPICDS_NAMELEN]; - struct spinlock *lock; + sndlock_t lock; }; static void diff --git a/sys/dev/sound/pci/t4dwave.c b/sys/dev/sound/pci/t4dwave.c index 48e39a88ed..bd47139af8 100644 --- a/sys/dev/sound/pci/t4dwave.c +++ b/sys/dev/sound/pci/t4dwave.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/t4dwave.c,v 1.48 2005/03/01 08:58:05 imp Exp $ - * $DragonFly: src/sys/dev/sound/pci/t4dwave.c,v 1.9 2007/01/04 22:47:02 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pci/t4dwave.c,v 1.10 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -34,7 +34,7 @@ #include #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/t4dwave.c,v 1.9 2007/01/04 22:47:02 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/t4dwave.c,v 1.10 2007/06/16 20:07:19 dillon Exp $"); /* -------------------------------------------------------------------- */ @@ -94,7 +94,7 @@ struct tr_info { int regtype, regid, irqid; void *ih; - struct spinlock *lock; + sndlock_t lock; u_int32_t playchns; unsigned int bufsz; diff --git a/sys/dev/sound/pci/via8233.c b/sys/dev/sound/pci/via8233.c index 84111c04e9..e6e137d281 100644 --- a/sys/dev/sound/pci/via8233.c +++ b/sys/dev/sound/pci/via8233.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/via8233.c,v 1.20.2.3 2007/04/26 08:21:44 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/via8233.c,v 1.9 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/via8233.c,v 1.10 2007/06/16 20:07:19 dillon Exp $ */ /* @@ -47,7 +47,7 @@ #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/via8233.c,v 1.9 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/via8233.c,v 1.10 2007/06/16 20:07:19 dillon Exp $"); #define VIA8233_PCI_ID 0x30591106 @@ -111,7 +111,7 @@ struct via_info { struct via_dma_op *sgd_table; u_int16_t codec_caps; u_int16_t n_dxs_registered; - struct spinlock *lock; + sndlock_t lock; }; static u_int32_t via_fmt[] = { diff --git a/sys/dev/sound/pci/via82c686.c b/sys/dev/sound/pci/via82c686.c index 73add05216..c0dd482aa5 100644 --- a/sys/dev/sound/pci/via82c686.c +++ b/sys/dev/sound/pci/via82c686.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/via82c686.c,v 1.34.2.2 2007/04/26 08:21:44 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/via82c686.c,v 1.9 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pci/via82c686.c,v 1.10 2007/06/16 20:07:19 dillon Exp $ */ #include @@ -36,7 +36,7 @@ #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/via82c686.c,v 1.9 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/via82c686.c,v 1.10 2007/06/16 20:07:19 dillon Exp $"); #define VIA_PCI_ID 0x30581106 #define NSEGS 4 /* Number of segments in SGD table */ @@ -89,7 +89,7 @@ struct via_info { struct via_chinfo pch, rch; struct via_dma_op *sgd_table; u_int16_t codec_caps; - struct spinlock *lock; + sndlock_t lock; }; static u_int32_t via_fmt[] = { diff --git a/sys/dev/sound/pcm/ac97.c b/sys/dev/sound/pcm/ac97.c index 40f889dfd9..c92585b947 100644 --- a/sys/dev/sound/pcm/ac97.c +++ b/sys/dev/sound/pcm/ac97.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/ac97.c,v 1.53.2.5 2007/05/13 20:53:39 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/ac97.c,v 1.24 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pcm/ac97.c,v 1.25 2007/06/16 20:07:22 dillon Exp $ */ #include @@ -35,7 +35,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/ac97.c,v 1.24 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/ac97.c,v 1.25 2007/06/16 20:07:22 dillon Exp $"); MALLOC_DEFINE(M_AC97, "ac97", "ac97 codec"); @@ -62,7 +62,7 @@ struct ac97_info { u_int32_t flags; struct ac97mixtable_entry mix[32]; char name[AC97_NAMELEN]; - struct spinlock *lock; + sndlock_t lock; }; struct ac97_vendorid { diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 9f7d0b4686..415af37c46 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/channel.c,v 1.99.2.5 2007/05/13 20:53:39 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/channel.c,v 1.13 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pcm/channel.c,v 1.14 2007/06/16 20:07:22 dillon Exp $ */ #include "use_isa.h" @@ -35,7 +35,7 @@ #include "feeder_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/channel.c,v 1.13 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/channel.c,v 1.14 2007/06/16 20:07:22 dillon Exp $"); #define MIN_CHUNK_SIZE 256 /* for uiomove etc. */ #if 0 @@ -162,7 +162,7 @@ chn_sleep(struct pcm_channel *c, char *str, int timeout) CHN_LOCKASSERT(c); #ifdef USING_MUTEX - ret = msleep(bs, c->lock, PCATCH, str, timeout); + ret = snd_mtxsleep(bs, c->lock, PCATCH, str, timeout); #else ret = tsleep(bs, PRIBIO | PCATCH, str, timeout); #endif diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h index 5592999174..fc75f0658a 100644 --- a/sys/dev/sound/pcm/channel.h +++ b/sys/dev/sound/pcm/channel.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/channel.h,v 1.31.2.1 2005/12/30 19:55:54 netchild Exp $ - * $DragonFly: src/sys/dev/sound/pcm/channel.h,v 1.5 2007/01/04 22:47:03 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pcm/channel.h,v 1.6 2007/06/16 20:07:22 dillon Exp $ */ struct pcmchan_children { @@ -63,7 +63,7 @@ struct pcm_channel { void *devinfo; device_t dev; char name[CHN_NAMELEN]; - struct spinlock *lock; + sndlock_t lock; SLIST_HEAD(, pcmchan_children) children; }; @@ -104,8 +104,8 @@ void chn_lock(struct pcm_channel *c); void chn_unlock(struct pcm_channel *c); #ifdef USING_MUTEX -#define CHN_LOCK(c) spin_lock_wr((struct spinlock *)((c)->lock)) -#define CHN_UNLOCK(c) spin_unlock_wr((struct spinlock *)((c)->lock)) +#define CHN_LOCK(c) snd_mtxlock(((c)->lock)) +#define CHN_UNLOCK(c) snd_mtxunlock(((c)->lock)) #define CHN_LOCKASSERT(c) #else #define CHN_LOCK(c) diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 961c90d406..fb0a6cf9a5 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/mixer.c,v 1.43.2.5 2007/05/13 20:53:39 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/mixer.c,v 1.16 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pcm/mixer.c,v 1.17 2007/06/16 20:07:22 dillon Exp $ */ #include @@ -32,7 +32,7 @@ #include "mixer_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/mixer.c,v 1.16 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/mixer.c,v 1.17 2007/06/16 20:07:22 dillon Exp $"); MALLOC_DEFINE(M_MIXER, "mixer", "mixer"); @@ -55,7 +55,7 @@ struct snd_mixer { u_int32_t child[32]; u_int8_t realdev[32]; char name[MIXER_NAMELEN]; - struct spinlock *lock; + sndlock_t lock; }; static u_int16_t snd_mixerdefaults[SOUND_MIXER_NRDEVICES] = { diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 2570f93993..1c332ca1f2 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/sound.c,v 1.93.2.5 2007/06/04 09:06:05 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.10 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.11 2007/06/16 20:07:22 dillon Exp $ */ #include @@ -35,7 +35,7 @@ #include "feeder_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.10 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.11 2007/06/16 20:07:22 dillon Exp $"); devclass_t pcm_devclass; @@ -73,12 +73,12 @@ void * snd_mtxcreate(const char *desc, const char *type) { #ifdef USING_MUTEX - struct spinlock *m; + struct lock *m; m = kmalloc(sizeof(*m), M_DEVBUF, M_WAITOK | M_ZERO); if (m == NULL) return NULL; - spin_init(m); + lockinit(m, __DECONST(char *, type), 0, LK_CANRECURSE); return m; #else return (void *)0xcafebabe; @@ -89,11 +89,9 @@ void snd_mtxfree(void *m) { #ifdef USING_MUTEX - struct spinlock *mtx = m; + struct lock *lk = m; - /* mtx_assert(mtx, MA_OWNED); */ - spin_uninit(mtx); - kfree(mtx, M_DEVBUF); + kfree(lk, M_DEVBUF); #endif } @@ -102,18 +100,18 @@ snd_mtxassert(void *m) { #ifdef USING_MUTEX #ifdef INVARIANTS - /* XXX can't assert spinlocks */ + /* XXX */ #endif #endif } -/* + void snd_mtxlock(void *m) { #ifdef USING_MUTEX - struct spinlock *mtx = m; + struct lock *lk = m; - spin_lock_wr(mtx); + lockmgr(lk, LK_EXCLUSIVE | LK_RETRY); #endif } @@ -121,12 +119,28 @@ void snd_mtxunlock(void *m) { #ifdef USING_MUTEX - struct spinlock *mtx = m; + struct lock *lk = m; - spin_unlock_wr(mtx); + lockmgr(lk, LK_RELEASE); #endif } -*/ + +int +snd_mtxsleep(void *addr, sndlock_t lock, int flags, const char *wmesg, int timo) +{ + int r; + + crit_enter(); + tsleep_interlock(addr); + snd_mtxunlock(lock); + r = tsleep(addr, flags, wmesg, timo); + snd_mtxlock(lock); + crit_exit(); + return(r); +} + + + int snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep) { diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index e5d6842572..20be4414a3 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/sound.h,v 1.63.2.3 2007/05/13 20:53:39 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/sound.h,v 1.12 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pcm/sound.h,v 1.13 2007/06/16 20:07:22 dillon Exp $ */ /* @@ -74,8 +74,8 @@ #undef USING_MUTEX #undef USING_DEVFS -#include -#include +#include /* lockmgr locks */ +typedef struct lock *sndlock_t; /* opaque lock structure */ #define USING_MUTEX #define INTR_TYPE_AV 0 @@ -242,8 +242,9 @@ int snd_setup_intr(device_t dev, struct resource *res, int flags, void *snd_mtxcreate(const char *desc, const char *type); void snd_mtxfree(void *m); void snd_mtxassert(void *m); -#define snd_mtxlock(m) spin_lock_wr(m) -#define snd_mtxunlock(m) spin_unlock_wr(m) +void snd_mtxlock(void *m); +void snd_mtxunlock(void *m); +int snd_mtxsleep(void *, sndlock_t, int, const char *, int); int sysctl_hw_snd_vchans(SYSCTL_HANDLER_ARGS); @@ -304,14 +305,14 @@ struct snddev_info { char status[SND_STATUSLEN]; struct sysctl_ctx_list sysctl_tree; struct sysctl_oid *sysctl_tree_top; - struct spinlock *lock; + sndlock_t lock; struct cdev *mixer_dev; }; #ifdef PCM_DEBUG_MTX -#define pcm_lock(d) spin_lock_wr(((struct snddev_info *)(d))->lock) -#define pcm_unlock(d) spin_unlock_wr(((struct snddev_info *)(d))->lock) +#define pcm_lock(d) snd_mtxlock(((struct snddev_info *)(d))->lock) +#define pcm_unlock(d) snd_mtxunlock(((struct snddev_info *)(d))->lock) #else void pcm_lock(struct snddev_info *d); void pcm_unlock(struct snddev_info *d); -- 2.11.4.GIT