From: Giuliano Pochini Subject: busy-wait questions Date: Wed, 28 Apr 2004 23:09:36 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: <20040428230936.4e3e5fc5.pochini@shiny.it> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Alsa-devel List-Id: alsa-devel@alsa-project.org After a lot of cleanups and coding style changes, my driver still has some things that must be fixed properly. Busy-waits are one of those. The most used busy-waits have a timeout of 10ms and 100ms and they are called with a spinlock_irq held or from the irq handler. With my card the longest wait I measured was 190us, so I guess it's ok. But two functions, read_dsp() and write_dsp() have a timeout of 10s. They are used exclusively for loading the DSP firmware and the ASICs. They are very fast on my card, but other cards (the driver supports 8 cards) may be slower. I was thinking about calling the scheduler in case of a long wait, but two cards need to reload the ASICs in order to switch between S/PDIF and ADAT and one card also has to reload the ASICs when the sample rate crosses the 50KHz boundary. Since those operations are protected by a spinlock, it's not a great idea to call the scheduler. Any hint ? Perhaps we could just live with it, since the reload is not required very often... While looking for examples I noticed that all busy waits in the ens1370 driver have this form: for (t = 0; t < POLL_COUNT; t++) { if (inl(xxxx)) break; } IMHO it isn's correct because it waits for an amout of time that depends on the processor speed. -- Giuliano. ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click