Re: Memory mapped IO vs Port IO

Jamie Lokier
2003-09-12T16:23:41Z

Anthony Dominic Truong wrote:
> Wouldn't it be better if we set the IN and OUT function pointers to the
> right functions during driver init. based on the setting of dev->mmio.
> And throughout the driver, we just call the IN and OUT functions by
> their pointers. Then we don't have to do if (dev->mmio) every time.
> It's similar to the concept of virtual member function in C++.

I think it would be faster to hide the "if (mmio)" part into an
inline function which calls one or the other, given a resource cookie.

Branch prediction will remove most of the cost of a conditional test,
which is always the same in these drivers after all, but I don't think
it's quite so good at predicting indirect function calls.

-- Jamie