* via82xx calc_linear_pos bug
@ 2004-07-23 15:47 Timo Hirvonen
2004-07-27 13:39 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Timo Hirvonen @ 2004-07-23 15:47 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
After playing about 10-20 seconds snd_pcm_status_get_avail returns too
large value (1972895704, 1972895664 ..).
Tested kernels:
2.6.7-mm1 works
2.6.7-mm2 broken
2.6.8-rc1-mm1 broken
lspci -v
0000:00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235 AC97 Audio Controller (rev 50)
Subsystem: VIA Technologies, Inc.: Unknown device 4161
Flags: medium devsel, IRQ 22
I/O ports at e800
Capabilities: [c0] Power Management version 2
Attached patch (against 2.6.8-rc1-mm1) changes calc_linear_pos to the
state it was in 2.6.7-mm1.
I don't understand the code so this might not be right solution to this
problem but it seems to work.
[-- Attachment #2: via82xx-calc_linear_pos.patch --]
[-- Type: text/x-patch, Size: 630 bytes --]
--- sound/pci/via82xx.c.orig 2004-07-23 16:16:23.000000000 +0300
+++ sound/pci/via82xx.c 2004-07-23 16:16:40.000000000 +0300
@@ -715,11 +715,7 @@ static inline unsigned int calc_linear_p
unsigned int size, res;
size = viadev->idx_table[idx].size;
- /* FIXME: is this always true? */
- if (count)
- res = viadev->idx_table[idx].offset + size - count;
- else
- res = viadev->idx_table[idx].offset;
+ res = viadev->idx_table[idx].offset + size - count;
/* check the validity of the calculated position */
if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: via82xx calc_linear_pos bug
2004-07-23 15:47 via82xx calc_linear_pos bug Timo Hirvonen
@ 2004-07-27 13:39 ` Takashi Iwai
2004-07-27 14:53 ` Timo Hirvonen
0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2004-07-27 13:39 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 348 bytes --]
At Fri, 23 Jul 2004 18:47:30 +0300,
Timo Hirvonen wrote:
>
> After playing about 10-20 seconds snd_pcm_status_get_avail returns too
> large value (1972895704, 1972895664 ..).
Grrr, the empire strikes again.
The change in the recent version was a workaround to fix the similar
bug on many buggy mobos.
Could you try the attached patch?
Takashi
[-- Attachment #2: Type: text/plain, Size: 2389 bytes --]
Index: alsa-kernel/pci/via82xx.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v
retrieving revision 1.122
diff -u -r1.122 via82xx.c
--- alsa-kernel/pci/via82xx.c 15 Jul 2004 14:55:29 -0000 1.122
+++ alsa-kernel/pci/via82xx.c 27 Jul 2004 13:37:25 -0000
@@ -707,29 +707,36 @@
/*
* calculate the linear position at the given sg-buffer index and the rest count
*/
+
+#define check_invalid_pos(viadev,pos) \
+ ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))
+
static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count)
{
unsigned int size, res;
size = viadev->idx_table[idx].size;
- /* FIXME: is this always true? */
- if (count)
- res = viadev->idx_table[idx].offset + size - count;
- else
- res = viadev->idx_table[idx].offset;
+ res = viadev->idx_table[idx].offset + size - count;
/* check the validity of the calculated position */
- if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) {
+ if (size < count) {
+ snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", (int)size, (int)count);
+ res = viadev->lastpos;
+ } else if (check_invalid_pos(viadev, res)) {
#ifdef POINTER_DEBUG
printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count);
#endif
- /* count register returns full size when end of buffer is reached */
- if (size != count) {
+ if (count && size < count) {
snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n");
res = viadev->lastpos;
} else {
- res = viadev->idx_table[idx].offset + size;
- if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) {
+ if (! count)
+ /* bogus count 0 on the DMA boundary? */
+ res = viadev->idx_table[idx].offset;
+ else
+ /* count register returns full size when end of buffer is reached */
+ res = viadev->idx_table[idx].offset + size;
+ if (check_invalid_pos(viadev, res)) {
snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n");
res = viadev->lastpos;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: via82xx calc_linear_pos bug
2004-07-27 13:39 ` Takashi Iwai
@ 2004-07-27 14:53 ` Timo Hirvonen
2004-07-27 15:42 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Timo Hirvonen @ 2004-07-27 14:53 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
On Tue, 2004-07-27 at 15:39 +0200, Takashi Iwai wrote:
> At Fri, 23 Jul 2004 18:47:30 +0300,
> Timo Hirvonen wrote:
> >
> > After playing about 10-20 seconds snd_pcm_status_get_avail returns too
> > large value (1972895704, 1972895664 ..).
>
> Grrr, the empire strikes again.
>
> The change in the recent version was a workaround to fix the similar
> bug on many buggy mobos.
> Could you try the attached patch?
That patch works. snd_pcm_status_get_avail returns now sane values
again. I don't see any "invalid via82xx_cur_ptr" messages so the code
seems to be correct now.
thanks
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: via82xx calc_linear_pos bug
2004-07-27 14:53 ` Timo Hirvonen
@ 2004-07-27 15:42 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2004-07-27 15:42 UTC (permalink / raw)
To: Timo Hirvonen; +Cc: alsa-devel
At Tue, 27 Jul 2004 17:53:37 +0300,
Timo Hirvonen wrote:
>
> On Tue, 2004-07-27 at 15:39 +0200, Takashi Iwai wrote:
> > At Fri, 23 Jul 2004 18:47:30 +0300,
> > Timo Hirvonen wrote:
> > >
> > > After playing about 10-20 seconds snd_pcm_status_get_avail returns too
> > > large value (1972895704, 1972895664 ..).
> >
> > Grrr, the empire strikes again.
> >
> > The change in the recent version was a workaround to fix the similar
> > bug on many buggy mobos.
> > Could you try the attached patch?
>
> That patch works. snd_pcm_status_get_avail returns now sane values
> again. I don't see any "invalid via82xx_cur_ptr" messages so the code
> seems to be correct now.
Ok, I applied the patch to cvs.
thanks for testing.
Takashi
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-07-27 15:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-23 15:47 via82xx calc_linear_pos bug Timo Hirvonen
2004-07-27 13:39 ` Takashi Iwai
2004-07-27 14:53 ` Timo Hirvonen
2004-07-27 15:42 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.