From: Jingoo Han <jg1.han@samsung.com>
To: 'Pratyush Anand' <pratyush.anand@st.com>,
'shiv prakash Agarwal' <chhotu.shiv@gmail.com>
Cc: 'Bjorn Helgaas' <bhelgaas@google.com>,
linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
'linux-arm' <linux-arm-kernel@lists.infradead.org>,
'Jingoo Han' <jg1.han@samsung.com>
Subject: Re: Memory mapping of config space of pcie devices
Date: Mon, 16 Dec 2013 13:20:10 +0900 [thread overview]
Message-ID: <006801cefa16$1c0f91d0$542eb570$%han@samsung.com> (raw)
In-Reply-To: <20131216034544.GA2445@pratyush-vbox>
On Monday, December 16, 2013 12:46 PM, shiv prakash Agarwal wrote:
> On Sun, Dec 15, 2013 at 04:18:23AM +0800, Bjorn Helgaas wrote:
> > [+cc devicetree, linux-arm-kernel]
> >
> > On Sat, Dec 14, 2013 at 1:05 PM, shiv prakash Agarwal
> > <chhotu.shiv@gmail.com> wrote:
> > > On Sun, Dec 15, 2013 at 12:29 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> > >> On Sat, Dec 14, 2013 at 11:32 AM, shiv prakash Agarwal
> > >> <chhotu.shiv@gmail.com> wrote:
> > >>> Hi All,
> > >>>
> > >>> How devices config spaces are mapped to host memory?
> > >>> Is it being handled by core driver? I could not locate.
> > >>
> > >> The PCI core does not map config space into memory. That's not even
> > >> possible for the legacy config access methods, e.g., using I/O ports
> > >> 0xcf8 and 0xcfc [1].
> > >>
> > >> If you're wondering about how Linux uses ECAM, that's mostly in
> > >> arch/x86/pci/mmconfig*. That code does ioremap the ECAM area into
> > >> kernel virtual space, but only for access via pci_read_config_word(),
> > >> pci_write_config_word(), etc.
> > >>
> > >> Bjorn
> > >>
> > >> [1] http://en.wikipedia.org/wiki/PCI_configuration_space#Software_implementation
> > >
> > > Thanks Bjorn for quick reply,
> > >
> > > Above reference says:
> > > During system initialization, firmware determines the base address for
> > > this “stolen” address region and communicates it to the root complex
> > > and to the operating system. This communication method is
> > > implementation-specific, and not defined in the PCI Express
> > > specification.
> > >
> > > How above is implemented on ARM?
> >
> > On x86, we learn the ECAM address via ACPI (the MCFG table or a host
> > bridge _CBA method). I don't know how this is done on ARM. I could
> > imagine it being done via device tree, but I really don't know.
> > Unfortunately both the address discovery and the actual ECAM accesses
> > are in arch-specific code.
>
> Yes, it comes from device tree. DT sends CPU address range allocated
> for cfg transfers. pci_read_config_word and pci_write_config_word
> send bdf and offset. Address translation unit of your RC driver should
> be programmed in such a way that it translates cpu address to the cfg
> address based on bdf and offset.
>
> You can see one such implementation in drivers/pci/host/pcie-designware.c
As Bjorn said, the PCI core does not map config space into memory.
As Pratyush Anand said, address mapping can be done via device tree.
Please refer to the following in order to understand PCI Device
tree standard.
http://devicetree.org/Device_Tree_Usage#PCI_Host_Bridge
Best regards,
Jingoo Han
prev parent reply other threads:[~2013-12-16 4:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAHH3p5+3Zy+YkgDS_1bJ7B84w5iHOh6-QG7LRJXo2WQHREcRHw@mail.gmail.com>
[not found] ` <CAErSpo59htYoPBoouUfSXAVXwCUQPK-TB_zG0BkE-PLhV=KRbQ@mail.gmail.com>
[not found] ` <CAHH3p5J7Se8zu64MfoSDkAN_NtOp=qv1DcvWBAa8jWKouo0TXg@mail.gmail.com>
2013-12-14 20:18 ` Memory mapping of config space of pcie devices Bjorn Helgaas
2013-12-16 3:45 ` Pratyush Anand
2013-12-16 4:20 ` Jingoo Han [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='006801cefa16$1c0f91d0$542eb570$%han@samsung.com' \
--to=jg1.han@samsung.com \
--cc=bhelgaas@google.com \
--cc=chhotu.shiv@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=pratyush.anand@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox