lkml.org 
[lkml]   [1999]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Specifying properly the PCI driver model on all linux architectur es, (ioremap(), bus_to_virt() ...)
From
Date
>>>>> "Patrick" == Patrick Lerda <LERDA@microprocess.com> writes:

Patrick> My goal is to specify a model to write properly a PCI drivers
Patrick> and to remove the junk on the actual drivers. ( Ex on
Patrick> matroxfb.c: if __power__pc use bus_to_virt() ..., if __i386__
Patrick> use ioremap() and so on)...

This goal is already achieved, if the PPC uses bus_to_virt() it is
doing it wrong. The correct way is to use ioremap(), however what
ioremap() returns what could be referred to as a _bus_ _virtual_
address. This one is not allowed to be accessed directly by the CPU
but must use the readl/writel macros, or __raw_readl/__raw_writel
ones.

The point is that you cannot access PCI memory before you have used
ioremap() to map it. Some architectures may allow this, however it is
improper use of the API. Once this is done you can use
bus_to_virt()/virt_to_bus() to convert between bus virtual and bus
'physical' addresses.

Patrick> Some functions are not defined properly: ioremap(void *,size)
Patrick> (2) Seems to take a ptr on the PCI bus memory (use
Patrick> base_address[] as argument)

This is correct for ioremap()

Patrick> (1), (2) A lot of drivers use ioremap() or bus_to_virt() to
Patrick> get the virtual memory pointer of the PCI memory space
Patrick> device. Using directly bus_to_virt() is not a good idea on
Patrick> some architecture the MMU page is not defined, and linux
Patrick> crash.

No it is not just a bad idea, it is wrong.

Patrick> Using ioremap() seems to be the good way, but a lot
Patrick> of drivers use the PCI bus memory as an argument to
Patrick> ioremap(). ioremap() seems to be a general function not
Patrick> limited to the allocation of PCI memory...

ioremap() as it is today is mainly for PCI memory, however it also
works on other busses that look similar to PCI.

Patrick> I think the good way will be to defined base_address[6],
Patrick> rom_address (1) to return the physical memory pointer. And
Patrick> to give to ioremap() the physical memory pointer.

Remember that the base_address[] value are not some that we just make
out of nowhere, they are assigned by the hardware/bios at boot time
and we read them out of registers.

Jes

-
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:54    [W:0.030 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site