Skip to content

Commit 68f86a9

Browse files
committed
ALSA: pcsp: Replace tasklet with work
The tasklet is an old API that should be deprecated, usually can be converted to another decent API. This patch replaces the usage of tasklet in pcsp driver with a simple work. In pcsp driver, a global tasklet is used for offloading the period-elapse handling in the hrtimer callback (introduced in commit 96c7d47 "ALSA: pcsp - Fix locking messes in snd-pcsp"). It can be achieved gracefully with a work queued in the high-prio system workqueue. This also changes tasklet_kill() with cancel_work_sync() in the sync_stop callback, which is anyway better to assure canceling the pending tasks. Link: https://lore.kernel.org/r/20200903104131.21097-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 9ddb236 commit 68f86a9

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

‎sound/drivers/pcsp/pcsp_lib.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ MODULE_PARM_DESC(nforce_wa, "Apply NForce chipset workaround "
2323
#define DMIX_WANTS_S16 1
2424

2525
/*
26-
* Call snd_pcm_period_elapsed in a tasklet
26+
* Call snd_pcm_period_elapsed in a work
2727
* This avoids spinlock messes and long-running irq contexts
2828
*/
29-
static void pcsp_call_pcm_elapsed(unsigned long priv)
29+
static void pcsp_call_pcm_elapsed(struct work_struct *work)
3030
{
3131
if (atomic_read(&pcsp_chip.timer_active)) {
3232
struct snd_pcm_substream *substream;
@@ -36,7 +36,7 @@ static void pcsp_call_pcm_elapsed(unsigned long priv)
3636
}
3737
}
3838

39-
static DECLARE_TASKLET_OLD(pcsp_pcm_tasklet, pcsp_call_pcm_elapsed);
39+
static DECLARE_WORK(pcsp_pcm_work, pcsp_call_pcm_elapsed);
4040

4141
/* write the port and returns the next expire time in ns;
4242
* called at the trigger-start and in hrtimer callback
@@ -119,11 +119,9 @@ static void pcsp_pointer_update(struct snd_pcsp *chip)
119119
if (periods_elapsed) {
120120
chip->period_ptr += periods_elapsed * period_bytes;
121121
chip->period_ptr %= buffer_bytes;
122+
queue_work(system_highpri_wq, &pcsp_pcm_work);
122123
}
123124
spin_unlock_irqrestore(&chip->substream_lock, flags);
124-
125-
if (periods_elapsed)
126-
tasklet_schedule(&pcsp_pcm_tasklet);
127125
}
128126

129127
enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
@@ -196,7 +194,7 @@ void pcsp_sync_stop(struct snd_pcsp *chip)
196194
pcsp_stop_playing(chip);
197195
local_irq_enable();
198196
hrtimer_cancel(&chip->timer);
199-
tasklet_kill(&pcsp_pcm_tasklet);
197+
cancel_work_sync(&pcsp_pcm_work);
200198
}
201199

202200
static int snd_pcsp_playback_close(struct snd_pcm_substream *substream)

0 commit comments

Comments
 (0)