Skip to contentSkip to conversation

ioremap() question

DISCUSSION Oliver Korpilla 2 participants 4 messages May 26, 2004 – May 27, 2004

lore
Share & tools
lore
#0 lore raw

Hello!

I start with a CPU physical address somwhere within the PCI bridge space: 0x85000000 Then I use ioremap_nocache on it to obtain a (range of) virtual address(es):
0xC302D000
And then I use virt_to_bus() to obtain an address to hand over to the PCI device:
0x0302D000

While I do see this conforms to the implementation of virt_to_bus(), I cannot decide whether this makes sense.

Is ioremap() fixed, so it always returns the same virtual addresses for the same given physical ones?

Or does it return "what's available" in virtual address space (so the above bus address would be somehow bogus I guess)?

Would a function like phys_to_bus() give me the same result?

Thanks in advance,
Oliver Korpilla

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

#1 lore raw
Quoted 10 lines · Oliver Korpilla

Hello!

I start with a CPU physical address somwhere within the PCI bridge space:
0x85000000
Then I use ioremap_nocache on it to obtain a (range of) virtual address(es):
0xC302D000
And then I use virt_to_bus() to obtain an address to hand over to the PCI device:
0x0302D000

You cannot use virt_to_bus() on ioremap returned addresses.

Eugene.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

#2 lore raw
Quoted 7 lines · Eugene Surovegin

On Wed, May 26, 2004 at 04:35:19PM +0200, Oliver Korpilla wrote:

You cannot use virt_to_bus() on ioremap returned addresses.

Thanks! Do I need something like phys_to_bus() instead?

With kind regards,
Oliver Korpilla

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

#3 lore raw
In reply to Eugene Surovegin
Quoted 6 lines · Eugene Surovegin

You cannot use virt_to_bus() on ioremap returned addresses.

Eugene.

Hello!

Maybe I may go like this:

I know my PCI from the device bus, so:

unsigned long bus_address;
struct pci_bus *my_bus = universe_pci_dev->bus; bus_address = pci_phys_to_bus(physical_address, my_bus->number);

Since pci_phys_to_bus() is an exported symbol, this should work in my module, shouldn't it?

Thanks in advance,
Oliver Korpilla

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/