Re: [PATCH] lp.c, eexpress.c jiffies cleanup

Andreas Dilger (adilger@turbolabs.com)
Tue, 6 Nov 2001 14:15:21 -0700


On Nov 06, 2001 21:04 +0100, Tim Schmielau wrote:
> In eexpress.c I also turned absolute jiffies number into multiples of HZ,
> yet the resulting timeout values still do not always seem reasonable to
> me.

I agree. It seems very ugly. I looked at a few drivers which loop 1 or 2
jiffies, but to busy-loop for 1/10th of a second, or even 20 seconds
is terribly bad. I took a look at the functions scb_rdcmd() and
scb_status() and they are only reading from an I/O port, so no chance
of sleeping/blocking, just busy waiting.

> - unsigned long int oldtime = jiffies;
> - while (scb_rdcmd(dev) && ((jiffies-oldtime)<10));
> + unsigned long timeout = jiffies + HZ/10;
> + while (scb_rdcmd(dev) && (time_before(jiffies, timeout)));
> if (scb_rdcmd(dev)) {
> printk("%s: command didn't clear\n", dev->name);
> }
> @@ -1598,16 +1598,16 @@
> #endif
> - oj = jiffies;
> + timeout = jiffies + 20*HZ;
> while ((SCB_CUstat(scb_status(dev)) == 2) &&
> - ((jiffies-oj) < 2000));
> + time_before(jiffies, timeout));
> if (SCB_CUstat(scb_status(dev)) == 2)
> printk("%s: warning, CU didn't stop\n", dev->name);
> lp->started &= ~(STARTED_CU);

Cheers, Andreas

--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

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