public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Tanmay Inamdar <tinamdar@apm.com>
Cc: "linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Grant Likely <grant.likely@linaro.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Rob Landley <rob@landley.net>,
	devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-pci@vger.kernel.org, patches <patches@apm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jon Masters <jcm@redhat.com>
Subject: Re: [RFC PATCH 1/3] pci: APM X-Gene PCIe controller driver
Date: Tue, 7 Jan 2014 10:27:59 +0100	[thread overview]
Message-ID: <201401071028.00225.arnd@arndb.de> (raw)
In-Reply-To: <CACoXjck9KvQjB-8t3GYa95pZ6AwAyhyRKVg=5CYog_nFAfCiAQ@mail.gmail.com>

On Tuesday 07 January 2014, Tanmay Inamdar wrote:
> > Also, the implementation is wrong since the I/O port range already needs
> > to be ioremapped in order for inb/outb to work. There is already a
> > generic implementation of this in include/asm-generic/iomap.h, which
> > correctly calls ioport_map. Make sure that arm64 uses this implementation
> > and provides an ioport_map() function like
> >
> > static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
> > {
> >         return PCI_IOBASE + port;
> > }
> 
> For X-Gene, IO regions are memory mapped IO regions. So I am not sure
> if 'ioport_map'
> would work.

It should. In fact all ARM and ARM64 platforms I have seen (and most powerpc
ones) have their IO region memory mapped. The way we handle this in Linux
is to map the IO space to a fixed virtual address at the time the host
controller is initialized, and all accesses to an IO port translate to
a access in this virtual address. See the inb()/outb() implementation on
arm and arm64, as well as the arm pci_ioremap_io() function for more
details.

> >> +static void xgene_pcie_setup_lanes(struct xgene_pcie_port *port)
> >> +{
> >> +     void *csr_base = port->csr_base;
> >> +     u32 val;
> >> +
> > ...
> >> +static void xgene_pcie_setup_link(struct xgene_pcie_port *port)
> >> +{
> >> +     void *csr_base = port->csr_base;
> >> +     u32 val;
> >> +
> >
> > Don't these belong into the PHY driver? Can the setup be done in the
> > firmware instead so we don't have to bother with it in Linux?
> > Presumably you already need PCI support at boot time already if
> > you want to boot from a PCI device.
> 
> They do look like phy setup functions but they are part of PCIe core
> register space.

Ok.

> >> +static void xgene_pcie_config_pims(void *csr_base, u32 addr,
> >> +                                u64 pim, resource_size_t size)
> >> +{
> >> +     u32 val;
> >> +
> >> +     xgene_pcie_out32(csr_base + addr, lower_32_bits(pim));
> >> +     val = upper_32_bits(pim) | EN_COHERENCY;
> >> +     xgene_pcie_out32(csr_base + addr + 0x04, val);
> >> +     xgene_pcie_out32(csr_base + addr + 0x08, 0x0);
> >> +     xgene_pcie_out32(csr_base + addr + 0x0c, 0x0);
> >> +     val = lower_32_bits(size);
> >> +     xgene_pcie_out32(csr_base + addr + 0x10, val);
> >> +     val = upper_32_bits(size);
> >> +     xgene_pcie_out32(csr_base + addr + 0x14, val);
> >> +}
> >
> > I suspect this is for programming the inbound translation window for
> > DMA transactions (maybe add a comment?), and the second 64-bit word is
> > for the bus-side address. Are you sure you want a translation starting
> > at zero, rather than an identity-mapping like this?
> 
> Actually it is an unused sub-region. I will remove setting to 0. It
> defaults to 0 anyways.

Is it always an identity-mapping then?

> >> +struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
> >> +{
> >> +     struct xgene_pcie_port *port = xgene_pcie_bus_to_port(bus);
> >> +
> >> +     return of_node_get(port->node);
> >> +}
> >
> > Another pointless wrapper to remove.
> 
> If I remove this, then we get a failure while parsing irqs
> "pci 0000:00:00.0: of_irq_parse_pci() failed with rc=-22"

I mean it would be just as easy to open-code the function in the
callers, and more readable.

> >> +static int xgene_pcie_populate_inbound_regions(struct xgene_pcie_port *port)
> >> +{
> >> +     struct resource *msi_res = &port->res[XGENE_MSI];
> >> +     phys_addr_t ddr_size = memblock_phys_mem_size();
> >> +     phys_addr_t ddr_base = memblock_start_of_DRAM();
> >
> > This looks fragile. What about discontiguous memory? It's probably better to
> > leave this setup to the firmware, which already has to do it.
> 
> Idea is to map whole RAM. The memory controller in X-Gene does not
> allow holes or discontinuity in RAM.

There might be holes in the memory map for other reasons, e.g. some part of
memory could be reserved for use by a particular piece of software.
There is actually a definition for a "dma-ranges" property that is normally
use to communicate this information, i.e. which bus addresses for DMA
translate into which parent bus (or memory) addresses. I think it would
be more logical to use that property.

	Arnd

  reply	other threads:[~2014-01-07  9:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-23  8:02 [RFC PATCH 0/3] APM X-Gene PCIe driver Tanmay Inamdar
2013-12-23  8:02 ` [RFC PATCH 1/3] pci: APM X-Gene PCIe controller driver Tanmay Inamdar
2014-01-02 21:08   ` Bjorn Helgaas
2014-01-03 12:07   ` Arnd Bergmann
2014-01-07  2:41     ` Tanmay Inamdar
2014-01-07  9:27       ` Arnd Bergmann [this message]
2014-01-10  1:20         ` Tanmay Inamdar
2014-01-06  1:47   ` Jingoo Han
2014-01-07  2:45     ` Tanmay Inamdar
2014-01-07  3:31       ` Jingoo Han
2013-12-23  8:02 ` [RFC PATCH 2/3] arm64: dts: APM X-Gene PCIe device tree nodes Tanmay Inamdar
2013-12-23 17:46   ` Jason Gunthorpe
2014-01-02 21:56     ` Tanmay Inamdar
2014-01-03  0:52       ` Jason Gunthorpe
2014-01-07  2:56         ` Tanmay Inamdar
2014-01-07 17:27           ` Jason Gunthorpe
2014-01-10  1:30             ` Tanmay Inamdar
2013-12-23  8:02 ` [RFC PATCH 3/3] dt-bindings: pci: xgene pcie device tree bindings Tanmay Inamdar
2014-01-03  9:49   ` Arnd Bergmann
2014-01-07  3:04     ` Tanmay Inamdar
2014-01-07 15:35       ` Arnd Bergmann
2014-01-07 15:44         ` Arnd Bergmann
2014-01-07 18:31         ` Jason Gunthorpe
2014-01-10  1:32           ` Tanmay Inamdar
2014-01-11  0:12         ` Tanmay Inamdar
2014-01-11 13:06           ` Arnd Bergmann
2013-12-23  8:56 ` [RFC PATCH 0/3] APM X-Gene PCIe driver Tanmay Inamdar

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=201401071028.00225.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=jcm@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=patches@apm.com \
    --cc=rob@landley.net \
    --cc=tinamdar@apm.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