* Question: how can I get the real PCI address of a BAR?
@ 2012-12-28 9:36 Cédric Cano
2012-12-30 19:46 ` Bjorn Helgaas
0 siblings, 1 reply; 3+ messages in thread
From: Cédric Cano @ 2012-12-28 9:36 UTC (permalink / raw)
To: linux-pci
Hi,
I'm writing a driver for a DMA engine on the PCI bus. My architecture is
a 36-bit PowerPC (MPC85xx).
In my DMA driver, I want to configure the DMA to transfer data to/from a
PCI device.
I get the PCI address of the device BAR with the command pci_resource_start.
This address is 36-bit but the PCI BAR of the device is 32-bit: I can't
use the 36-bit address to run the DMA.
In kernel documentations, it's advised not to directly read the BAR.
Is there a function which provides the real PCI address i.e. the one
stored in the BAR?
Thanks.
C. Cano
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question: how can I get the real PCI address of a BAR?
2012-12-28 9:36 Question: how can I get the real PCI address of a BAR? Cédric Cano
@ 2012-12-30 19:46 ` Bjorn Helgaas
2013-01-03 8:58 ` Cédric Cano
0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2012-12-30 19:46 UTC (permalink / raw)
To: Cédric Cano; +Cc: linux-pci
On Fri, Dec 28, 2012 at 2:36 AM, Cédric Cano <ccano@interfaceconcept.com> wrote:
> Hi,
>
> I'm writing a driver for a DMA engine on the PCI bus. My architecture is a
> 36-bit PowerPC (MPC85xx).
>
> In my DMA driver, I want to configure the DMA to transfer data to/from a PCI
> device.
> I get the PCI address of the device BAR with the command pci_resource_start.
pci_resource_start() doesn't give you a PCI bus address; it gives you
a CPU physical address. You ioremap() that address if you want a CPU
to access the BAR MMIO space.
> This address is 36-bit but the PCI BAR of the device is 32-bit: I can't use
> the 36-bit address to run the DMA.
>
> In kernel documentations, it's advised not to directly read the BAR.
>
> Is there a function which provides the real PCI address i.e. the one stored
> in the BAR?
You can use pcibios_resource_to_bus() to convert the CPU physical
address from the pci_dev.resource[] back to a PCI bus address.
sym_iomap_device() does something similar to what you're asking about.
Bjorn
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question: how can I get the real PCI address of a BAR?
2012-12-30 19:46 ` Bjorn Helgaas
@ 2013-01-03 8:58 ` Cédric Cano
0 siblings, 0 replies; 3+ messages in thread
From: Cédric Cano @ 2013-01-03 8:58 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci
Hi,
pcibios_resource_to_bus() does what I need.
Thanks.
Le 30/12/2012 20:46, Bjorn Helgaas a écrit :
> On Fri, Dec 28, 2012 at 2:36 AM, Cédric Cano <ccano@interfaceconcept.com> wrote:
>> Hi,
>>
>> I'm writing a driver for a DMA engine on the PCI bus. My architecture is a
>> 36-bit PowerPC (MPC85xx).
>>
>> In my DMA driver, I want to configure the DMA to transfer data to/from a PCI
>> device.
>> I get the PCI address of the device BAR with the command pci_resource_start.
> pci_resource_start() doesn't give you a PCI bus address; it gives you
> a CPU physical address. You ioremap() that address if you want a CPU
> to access the BAR MMIO space.
>
>> This address is 36-bit but the PCI BAR of the device is 32-bit: I can't use
>> the 36-bit address to run the DMA.
>>
>> In kernel documentations, it's advised not to directly read the BAR.
>>
>> Is there a function which provides the real PCI address i.e. the one stored
>> in the BAR?
> You can use pcibios_resource_to_bus() to convert the CPU physical
> address from the pci_dev.resource[] back to a PCI bus address.
> sym_iomap_device() does something similar to what you're asking about.
>
> Bjorn
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-03 9:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-28 9:36 Question: how can I get the real PCI address of a BAR? Cédric Cano
2012-12-30 19:46 ` Bjorn Helgaas
2013-01-03 8:58 ` Cédric Cano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).