Re: lib/iomap.c mmio_{in,out}s* vs. __raw_* accessors

From: Linus Torvalds
Date: Sat Nov 04 2006 - 18:55:09 EST




On Sun, 5 Nov 2006, Benjamin Herrenschmidt wrote:
>
> I'm tempted to remove those mmio_* things from iomap.c completely. I
> need to check who uses them, but in all cases, I don't see what they do
> in iomap.c, it's not their place.

I don't think you understand the point. The point is that a lot of the
tests for whether something is MMIO or PIO can be done _once_, instead of
doing it for every access.

> Versions that would transparently use MMIO or PIO would make sense.

No, they would be idiotic, because we already have those. If you want to
use MMIO or PIO transparently one access at a time, YOU SHOULD NOT USE THE
"STRING" VERSION. You should just use "ioread8()" or something like that.

That _is_ the single-access-does-MMIO-or-PIO-transparently function!

> A pure MMIO implementation doesn't, that has to be arch specific. It makes
> the generic iomap suddently non-portable in some ways.

Whaa? I really don't see what's wrong with the one that is in lib/iomap.c.
But if you want to do your own, go ahead and do so - the whole point of
lib/iomap.c is to be a library that can be used by architectures that can
use the generic functionality. It's all hidden behind
CONFIG_GENERIC_IOMAP.

In other words, this whole thread makes absolutely _zero_ sense. Either
you use those functions or you don't. Trying to change them would be
insane.

> So I think we need to make sure all archs grow readsb,sw,sl etc... and
> just have iomap use those for the "transparent" versions.

Again, totally insane. If you don't want to use GENERIC_IOMAP, don't. But
don't force other architectures to follow that path to insanity.

So, in short:
(a) if the generic library doesn't work for you, stop using it

(b) the whole _point_ of the "repeat" instructions is to avoid doing the
same tests over and over again for an iomem address that won't
change, so doing them in the individual accessor functions would be
_crazy_.

(c) if you want to add #IO barriers to that thing, again, do it _around_
the repeat string, not in the individual accesses. If you need them
on an individual access basis, you're probably better off doing your
own version altogether.

Please explain what is so wrong with the current setup, and please explain
why you'd want to break the obvious "check the address only once!" rule
that makes sense for _any_ architecture that has separate #PIO and #MMIO
address spaces.

Linus
-
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/