From: pl bossart <bossart.nospam@gmail.com>
To: alsa-devel@alsa-project.org,
General PulseAudio Discussion
<pulseaudio-discuss@mail.0pointer.de>
Subject: [RFC] disabling ALSA period interrupts
Date: Thu, 29 Apr 2010 17:38:50 -0500 [thread overview]
Message-ID: <h2l6160a5131004291538w6c7891fbn2db3425846aefd60@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1293 bytes --]
Howdy,
When PulseAudio is used and all PCM is routed through PulseAudio
(Fedora, Meego, etc), the notion of ALSA periods isn't very useful.
PulseAudio uses a timer to refill buffers and the period interrupts
are not used at all.
So why not disable them entirely to reduce the number of wakeups? This
is possible with a number of existing DMA controllers. The simple
patch attached shows a proof-of-concept on HDAudio, it's been working
for 5 hours on my Fedora12 laptop without any glitches and powertop
does show _zero_ wakeups from the HDAudio controller (except on
startup). I am told by my colleagues working in Windows environments
that this is what's done on Vista/Windows7 btw. This isn't to say
Windows is great but that artificial generation of not-needed
interrupts is avoidable.
There are probably some cases where you don't want this type of
behavior (broken hardware, legacy code with multiple-buffering,
disabled timer in PulseAudio), so I think it would make sense to
request the disabling of interrupts when hw_params are set, since this
is also the time when period sizes are set. I am aware that some
changes would be needed in pcm_lib.c, where all the error checks are
done. Takashi, Jaroslav, Lennart, what do you think?
Feedback and suggestions welcome.
Cheers
- Pierre
[-- Attachment #2: 0001-hda-remove-HDA-interrupts-when-buffer-is-processed.patch --]
[-- Type: application/octet-stream, Size: 2348 bytes --]
From 1edc402dc0a1f44117b910e4a42c5f6e6bc6b27f Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Date: Thu, 29 Apr 2010 17:00:59 -0500
Subject: [PATCH] [hda] remove HDA interrupts when buffer is processed
This patch assumes a timer is used to wake-up the system and refill buffers
(as PulseAudio does)
---
core/pcm_lib.c | 2 ++
pci/hda/hda_intel.c | 14 ++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/core/pcm_lib.c b/core/pcm_lib.c
index a2ff861..d1d5f77 100644
--- a/core/pcm_lib.c
+++ b/core/pcm_lib.c
@@ -420,6 +420,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size);
}
no_jiffies_check:
+#if 0 // skip when interrupts are not enabled
if (delta > runtime->period_size + runtime->period_size / 2) {
hw_ptr_error(substream,
"Lost interrupts? %s"
@@ -430,6 +431,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
(long)new_hw_ptr,
(long)old_hw_ptr);
}
+#endif
if (runtime->status->hw_ptr == new_hw_ptr)
return 0;
diff --git a/pci/hda/hda_intel.c b/pci/hda/hda_intel.c
index 8b6815d..c64106e 100644
--- a/pci/hda/hda_intel.c
+++ b/pci/hda/hda_intel.c
@@ -1158,6 +1158,11 @@ static int setup_bdle(struct snd_pcm_substream *substream,
{
u32 *bdl = *bdlp;
+#define NO_INTERRUPTS
+#ifdef NO_INTERRUPTS
+ snd_printk(KERN_ERR SFX "plb- setup_bdle: interrupts disabled\n");
+#endif
+
while (size > 0) {
dma_addr_t addr;
int chunk;
@@ -1176,7 +1181,13 @@ static int setup_bdle(struct snd_pcm_substream *substream,
* only when the whole fragment is processed
*/
size -= chunk;
+
+#ifdef NO_INTERRUPTS
+ bdl[3] = 0; /* no interrupts when buffer is processed */
+#else
bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01);
+#endif
+
bdl += 4;
azx_dev->frags++;
ofs += chunk;
@@ -1937,6 +1948,9 @@ static void azx_irq_pending_work(struct work_struct *work)
if (azx_position_ok(chip, azx_dev)) {
azx_dev->irq_pending = 0;
spin_unlock(&chip->reg_lock);
+#ifdef NO_INTERRUPTS
+ snd_printk(KERN_ERR SFX "plb- period elapsed: THIS SHOULD NOT HAPPEN \n");
+#endif
snd_pcm_period_elapsed(azx_dev->substream);
spin_lock(&chip->reg_lock);
} else
--
1.6.6.1
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next reply other threads:[~2010-04-29 22:38 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-29 22:38 pl bossart [this message]
2010-04-29 23:18 ` [RFC] disabling ALSA period interrupts Raymond Yau
[not found] ` <k2j6160a5131004291644rd8645dc7oecee28ee290b683f@mail.gmail.com>
2010-04-30 0:59 ` Raymond Yau
2010-04-30 1:09 ` Raymond Yau
2010-04-30 13:46 ` pl bossart
2010-04-30 22:51 ` Raymond Yau
2010-04-30 3:47 ` Raymond Yau
2010-04-30 11:24 ` Clemens Ladisch
2010-04-30 13:44 ` pl bossart
2010-05-06 1:24 ` Raymond Yau
2010-05-14 8:12 ` Takashi Iwai
2010-05-14 13:36 ` pl bossart
2010-05-14 21:03 ` pl bossart
2010-05-17 9:12 ` Clemens Ladisch
2010-05-17 9:14 ` [PATCH 1/3] add API to allow disabling " Clemens Ladisch
2010-05-17 9:23 ` Jassi Brar
2010-05-17 11:16 ` Clemens Ladisch
2010-05-17 11:27 ` Jassi Brar
2010-05-17 14:42 ` Jaroslav Kysela
2010-05-17 16:05 ` pl bossart
2010-05-17 16:22 ` Jaroslav Kysela
2010-05-17 16:37 ` pl bossart
2010-05-17 16:54 ` Jaroslav Kysela
2010-05-18 9:11 ` Jassi Brar
2010-05-17 13:59 ` pl bossart
2010-05-17 9:14 ` [PATCH 2/3] ALSA: hda-intel: add support for disabling period irq Clemens Ladisch
2010-05-17 14:05 ` pl bossart
2010-05-17 9:15 ` [PATCH 3/3] ALSA: oxygen: " Clemens Ladisch
2010-05-17 14:17 ` [RFC] disabling ALSA period interrupts pl bossart
2010-05-20 14:50 ` Clemens Ladisch
2010-04-30 16:44 ` Liam Girdwood
2010-04-30 17:39 ` pl bossart
2010-05-04 3:18 ` Raymond Yau
2010-05-07 23:25 ` [alsa-devel] " Lennart Poettering
2010-05-08 3:12 ` pl bossart
2010-05-12 4:00 ` pl bossart
2010-05-12 13:00 ` Jaroslav Kysela
2010-05-12 17:10 ` [alsa-devel] " pl bossart
2010-05-12 18:15 ` Jaroslav Kysela
2010-05-13 3:56 ` pl bossart
2010-05-12 7:22 ` James Courtier-Dutton
2010-05-12 12:42 ` pl bossart
2010-05-13 0:37 ` Raymond Yau
2010-05-14 0:43 ` Raymond Yau
2010-05-14 1:51 ` pl bossart
2010-05-14 2:45 ` Raymond Yau
2010-05-14 3:09 ` Raymond Yau
2010-05-14 4:03 ` Raymond Yau
2010-05-12 13:08 ` Jassi Brar
2010-05-12 13:50 ` [alsa-devel] " pl bossart
2010-05-12 14:15 ` Jassi Brar
2010-05-12 14:16 ` Mark Brown
2010-05-13 0:04 ` Raymond Yau
2010-05-14 4:07 ` Jassi Brar
2010-05-14 4:39 ` pl bossart
2010-05-14 5:27 ` Jassi Brar
2010-05-12 14:41 ` Raymond Yau
2010-05-13 7:27 ` Raymond Yau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=h2l6160a5131004291538w6c7891fbn2db3425846aefd60@mail.gmail.com \
--to=bossart.nospam@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=pulseaudio-discuss@mail.0pointer.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).