From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Cyrille Pitchen <cyrille.pitchen@free-electrons.com>,
Bjorn Helgaas <bhelgaas@google.com>,
kishon@ti.com, linux-pci <linux-pci@vger.kernel.org>,
adouglas@cadence.com, Scott Telford <stelford@cadence.com>,
dgary@cadence.com, kgopi@cadence.com, eandrews@cadence.com,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
sureshp@cadence.com, nsekhar@ti.com,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Rob Herring <robh@kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 3/5] PCI: cadence: Add host driver for Cadence PCIe controller
Date: Wed, 6 Dec 2017 11:32:17 +0000 [thread overview]
Message-ID: <20171206113214.GA27582@red-moon> (raw)
In-Reply-To: <CAKv+Gu_1XZmsKJ_7ay7D74xSAhDW0y++7-CC3YfG7LOUcNZSqA@mail.gmail.com>
On Mon, Dec 04, 2017 at 06:49:12PM +0000, Ard Biesheuvel wrote:
[...]
> >> >> +static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc)
> >> >> +{
> >> >> + const struct cdns_pcie_rc_data *data = rc->data;
> >> >> + struct cdns_pcie *pcie = &rc->pcie;
> >> >> + u8 pbn, sbn, subn;
> >> >> + u32 value, ctrl;
> >> >> +
> >> >> + /*
> >> >> + * Set the root complex BAR configuration register:
> >> >> + * - disable both BAR0 and BAR1.
> >> >> + * - enable Prefetchable Memory Base and Limit registers in type 1
> >> >> + * config space (64 bits).
> >> >> + * - enable IO Base and Limit registers in type 1 config
> >> >> + * space (32 bits).
> >> >> + */
> >> >> + ctrl = CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED;
> >> >> + value = CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL(ctrl) |
> >> >> + CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL(ctrl) |
> >> >> + CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE |
> >> >> + CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS |
> >> >> + CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE |
> >> >> + CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS;
> >> >> + cdns_pcie_writel(pcie, CDNS_PCIE_LM_RC_BAR_CFG, value);
> >> >> +
> >> >> + /* Set root port configuration space */
> >> >> + if (data->vendor_id != 0xffff)
> >> >> + cdns_pcie_rp_writew(pcie, PCI_VENDOR_ID, data->vendor_id);
> >> >> + if (data->device_id != 0xffff)
> >> >> + cdns_pcie_rp_writew(pcie, PCI_DEVICE_ID, data->device_id);
> >> >> +
> >> >> + cdns_pcie_rp_writeb(pcie, PCI_CLASS_REVISION, 0);
> >> >> + cdns_pcie_rp_writeb(pcie, PCI_CLASS_PROG, 0);
> >> >> + cdns_pcie_rp_writew(pcie, PCI_CLASS_DEVICE, PCI_CLASS_BRIDGE_PCI);
> >> >> +
> >> >> + pbn = rc->bus_range->start;
> >> >> + sbn = pbn + 1; /* Single root port. */
> >> >> + subn = rc->bus_range->end;
> >> >> + cdns_pcie_rp_writeb(pcie, PCI_PRIMARY_BUS, pbn);
> >> >> + cdns_pcie_rp_writeb(pcie, PCI_SECONDARY_BUS, sbn);
> >> >> + cdns_pcie_rp_writeb(pcie, PCI_SUBORDINATE_BUS, subn);
> >> >
> >> > Again - I do not have the datasheet for this device therefore I would
> >> > kindly ask you how this works; it seems to me that what you are doing
> >> > here is done through normal configuration cycles in an ECAM compliant
> >> > system to program the RP PRIMARY/SECONDARY/SUBORDINATE bus - I would
> >> > like to understand why this code is needed.
> >> >
> >>
> >> I will test without those lines to test whether I can remove them.
> >>
> >> At first, the PCIe controller was tested by Cadence team: there was code
> >> in their bootloader to initialize the hardware (building the AXI <-> PCIe
> >> mappings, ...): the bootloader used to set the primary, secondary and
> >> subordinate bus numbers in the root port PCI config space.
> >>
> >> Also there was a hardware trick to redirect accesses of the lowest
> >> addresses in the AXI bus to the APB bus so the PCI configuration space of
> >> the root port could have been accessed from the AXI bus too.
> >>
> >> The AXI <-> PCIe mapping being done by the bootloader and the root port
> >> config space being accessible from the AXI bus, it was possible to use
> >> the pci-host-generic driver.
> >
> > That's what I was getting at. Ard (CC'ed) implemented a firmware set-up
> > (even though it was for a different IP but maybe it applies here) that
> > allows the kernel to use the pci-host-generic driver to initialize the
> > PCI controller:
> >
> > https://marc.info/?l=linux-pci&m=150360022626351&w=2
> >
> > I want to understand if there is an IP initialization sequence whereby
> > this IP can be made to work in an ECAM compliant way and therefore
> > reuse (most of) the pci-host-generic driver code.
> >
>
> I think the Synopsys case is probably very similar. There are some
> registers that look like the config space of a root port, but in
> reality, every memory access that hits a live host bridge window is
> forwarded onto the link, regardless of the values of the bridge BARs.
> That is why in the quoted case, we can get away with ignoring the root
> port altogether, rather than jumping through hoops to make the IP
> block's PCI config space registers appear at B/D/F 0/0/0, while still
> having to filter type 0 config TLPs going onto the link (which is
> arguably the job of the root port to begin with)
>
> So if this IP does implement a proper root port (i.e., one where the
> bridge BARs are actually taken into account, and where type 0 config
> TLPs are in fact filtered), I strongly recommend mapping its config
> space registers in an ECAM compliant matter, which implies no
> accessors in the OS.
>
> However, given the observation above, this IP does not appear to
> filter type 0 config TLPs to devfn > 0 downstream of the root port
> either.
Unfortunately that matches my understanding too, let's wait for
Cyrille's reply on my query.
> >> However, the hardware trick won't be included in the final design since
> >> Cadence now wants to perform all PCI configuration space accesses through
> >> a small 4KB window at a fixed address on the AXI bus.
> >
> > I would like to understand what the HW "trick" (if you can disclose it)
> > was, because if there is a chance to reuse the pci-host-generic driver
> > for this IP I want to take it (yes it may entail some firmware set-up in
> > the bootloader) - was it a HW trick or a specific IP SW configuration ?
> >
> >> Also, we now want all initialisations to be done by the linux driver
> >> instead of the bootloader.
> >
> > That's a choice, I do not necessarily agree with it and I think we
> > should aim for more standardization on the PCI host bridge set-up
> > at firmware->kernel handover on DT platforms.
> >
>
> Well, for one, it means this IP will never be supported by ACPI, which
> seems like a huge downside to me.
Yes it is - that's exactly where my comments were heading.
Thanks,
Lorenzo
next prev parent reply other threads:[~2017-12-06 11:32 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-23 15:01 [PATCH 0/5] PCI: Add support to the Cadence PCIe controller Cyrille Pitchen
2017-11-23 15:01 ` [PATCH 1/5] PCI: Add vendor ID for Cadence Cyrille Pitchen
2017-12-06 21:27 ` Bjorn Helgaas
2017-11-23 15:01 ` [PATCH 2/5] dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host controller Cyrille Pitchen
2017-11-26 19:32 ` Rob Herring
2017-11-23 15:01 ` [PATCH 3/5] PCI: cadence: Add host driver for Cadence PCIe controller Cyrille Pitchen
2017-11-28 20:41 ` Bjorn Helgaas
2017-11-28 20:46 ` Bjorn Helgaas
2017-11-29 8:19 ` Thomas Petazzoni
2017-11-29 15:55 ` Bjorn Helgaas
2017-11-29 14:14 ` Lorenzo Pieralisi
2017-12-01 10:37 ` Cyrille Pitchen
2017-12-01 16:20 ` Lorenzo Pieralisi
2017-11-29 17:34 ` Lorenzo Pieralisi
2017-12-03 20:44 ` Cyrille Pitchen
2017-12-04 18:20 ` Lorenzo Pieralisi
2017-12-04 18:49 ` Ard Biesheuvel
2017-12-06 11:32 ` Lorenzo Pieralisi [this message]
2017-12-13 16:42 ` Cyrille Pitchen
2017-11-29 18:25 ` Lorenzo Pieralisi
2017-11-30 10:06 ` Lorenzo Pieralisi
2017-11-23 15:01 ` [PATCH 4/5] dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe endpoint controller Cyrille Pitchen
2017-11-26 19:33 ` Rob Herring
2017-11-23 15:01 ` [PATCH 5/5] PCI: cadence: add EndPoint Controller driver for Cadence PCIe controller Cyrille Pitchen
2017-12-01 12:20 ` Lorenzo Pieralisi
2017-12-04 14:56 ` Cyrille Pitchen
2017-12-05 9:19 ` Kishon Vijay Abraham I
2017-12-07 10:05 ` Philippe Ombredanne
2017-12-13 16:03 ` Cyrille Pitchen
2017-12-13 16:50 ` Cyrille Pitchen
2017-12-14 17:03 ` Cyrille Pitchen
2017-12-15 5:49 ` Kishon Vijay Abraham I
2017-12-15 11:49 ` Cyrille Pitchen
2017-11-28 15:50 ` [PATCH 0/5] PCI: Add support to the " Lorenzo Pieralisi
2017-11-30 7:13 ` Kishon Vijay Abraham I
2017-11-30 18:18 ` Lorenzo Pieralisi
2017-11-30 18:45 ` Cyrille Pitchen
2017-11-30 20:05 ` Cyrille Pitchen
2017-11-30 23:05 ` Bjorn Helgaas
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=20171206113214.GA27582@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=adouglas@cadence.com \
--cc=ard.biesheuvel@linaro.org \
--cc=bhelgaas@google.com \
--cc=cyrille.pitchen@free-electrons.com \
--cc=devicetree@vger.kernel.org \
--cc=dgary@cadence.com \
--cc=eandrews@cadence.com \
--cc=kgopi@cadence.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=robh@kernel.org \
--cc=stelford@cadence.com \
--cc=sureshp@cadence.com \
--cc=thomas.petazzoni@free-electrons.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;
as well as URLs for NNTP newsgroup(s).