Re: ioremap(), bus_to_virt() and PCI devices on different Linux a

Peter Desnoyers (pjd@fred001.dynip.com)
Fri, 29 Oct 1999 10:49:08 -0400 (EDT)


[...]
> Take into account that dev->base_address[0] returns the PCI bus memory
> pointer.

When replying to this thread last night I had an insight which I think
will fix some of the problems I've been having, if it's correct.

I was being confused because there are two types of bus addresses, which
I (and maybe Patrick) had been confusing because they seem to be the same
thing sometimes. (i.e. they live in the same PCI address space)

Host memory bus addresses are used on the PCI bus by PCI devices to
initiate DMA to/from host memory. They may pass through something like
the sun IOMMU on the way into the machine to map 32-bit bus addresses
onto bigger (or just different) host memory physical addresses. You get
host-memory bus addresses from virt_to_bus().

Device bus addresses are used on the PCI bus by the CPU to initiate reads/
writes to the PCI device. They are interpreted directly by the device as
an offset from one of its base registers. (note that I'm ignoring I/O
spaces - whether memory mapped or i/o mapped - for this discussion, and
just worrying about PCI memory transactions)

The combination of PCI setup, ioremap() and readl/writel convert device
memory-space bus addresses into kernel virtual addresses which are
dereferenced to access the device. The address translation that occurs
here occurs in the outgoing direction, using some combination of readl/
writel and virtual memory mapping.

So I believe I've just convinced myself that it's completely illegal to
call bus_to_virt on device bus addresses, as the purpose of bus_to_virt
is to undo the IOMMU mapping, not to undo the ioremap mapping. Of course,
the fact that bus=phys on x86 makes it hard to test these theories...

............................................................................
Peter Desnoyers
162 Pleasant St. (617) 661-1979 pjd@fred.cambridge.ma.us
Cambridge, Mass. 02139 (978) 461-0402 (work) pjd@giga-net.com

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