From: Takashi Iwai <tiwai@suse.de>
To: David Miller <davem@davemloft.net>
Cc: bzolnier@gmail.com, sven.koehler@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: sound skipping regression introduced in 2.6.30-rc8
Date: Mon, 15 Jun 2009 11:58:13 +0200 [thread overview]
Message-ID: <s5htz2hes3u.wl%tiwai@suse.de> (raw)
In-Reply-To: <s5hy6rtesjo.wl%tiwai@suse.de>
At Mon, 15 Jun 2009 11:48:43 +0200,
I wrote:
>
> At Mon, 15 Jun 2009 02:25:47 -0700 (PDT),
> David Miller wrote:
> >
> > From: Takashi Iwai <tiwai@suse.de>
> > Date: Mon, 15 Jun 2009 10:39:50 +0200
> >
> > > If that patch also doesn't work, we need to track the position update
> > > sequence in more details.
> > > The patch below will dump the each position update (CAUTION: it can be
> > > long logs!). Please apply it instead of the previous one, run with
> > > xrun_debug=5 on 2.6.31 (or xrun_debug=1 on 2.6.30), and give the
> > > outputs around a skip occurs.
> >
> > The patch doesn't work.
> >
> > I put up a debugging log at:
> >
> > http://vger.kernel.org/~davem/asound.log
> >
> > there is a "PCM: hw_ptr skipping! ..." message near the end.
>
> Thanks! I see the problem now. It's a race in the update of the
> current buffer position. The counter was reset to the full fragment
> size, but its index still points the previous position. So, the
> driver was confused and put the position back.
>
> The below is a revised patch. It has an additional sanity check.
> Please give it a try.
Damn, that was buggy again. The fixed version is below.
Takashi
---
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 173bebf..8aa5687 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -356,8 +356,6 @@ struct ichdev {
unsigned int position;
unsigned int pos_shift;
unsigned int last_pos;
- unsigned long last_pos_jiffies;
- unsigned int jiffy_to_bytes;
int frags;
int lvi;
int lvi_frag;
@@ -844,7 +842,6 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
val = ICH_IOCE | ICH_STARTBM;
ichdev->last_pos = ichdev->position;
- ichdev->last_pos_jiffies = jiffies;
break;
case SNDRV_PCM_TRIGGER_SUSPEND:
ichdev->suspended = 1;
@@ -1048,7 +1045,6 @@ static int snd_intel8x0_pcm_prepare(struct snd_pcm_substream *substream)
ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1;
}
snd_intel8x0_setup_periods(chip, ichdev);
- ichdev->jiffy_to_bytes = (runtime->rate * 4 * ichdev->pos_shift) / HZ;
return 0;
}
@@ -1073,19 +1069,23 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs
ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
break;
} while (timeout--);
+ ptr = ichdev->last_pos;
if (ptr1 != 0) {
ptr1 <<= ichdev->pos_shift;
ptr = ichdev->fragsize1 - ptr1;
ptr += position;
- ichdev->last_pos = ptr;
- ichdev->last_pos_jiffies = jiffies;
- } else {
- ptr1 = jiffies - ichdev->last_pos_jiffies;
- if (ptr1)
- ptr1 -= 1;
- ptr = ichdev->last_pos + ptr1 * ichdev->jiffy_to_bytes;
- ptr %= ichdev->size;
+ if (ptr < ichdev->last_pos) {
+ unsigned int pos_base, last_base;
+ pos_base = position / ichdev->fragsize1;
+ last_base = ichdev->last_pos / ichdev->fragsize1;
+ /* another sanity check; ptr1 can go back to full
+ * before the base position is updated
+ */
+ if (pos_base == last_base)
+ ptr = ichdev->last_pos;
+ }
}
+ ichdev->last_pos = ptr;
spin_unlock(&chip->reg_lock);
if (ptr >= ichdev->size)
return 0;
next prev parent reply other threads:[~2009-06-15 9:58 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-10 18:28 David Miller
2009-06-10 19:37 ` Takashi Iwai
2009-06-11 11:28 ` David Miller
2009-06-11 12:02 ` David Miller
2009-06-11 13:32 ` Bartlomiej Zolnierkiewicz
2009-06-11 13:56 ` Takashi Iwai
2009-06-11 14:14 ` Bartlomiej Zolnierkiewicz
2009-06-11 14:23 ` Takashi Iwai
2009-06-11 15:40 ` Bartlomiej Zolnierkiewicz
2009-06-11 16:07 ` Takashi Iwai
2009-06-11 17:36 ` Bartlomiej Zolnierkiewicz
2009-06-11 14:02 ` Takashi Iwai
2009-06-10 19:37 ` Sven Köhler
2009-06-11 0:58 ` Takashi Iwai
2009-06-11 6:47 ` Sven Köhler
2009-06-11 8:18 ` Takashi Iwai
2009-06-11 21:38 ` Sven Köhler
2009-06-12 1:52 ` Takashi Iwai
2009-06-12 11:44 ` Bartlomiej Zolnierkiewicz
2009-06-15 8:30 ` Takashi Iwai
2009-06-15 8:39 ` Takashi Iwai
2009-06-15 9:25 ` David Miller
2009-06-15 9:48 ` Takashi Iwai
2009-06-15 9:58 ` Takashi Iwai [this message]
2009-06-15 10:11 ` David Miller
2009-06-15 10:26 ` Takashi Iwai
2009-06-15 18:25 ` Sven Köhler
2009-06-15 19:15 ` Bartlomiej Zolnierkiewicz
2009-06-15 10:09 ` David Miller
2009-06-15 9:18 ` David Miller
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=s5htz2hes3u.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=bzolnier@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sven.koehler@gmail.com \
/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
all inboxes | Powered by JetHome®