Module Name:    src
Committed By:   isaki
Date:           Sun Feb 14 03:41:13 UTC 2021

Modified Files:
        src/sys/dev/audio: audio.c

Log Message:
Add missing curlwp_bindx() corresponding to curlwp_bind().
Pointed out by riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.90 src/sys/dev/audio/audio.c:1.91
--- src/sys/dev/audio/audio.c:1.90	Tue Feb  9 12:36:34 2021
+++ src/sys/dev/audio/audio.c	Sun Feb 14 03:41:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.90 2021/02/09 12:36:34 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.91 2021/02/14 03:41:13 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.90 2021/02/09 12:36:34 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.91 2021/02/14 03:41:13 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1544,9 +1544,6 @@ audio_sc_acquire_foropen(struct audio_so
 {
 	int s;
 
-	/* psref(9) forbids to migrate CPUs */
-	curlwp_bind();
-
 	/* Block audiodetach while we acquire a reference */
 	s = pserialize_read_enter();
 
@@ -1574,9 +1571,6 @@ audio_sc_acquire_fromfile(audio_file_t *
 	int s;
 	bool dying;
 
-	/* psref(9) forbids to migrate CPUs */
-	curlwp_bind();
-
 	/* Block audiodetach while we acquire a reference */
 	s = pserialize_read_enter();
 
@@ -1679,6 +1673,7 @@ audioopen(dev_t dev, int flags, int ifmt
 {
 	struct audio_softc *sc;
 	struct psref sc_ref;
+	int bound;
 	int error;
 
 	/* Find the device */
@@ -1686,6 +1681,7 @@ audioopen(dev_t dev, int flags, int ifmt
 	if (sc == NULL || sc->hw_if == NULL)
 		return ENXIO;
 
+	bound = curlwp_bind();
 	audio_sc_acquire_foropen(sc, &sc_ref);
 
 	error = audio_exlock_enter(sc);
@@ -1712,6 +1708,7 @@ audioopen(dev_t dev, int flags, int ifmt
 
 done:
 	audio_sc_release(sc, &sc_ref);
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1721,6 +1718,7 @@ audioclose(struct file *fp)
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	audio_file_t *file;
+	int bound;
 	int error;
 	dev_t dev;
 
@@ -1736,6 +1734,7 @@ audioclose(struct file *fp)
 	 * - free all memory objects, regardless of sc.
 	 */
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
 	if (sc) {
 		switch (AUDIODEV(dev)) {
@@ -1756,6 +1755,7 @@ audioclose(struct file *fp)
 
 		audio_sc_release(sc, &sc_ref);
 	}
+	curlwp_bindx(bound);
 
 	/* Free memory objects anyway */
 	TRACEF(2, file, "free memory");
@@ -1776,6 +1776,7 @@ audioread(struct file *fp, off_t *offp, 
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	audio_file_t *file;
+	int bound;
 	int error;
 	dev_t dev;
 
@@ -1783,9 +1784,12 @@ audioread(struct file *fp, off_t *offp, 
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	if (fp->f_flag & O_NONBLOCK)
 		ioflag |= IO_NDELAY;
@@ -1805,6 +1809,8 @@ audioread(struct file *fp, off_t *offp, 
 	}
 
 	audio_sc_release(sc, &sc_ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1815,6 +1821,7 @@ audiowrite(struct file *fp, off_t *offp,
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	audio_file_t *file;
+	int bound;
 	int error;
 	dev_t dev;
 
@@ -1822,9 +1829,12 @@ audiowrite(struct file *fp, off_t *offp,
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	if (fp->f_flag & O_NONBLOCK)
 		ioflag |= IO_NDELAY;
@@ -1844,6 +1854,8 @@ audiowrite(struct file *fp, off_t *offp,
 	}
 
 	audio_sc_release(sc, &sc_ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1854,6 +1866,7 @@ audioioctl(struct file *fp, u_long cmd, 
 	struct psref sc_ref;
 	audio_file_t *file;
 	struct lwp *l = curlwp;
+	int bound;
 	int error;
 	dev_t dev;
 
@@ -1861,9 +1874,12 @@ audioioctl(struct file *fp, u_long cmd, 
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	switch (AUDIODEV(dev)) {
 	case SOUND_DEVICE:
@@ -1887,6 +1903,8 @@ audioioctl(struct file *fp, u_long cmd, 
 	}
 
 	audio_sc_release(sc, &sc_ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1896,14 +1914,20 @@ audiostat(struct file *fp, struct stat *
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	audio_file_t *file;
+	int bound;
+	int error;
 
 	KASSERT(fp->f_audioctx);
 	file = fp->f_audioctx;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
+	error = 0;
 	memset(st, 0, sizeof(*st));
 
 	st->st_dev = file->dev;
@@ -1912,7 +1936,9 @@ audiostat(struct file *fp, struct stat *
 	st->st_mode = S_IFCHR;
 
 	audio_sc_release(sc, &sc_ref);
-	return 0;
+done:
+	curlwp_bindx(bound);
+	return error;
 }
 
 static int
@@ -1922,6 +1948,7 @@ audiopoll(struct file *fp, int events)
 	struct psref sc_ref;
 	audio_file_t *file;
 	struct lwp *l = curlwp;
+	int bound;
 	int revents;
 	dev_t dev;
 
@@ -1929,9 +1956,12 @@ audiopoll(struct file *fp, int events)
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return POLLERR;
+	if (sc == NULL) {
+		revents = POLLERR;
+		goto done;
+	}
 
 	switch (AUDIODEV(dev)) {
 	case SOUND_DEVICE:
@@ -1948,6 +1978,8 @@ audiopoll(struct file *fp, int events)
 	}
 
 	audio_sc_release(sc, &sc_ref);
+done:
+	curlwp_bindx(bound);
 	return revents;
 }
 
@@ -1958,15 +1990,19 @@ audiokqfilter(struct file *fp, struct kn
 	struct psref sc_ref;
 	audio_file_t *file;
 	dev_t dev;
+	int bound;
 	int error;
 
 	KASSERT(fp->f_audioctx);
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	switch (AUDIODEV(dev)) {
 	case SOUND_DEVICE:
@@ -1983,6 +2019,8 @@ audiokqfilter(struct file *fp, struct kn
 	}
 
 	audio_sc_release(sc, &sc_ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -1994,15 +2032,19 @@ audiommap(struct file *fp, off_t *offp, 
 	struct psref sc_ref;
 	audio_file_t *file;
 	dev_t dev;
+	int bound;
 	int error;
 
 	KASSERT(fp->f_audioctx);
 	file = fp->f_audioctx;
 	dev = file->dev;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	mutex_enter(sc->sc_lock);
 	device_active(sc->sc_dev, DVA_SYSTEM); /* XXXJDM */
@@ -2022,6 +2064,8 @@ audiommap(struct file *fp, off_t *offp, 
 	}
 
 	audio_sc_release(sc, &sc_ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -2038,6 +2082,7 @@ audiobellopen(dev_t dev, audio_file_t **
 {
 	struct audio_softc *sc;
 	struct psref sc_ref;
+	int bound;
 	int error;
 
 	/* Find the device */
@@ -2045,6 +2090,7 @@ audiobellopen(dev_t dev, audio_file_t **
 	if (sc == NULL || sc->hw_if == NULL)
 		return ENXIO;
 
+	bound = curlwp_bind();
 	audio_sc_acquire_foropen(sc, &sc_ref);
 
 	error = audio_exlock_enter(sc);
@@ -2057,6 +2103,7 @@ audiobellopen(dev_t dev, audio_file_t **
 	audio_exlock_exit(sc);
 done:
 	audio_sc_release(sc, &sc_ref);
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -2066,6 +2113,7 @@ audiobellclose(audio_file_t *file)
 {
 	struct audio_softc *sc;
 	struct psref sc_ref;
+	int bound;
 	int error;
 
 	error = 0;
@@ -2074,11 +2122,13 @@ audiobellclose(audio_file_t *file)
 	 * - unplug track from the trackmixer if sc exist.
 	 * - free all memory objects, regardless of sc.
 	 */
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
 	if (sc) {
 		error = audio_close(sc, file);
 		audio_sc_release(sc, &sc_ref);
 	}
+	curlwp_bindx(bound);
 
 	/* Free memory objects anyway */
 	KASSERT(file->ptrack);
@@ -2095,23 +2145,29 @@ audiobellsetrate(audio_file_t *file, u_i
 	struct audio_softc *sc;
 	struct psref sc_ref;
 	struct audio_info ai;
+	int bound;
 	int error;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done1;
+	}
 
 	AUDIO_INITINFO(&ai);
 	ai.play.sample_rate = sample_rate;
 
 	error = audio_exlock_enter(sc);
 	if (error)
-		goto done;
+		goto done2;
 	error = audio_file_setinfo(sc, file, &ai);
 	audio_exlock_exit(sc);
 
-done:
+done2:
 	audio_sc_release(sc, &sc_ref);
+done1:
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -2121,15 +2177,21 @@ audiobellwrite(audio_file_t *file, struc
 {
 	struct audio_softc *sc;
 	struct psref sc_ref;
+	int bound;
 	int error;
 
+	bound = curlwp_bind();
 	sc = audio_sc_acquire_fromfile(file, &sc_ref);
-	if (sc == NULL)
-		return EIO;
+	if (sc == NULL) {
+		error = EIO;
+		goto done;
+	}
 
 	error = audio_write(sc, uio, 0, file);
 
 	audio_sc_release(sc, &sc_ref);
+done:
+	curlwp_bindx(bound);
 	return error;
 }
 

Reply via email to