On Wed, Feb 12, 2014 at 06:10:15PM +0000, Will Deacon wrote: > > AFAIK, the job is fairly simple, when you call pci_add_resource_offset > > for memory compute the offset from > > of_pci_range.pci_addr - of_pci_range.cpu_addr > > > > (or is it the other way around ?) > > I think it's the other way round: bus = cpu - offset, then Arnd's example of > PCI bus 0 works out as: 0 = cpu - pci->mem_start. That looks right to me > I added that to my driver, but I get some weird looking bus addresses in > dmesg: > > [ 0.307585] pci-arm-generic 40000000.pci: PCI host bridge to bus 0000:00 > [ 0.307601] pci_bus 0000:00: root bus resource [io 0x0000-0xffff] > [ 0.307615] pci_bus 0000:00: root bus resource [mem 0x00000000-0x3effffff] (bus address [0xffffffffbf000000-0xfffffffffdffffff]) > > Looking at drivers/pci/probe.c, it seems to think that res->start - offset > gives a bus address, which implies that the resources are indeed *CPU* > addresses. > > Are you sure pci_add_resource_offset wants bus addresses? Sorry, I wasn't clear: It accepts a cpu address in the struct resource and an offset to convert back to a bus address. You should compute 0 as the offset in the normal case, ie of_pci_range.pci_addr and of_pci_range.cpu_addr should be identical, which depends on the DT ranges being correct.. Jason -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html