CVS commit: [netbsd-5] src/sys/dev/isa

2011-06-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jun 18 16:24:10 UTC 2011

Modified Files:
src/sys/dev/isa [netbsd-5]: pcppi.c pcppivar.h

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1625):
sys/dev/isa/pcppivar.h: revision 1.10
sys/dev/isa/pcppi.c: revision 1.36
convert a lockless + spltty() combo to a IPL_VM mutex and cv.
hopefully this will avoid the beep-didn't-stop problem i had recently
that i was able to fix by calling wakeup() on pcppi's softc from ddb.


To generate a diff of this commit:
cvs rdiff -u -r1.32.14.1 -r1.32.14.2 src/sys/dev/isa/pcppi.c
cvs rdiff -u -r1.9 -r1.9.14.1 src/sys/dev/isa/pcppivar.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/isa/pcppi.c
diff -u src/sys/dev/isa/pcppi.c:1.32.14.1 src/sys/dev/isa/pcppi.c:1.32.14.2
--- src/sys/dev/isa/pcppi.c:1.32.14.1	Sat Nov 20 17:41:27 2010
+++ src/sys/dev/isa/pcppi.c	Sat Jun 18 16:24:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pcppi.c,v 1.32.14.1 2010/11/20 17:41:27 riz Exp $ */
+/* $NetBSD: pcppi.c,v 1.32.14.2 2011/06/18 16:24:10 bouyer Exp $ */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pcppi.c,v 1.32.14.1 2010/11/20 17:41:27 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: pcppi.c,v 1.32.14.2 2011/06/18 16:24:10 bouyer Exp $);
 
 #include attimer.h
 
@@ -39,8 +39,9 @@
 #include sys/proc.h
 #include sys/device.h
 #include sys/errno.h
-
 #include sys/bus.h
+#include sys/mutex.h
+#include sys/condvar.h
 
 #include dev/ic/attimervar.h
 
@@ -193,6 +194,10 @@
 	callout_stop(sc-sc_bell_ch);
 	callout_destroy(sc-sc_bell_ch);
 	bus_space_unmap(sc-sc_iot, sc-sc_ppi_ioh, sc-sc_size);
+
+	mutex_destroy(sc-sc_lock);
+	cv_destroy(sc-sc_stop_cv);
+
 	return 0;
 }
 
@@ -206,6 +211,9 @@
 
 sc-sc_bellactive = sc-sc_bellpitch = sc-sc_slp = 0;
 
+	mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_VM);
+	cv_init(sc-sc_stop_cv, bell);
+
 #if NPCKBD  0
 	/* Provide a beeper for the PC Keyboard, if there isn't one already. */
 	pckbd_hookup_bell(pcppi_pckbd_bell, sc);
@@ -251,21 +259,20 @@
 pcppi_bell(pcppi_tag_t self, int pitch, int period, int slp)
 {
 	struct pcppi_softc *sc = self;
-	int s;
 
-	s = spltty(); /* ??? */
+	mutex_enter(sc-sc_lock);
 	if (sc-sc_bellactive) {
 		if (sc-sc_timeout) {
 			sc-sc_timeout = 0;
 			callout_stop(sc-sc_bell_ch);
 		}
 		if (sc-sc_slp)
-			wakeup(pcppi_bell_stop);
+			cv_broadcast(sc-sc_stop_cv);
 	}
 	if (pitch == 0 || period == 0) {
 		pcppi_bell_stop(sc);
 		sc-sc_bellpitch = 0;
-		splx(s);
+		mutex_exit(sc-sc_lock);
 		return;
 	}
 	if (!sc-sc_bellactive || sc-sc_bellpitch != pitch) {
@@ -289,20 +296,19 @@
 		callout_reset(sc-sc_bell_ch, period, pcppi_bell_stop, sc);
 		if (slp  PCPPI_BELL_SLEEP) {
 			sc-sc_slp = 1;
-			tsleep(pcppi_bell_stop, PCPPIPRI | PCATCH, bell, 0);
+			cv_wait_sig(sc-sc_stop_cv, sc-sc_lock);
 			sc-sc_slp = 0;
 		}
 	}
-	splx(s);
+	mutex_exit(sc-sc_lock);
 }
 
 static void
 pcppi_bell_stop(void *arg)
 {
 	struct pcppi_softc *sc = arg;
-	int s;
 
-	s = spltty(); /* ??? */
+	mutex_enter(sc-sc_lock);
 	sc-sc_timeout = 0;
 
 	/* disable bell */
@@ -311,8 +317,8 @@
 			   ~PIT_SPKR);
 	sc-sc_bellactive = 0;
 	if (sc-sc_slp)
-		wakeup(pcppi_bell_stop);
-	splx(s);
+		cv_broadcast(sc-sc_stop_cv);
+	mutex_exit(sc-sc_lock);
 }
 
 #if NPCKBD  0

Index: src/sys/dev/isa/pcppivar.h
diff -u src/sys/dev/isa/pcppivar.h:1.9 src/sys/dev/isa/pcppivar.h:1.9.14.1
--- src/sys/dev/isa/pcppivar.h:1.9	Tue Mar  4 16:35:19 2008
+++ src/sys/dev/isa/pcppivar.h	Sat Jun 18 16:24:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pcppivar.h,v 1.9 2008/03/04 16:35:19 cube Exp $ */
+/* $NetBSD: pcppivar.h,v 1.9.14.1 2011/06/18 16:24:10 bouyer Exp $ */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -37,18 +37,21 @@
 };
 
 struct pcppi_softc {
-device_t sc_dv;  
+	device_t sc_dv;  
 
-bus_space_tag_t sc_iot;
-bus_space_handle_t sc_ppi_ioh;
-bus_size_t sc_size;
-device_t sc_timer;
+	bus_space_tag_t sc_iot;
+	bus_space_handle_t sc_ppi_ioh;
+	bus_size_t sc_size;
+	device_t sc_timer;
 
-struct callout sc_bell_ch;
+	struct callout sc_bell_ch;
 
-int sc_bellactive, sc_bellpitch;
-int sc_slp;
-int sc_timeout;
+	int sc_bellactive, sc_bellpitch;
+	int sc_slp;
+	int sc_timeout;
+
+	kmutex_t sc_lock;
+	kcondvar_t sc_stop_cv;
 };
 
 void pcppi_attach(struct pcppi_softc *);



CVS commit: [netbsd-5] src/sys/dev/isa

2011-06-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jun 18 22:47:20 UTC 2011

Modified Files:
src/sys/dev/isa [netbsd-5]: pcppi.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1625):
sys/dev/isa/pcppi.c: revision 1.37
avoid mutex locking botch and introduce an unlocked version of
pcppi_bell_stop().  fixes a problem reported in private email.


To generate a diff of this commit:
cvs rdiff -u -r1.32.14.2 -r1.32.14.3 src/sys/dev/isa/pcppi.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/isa/pcppi.c
diff -u src/sys/dev/isa/pcppi.c:1.32.14.2 src/sys/dev/isa/pcppi.c:1.32.14.3
--- src/sys/dev/isa/pcppi.c:1.32.14.2	Sat Jun 18 16:24:10 2011
+++ src/sys/dev/isa/pcppi.c	Sat Jun 18 22:47:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pcppi.c,v 1.32.14.2 2011/06/18 16:24:10 bouyer Exp $ */
+/* $NetBSD: pcppi.c,v 1.32.14.3 2011/06/18 22:47:20 bouyer Exp $ */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pcppi.c,v 1.32.14.2 2011/06/18 16:24:10 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: pcppi.c,v 1.32.14.3 2011/06/18 22:47:20 bouyer Exp $);
 
 #include attimer.h
 
@@ -65,6 +65,7 @@
 pcppi_match, pcppi_isa_attach, pcppi_detach, NULL, NULL, pcppi_childdet);
 
 static int pcppisearch(device_t, cfdata_t, const int *, void *);
+static void pcppi_bell_stop_unlocked(void*);
 static void pcppi_bell_stop(void*);
 
 #if NATTIMER  0
@@ -270,7 +271,7 @@
 			cv_broadcast(sc-sc_stop_cv);
 	}
 	if (pitch == 0 || period == 0) {
-		pcppi_bell_stop(sc);
+		pcppi_bell_stop_unlocked(sc);
 		sc-sc_bellpitch = 0;
 		mutex_exit(sc-sc_lock);
 		return;
@@ -290,7 +291,7 @@
 	sc-sc_bellactive = 1;
 	if (slp  PCPPI_BELL_POLL) {
 		delay((period * 100) / hz);
-		pcppi_bell_stop(sc);
+		pcppi_bell_stop_unlocked(sc);
 	} else {
 		sc-sc_timeout = 1;
 		callout_reset(sc-sc_bell_ch, period, pcppi_bell_stop, sc);
@@ -304,11 +305,10 @@
 }
 
 static void
-pcppi_bell_stop(void *arg)
+pcppi_bell_stop_unlocked(void *arg)
 {
 	struct pcppi_softc *sc = arg;
 
-	mutex_enter(sc-sc_lock);
 	sc-sc_timeout = 0;
 
 	/* disable bell */
@@ -318,6 +318,15 @@
 	sc-sc_bellactive = 0;
 	if (sc-sc_slp)
 		cv_broadcast(sc-sc_stop_cv);
+}
+
+static void
+pcppi_bell_stop(void *arg)
+{
+	struct pcppi_softc *sc = arg;
+
+	mutex_enter(sc-sc_lock);
+	pcppi_bell_stop_unlocked(arg);
 	mutex_exit(sc-sc_lock);
 }
 



CVS commit: [netbsd-5] src/sys/dev/isa

2009-09-29 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Sep 29 23:59:45 UTC 2009

Modified Files:
src/sys/dev/isa [netbsd-5]: if_tr_isa.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1040):
sys/dev/isa/if_tr_isa.c: revision 1.19
Fix printf format after bus_size_t change


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.10.1 src/sys/dev/isa/if_tr_isa.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/isa/if_tr_isa.c
diff -u src/sys/dev/isa/if_tr_isa.c:1.18 src/sys/dev/isa/if_tr_isa.c:1.18.10.1
--- src/sys/dev/isa/if_tr_isa.c:1.18	Mon Apr 28 20:23:52 2008
+++ src/sys/dev/isa/if_tr_isa.c	Tue Sep 29 23:59:45 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tr_isa.c,v 1.18 2008/04/28 20:23:52 martin Exp $	*/
+/*	$NetBSD: if_tr_isa.c,v 1.18.10.1 2009/09/29 23:59:45 snj Exp $	*/
 
 /* XXXJRT changes isa_attach_args too early!! */
 
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_tr_isa.c,v 1.18 2008/04/28 20:23:52 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_tr_isa.c,v 1.18.10.1 2009/09/29 23:59:45 snj Exp $);
 
 #undef TRISADEBUG
 
@@ -107,7 +107,7 @@
 	mmio = ((s  0xfc)  11) + TR_MMIO_OFFSET;
 	if (bus_space_map(ia-ia_memt, mmio, TR_MMIO_SIZE, 0, mmioh)) {
 		printf(tr_isa_map_io: can't map MMIO region 0x%05lx/%d\n,
-			mmio, TR_MMIO_SIZE);
+			(u_long)mmio, TR_MMIO_SIZE);
 		bus_space_unmap(ia-ia_iot, *pioh, ia-ia_io[0].ir_size);
 		return 1;
 	}



CVS commit: [netbsd-5] src/sys/dev/isa

2009-09-29 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Sep 30 00:01:19 UTC 2009

Modified Files:
src/sys/dev/isa [netbsd-5]: if_lc_isa.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1040):
sys/dev/isa/if_lc_isa.c: revision 1.30
sys/dev/pci/pccbb.c: revision 1.183
Fix bus_addr_t/bus_size_t confusion


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.14.1 src/sys/dev/isa/if_lc_isa.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/isa/if_lc_isa.c
diff -u src/sys/dev/isa/if_lc_isa.c:1.29 src/sys/dev/isa/if_lc_isa.c:1.29.14.1
--- src/sys/dev/isa/if_lc_isa.c:1.29	Tue Apr  8 20:08:50 2008
+++ src/sys/dev/isa/if_lc_isa.c	Wed Sep 30 00:01:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lc_isa.c,v 1.29 2008/04/08 20:08:50 cegger Exp $ */
+/*	$NetBSD: if_lc_isa.c,v 1.29.14.1 2009/09/30 00:01:19 snj Exp $ */
 
 /*-
  * Copyright (c) 1994, 1995, 1997 Matt Thomas m...@3am-software.com
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_lc_isa.c,v 1.29 2008/04/08 20:08:50 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_lc_isa.c,v 1.29.14.1 2009/09/30 00:01:19 snj Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -76,7 +76,7 @@
 	int attach;
 {
 	bus_addr_t maddr;
-	bus_addr_t msiz;
+	bus_size_t msiz;
 	int rv = 0, irq;
 
 	if (ia-ia_nio  1)