Skip to content

Commit 43aa56d

Browse files
bhaktipriyatiwai
authored andcommitted
ALSA: sh: aica: Remove deprecated create_workqueue
System workqueues have been able to handle high level of concurrency for a long time now and there's no reason to use dedicated workqueues just to gain concurrency. Since aica_queue for AICA sound driver has workitem dreamcastcard->spu_dma_work (maps to run_spu_dma) which is involved in aica dma transfers and is not being used on a memory reclaim path, dedicated aica_queue has been replaced with the use of system_wq. Unlike a dedicated per-cpu workqueue created with create_workqueue(), system_wq allows multiple work items to overlap executions even on the same CPU; however, a per-cpu workqueue doesn't have any CPU locality or global ordering guarantees unless the target CPU is explicitly specified and thus the increase of local concurrency shouldn't make any difference. Since the work items could be pending, flush_work() has been used in snd_aicapcm_pcm_close() to ensure that there is no pending task while disconnecting the driver. Signed-off-by: Bhaktipriya Shridhar <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent fabc16f commit 43aa56d

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

sound/sh/aica.c

+3-13
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
6363
module_param(enable, bool, 0644);
6464
MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
6565

66-
/* Use workqueue */
67-
static struct workqueue_struct *aica_queue;
68-
6966
/* Simple platform device */
7067
static struct platform_device *pd;
7168
static struct resource aica_memory_space[2] = {
@@ -327,7 +324,7 @@ static void aica_period_elapsed(unsigned long timer_var)
327324
dreamcastcard->current_period = play_period;
328325
if (unlikely(dreamcastcard->dma_check == 0))
329326
dreamcastcard->dma_check = 1;
330-
queue_work(aica_queue, &(dreamcastcard->spu_dma_work));
327+
schedule_work(&(dreamcastcard->spu_dma_work));
331328
}
332329

333330
static void spu_begin_dma(struct snd_pcm_substream *substream)
@@ -337,7 +334,7 @@ static void spu_begin_dma(struct snd_pcm_substream *substream)
337334
runtime = substream->runtime;
338335
dreamcastcard = substream->pcm->private_data;
339336
/*get the queue to do the work */
340-
queue_work(aica_queue, &(dreamcastcard->spu_dma_work));
337+
schedule_work(&(dreamcastcard->spu_dma_work));
341338
/* Timer may already be running */
342339
if (unlikely(dreamcastcard->timer.data)) {
343340
mod_timer(&dreamcastcard->timer, jiffies + 4);
@@ -381,7 +378,7 @@ static int snd_aicapcm_pcm_close(struct snd_pcm_substream
381378
*substream)
382379
{
383380
struct snd_card_aica *dreamcastcard = substream->pcm->private_data;
384-
flush_workqueue(aica_queue);
381+
flush_work(&(dreamcastcard->spu_dma_work));
385382
if (dreamcastcard->timer.data)
386383
del_timer(&dreamcastcard->timer);
387384
kfree(dreamcastcard->channel);
@@ -633,9 +630,6 @@ static int snd_aica_probe(struct platform_device *devptr)
633630
if (unlikely(err < 0))
634631
goto freedreamcast;
635632
platform_set_drvdata(devptr, dreamcastcard);
636-
aica_queue = create_workqueue(CARD_NAME);
637-
if (unlikely(!aica_queue))
638-
goto freedreamcast;
639633
snd_printk
640634
("ALSA Driver for Yamaha AICA Super Intelligent Sound Processor\n");
641635
return 0;
@@ -671,10 +665,6 @@ static int __init aica_init(void)
671665

672666
static void __exit aica_exit(void)
673667
{
674-
/* Destroy the aica kernel thread *
675-
* being extra cautious to check if it exists*/
676-
if (likely(aica_queue))
677-
destroy_workqueue(aica_queue);
678668
platform_device_unregister(pd);
679669
platform_driver_unregister(&snd_aica_driver);
680670
/* Kill any sound still playing and reset ARM7 to safe state */

0 commit comments

Comments
 (0)