Skip to content

Commit fabb26d

Browse files
committed
ALSA: pcm: Add card sync_irq field
Many PCI and other drivers performs snd_pcm_period_elapsed() simply in its interrupt handler, so the sync_stop operation is just to call synchronize_irq(). Instead of putting this call multiple times, introduce the common card->sync_irq field. When this field is set, PCM core performs synchronize_irq() for sync-stop operation. Each driver just needs to copy its local IRQ number to card->sync_irq, and that's all we need. Link: https://lore.kernel.org/r/20191117085308.23915-8-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 1e850be commit fabb26d

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎include/sound/core.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct snd_card {
117117
struct device card_dev; /* cardX object for sysfs */
118118
const struct attribute_group *dev_groups[4]; /* assigned sysfs attr */
119119
bool registered; /* card_dev is registered? */
120+
int sync_irq; /* assigned irq, used for PCM sync */
120121
wait_queue_head_t remove_sleep;
121122

122123
#ifdef CONFIG_PM

‎sound/core/init.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
215215
init_waitqueue_head(&card->power_sleep);
216216
#endif
217217
init_waitqueue_head(&card->remove_sleep);
218+
card->sync_irq = -1;
218219

219220
device_initialize(&card->card_dev);
220221
card->card_dev.parent = parent;

‎sound/core/pcm_native.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ static void snd_pcm_sync_stop(struct snd_pcm_substream *substream)
574574
substream->runtime->stop_operating = false;
575575
if (substream->ops->sync_stop)
576576
substream->ops->sync_stop(substream);
577+
else if (substream->pcm->card->sync_irq > 0)
578+
synchronize_irq(substream->pcm->card->sync_irq);
577579
}
578580
}
579581

0 commit comments

Comments
 (0)