Re: When to use ioremap?

Stephen C. Tweedie (sct@redhat.com)
Mon, 26 Apr 1999 18:30:43 +0100 (BST)


Hi,

On Sat, 24 Apr 1999 20:10:11 -0400 (EDT), Jeff Garzik
<jgarzik@pobox.com> said:

> Fresh from reading linux/Documentation/IO-mapping.txt (written by
> Linus), I have a couple dumb questions that hopefully someone will
> answer:

> IO-mapping.txt describes reading from I/O space like
> unsigned value = readl(0xc0000);
> but it describes writing with ioremap().

> Why does reading not require ioremap, while writing does?

It doesn't. The main difference between those two examples is that one
shows accessing ISA memory (ie. the memory region between 640K and 1MB
on a PC), and the other is accessing PCI memory. PCI requires ioremap.
ISA doesn't (for now --- this is likely to change).

> And the file seems to imply that read/write[bwl] should be the sole way
> to address I/O memory.

Yes.

> Why, then, does drivers/video/matroxfb.c have code for the case where
> READx_WORKS is not true? Is this simply a performance optimization, or
> a real requirement?

Good question. If you look at linux/include/asm-i386/io.h, you'll see
that readb etc. perform a __io_virt() on the address, which
essentially forces the address into the kernel's virtual address mapping
region. The only reason for this is so that you can use both ISA
addresses and kernel virtual addresses safely inside read*/write*(). As
the result of an ioremap() is guaranteed to be in the kernel VA already,
readb() should be identical to a direct lookup of the memory address,
and there should be no need to special-case it out.

--Stephen

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