Skip to contentSkip to conversation

virt_to_bus and virt_to_phys on Apple G4 target

DISCUSSION [email protected] 4 participants 4 messages Jul 3, 2001 – Jul 4, 2001

lore
Share & tools
lore
#0 lore raw

I am running linux 2.4.2 on Apple G4 machine. I think the 'PCI bus addresses' and 'physical addresses' are same on this architecture. I expected the two be different but according to asm/io.h 'virt_to_bus(addr) = virt_to_phys(addr) + PCI_DRAM_OFFSET'. I printed the value of 'PCI_DRAM_OFFSET' and that come out to be zero. Is this correct?

If I somehow get the physical address of a user space buffer in a module and take this as a PCI bus address, will I be able to do DMA properly?

thanks,
Daljeet.

#1 lore raw
Quoted 8 lines · [email protected] writes:

I am running linux 2.4.2 on Apple G4 machine. I think the 'PCI bus addresses' and 'physical addresses' are same on this architecture. I expected the two be different but according to asm/io.h 'virt_to_bus(addr) = virt_to_phys(addr) + PCI_DRAM_OFFSET'. I printed the value of 'PCI_DRAM_OFFSET' and that come out to be zero. Is this correct?

If I somehow get the physical address of a user space buffer in a module and take this as a PCI bus address, will I be able to do DMA properly?

virt_to_bus() and bus_to_virt() are deprecated interfaces and should not be used by anything new. See Documentation/DMA-mapping.txt for details.

Later,
David S. Miller
[email protected]

#2 lore raw
In reply to [email protected]
Quoted 2 lines · [email protected] writes:

I am running linux 2.4.2 on Apple G4 machine. I think the 'PCI bus addresses' and 'physical addresses' are same on this architecture. I

They are the same on an Apple G4 but not necessarily on other PowerPC machines. It depends on the PCI host bridge implementation.

Quoted 3 lines

expected the two be different but according to asm/io.h 'virt_to_bus(addr) = virt_to_phys(addr) + PCI_DRAM_OFFSET'. I printed the value of 'PCI_DRAM_OFFSET' and that come out to be zero. Is this correct?

Yes, for an Apple G4.

Quoted 2 lines

If I somehow get the physical address of a user space buffer in a module and take this as a PCI bus address, will I be able to do DMA properly?

Yes, on an Apple G4. If you use virt_to_bus then it should work on all PowerPC machines that I know of (that run 32-bit PPC/Linux). But as Dave points out, you should use the interfaces described in Documentation/DMA-mapping.txt instead if at all possible. It's quite possible that virt_to_bus will be removed during 2.5.x development.

Paul.

#3 lore raw
In reply to [email protected]
Quoted 8 lines · David S. Miller
Quoted 6 lines · [email protected] writes:

I am running linux 2.4.2 on Apple G4 machine. I think the 'PCI bus addresses' and 'physical addresses' are same on this architecture. I expected the two be different but according to asm/io.h 'virt_to_bus(addr) = virt_to_phys(addr) + PCI_DRAM_OFFSET'. I printed the value of 'PCI_DRAM_OFFSET' and that come out to be zero. Is this correct?

Quoted 6 lines
Quoted 2 lines

If I somehow get the physical address of a user space buffer in a module and take this as a PCI bus address, will I be able to do DMA properly?

virt_to_bus() and bus_to_virt() are deprecated interfaces and should not be used by anything new. See Documentation/DMA-mapping.txt for details.

What about non-PCI devices? The IBM 405GP on-chip ethernet controller is not PCI. It isn't in the standard kernel yet, but I am sure there are other things that do DMA that aren't PCI.