Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F175259331
D60465.id189171.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D60465.id189171.diff
View Options
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -740,7 +740,6 @@
* and MIDI). Handle those special cases here.
*/
if (IOCGROUP(cmd) == 'X') {
- PCM_ACQUIRE(d);
switch(cmd) {
case SNDCTL_SYSINFO:
sound_oss_sysinfo((oss_sysinfo *)arg);
@@ -765,7 +764,6 @@
default:
ret = EINVAL;
}
- PCM_RELEASE(d);
PCM_GIANT_EXIT(d);
return (ret);
}
@@ -2164,27 +2162,24 @@
}
}
- PCM_UNLOCKASSERT(d);
- PCM_LOCK(d);
if ((ai->dev == -1 && d->dsp_dev == i_dev) ||
- (ai->dev == unit)) {
- PCM_UNLOCK(d);
+ (ai->dev == unit))
break;
- } else {
- PCM_UNLOCK(d);
- d = NULL;
- }
+ d = NULL;
}
- bus_topo_unlock();
- /* Exhausted the search -- nothing is locked, so return. */
- if (d == NULL)
+ /* Exhausted the search. */
+ if (d == NULL) {
+ bus_topo_unlock();
return (EINVAL);
+ }
- /* XXX Need Giant magic entry ??? */
-
- PCM_UNLOCKASSERT(d);
- PCM_LOCK(d);
+ /*
+ * Do not give up the topology lock until the device is busied, or it
+ * might detach between unlocking and busying.
+ */
+ PCM_ACQUIRE(d);
+ bus_topo_unlock();
bzero((void *)ai, sizeof(oss_audioinfo));
ai->dev = unit;
@@ -2270,7 +2265,7 @@
if (ai->min_channels == INT_MAX)
ai->min_channels = 0;
- PCM_UNLOCK(d);
+ PCM_RELEASE(d);
return (0);
}
@@ -2332,18 +2327,24 @@
* Search for the requested audio device (channel). Start by
* iterating over pcm devices.
*/
- bus_topo_lock();
- for (unit = 0; pcm_devclass != NULL &&
- unit < devclass_get_maxunit(pcm_devclass); unit++) {
+ for (unit = 0; ; unit++) {
+ bus_topo_lock();
+ if (pcm_devclass == NULL ||
+ unit >= devclass_get_maxunit(pcm_devclass)) {
+ bus_topo_unlock();
+ break;
+ }
d = devclass_get_softc(pcm_devclass, unit);
- if (!PCM_REGISTERED(d))
+ if (!PCM_REGISTERED(d)) {
+ bus_topo_unlock();
continue;
-
- /* XXX Need Giant magic entry ??? */
-
- /* See the note in function docblock */
- PCM_UNLOCKASSERT(d);
- PCM_LOCK(d);
+ }
+ /*
+ * Do not give up the topology lock until the device is busied,
+ * or it might detach between unlocking and busying.
+ */
+ PCM_ACQUIRE(d);
+ bus_topo_unlock();
CHN_FOREACH(ch, d, channels.pcm) {
CHN_UNLOCKASSERT(ch);
@@ -2357,7 +2358,7 @@
}
if (ch == NULL) {
- PCM_UNLOCK(d);
+ PCM_RELEASE(d);
continue;
}
@@ -2481,14 +2482,12 @@
ai->next_rec_engine = 0;
CHN_UNLOCK(ch);
- PCM_UNLOCK(d);
- bus_topo_unlock();
+ PCM_RELEASE(d);
return (0);
}
- bus_topo_unlock();
- /* Exhausted the search -- nothing is locked, so return. */
+ /* Exhausted the search. */
return (EINVAL);
}
diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c
--- a/sys/dev/sound/pcm/mixer.c
+++ b/sys/dev/sound/pcm/mixer.c
@@ -887,6 +887,18 @@
return (EBADF);
PCM_GIANT_ENTER(d);
+
+ /*
+ * This group of ioctls can report info about any device in the system,
+ * and they busy each one as they inspect it, so they must not run with
+ * this device already busied, otherwise we will recurse on the sx.
+ */
+ if (IOCGROUP(cmd) == 'X') {
+ ret = mixer_ioctl_cmd(i_dev, cmd, arg, mode, td);
+ PCM_GIANT_EXIT(d);
+ return (ret);
+ }
+
PCM_ACQUIRE(d);
ret = mixer_ioctl_cmd(i_dev, cmd, arg, mode, td);
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -509,18 +509,24 @@
j = 0;
- bus_topo_lock();
- for (i = 0; pcm_devclass != NULL &&
- i < devclass_get_maxunit(pcm_devclass); i++) {
+ for (i = 0; ; i++) {
+ bus_topo_lock();
+ if (pcm_devclass == NULL ||
+ i >= devclass_get_maxunit(pcm_devclass)) {
+ bus_topo_unlock();
+ break;
+ }
d = devclass_get_softc(pcm_devclass, i);
- if (!PCM_REGISTERED(d))
+ if (!PCM_REGISTERED(d)) {
+ bus_topo_unlock();
continue;
-
- /* XXX Need Giant magic entry ??? */
-
- /* See note in function's docblock */
- PCM_UNLOCKASSERT(d);
- PCM_LOCK(d);
+ }
+ /*
+ * Do not give up the topology lock until the device is busied,
+ * or it might detach between unlocking and busying.
+ */
+ PCM_ACQUIRE(d);
+ bus_topo_unlock();
si->numaudioengines += PCM_CHANCOUNT(d);
@@ -534,9 +540,8 @@
j++;
}
- PCM_UNLOCK(d);
+ PCM_RELEASE(d);
}
- bus_topo_unlock();
si->numsynths = 0; /* OSSv4 docs: this field is obsolete */
/**
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 10, 12:31 PM (16 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40539372
Default Alt Text
D60465.id189171.diff (4 KB)
Attached To
Mode
D60465: sound: Busy the device being inspected, not the caller's
Attached
Detach File
Event Timeline
Log In to Comment