From: Takashi Iwai Subject: Re: Backported sbxfi driver, possible fix Date: Sat, 25 Oct 2008 18:05:17 +0200 Message-ID: References: <4900A4FA.7020300@jasonline.co.uk> <4900B523.3020801@jasonline.co.uk> <4900DBBD.2020806@jasonline.co.uk> <49017FBF.4030005@jasonline.co.uk> <20081025130652.GA27621@rzle423.uni-duisburg.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (ns.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 9C94724467 for ; Sat, 25 Oct 2008 18:05:35 +0200 (CEST) In-Reply-To: <20081025130652.GA27621@rzle423.uni-duisburg.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Thomas Scheunemann Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org 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. >