svn commit: r364920 - in head/sys: dev/speaker sys

Warner Losh imp at FreeBSD.org
Fri Aug 28 16:40:34 UTC 2020


Author: imp
Date: Fri Aug 28 16:40:33 2020
New Revision: 364920
URL: https://svnweb.freebsd.org/changeset/base/364920

Log:
  Remove splclock(). It's not useful to keep.
  
  splclock is used in one driver (spkr) to control access to
  timer_spkr_* routines.  However, nothing else does. So it shows no
  useful locking info to someone that would want to lock spkr.
  
  NOTE: I think there's races with timer_spkr_{acquire,release} since
  there's no interlock in those routines, despite there being a spin
  lock to protect the clock. Current other users appear to use no extra
  locking protocol, though they themselves appear to be at least
  attempting to make sure that only a single thread calls these
  routines. I suspect the right answer is to update these routines to
  take/release the clock spin lock since they are short and to the
  point, but that's beyond the scope of this commit.

Modified:
  head/sys/dev/speaker/spkr.c
  head/sys/sys/systm.h

Modified: head/sys/dev/speaker/spkr.c
==============================================================================
--- head/sys/dev/speaker/spkr.c	Fri Aug 28 15:35:45 2020	(r364919)
+++ head/sys/dev/speaker/spkr.c	Fri Aug 28 16:40:33 2020	(r364920)
@@ -65,7 +65,7 @@ static void playstring(char *cp, size_t slen);
 static void
 tone(unsigned int thz, unsigned int centisecs)
 {
-	int sps, timo;
+	int timo;
 
 	if (thz <= 0)
 		return;
@@ -75,14 +75,10 @@ tone(unsigned int thz, unsigned int centisecs)
 #endif /* DEBUG */
 
 	/* set timer to generate clicks at given frequency in Hertz */
-	sps = splclock();
-
 	if (timer_spkr_acquire()) {
 		/* enter list of waiting procs ??? */
-		splx(sps);
 		return;
 	}
-	splx(sps);
 	disable_intr();
 	timer_spkr_setfreq(thz);
 	enable_intr();
@@ -95,9 +91,7 @@ tone(unsigned int thz, unsigned int centisecs)
 	timo = centisecs * hz / 100;
 	if (timo > 0)
 		tsleep(&endtone, SPKRPRI | PCATCH, "spkrtn", timo);
-	sps = splclock();
 	timer_spkr_release();
-	splx(sps);
 }
 
 /*

Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h	Fri Aug 28 15:35:45 2020	(r364919)
+++ head/sys/sys/systm.h	Fri Aug 28 16:40:33 2020	(r364920)
@@ -497,7 +497,6 @@ void	kern_reboot(int) __dead2;
 void	shutdown_nice(int);
 
 /* Stubs for obsolete functions that used to be for interrupt management */
-static __inline intrmask_t	splclock(void)		{ return 0; }
 static __inline intrmask_t	splhigh(void)		{ return 0; }
 static __inline intrmask_t	splimp(void)		{ return 0; }
 static __inline intrmask_t	splnet(void)		{ return 0; }


More information about the svn-src-head mailing list