ALSA: hda - Use own workqueue
snd-hda-intel driver used schedule_work() fot the delayed DMA pointer updates, but this has several potential problems: - it may block other eventsd works longer - it may deadlock when probing fails and flush_scheduled_work() is called during probe callback (as probe callback itself could be invoked from eventd) This patch adds an own workq for each driver instance to solve these problems. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
4b55899104
commit
6acaed38a3
|
@ -135,7 +135,6 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
|
|||
struct hda_beep *beep = codec->beep;
|
||||
if (beep) {
|
||||
cancel_work_sync(&beep->beep_work);
|
||||
flush_scheduled_work();
|
||||
|
||||
input_unregister_device(beep->dev);
|
||||
kfree(beep);
|
||||
|
|
|
@ -373,7 +373,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
|
|||
unsol->queue[wp] = res;
|
||||
unsol->queue[wp + 1] = res_ex;
|
||||
|
||||
schedule_work(&unsol->work);
|
||||
queue_work(bus->workq, &unsol->work);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -437,15 +437,17 @@ static int snd_hda_bus_free(struct hda_bus *bus)
|
|||
|
||||
if (!bus)
|
||||
return 0;
|
||||
if (bus->unsol) {
|
||||
flush_scheduled_work();
|
||||
if (bus->workq)
|
||||
flush_workqueue(bus->workq);
|
||||
if (bus->unsol)
|
||||
kfree(bus->unsol);
|
||||
}
|
||||
list_for_each_entry_safe(codec, n, &bus->codec_list, list) {
|
||||
snd_hda_codec_free(codec);
|
||||
}
|
||||
if (bus->ops.private_free)
|
||||
bus->ops.private_free(bus);
|
||||
if (bus->workq)
|
||||
destroy_workqueue(bus->workq);
|
||||
kfree(bus);
|
||||
return 0;
|
||||
}
|
||||
|
@ -485,6 +487,7 @@ int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
|
|||
{
|
||||
struct hda_bus *bus;
|
||||
int err;
|
||||
char qname[8];
|
||||
static struct snd_device_ops dev_ops = {
|
||||
.dev_register = snd_hda_bus_dev_register,
|
||||
.dev_free = snd_hda_bus_dev_free,
|
||||
|
@ -514,6 +517,14 @@ int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
|
|||
mutex_init(&bus->cmd_mutex);
|
||||
INIT_LIST_HEAD(&bus->codec_list);
|
||||
|
||||
snprintf(qname, sizeof(qname), "hda%d", card->number);
|
||||
bus->workq = create_workqueue(qname);
|
||||
if (!bus->workq) {
|
||||
snd_printk(KERN_ERR "cannot create workqueue %s\n", qname);
|
||||
kfree(bus);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
|
||||
if (err < 0) {
|
||||
snd_hda_bus_free(bus);
|
||||
|
@ -684,7 +695,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
|
|||
return;
|
||||
#ifdef CONFIG_SND_HDA_POWER_SAVE
|
||||
cancel_delayed_work(&codec->power_work);
|
||||
flush_scheduled_work();
|
||||
flush_workqueue(codec->bus->workq);
|
||||
#endif
|
||||
list_del(&codec->list);
|
||||
snd_array_free(&codec->mixers);
|
||||
|
@ -1273,7 +1284,7 @@ void snd_hda_codec_reset(struct hda_codec *codec)
|
|||
|
||||
#ifdef CONFIG_SND_HDA_POWER_SAVE
|
||||
cancel_delayed_work(&codec->power_work);
|
||||
flush_scheduled_work();
|
||||
flush_workqueue(codec->bus->workq);
|
||||
#endif
|
||||
snd_hda_ctls_clear(codec);
|
||||
/* relase PCMs */
|
||||
|
|
|
@ -614,6 +614,7 @@ struct hda_bus {
|
|||
|
||||
/* unsolicited event queue */
|
||||
struct hda_bus_unsolicited *unsol;
|
||||
struct workqueue_struct *workq; /* common workqueue for codecs */
|
||||
|
||||
/* assigned PCMs */
|
||||
DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);
|
||||
|
|
|
@ -996,10 +996,11 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id)
|
|||
spin_unlock(&chip->reg_lock);
|
||||
snd_pcm_period_elapsed(azx_dev->substream);
|
||||
spin_lock(&chip->reg_lock);
|
||||
} else {
|
||||
} else if (chip->bus && chip->bus->workq) {
|
||||
/* bogus IRQ, process it later */
|
||||
azx_dev->irq_pending = 1;
|
||||
schedule_work(&chip->irq_pending_work);
|
||||
queue_work(chip->bus->workq,
|
||||
&chip->irq_pending_work);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1741,7 +1742,6 @@ static void azx_clear_irq_pending(struct azx *chip)
|
|||
for (i = 0; i < chip->num_streams; i++)
|
||||
chip->azx_dev[i].irq_pending = 0;
|
||||
spin_unlock_irq(&chip->reg_lock);
|
||||
flush_scheduled_work();
|
||||
}
|
||||
|
||||
static struct snd_pcm_ops azx_pcm_ops = {
|
||||
|
|
Loading…
Reference in a new issue