aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2012-05-04 05:05:55 -0400
committerTakashi Iwai <tiwai@suse.de>2012-05-09 04:22:06 -0400
commit32cf4023e689ad5b3a81a749d8cc99d7f184cb99 (patch)
tree28090820b11f20776b4c12ff6c9fb1cf2eedee93 /sound
parent619a341b78f17fb86d92e89c04612676cd05e26f (diff)
ALSA: HDA: Lessen CPU usage when waiting for chip to respond
When an IRQ for some reason gets lost, we wait up to a second using udelay, which is CPU intensive. This patch improves the situation by waiting about 30 ms in the CPU intensive mode, then stepping down to using msleep(2) instead. In essence, we trade some granularity in exchange for less CPU consumption when the waiting time is a bit longer. As a result, PulseAudio should no longer be killed by the kernel for taking up to much RT-prio CPU time. At least not for *this* reason. Signed-off-by: David Henningsson <david.henningsson@canonical.com> Tested-by: Arun Raghavan <arun.raghavan@collabora.co.uk> Cc: <stable@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/hda_intel.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 6e958bf94191..1f350522bed4 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -783,11 +783,13 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
783{ 783{
784 struct azx *chip = bus->private_data; 784 struct azx *chip = bus->private_data;
785 unsigned long timeout; 785 unsigned long timeout;
786 unsigned long loopcounter;
786 int do_poll = 0; 787 int do_poll = 0;
787 788
788 again: 789 again:
789 timeout = jiffies + msecs_to_jiffies(1000); 790 timeout = jiffies + msecs_to_jiffies(1000);
790 for (;;) { 791
792 for (loopcounter = 0;; loopcounter++) {
791 if (chip->polling_mode || do_poll) { 793 if (chip->polling_mode || do_poll) {
792 spin_lock_irq(&chip->reg_lock); 794 spin_lock_irq(&chip->reg_lock);
793 azx_update_rirb(chip); 795 azx_update_rirb(chip);
@@ -803,7 +805,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
803 } 805 }
804 if (time_after(jiffies, timeout)) 806 if (time_after(jiffies, timeout))
805 break; 807 break;
806 if (bus->needs_damn_long_delay) 808 if (bus->needs_damn_long_delay || loopcounter > 3000)
807 msleep(2); /* temporary workaround */ 809 msleep(2); /* temporary workaround */
808 else { 810 else {
809 udelay(10); 811 udelay(10);