CVS commit: [jmcneill-audiomp3] src/sys/dev/sbus

2011-11-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Nov 22 17:36:01 UTC 2011

Modified Files:
src/sys/dev/sbus [jmcneill-audiomp3]: cs4231_sbus.c

Log Message:
we need to initialize the locks before using them
Now this works on my Ultra 1


To generate a diff of this commit:
cvs rdiff -u -r1.48.4.2 -r1.48.4.3 src/sys/dev/sbus/cs4231_sbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sbus/cs4231_sbus.c
diff -u src/sys/dev/sbus/cs4231_sbus.c:1.48.4.2 src/sys/dev/sbus/cs4231_sbus.c:1.48.4.3
--- src/sys/dev/sbus/cs4231_sbus.c:1.48.4.2	Sun Nov 20 11:41:53 2011
+++ src/sys/dev/sbus/cs4231_sbus.c	Tue Nov 22 17:36:01 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cs4231_sbus.c,v 1.48.4.2 2011/11/20 11:41:53 mrg Exp $	*/
+/*	$NetBSD: cs4231_sbus.c,v 1.48.4.3 2011/11/22 17:36:01 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2002, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cs4231_sbus.c,v 1.48.4.2 2011/11/20 11:41:53 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cs4231_sbus.c,v 1.48.4.3 2011/11/22 17:36:01 macallan Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -161,9 +161,9 @@ cs4231_sbus_attach(device_t parent, devi
 	sbsc->sc_bt = sc->sc_bustag = sa->sa_bustag;
 	sc->sc_dmatag = sa->sa_dmatag;
 
-	sbsc->sc_pint = sparc_softintr_establish(IPL_VM,
+	sbsc->sc_pint = sparc_softintr_establish(IPL_SCHED,
 	(void *)cs4231_sbus_pint, sc);
-	sbsc->sc_rint = sparc_softintr_establish(IPL_VM,
+	sbsc->sc_rint = sparc_softintr_establish(IPL_SCHED,
 	(void *)cs4231_sbus_rint, sc);
 
 	/*
@@ -188,6 +188,7 @@ cs4231_sbus_attach(device_t parent, devi
 	cs4231_common_attach(sc, self, bh);
 	printf("\n");
 
+	ad1848_init_locks(&sc->sc_ad1848, IPL_SCHED);
 	/* Establish interrupt channel */
 	if (sa->sa_nintr)
 		bus_intr_establish(sa->sa_bustag,



CVS commit: [jmcneill-audiomp3] src/sys/dev/sbus

2011-11-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Nov 20 12:07:13 UTC 2011

Modified Files:
src/sys/dev/sbus [jmcneill-audiomp3]: dbri.c

Log Message:
convert spl*() to use the sc_intr_lock mutex, and hold it in a couple
of other places we should as well.


To generate a diff of this commit:
cvs rdiff -u -r1.33.6.1 -r1.33.6.2 src/sys/dev/sbus/dbri.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sbus/dbri.c
diff -u src/sys/dev/sbus/dbri.c:1.33.6.1 src/sys/dev/sbus/dbri.c:1.33.6.2
--- src/sys/dev/sbus/dbri.c:1.33.6.1	Sun Nov 20 10:48:54 2011
+++ src/sys/dev/sbus/dbri.c	Sun Nov 20 12:07:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dbri.c,v 1.33.6.1 2011/11/20 10:48:54 mrg Exp $	*/
+/*	$NetBSD: dbri.c,v 1.33.6.2 2011/11/20 12:07:13 mrg Exp $	*/
 
 /*
  * Copyright (C) 1997 Rudolf Koenig (rfkoe...@immd4.informatik.uni-erlangen.de)
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.33.6.1 2011/11/20 10:48:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.33.6.2 2011/11/20 12:07:13 mrg Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -472,6 +472,8 @@ dbri_intr(void *hdl)
 	bus_space_handle_t ioh = sc->sc_ioh;
 	int x;
 
+	mutex_spin_enter(&sc->sc_intr_lock);
+
 	/* clear interrupt */
 	x = bus_space_read_4(iot, ioh, DBRI_REG1);
 	if (x & (DBRI_MRR | DBRI_MLE | DBRI_LBG | DBRI_MBE)) {
@@ -506,6 +508,8 @@ dbri_intr(void *hdl)
 
 	dbri_process_interrupt_buffer(sc);
 
+	mutex_spin_exit(&sc->sc_intr_lock);
+
 	return (1);
 }
 
@@ -598,9 +602,8 @@ dbri_command_send(struct dbri_softc *sc,
 	bus_space_handle_t ioh = sc->sc_ioh;
 	bus_space_tag_t iot = sc->sc_iot;
 	int maxloops = 100;
-	int x;
 
-	x = splsched();
+	mutex_spin_enter(&sc->sc_intr_lock);
 
 	sc->sc_locked--;
 
@@ -638,7 +641,7 @@ dbri_command_send(struct dbri_softc *sc,
 		}
 	}
 
-	splx(x);
+	mutex_spin_exit(&sc->sc_intr_lock);
 
 	return;
 }
@@ -1266,7 +1269,7 @@ setup_ring_xmit(struct dbri_softc *sc, i
 		void (*callback)(void *), void *callback_args)
 {
 	volatile uint32_t *cmd;
-	int x, i;
+	int i;
 	int td;
 	int td_first, td_last;
 	bus_addr_t dmabuf, dmabase;
@@ -1316,7 +1319,7 @@ setup_ring_xmit(struct dbri_softc *sc, i
 	dd->callback = callback;
 	dd->callback_args = callback_args;
 
-	x = splsched();
+	mutex_spin_enter(&sc->sc_intr_lock);
 
 	/* the pipe shouldn't be active */
 	if (pipe_active(sc, pipe)) {
@@ -1352,7 +1355,7 @@ setup_ring_xmit(struct dbri_softc *sc, i
 		DPRINTF("%s: starting DMA\n", __func__);
 	}
 
-	splx(x);
+	mutex_spin_exit(&sc->sc_intr_lock);
 
 	return;
 }
@@ -1362,7 +1365,7 @@ setup_ring_recv(struct dbri_softc *sc, i
 		void (*callback)(void *), void *callback_args)
 {
 	volatile uint32_t *cmd;
-	int x, i;
+	int i;
 	int td_first, td_last;
 	bus_addr_t dmabuf, dmabase;
 	struct dbri_desc *dd = &sc->sc_desc[which];
@@ -1407,7 +1410,7 @@ setup_ring_recv(struct dbri_softc *sc, i
 	dd->callback = callback;
 	dd->callback_args = callback_args;
 
-	x = splsched();
+	mutex_spin_enter(&sc->sc_intr_lock);
 
 	/* the pipe shouldn't be active */
 	if (pipe_active(sc, pipe)) {
@@ -1443,7 +1446,7 @@ setup_ring_recv(struct dbri_softc *sc, i
 		DPRINTF("%s: starting DMA\n", __func__);
 	}
 
-	splx(x);
+	mutex_spin_exit(&sc->sc_intr_lock);
 
 	return;
 }
@@ -2211,10 +2214,9 @@ dbri_resume(device_t self, const pmf_qua
 	aprint_verbose("resume: %d\n", sc->sc_refcount);
 	if (sc->sc_playing) {
 		volatile uint32_t *cmd;
-		int s;
 
 		dbri_bring_up(sc);
-		s = splsched();
+		mutex_spin_enter(&sc->sc_intr_lock);
 		cmd = dbri_command_lock(sc);
 		*(cmd++) = DBRI_CMD(DBRI_COMMAND_SDP,
 		0, sc->sc_pipe[4].sdp |
@@ -2223,7 +2225,7 @@ dbri_resume(device_t self, const pmf_qua
 		*(cmd++) = sc->sc_dmabase +
 		dbri_dma_off(xmit, 0);
 		dbri_command_send(sc, cmd);
-		splx(s);
+		mutex_spin_exit(&sc->sc_intr_lock);
 	}
 	return true;
 }



CVS commit: [jmcneill-audiomp3] src/sys/dev/sbus

2011-11-20 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Nov 20 10:48:55 UTC 2011

Modified Files:
src/sys/dev/sbus [jmcneill-audiomp3]: dbri.c dbrivar.h

Log Message:
port to audiomp:  update allocm/freem, and add get_locks() support.
bots on my ss20, but i haven't really tested it yet.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.6.1 src/sys/dev/sbus/dbri.c
cvs rdiff -u -r1.12 -r1.12.10.1 src/sys/dev/sbus/dbrivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sbus/dbri.c
diff -u src/sys/dev/sbus/dbri.c:1.33 src/sys/dev/sbus/dbri.c:1.33.6.1
--- src/sys/dev/sbus/dbri.c:1.33	Wed Mar  9 05:40:11 2011
+++ src/sys/dev/sbus/dbri.c	Sun Nov 20 10:48:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dbri.c,v 1.33 2011/03/09 05:40:11 macallan Exp $	*/
+/*	$NetBSD: dbri.c,v 1.33.6.1 2011/11/20 10:48:54 mrg Exp $	*/
 
 /*
  * Copyright (C) 1997 Rudolf Koenig (rfkoe...@immd4.informatik.uni-erlangen.de)
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.33 2011/03/09 05:40:11 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.33.6.1 2011/11/20 10:48:54 mrg Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -43,11 +43,11 @@ __KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.3
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -156,9 +156,10 @@ static int	dbri_trigger_output(void *, v
 void (*)(void *), void *, const struct audio_params *);
 static int	dbri_trigger_input(void *, void *, void *, int,
 void (*)(void *), void *, const struct audio_params *);
+static void	dbri_get_locks(void *, kmutex_t **, kmutex_t **);
 
-static void	*dbri_malloc(void *, int, size_t, struct malloc_type *, int);
-static void	dbri_free(void *, void *, struct malloc_type *);
+static void	*dbri_malloc(void *, int, size_t);
+static void	dbri_free(void *, void *, size_t);
 static paddr_t	dbri_mappage(void *, void *, off_t, int);
 static void	dbri_set_power(struct dbri_softc *, int);
 static void	dbri_bring_up(struct dbri_softc *);
@@ -175,32 +176,25 @@ struct audio_device dbri_device = {
 };
 
 struct audio_hw_if dbri_hw_if = {
-	dbri_open,
-	dbri_close,
-	NULL,	/* drain */
-	dbri_query_encoding,
-	dbri_set_params,
-	dbri_round_blocksize,
-	NULL,	/* commit_settings */
-	NULL,	/* init_output */
-	NULL,	/* init_input */
-	NULL,	/* start_output */
-	NULL,	/* start_input */
-	dbri_halt_output,
-	dbri_halt_input,
-	NULL,	/* speaker_ctl */
-	dbri_getdev,
-	NULL,	/* setfd */
-	dbri_set_port,
-	dbri_get_port,
-	dbri_query_devinfo,
-	dbri_malloc,
-	dbri_free,
-	dbri_round_buffersize,
-	dbri_mappage,
-	dbri_get_props,
-	dbri_trigger_output,
-	dbri_trigger_input
+	.open			= dbri_open,
+	.close			= dbri_close,
+	.query_encoding		= dbri_query_encoding,
+	.set_params		= dbri_set_params,
+	.round_blocksize	= dbri_round_blocksize,
+	.halt_output		= dbri_halt_output,
+	.halt_input		= dbri_halt_input,
+	.getdev			= dbri_getdev,
+	.set_port		= dbri_set_port,
+	.get_port		= dbri_get_port,
+	.query_devinfo		= dbri_query_devinfo,
+	.allocm			= dbri_malloc,
+	.freem			= dbri_free,
+	.round_buffersize	= dbri_round_buffersize,
+	.mappage		= dbri_mappage,
+	.get_props		= dbri_get_props,
+	.trigger_output		= dbri_trigger_output,
+	.trigger_input		= dbri_trigger_input,
+	.get_locks		= dbri_get_locks,
 };
 
 CFATTACH_DECL_NEW(dbri, sizeof(struct dbri_softc),
@@ -370,6 +364,9 @@ dbri_attach_sbus(device_t parent, device
 	sc->sc_dmabase = sc->sc_dmamap->dm_segs[0].ds_addr;
 	sc->sc_bufsiz = size;
 
+	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
+
 	bus_intr_establish(sa->sa_bustag, sa->sa_pri, IPL_SCHED, dbri_intr,
 	sc);
 
@@ -2049,6 +2046,14 @@ dbri_trigger_input(void *hdl, void *star
 	return 0;
 }
 
+static void
+dbri_get_locks(void *opaque, kmutex_t **intr, kmutex_t **thread)
+{
+	struct dbri_softc *sc = opaque;
+
+	*intr = &sc->sc_intr_lock;
+	*thread = &sc->sc_lock;
+}
 
 static uint32_t
 reverse_bytes(uint32_t b, int len)
@@ -2075,7 +2080,7 @@ reverse_bytes(uint32_t b, int len)
 }
 
 static void *
-dbri_malloc(void *v, int dir, size_t s, struct malloc_type *mt, int flags)
+dbri_malloc(void *v, int dir, size_t s)
 {
 	struct dbri_softc *sc = v;
 	struct dbri_desc *dd = &sc->sc_desc[sc->sc_desc_used];
@@ -2116,7 +2121,7 @@ dbri_malloc(void *v, int dir, size_t s, 
 }
 
 static void
-dbri_free(void *v, void *p, struct malloc_type *mt)
+dbri_free(void *v, void *p, size_t size)
 {
 	struct dbri_softc *sc = v;
 	struct dbri_desc *dd;

Index: src/sys/dev/sbus/dbrivar.h
diff -u src/sys/dev/sbus/dbrivar.h:1.12 src/sys/dev/sbus/dbrivar.h:1.12.10.1
--- src/sys/dev/sbus/dbrivar.h:1.12	Tue Jan 11 00:49:50 2011
+++ src/sys/dev/sbus/dbrivar.h	Sun Nov 20 10:48:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dbrivar.h,v 1.12 2011/01/11 00:49:50 macallan Exp $	*/
+/*	$NetBSD: dbrivar.h,v 1.12.10.1 2011/11/20 10