Re: [PATCH] deinline sleep/delay functions

From: Denis Vlasenko
Date: Thu Jun 30 2005 - 07:22:37 EST


On Thursday 30 June 2005 15:04, Russell King wrote:
> On Thu, Jun 30, 2005 at 02:44:51PM +0300, Denis Vlasenko wrote:
> > On Thursday 30 June 2005 14:21, Russell King wrote:
> > > The maximum delay is dependent on the architecture implementation,
> > > and it depends on bogomips. There is no one single value for it.
> > > Architectures have to decide this from the way that they do the
> > > math and the expected range of bogomips.
> >
> > In example I posted these limitations are lifted. Granted these
> > limitations were not critical, but removing them can't do harm,
> > I guess?
>
> They're lifted poorly. You include a mandatory division in the path.
> On systems where division has to be done in code, this is not acceptable,
> especially when we're trying to get short delays on embedded CPUs
> running below 100MHz. The time it takes to do the division could
> swamp the required delay value.

What divisions? Where?

void udelay(unsigned int usecs)
{
        unsigned int k = usecs/1024;
        while (k--)
                __udelay(1024);
        __udelay(usecs % 1024);
}

I see no divisions. I see shifts and ANDs.
I can code them explicitly:

void udelay(unsigned int usecs)
{
        unsigned int k = usecs >> 10; /* divide by 1024 */
        while (k--)
                __udelay(0x400); /* 1024 */
        __udelay(usecs & 0x3ff); /* mod 1024 */
}

Should be ok now.
--
vda

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