[alsa-devel] Backported sbxfi driver, possible fix

Takashi Iwai tiwai at suse.de
Sat Oct 25 18:05:17 CEST 2008


At Sat, 25 Oct 2008 15:06:52 +0200,
Thomas Scheunemann wrote:
> 
> I think I found a bug in the driver, which at least for me was
> responsible for the crashes with pulseaudio.
> 
> A little backstory:
> 
> I have a Fedora 8 System with an SB X-Fi installed and of course
> no sound. I didn't want to replace the entire ALSA driver, so I
> just took the files sbxfi.c and emu20k1-regs.h from the unstable
> sources, wrote a small spec-file and am now at a point where I
> can just "rpm -i" the driver as a dkms package and just modprobe
> the driver.
> 
> After that "speaker-test -D hw -c 2 -r 96000 -t sine" works just
> fine, but as soon as pulseaudio is started my System froze.
> 
> The bug I think I found is in the get_xfi_order function. As long
> as pages actually is a power of two it works correctly. But if
> pages isn't a power of two it should round up, but it rounds down.
> As a result I believe this screws up sbxfi_alloc_tlb_pages.
> 
> After a small modification to get_xfi_order:

Thanks for the patch.
Yeah, I found the very same problem in this morning, but I couldn't
update the repo and snapshot until now due to the server crash.

My solution is to use roundup_pow_of_two() instead of the own
funciton.  This should work better in general.

Anyway, I updated the repo (and rebased, sorry), updated the snapshot,
too.

thanks,

Takashi


> --- /tmp/sbxfi.c	2008-10-25 14:51:55.000000000 +0200
> +++ sbxfi.c	2008-10-25 14:03:48.000000000 +0200
> @@ -851,11 +851,12 @@
>  /* get the order of pages (power-of-two) */
>  static int get_xfi_order(unsigned int pages)
>  {
> -	int order = -1;
> -	do {
> +	int order = 0;
> +	pages--;
> +	while(pages){
>  		pages >>= 1;
>  		order++;
> -	} while (pages);
> +	}
>  	return order;
>  }
>  
> the driver started working with pulseaudio, it doesn't crash, and I
> even get sound though it still is a bit distorted.
> 


More information about the Alsa-devel mailing list