ALSA: hda - Use standard workqueue for unsol and jack events

The events that are handled by HD-audio drivers are no frequent and
urgent ones, so we can use the standard workqueue without any problem
nowadays.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2015-02-27 22:43:26 +01:00
parent bcd96557bd
commit 2f35c630f7
6 changed files with 14 additions and 36 deletions

View File

@ -681,7 +681,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
struct hda_bus_unsolicited *unsol;
unsigned int wp;
if (!bus || !bus->workq)
if (!bus)
return 0;
trace_hda_unsol_event(bus, res, res_ex);
@ -693,7 +693,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;
queue_work(bus->workq, &unsol->work);
schedule_work(&unsol->work);
return 0;
}
@ -732,13 +732,9 @@ static void snd_hda_bus_free(struct hda_bus *bus)
return;
WARN_ON(!list_empty(&bus->codec_list));
if (bus->workq)
flush_workqueue(bus->workq);
cancel_work_sync(&bus->unsol.work);
if (bus->ops.private_free)
bus->ops.private_free(bus);
if (bus->workq)
destroy_workqueue(bus->workq);
kfree(bus);
}
@ -785,16 +781,6 @@ int snd_hda_bus_new(struct snd_card *card,
INIT_LIST_HEAD(&bus->codec_list);
INIT_WORK(&bus->unsol.work, process_unsol_events);
snprintf(bus->workq_name, sizeof(bus->workq_name),
"hd-audio%d", card->number);
bus->workq = create_singlethread_workqueue(bus->workq_name);
if (!bus->workq) {
dev_err(card->dev, "cannot create workqueue %s\n",
bus->workq_name);
kfree(bus);
return -ENOMEM;
}
err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
if (err < 0) {
snd_hda_bus_free(bus);
@ -1068,8 +1054,8 @@ static void hda_jackpoll_work(struct work_struct *work)
if (!codec->jackpoll_interval)
return;
queue_delayed_work(codec->bus->workq, &codec->jackpoll_work,
codec->jackpoll_interval);
schedule_delayed_work(&codec->jackpoll_work,
codec->jackpoll_interval);
}
static void init_hda_cache(struct hda_cache_rec *cache,
@ -1178,7 +1164,6 @@ static void codec_release_pcms(struct hda_codec *codec)
void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
{
cancel_delayed_work_sync(&codec->jackpoll_work);
flush_workqueue(codec->bus->workq);
if (!codec->in_freeing)
snd_hda_ctls_clear(codec);
codec_release_pcms(codec);
@ -1214,7 +1199,6 @@ static void snd_hda_codec_free(struct hda_codec *codec)
if (device_is_registered(hda_codec_dev(codec)))
device_del(hda_codec_dev(codec));
free_init_pincfgs(codec);
flush_workqueue(codec->bus->workq);
list_del(&codec->list);
codec->bus->caddr_tbl[codec->addr] = NULL;
clear_bit(codec->addr, &codec->bus->codec_powered);

View File

@ -132,8 +132,6 @@ struct hda_bus {
/* unsolicited event queue */
struct hda_bus_unsolicited unsol;
char workq_name[16];
struct workqueue_struct *workq; /* common workqueue for codecs */
/* assigned PCMs */
DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);

View File

@ -528,10 +528,10 @@ static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev)
if (ok == 1) {
azx_dev->irq_pending = 0;
return ok;
} else if (ok == 0 && chip->bus && chip->bus->workq) {
} else if (ok == 0) {
/* bogus IRQ, process it later */
azx_dev->irq_pending = 1;
queue_work(chip->bus->workq, &hda->irq_pending_work);
schedule_work(&hda->irq_pending_work);
}
return 0;
}
@ -893,8 +893,8 @@ static int azx_runtime_resume(struct device *dev)
if (status && bus) {
list_for_each_entry(codec, &bus->codec_list, list)
if (status & (1 << codec->addr))
queue_delayed_work(codec->bus->workq,
&codec->jackpoll_work, codec->jackpoll_interval);
schedule_delayed_work(&codec->jackpoll_work,
codec->jackpoll_interval);
}
/* disable controller Wake Up event*/

View File

@ -4410,8 +4410,7 @@ static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
* state machine run.
*/
cancel_delayed_work_sync(&spec->unsol_hp_work);
queue_delayed_work(codec->bus->workq, &spec->unsol_hp_work,
msecs_to_jiffies(500));
schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(500));
cb->tbl->block_report = 1;
}

View File

@ -1576,9 +1576,8 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
update_eld = true;
}
else if (repoll) {
queue_delayed_work(codec->bus->workq,
&per_pin->work,
msecs_to_jiffies(300));
schedule_delayed_work(&per_pin->work,
msecs_to_jiffies(300));
goto unlock;
}
}
@ -2198,11 +2197,10 @@ static void generic_hdmi_free(struct hda_codec *codec)
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
cancel_delayed_work(&per_pin->work);
cancel_delayed_work_sync(&per_pin->work);
eld_proc_free(per_pin);
}
flush_workqueue(codec->bus->workq);
hdmi_array_free(spec);
kfree(spec);
}

View File

@ -222,8 +222,7 @@ static void vt1708_update_hp_work(struct hda_codec *codec)
if (!spec->hp_work_active) {
codec->jackpoll_interval = msecs_to_jiffies(100);
snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0);
queue_delayed_work(codec->bus->workq,
&codec->jackpoll_work, 0);
schedule_delayed_work(&codec->jackpoll_work, 0);
spec->hp_work_active = true;
}
} else if (!hp_detect_with_aa(codec))