diff options
author | Arnd Bergmann <arnd@arndb.de> | 2014-01-02 07:07:51 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-01-14 10:12:07 -0500 |
commit | cdef2e5f358db5fd27eec4c72eb295c232287813 (patch) | |
tree | 83f0821da55eff4924b2947c29d8e2b87d302494 /sound/oss | |
parent | 1a1e0a80ceb766852e8abd5d4c3d9475611a7d85 (diff) |
sound: oss: remove last sleep_on users
There are three files in oss for which I could not find an easy way to
replace interruptible_sleep_on_timeout with a non-racy version. This
patch instead just adds a private implementation of the function, now
named oss_broken_sleep_on, and changes over the remaining users in
sound/oss/ so we can remove the global interface.
[fixed coding style warnings by tiwai]
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/oss')
-rw-r--r-- | sound/oss/dmabuf.c | 14 | ||||
-rw-r--r-- | sound/oss/sequencer.c | 16 | ||||
-rw-r--r-- | sound/oss/sleep.h | 18 | ||||
-rw-r--r-- | sound/oss/swarm_cs4297a.c | 14 |
4 files changed, 39 insertions, 23 deletions
diff --git a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c index 461d94cfecbe..e3f29132d3ac 100644 --- a/sound/oss/dmabuf.c +++ b/sound/oss/dmabuf.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/gfp.h> | 29 | #include <linux/gfp.h> |
30 | #include "sound_config.h" | 30 | #include "sound_config.h" |
31 | #include "sleep.h" | ||
31 | 32 | ||
32 | #define DMAP_FREE_ON_CLOSE 0 | 33 | #define DMAP_FREE_ON_CLOSE 0 |
33 | #define DMAP_KEEP_ON_CLOSE 1 | 34 | #define DMAP_KEEP_ON_CLOSE 1 |
@@ -351,8 +352,7 @@ static void dma_reset_output(int dev) | |||
351 | if (!signal_pending(current) && adev->dmap_out->qlen && | 352 | if (!signal_pending(current) && adev->dmap_out->qlen && |
352 | adev->dmap_out->underrun_count == 0){ | 353 | adev->dmap_out->underrun_count == 0){ |
353 | spin_unlock_irqrestore(&dmap->lock,flags); | 354 | spin_unlock_irqrestore(&dmap->lock,flags); |
354 | interruptible_sleep_on_timeout(&adev->out_sleeper, | 355 | oss_broken_sleep_on(&adev->out_sleeper, dmabuf_timeout(dmap)); |
355 | dmabuf_timeout(dmap)); | ||
356 | spin_lock_irqsave(&dmap->lock,flags); | 356 | spin_lock_irqsave(&dmap->lock,flags); |
357 | } | 357 | } |
358 | adev->dmap_out->flags &= ~(DMA_SYNCING | DMA_ACTIVE); | 358 | adev->dmap_out->flags &= ~(DMA_SYNCING | DMA_ACTIVE); |
@@ -446,7 +446,7 @@ int DMAbuf_sync(int dev) | |||
446 | long t = dmabuf_timeout(dmap); | 446 | long t = dmabuf_timeout(dmap); |
447 | spin_unlock_irqrestore(&dmap->lock,flags); | 447 | spin_unlock_irqrestore(&dmap->lock,flags); |
448 | /* FIXME: not safe may miss events */ | 448 | /* FIXME: not safe may miss events */ |
449 | t = interruptible_sleep_on_timeout(&adev->out_sleeper, t); | 449 | t = oss_broken_sleep_on(&adev->out_sleeper, t); |
450 | spin_lock_irqsave(&dmap->lock,flags); | 450 | spin_lock_irqsave(&dmap->lock,flags); |
451 | if (!t) { | 451 | if (!t) { |
452 | adev->dmap_out->flags &= ~DMA_SYNCING; | 452 | adev->dmap_out->flags &= ~DMA_SYNCING; |
@@ -466,7 +466,7 @@ int DMAbuf_sync(int dev) | |||
466 | while (!signal_pending(current) && | 466 | while (!signal_pending(current) && |
467 | adev->d->local_qlen(dev)){ | 467 | adev->d->local_qlen(dev)){ |
468 | spin_unlock_irqrestore(&dmap->lock,flags); | 468 | spin_unlock_irqrestore(&dmap->lock,flags); |
469 | interruptible_sleep_on_timeout(&adev->out_sleeper, | 469 | oss_broken_sleep_on(&adev->out_sleeper, |
470 | dmabuf_timeout(dmap)); | 470 | dmabuf_timeout(dmap)); |
471 | spin_lock_irqsave(&dmap->lock,flags); | 471 | spin_lock_irqsave(&dmap->lock,flags); |
472 | } | 472 | } |
@@ -587,8 +587,7 @@ int DMAbuf_getrdbuffer(int dev, char **buf, int *len, int dontblock) | |||
587 | timeout = dmabuf_timeout(dmap); | 587 | timeout = dmabuf_timeout(dmap); |
588 | 588 | ||
589 | spin_unlock_irqrestore(&dmap->lock,flags); | 589 | spin_unlock_irqrestore(&dmap->lock,flags); |
590 | timeout = interruptible_sleep_on_timeout(&adev->in_sleeper, | 590 | timeout = oss_broken_sleep_on(&adev->in_sleeper, timeout); |
591 | timeout); | ||
592 | if (!timeout) { | 591 | if (!timeout) { |
593 | /* FIXME: include device name */ | 592 | /* FIXME: include device name */ |
594 | err = -EIO; | 593 | err = -EIO; |
@@ -768,8 +767,7 @@ static int output_sleep(int dev, int dontblock) | |||
768 | timeout_value = dmabuf_timeout(dmap); | 767 | timeout_value = dmabuf_timeout(dmap); |
769 | else | 768 | else |
770 | timeout_value = MAX_SCHEDULE_TIMEOUT; | 769 | timeout_value = MAX_SCHEDULE_TIMEOUT; |
771 | timeout_value = interruptible_sleep_on_timeout(&adev->out_sleeper, | 770 | timeout_value = oss_broken_sleep_on(&adev->out_sleeper, timeout_value); |
772 | timeout_value); | ||
773 | if (timeout != MAX_SCHEDULE_TIMEOUT && !timeout_value) { | 771 | if (timeout != MAX_SCHEDULE_TIMEOUT && !timeout_value) { |
774 | printk(KERN_WARNING "Sound: DMA (output) timed out - IRQ/DRQ config error?\n"); | 772 | printk(KERN_WARNING "Sound: DMA (output) timed out - IRQ/DRQ config error?\n"); |
775 | dma_reset_output(dev); | 773 | dma_reset_output(dev); |
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c index 4ff60a6427d9..9b9f7d385134 100644 --- a/sound/oss/sequencer.c +++ b/sound/oss/sequencer.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "sound_config.h" | 19 | #include "sound_config.h" |
20 | 20 | ||
21 | #include "midi_ctrl.h" | 21 | #include "midi_ctrl.h" |
22 | #include "sleep.h" | ||
22 | 23 | ||
23 | static int sequencer_ok; | 24 | static int sequencer_ok; |
24 | static struct sound_timer_operations *tmr; | 25 | static struct sound_timer_operations *tmr; |
@@ -100,8 +101,7 @@ int sequencer_read(int dev, struct file *file, char __user *buf, int count) | |||
100 | return -EAGAIN; | 101 | return -EAGAIN; |
101 | } | 102 | } |
102 | 103 | ||
103 | interruptible_sleep_on_timeout(&midi_sleeper, | 104 | oss_broken_sleep_on(&midi_sleeper, pre_event_timeout); |
104 | pre_event_timeout); | ||
105 | spin_lock_irqsave(&lock,flags); | 105 | spin_lock_irqsave(&lock,flags); |
106 | if (!iqlen) | 106 | if (!iqlen) |
107 | { | 107 | { |
@@ -343,7 +343,7 @@ static int seq_queue(unsigned char *note, char nonblock) | |||
343 | /* | 343 | /* |
344 | * Sleep until there is enough space on the queue | 344 | * Sleep until there is enough space on the queue |
345 | */ | 345 | */ |
346 | interruptible_sleep_on(&seq_sleeper); | 346 | oss_broken_sleep_on(&seq_sleeper, MAX_SCHEDULE_TIMEOUT); |
347 | } | 347 | } |
348 | if (qlen >= SEQ_MAX_QUEUE) | 348 | if (qlen >= SEQ_MAX_QUEUE) |
349 | { | 349 | { |
@@ -1122,8 +1122,7 @@ static void seq_drain_midi_queues(void) | |||
1122 | */ | 1122 | */ |
1123 | 1123 | ||
1124 | if (n) | 1124 | if (n) |
1125 | interruptible_sleep_on_timeout(&seq_sleeper, | 1125 | oss_broken_sleep_on(&seq_sleeper, HZ/10); |
1126 | HZ/10); | ||
1127 | } | 1126 | } |
1128 | } | 1127 | } |
1129 | 1128 | ||
@@ -1145,8 +1144,7 @@ void sequencer_release(int dev, struct file *file) | |||
1145 | while (!signal_pending(current) && qlen > 0) | 1144 | while (!signal_pending(current) && qlen > 0) |
1146 | { | 1145 | { |
1147 | seq_sync(); | 1146 | seq_sync(); |
1148 | interruptible_sleep_on_timeout(&seq_sleeper, | 1147 | oss_broken_sleep_on(&seq_sleeper, 3*HZ); |
1149 | 3*HZ); | ||
1150 | /* Extra delay */ | 1148 | /* Extra delay */ |
1151 | } | 1149 | } |
1152 | } | 1150 | } |
@@ -1201,7 +1199,7 @@ static int seq_sync(void) | |||
1201 | seq_startplay(); | 1199 | seq_startplay(); |
1202 | 1200 | ||
1203 | if (qlen > 0) | 1201 | if (qlen > 0) |
1204 | interruptible_sleep_on_timeout(&seq_sleeper, HZ); | 1202 | oss_broken_sleep_on(&seq_sleeper, HZ); |
1205 | return qlen; | 1203 | return qlen; |
1206 | } | 1204 | } |
1207 | 1205 | ||
@@ -1224,7 +1222,7 @@ static void midi_outc(int dev, unsigned char data) | |||
1224 | 1222 | ||
1225 | spin_lock_irqsave(&lock,flags); | 1223 | spin_lock_irqsave(&lock,flags); |
1226 | while (n && !midi_devs[dev]->outputc(dev, data)) { | 1224 | while (n && !midi_devs[dev]->outputc(dev, data)) { |
1227 | interruptible_sleep_on_timeout(&seq_sleeper, HZ/25); | 1225 | oss_broken_sleep_on(&seq_sleeper, HZ/25); |
1228 | n--; | 1226 | n--; |
1229 | } | 1227 | } |
1230 | spin_unlock_irqrestore(&lock,flags); | 1228 | spin_unlock_irqrestore(&lock,flags); |
diff --git a/sound/oss/sleep.h b/sound/oss/sleep.h new file mode 100644 index 000000000000..a20fc925a5ce --- /dev/null +++ b/sound/oss/sleep.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #include <linux/wait.h> | ||
2 | |||
3 | /* | ||
4 | * Do not use. This is a replacement for the old | ||
5 | * "interruptible_sleep_on_timeout" function that has been | ||
6 | * deprecated for ages. All users should instead try to use | ||
7 | * wait_event_interruptible_timeout. | ||
8 | */ | ||
9 | |||
10 | static inline long | ||
11 | oss_broken_sleep_on(wait_queue_head_t *q, long timeout) | ||
12 | { | ||
13 | DEFINE_WAIT(wait); | ||
14 | prepare_to_wait(q, &wait, TASK_INTERRUPTIBLE); | ||
15 | timeout = schedule_timeout(timeout); | ||
16 | finish_wait(q, &wait); | ||
17 | return timeout; | ||
18 | } | ||
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c index 7d8803a00b79..f851fd0e199c 100644 --- a/sound/oss/swarm_cs4297a.c +++ b/sound/oss/swarm_cs4297a.c | |||
@@ -90,6 +90,8 @@ | |||
90 | #include <asm/sibyte/sb1250_mac.h> | 90 | #include <asm/sibyte/sb1250_mac.h> |
91 | #include <asm/sibyte/sb1250.h> | 91 | #include <asm/sibyte/sb1250.h> |
92 | 92 | ||
93 | #include "sleep.h" | ||
94 | |||
93 | struct cs4297a_state; | 95 | struct cs4297a_state; |
94 | 96 | ||
95 | static DEFINE_MUTEX(swarm_cs4297a_mutex); | 97 | static DEFINE_MUTEX(swarm_cs4297a_mutex); |
@@ -748,7 +750,7 @@ static int serdma_reg_access(struct cs4297a_state *s, u64 data) | |||
748 | /* Since a writer has the DSP open, we have to mux the | 750 | /* Since a writer has the DSP open, we have to mux the |
749 | request in */ | 751 | request in */ |
750 | s->reg_request = data; | 752 | s->reg_request = data; |
751 | interruptible_sleep_on(&s->dma_dac.reg_wait); | 753 | oss_broken_sleep_on(&s->dma_dac.reg_wait, MAX_SCHEDULE_TIMEOUT); |
752 | /* XXXKW how can I deal with the starvation case where | 754 | /* XXXKW how can I deal with the starvation case where |
753 | the opener isn't writing? */ | 755 | the opener isn't writing? */ |
754 | } else { | 756 | } else { |
@@ -790,7 +792,7 @@ static int cs4297a_read_ac97(struct cs4297a_state *s, u32 offset, | |||
790 | if (serdma_reg_access(s, (0xCLL << 60) | (1LL << 47) | ((u64)(offset & 0x7F) << 40))) | 792 | if (serdma_reg_access(s, (0xCLL << 60) | (1LL << 47) | ((u64)(offset & 0x7F) << 40))) |
791 | return -1; | 793 | return -1; |
792 | 794 | ||
793 | interruptible_sleep_on(&s->dma_adc.reg_wait); | 795 | oss_broken_sleep_on(&s->dma_adc.reg_wait, MAX_SCHEDULE_TIMEOUT); |
794 | *value = s->read_value; | 796 | *value = s->read_value; |
795 | CS_DBGOUT(CS_AC97, 2, | 797 | CS_DBGOUT(CS_AC97, 2, |
796 | printk(KERN_INFO "cs4297a: rdr reg %x -> %x\n", s->read_reg, s->read_value)); | 798 | printk(KERN_INFO "cs4297a: rdr reg %x -> %x\n", s->read_reg, s->read_value)); |
@@ -1740,7 +1742,7 @@ static ssize_t cs4297a_read(struct file *file, char *buffer, size_t count, | |||
1740 | start_adc(s); | 1742 | start_adc(s); |
1741 | if (file->f_flags & O_NONBLOCK) | 1743 | if (file->f_flags & O_NONBLOCK) |
1742 | return ret ? ret : -EAGAIN; | 1744 | return ret ? ret : -EAGAIN; |
1743 | interruptible_sleep_on(&s->dma_adc.wait); | 1745 | oss_broken_sleep_on(&s->dma_adc.wait, MAX_SCHEDULE_TIMEOUT); |
1744 | if (signal_pending(current)) | 1746 | if (signal_pending(current)) |
1745 | return ret ? ret : -ERESTARTSYS; | 1747 | return ret ? ret : -ERESTARTSYS; |
1746 | continue; | 1748 | continue; |
@@ -1836,7 +1838,7 @@ static ssize_t cs4297a_write(struct file *file, const char *buffer, | |||
1836 | start_dac(s); | 1838 | start_dac(s); |
1837 | if (file->f_flags & O_NONBLOCK) | 1839 | if (file->f_flags & O_NONBLOCK) |
1838 | return ret ? ret : -EAGAIN; | 1840 | return ret ? ret : -EAGAIN; |
1839 | interruptible_sleep_on(&d->wait); | 1841 | oss_broken_sleep_on(&d->wait, MAX_SCHEDULE_TIMEOUT); |
1840 | if (signal_pending(current)) | 1842 | if (signal_pending(current)) |
1841 | return ret ? ret : -ERESTARTSYS; | 1843 | return ret ? ret : -ERESTARTSYS; |
1842 | continue; | 1844 | continue; |
@@ -2452,7 +2454,7 @@ static int cs4297a_locked_open(struct inode *inode, struct file *file) | |||
2452 | return -EBUSY; | 2454 | return -EBUSY; |
2453 | } | 2455 | } |
2454 | mutex_unlock(&s->open_sem_dac); | 2456 | mutex_unlock(&s->open_sem_dac); |
2455 | interruptible_sleep_on(&s->open_wait_dac); | 2457 | oss_broken_sleep_on(&s->open_wait_dac, MAX_SCHEDULE_TIMEOUT); |
2456 | 2458 | ||
2457 | if (signal_pending(current)) { | 2459 | if (signal_pending(current)) { |
2458 | printk("open - sig pending\n"); | 2460 | printk("open - sig pending\n"); |
@@ -2469,7 +2471,7 @@ static int cs4297a_locked_open(struct inode *inode, struct file *file) | |||
2469 | return -EBUSY; | 2471 | return -EBUSY; |
2470 | } | 2472 | } |
2471 | mutex_unlock(&s->open_sem_adc); | 2473 | mutex_unlock(&s->open_sem_adc); |
2472 | interruptible_sleep_on(&s->open_wait_adc); | 2474 | oss_broken_sleep_on(&s->open_wait_adc, MAX_SCHEDULE_TIMEOUT); |
2473 | 2475 | ||
2474 | if (signal_pending(current)) { | 2476 | if (signal_pending(current)) { |
2475 | printk("open - sig pending\n"); | 2477 | printk("open - sig pending\n"); |