Drivers that don't reset TASK_{UN}INTERRUPTIBLE in loops

From: John Levon (levonj5@cs.man.ac.uk)
Date: Sat Sep 02 2000 - 12:19:13 EDT

  • Next message: Alan Cox: "Re: www.crucial.com won't talk to 2.4.0-test7 system"

    The drivers below loop, but don't set TASK_{UN}INTERRUPTIBLE each time ...

    thanks
    john

    --- drivers/char/drm/i810_dma.c Fri Aug 11 00:21:18 2000
    +++ drivers/char/drm/i810_dma.c.new Fri Sep 1 03:47:08 2000
    @@ -1068,7 +1068,6 @@
                        return;
             }
                   atomic_set(&dev_priv->flush_done, 0);
    - current->state = TASK_INTERRUPTIBLE;
                add_wait_queue(&dev_priv->flush_queue, &entry);
                end = jiffies + (HZ*3);
        
    @@ -1079,13 +1078,13 @@
                                DRM_ERROR("lockup\n");
                                break;
                     }
    + current->state = TASK_INTERRUPTIBLE;
                           schedule_timeout(HZ*3);
                           if (signal_pending(current)) {
                                break;
                     }
             }
        
    - current->state = TASK_RUNNING;
                remove_wait_queue(&dev_priv->flush_queue, &entry);
        
                return;
    --- drivers/char/ftape/lowlevel/ftape-io.c Wed Sep 22 20:12:53 1999
    +++ drivers/char/ftape/lowlevel/ftape-io.c.new Fri Sep 1 03:49:20 2000
    @@ -97,7 +97,6 @@
                     timeout = ticks;
                     save_flags(flags);
                     sti();
    - set_current_state(TASK_INTERRUPTIBLE);
                     do {
                             /* Mmm. Isn't current->blocked == 0xffffffff ?
                              */
    @@ -106,9 +105,9 @@
                                           "awoken by non-blocked signal :-(");
                                     break; /* exit on signal */
                             }
    - while (current->state != TASK_RUNNING) {
    - timeout = schedule_timeout(timeout);
    - }
    +
    + set_current_state(TASK_INTERRUPTIBLE);
    + timeout = schedule_timeout(timeout);
                     } while (timeout);
                     restore_flags(flags);
             }
    --- drivers/char/ftape/lowlevel/fdc-io.c Fri Dec 3 18:51:50 1999
    +++ drivers/char/ftape/lowlevel/fdc-io.c.new Fri Sep 1 03:56:35 2000
    @@ -386,7 +386,6 @@
     int fdc_interrupt_wait(unsigned int time)
     {
             DECLARE_WAITQUEUE(wait,current);
    - sigset_t old_sigmask;
             static int resetting = 0;
             long timeout;
     
    @@ -404,23 +403,12 @@
             /* timeout time will be up to USPT microseconds too long ! */
             timeout = (1000 * time + FT_USPT - 1) / FT_USPT;
     
    - spin_lock_irq(&current->sigmask_lock);
    - old_sigmask = current->blocked;
    - sigfillset(&current->blocked);
    - recalc_sigpending(current);
    - spin_unlock_irq(&current->sigmask_lock);
    -
    - current->state = TASK_INTERRUPTIBLE;
             add_wait_queue(&ftape_wait_intr, &wait);
    - while (!ft_interrupt_seen && (current->state == TASK_INTERRUPTIBLE)) {
    + while (!ft_interrupt_seen && timeout) {
    + current->state = TASK_UNINTERRUPTIBLE;
                     timeout = schedule_timeout(timeout);
             }
     
    - spin_lock_irq(&current->sigmask_lock);
    - current->blocked = old_sigmask;
    - recalc_sigpending(current);
    - spin_unlock_irq(&current->sigmask_lock);
    -
             remove_wait_queue(&ftape_wait_intr, &wait);
             /* the following IS necessary. True: as well
              * wake_up_interruptible() as the schedule() set TASK_RUNNING
    --- drivers/sound/cmpci.c Sat Aug 26 16:26:46 2000
    +++ drivers/sound/cmpci.c.new Fri Sep 1 03:58:33 2000
    @@ -1194,9 +1194,9 @@
     
             if (s->dma_dac.mapped || !s->dma_dac.ready)
                     return 0;
    - current->state = TASK_INTERRUPTIBLE;
             add_wait_queue(&s->dma_dac.wait, &wait);
             for (;;) {
    + current->state = TASK_INTERRUPTIBLE;
                     spin_lock_irqsave(&s->lock, flags);
                     count = s->dma_dac.count;
                     spin_unlock_irqrestore(&s->lock, flags);
    @@ -2031,9 +2031,9 @@
     
             lock_kernel();
             if (file->f_mode & FMODE_WRITE) {
    - __set_current_state(TASK_INTERRUPTIBLE);
                     add_wait_queue(&s->midi.owait, &wait);
                     for (;;) {
    + __set_current_state(TASK_INTERRUPTIBLE);
                             spin_lock_irqsave(&s->lock, flags);
                             count = s->midi.ocnt;
                             spin_unlock_irqrestore(&s->lock, flags);
    --- drivers/sound/maestro.c Sat Aug 26 16:26:50 2000
    +++ drivers/sound/maestro.c.new Fri Sep 1 03:59:56 2000
    @@ -2122,9 +2122,9 @@
     
             if (s->dma_dac.mapped || !s->dma_dac.ready)
                     return 0;
    - current->state = TASK_INTERRUPTIBLE;
             add_wait_queue(&s->dma_dac.wait, &wait);
             for (;;) {
    + current->state = TASK_INTERRUPTIBLE;
                     /* XXX uhm.. questionable locking*/
                     spin_lock_irqsave(&s->lock, flags);
                     count = s->dma_dac.count;
    @@ -2140,8 +2140,6 @@
                     }
                     tmo = (count * HZ) / s->ratedac;
                     tmo >>= sample_shift[(s->fmt >> ESS_DAC_SHIFT) & ESS_FMT_MASK];
    - /* XXX this is just broken. someone is waking us up alot, or schedule_timeout is broken.
    - or something. who cares. - zach */
                     if (!schedule_timeout(tmo ? tmo : 1) && tmo)
                             M_printk(KERN_DEBUG "maestro: dma timed out?? %ld\n",jiffies);
             }
    --- drivers/isdn/isdnloop/isdnloop.c Wed Nov 17 18:50:29 1999
    +++ drivers/isdn/isdnloop/isdnloop.c.new Fri Sep 1 04:03:34 2000
    @@ -1196,8 +1196,10 @@
                                                     if (!card->leased) {
                                                             card->leased = 1;
                                                             while (card->ptype == ISDN_PTYPE_UNKNOWN) {
    + set_current_state(TASK_UNINTERRUPTIBLE);
                                                                     schedule_timeout(10);
                                                             }
    + set_current_state(TASK_UNINTERRUPTIBLE);
                                                             schedule_timeout(10);
                                                             sprintf(cbuf, "00;FV2ON\n01;EAZ1\n02;EAZ2\n");
                                                             i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card);
    --- drivers/usb/devio.c Sat Aug 26 16:26:55 2000
    +++ drivers/usb/devio.c.new Fri Sep 1 04:04:43 2000
    @@ -84,10 +84,10 @@
             add_wait_queue(&s.wait, &wait);
             urb->context = &s;
             urb->complete = sync_completed;
    - set_current_state(TASK_INTERRUPTIBLE);
             if ((ret = usb_submit_urb(urb)))
                     goto out;
             while (urb->status == -EINPROGRESS) {
    + set_current_state(TASK_INTERRUPTIBLE);
                     tmdiff = tm - jiffies;
                     if (tmdiff <= 0) {
                             ret = -ETIMEDOUT;
    --- drivers/usb/usb.c Sat Aug 26 16:26:58 2000
    +++ drivers/usb/usb.c.new Fri Sep 1 04:10:47 2000
    @@ -865,7 +865,6 @@
             awd.wakeup = &wqh;
             awd.handler = 0;
             init_waitqueue_head(&wqh);
    - current->state = TASK_INTERRUPTIBLE;
             add_wait_queue(&wqh, &wait);
             urb->context = &awd;
             status = usb_submit_urb(urb);
    @@ -877,8 +876,10 @@
             }
     
             if (urb->status == -EINPROGRESS) {
    - while (timeout && urb->status == -EINPROGRESS)
    + while (timeout && urb->status == -EINPROGRESS) {
    + current->state = TASK_UNINTERRUPTIBLE;
                             status = timeout = schedule_timeout(timeout);
    + }
             } else
                     status = 1;
     

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    Please read the FAQ at http://www.tux.org/lkml/



    This archive was generated by hypermail 2b29 : Sat Sep 02 2000 - 12:20:35 EDT