Re: poor change in ncr53c8xx/linux-2.1.104

Paul Gortmaker (paul@rasty.ph.unimelb.edu.au)
Mon, 8 Jun 1998 17:50:13 +1000 (EST)


> Hi Mister X! if you want to maintain the ncr53c8xx driver by yourself,
> let me know. I do consider that sending directly patches to official
> guys without having submitted the change to the maintainer (at least
> for his information) to be act of rudeness.

The mdelay patch touched over 50 files, so looking up and e-mailing 50
different people was not really an option. No rudeness was intended
or implied. (The patch was also sent to linux-kernel@vger however)

> BTW, I do consider using several DIVISIONS when 1 COMPARISON is
> enough to be BAD PROGRAMMING, expecially when the code is intended
> to deal with a fiew MICRO-SECONDS.

If you are concerned with the accuracy of the smaller delays, then I
submit the following patch to you for your consideration.

With this patch, the smaller delays get translated directly into
"call __const_udelay", without any extra overhead of a "call DELAY"
function that in turn calls __udelay.

For sub-millisecond delays, [e.g. DELAY(100)] the executed code is:

Your Original This Patch
------------- ----------
pushl $100 pushl $429400
call DELAY call __const_udelay
pushl %ebx
movl 8(%esp),%ebx
cmpl $1000,%ebx
jle (taken)
testl %ebx,%ebx
je (not taken)
pushl %ebx
call __udelay
addl $4,%esp
popl %ebx
ret

where the code assoicated with the DELAY function is indented. The
above comparison also desn't include the fact that __udelay contains
about six movl+leal pairs that __const_udelay does not have.

So, if getting small delays without extra overhead is that important, then
this patch is even more efficient than the original (103 and earlier)
behaviour, and I trust you will agree after comparing the resulting
assembly.

Paul.

--- linux-21104/drivers/scsi/ncr53c8xx.c Sat Jun 6 18:12:52 1998
+++ linux/drivers/scsi/ncr53c8xx.c Mon Jun 8 15:36:17 1998
@@ -367,11 +367,13 @@
** Insert a delay in micro-seconds.
*/

-static void DELAY(long us)
-{
- if (us/1000) mdelay(us/1000);
- if (us%1000) udelay(us%1000);
-}
+#define DELAY(n) (\
+ (__builtin_constant_p(n) && (n)<=(MAX_UDELAY_MS*1000)) ? \
+ udelay(n) : \
+ ({unsigned long us=(n); \
+ for (; us>MAX_UDELAY_MS*1000; us-=MAX_UDELAY_MS*1000) \
+ mdelay(MAX_UDELAY_MS); \
+ if (us) udelay(us);}))

/*
** Internal data structure allocation.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu