lkml.org 
[lkml]   [1998]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Accessing MMIO PCI space - crossplatform
On Thu, Nov 12, 1998 at 06:59:02PM +0000, Petr Vandrovec Ing. VTEI wrote:
> a) every driver should be fixed to use ioremap

I agree.

> b) readl/writel should not do anything with address

I agree, and also address should be an ioaddr_t abstraction. (You can't
use it for anything else).

> c) virt_to_phys and virt_to_bus should walk through pagetables instead
> of anding/oring with something with something

With care.

- They should not walk pagetables when given a non-module
kernel virtual address because of 4M pages on i386, and because it's a
fast and easy thing to check.

- With pagetable walking, you can no longer assume

virt_to_bus(addr+N) == virt_to_bus(addr)+N.

virt_to_phys is only useful for MMU manipulation, so maybe it shouldn't
be exported outside the MMU manipulation code (mostly in mm/memory.c).

virt_to_bus would still need to call the (hidden) virt_to_phys.

> (after this change, you can do DMA I/O directly to/from userspace
> much easier)

Funny you should mention it, I'm writing a /dev/userdma driver to aid
with this right now.

> d) phys_to_virt, bus_to_virt should be removed, it cannot be done
> in linear time (I'm not aware of such solution (on ia32)) and
> ioremap is already here and should be used instead of this one-time
> translation) (or explicitly say that for shared (adaptor) memory
> it cannot be used)

I agree completely.

Remove phys_to_virt: it does not make sense.

bus_to_virt isn't required if all drivers use ioremap, which is actually
equivalent to bus_to_virt for most device addresses anyway.

> e) that means:
> 1) clear readl/writel interface that passed address must
> be obtained from ioremap (so first example fro IO-mapping.txt -
> - readl(0xC0000) - is wrong). On ia32, ioremap can return
> virtual address and readl/writel are simple reading/writting (no
> playing with PAGE_OFFSET), on alpha, ioremap can return bus
> address and readl/writel are complicated function as they are
> now.

I suggest an ioaddr_t abstraction. Then whatever representation is best
can be used, and it will help us find the places in drivers that need
changing.

> f) it must be done before 2.2, because of otherwise it is not possible
> to have more than 1.8 GB of memory in an Intel box (you can have
> it... but you cannot use it as system memory) (I know that no one
> real user uses ia32 this time, but there are such)

No way. 2.2 must be released this year!

2GB+ is not _that_ important that it's worth delaying the other X million
users.

The changes you are proposing will affect almost all the source files
(drivers) and take ages to do and debug.

A relatively simple change that may make it work, if you stick to known
ok drivers, is +PAGE_OFFSET instead of |PAGE_OFFSET where that is
written. (And its inverse). That can't go into the mainstream kernel
yet though because it will break some drivers even with <2GB.

Don't worry about not squeezing in your most desired feature at this
stage. Get into the habit of helping releases out the door, so that 2.4
won't take too long and will have your favourite features.

It's only fear that the 2.3 cycle will be as long as the 2.1 cycle
that's making people beg for stuff in 2.2.

> So unless someone has more correct solution (please, please), I have to use
> #ifdef __alpha__
> #define mga_readl(x) readl(x)
> #else
> #define mga_readl(x) (*(volatile u_int32_t*)(x))
> #endif
> But I do not want to have this crappy code in my driver because of I think
> that it should not be there (I've found only four #ifdef __alpha__ in
> drivers subtree of kernel, so I think that it is not right way to go).

The PPC case is the anomaly isn't it? readl() should work fine on most
things.

You could check for PPC and include a #warning, so it will get fixed
when it is possible as well as getting the PPC folks to think about the
issue.

> P.S.: I cannot believe to (3f), so I'm probably wrong... But I'm searching
> solution for more than week and I still have nothing.

Try my suggestion (+PAGE_OFFSET, -PAGE_OFFSET instead of |PAGE_OFFSET
and &~PAGE_OFFSET). A few people have noted it. Note that some drivers
that work with <2GB will break.

> P.P.S.: For Dave and/or Jakub (and others): On __sparc__, __sparc64__
> (one PCI sparc is probably coming here next year) and other non-listed
> ports (__m68k__), what is better, safe and working -
> (*(volatile u_int32_t*)(x)) or readl(x) ?

Use readl() until told otherwise, because that's documented. Or refuse
to compile (#error) except on architectures you know about if you're paranoid.

> P.P.P.P.S.: It (IO-mapping.txt) is a bit outdated, isn't it?
> unsigned long signature = *(unsigned int*)0xC0000;
> (at the end of doc) never worked in 2.1, isn't it?

Yes it's outdated. An earlier may be bogus given later comments about
needing to use readl() -- it's not made clear if the mailbox is in main
memory or device memory:

/* get the address from the controller */
retbuffer = bus_to_virt(mbox.bufstart);
switch (retbuffer[0]) {
case STATUS_OK:

-- Jamie

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

\
 
 \ /
  Last update: 2005-03-22 13:45    [W:0.050 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site