From: Takashi Iwai Subject: Re: [PATCH] sscape: fix incorrect timeout after microcode upload Date: Mon, 12 Jan 2009 18:01:15 +0100 Message-ID: References: <20090112175416.482cdc60.krzysztof.h1@poczta.fm> 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 (mx1.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id BEE1B1037EC for ; Mon, 12 Jan 2009 18:01:15 +0100 (CET) In-Reply-To: <20090112175416.482cdc60.krzysztof.h1@poczta.fm> 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: Krzysztof Helt Cc: Theodore Allen , Alsa-devel , Rene Herman List-Id: alsa-devel@alsa-project.org At Mon, 12 Jan 2009 17:54:16 +0100, Krzysztof Helt wrote: > > From: Krzysztof Helt > > A comment states that one should wait up to 5 secs > while a waiting loop waits only 5 system ticks. > > Signed-off-by: Krzysztof Helt > --- > Ted tested that patch and it allowed him uploading > a microcode into the Soundscape Elite. However, > midi does not work for him yet. > > sound/isa/sscape.c | 20 ++++++++++---------- > 1 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c > index bc44916..347a880 100644 > --- a/sound/isa/sscape.c > +++ b/sound/isa/sscape.c > @@ -393,19 +393,19 @@ static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned ti > */ > static int obp_startup_ack(struct soundscape *s, unsigned timeout) > { > - while (timeout != 0) { > + unsigned long end_time = jiffies + msecs_to_jiffies(timeout); > + > + while (time_before(jiffies, end_time)) { In general it's better to use a do-while for the time-out check. That is, the timeout should be checked after the data check. Could you fix and repost? thanks, Takashi > unsigned long flags; > unsigned char x; > > - schedule_timeout_uninterruptible(1); > - > spin_lock_irqsave(&s->lock, flags); > x = inb(HOST_DATA_IO(s->io_base)); > spin_unlock_irqrestore(&s->lock, flags); > if ((x & 0xfe) == 0xfe) > return 1; > > - --timeout; > + msleep(10); > } /* while */ > > return 0; > @@ -420,19 +420,19 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout) > */ > static int host_startup_ack(struct soundscape *s, unsigned timeout) > { > - while (timeout != 0) { > + unsigned long end_time = jiffies + msecs_to_jiffies(timeout); > + > + while (time_before(jiffies, end_time)) { > unsigned long flags; > unsigned char x; > > - schedule_timeout_uninterruptible(1); > - > spin_lock_irqsave(&s->lock, flags); > x = inb(HOST_DATA_IO(s->io_base)); > spin_unlock_irqrestore(&s->lock, flags); > if (x == 0xfe) > return 1; > > - --timeout; > + msleep(10); > } /* while */ > > return 0; > @@ -529,10 +529,10 @@ static int upload_dma_data(struct soundscape *s, > * give it 5 seconds (max) ... > */ > ret = 0; > - if (!obp_startup_ack(s, 5)) { > + if (!obp_startup_ack(s, 5000)) { > snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n"); > ret = -EAGAIN; > - } else if (!host_startup_ack(s, 5)) { > + } else if (!host_startup_ack(s, 5000)) { > snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); > ret = -EAGAIN; > } > -- > 1.5.2.2 > > > ----------------------------------------------------------------------- > Promocja w Speak Up. Kwartal angielskiego za darmo. > 3 miesiace nauki gratis. Sprawdz teraz! >> http://link.interia.pl/f2019 >