From: Takashi Iwai Subject: Re: [PATCH] Reduce interrupt latency in sound/pci/via82xx.c Date: Mon, 12 Sep 2005 14:35:17 +0200 Message-ID: References: <200509121418.05184.annabellesgarden@yahoo.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <200509121418.05184.annabellesgarden@yahoo.de> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Karsten Wiese Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Mon, 12 Sep 2005 14:18:04 +0200, Karsten Wiese wrote: > > From: Karsten Wiese > > > Reduce interrupt latency in sound/pci/via82xx.c > > > The change only affects the via823x kind of chips. > Here the via8233_pcm_pointer_hw() function > (named snd_via8233_pcm_pointer() before) > needs to loop until a non zero position is red from the chip. > > Measurements have shown that more than 200 loops are typically needed on > an Athlon64. > As io-reads cost many cycles, those loops sum up huge. > via8233_pcm_pointer_hw() runs either in interrupt or with interrupts > disabled. So it introduces significant interrupt latency. > > The patch introduces a calculated position value hwptr_done, > that is updated by the interrupt routine when a period is completed. > This works much faster at the cost of less precise positions. > Position precision is period_size, which is ok for nearly all applications. > > The actual method chosen depends on the period_size used and its > relation to the module parameter hw_position[]: > if (period_size >= hw_position[device_index])) > Use chip based precise position calculation > else > Use fast coarse position calculation > > > Signed-off-by: Karsten Wiese I don't like that the behavior depends on the period size. If it's bad to loop too much, we should fix this behavior. The question is how to handle the value 0 of CUR_COUNT register. Usually this occurs in a boundary, i.e. very likely only in snd_pcm_period_elapsed(). So, for example, add a flag indicating that the position callback is being called in the irq handler. And the position callback assumes the exact next period if CUR_COUNT is 0 and this flag is set. If the flag isn't set, the driver loops probing to get an accurate position. Takashi ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf