aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/seq/seq_memory.c')
-rw-r--r--sound/core/seq/seq_memory.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c
index c850345c43b5..5847c4475bf3 100644
--- a/sound/core/seq/seq_memory.c
+++ b/sound/core/seq/seq_memory.c
@@ -414,32 +414,33 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
414 return 0; 414 return 0;
415} 415}
416 416
417/* refuse the further insertion to the pool */
418void snd_seq_pool_mark_closing(struct snd_seq_pool *pool)
419{
420 unsigned long flags;
421
422 if (snd_BUG_ON(!pool))
423 return;
424 spin_lock_irqsave(&pool->lock, flags);
425 pool->closing = 1;
426 spin_unlock_irqrestore(&pool->lock, flags);
427}
428
417/* remove events */ 429/* remove events */
418int snd_seq_pool_done(struct snd_seq_pool *pool) 430int snd_seq_pool_done(struct snd_seq_pool *pool)
419{ 431{
420 unsigned long flags; 432 unsigned long flags;
421 struct snd_seq_event_cell *ptr; 433 struct snd_seq_event_cell *ptr;
422 int max_count = 5 * HZ;
423 434
424 if (snd_BUG_ON(!pool)) 435 if (snd_BUG_ON(!pool))
425 return -EINVAL; 436 return -EINVAL;
426 437
427 /* wait for closing all threads */ 438 /* wait for closing all threads */
428 spin_lock_irqsave(&pool->lock, flags);
429 pool->closing = 1;
430 spin_unlock_irqrestore(&pool->lock, flags);
431
432 if (waitqueue_active(&pool->output_sleep)) 439 if (waitqueue_active(&pool->output_sleep))
433 wake_up(&pool->output_sleep); 440 wake_up(&pool->output_sleep);
434 441
435 while (atomic_read(&pool->counter) > 0) { 442 while (atomic_read(&pool->counter) > 0)
436 if (max_count == 0) {
437 pr_warn("ALSA: snd_seq_pool_done timeout: %d cells remain\n", atomic_read(&pool->counter));
438 break;
439 }
440 schedule_timeout_uninterruptible(1); 443 schedule_timeout_uninterruptible(1);
441 max_count--;
442 }
443 444
444 /* release all resources */ 445 /* release all resources */
445 spin_lock_irqsave(&pool->lock, flags); 446 spin_lock_irqsave(&pool->lock, flags);
@@ -491,6 +492,7 @@ int snd_seq_pool_delete(struct snd_seq_pool **ppool)
491 *ppool = NULL; 492 *ppool = NULL;
492 if (pool == NULL) 493 if (pool == NULL)
493 return 0; 494 return 0;
495 snd_seq_pool_mark_closing(pool);
494 snd_seq_pool_done(pool); 496 snd_seq_pool_done(pool);
495 kfree(pool); 497 kfree(pool);
496 return 0; 498 return 0;