Skip to contentSkip to conversation

Purpose of PCI address in ranges property

DISCUSSION valmiki 2 participants 4 messages Mar 19, 2017 – Mar 23, 2017 PCI

lore
Share & tools
lore

valmiki

author
#0 lore raw

Hi,

When ranges property is being parsed using of_pci_get_host_bridge_resources, the pci address is being used for calculating the offset for pci_add_resource_offset.

What is this offset for ?

So the cpu address is being used for programming memory base and limit registers ?

Thanks & Regards,
Valmiki

#1 lore raw
Quoted 10 lines · valmiki

Hi,

When ranges property is being parsed using of_pci_get_host_bridge_resources, the pci address is being used for
calculating the offset for pci_add_resource_offset.

What is this offset for ?

So the cpu address is being used for programming memory base and limit registers ?

Linux IORESOURCE_MEM resources are defined in terms of CPU addresses, while PCI config space BAR registers are programmed with bus addresses. These are often the same, but on some machines they are not, which results in an offset that has to be used when accessing the BARs.

Arnd

author
#2 lore raw
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · valmiki

Hi,

When ranges property is being parsed using of_pci_get_host_bridge_resources, the pci address is being used for
calculating the offset for pci_add_resource_offset.

What is this offset for ?

Quoted 8 lines
Quoted 2 lines

So the cpu address is being used for programming memory base and limit registers ?

Linux IORESOURCE_MEM resources are defined in terms of CPU addresses, while PCI config space BAR registers are programmed with bus addresses. These are often the same, but on some machines they are not, which results in an offset that has to be used when accessing the BARs.

Thanks Arnd. So mem base and limit registers of RP are programmed with CPU addresses, and EP BARs are programmed with PCI bus addresses ?
So when will this offset be used, only when RP assigns BAR's to RP ?

Regards,
Valmiki

#3 lore raw
Quoted 22 lines · valmiki
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · valmiki

Hi,

When ranges property is being parsed using of_pci_get_host_bridge_resources,
the pci address is being used for calculating the offset for pci_add_resource_offset.

What is this offset for ?

Quoted 9 lines
Quoted 2 lines

So the cpu address is being used for programming memory base and limit registers ?

Linux IORESOURCE_MEM resources are defined in terms of CPU addresses, while PCI config space BAR registers are programmed with bus addresses. These are often the same, but on some machines they are not, which results in an offset that has to be used when accessing the BARs.

Quoted 4 lines

Thanks Arnd. So mem base and limit registers of RP are programmed with CPU addresses,
and EP BARs are programmed with PCI bus addresses ?
So when will this offset be used, only when RP assigns BAR's to RP ?

I think depending on your platform, we either assign the BARs or we read the ones that the firmware has assigned, and either way the offset has to be applied in or way or the other.

Arnd