linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 12/24] powerpc: 4xx PLB to PCI Express support
Date: Sun, 2 Dec 2007 13:32:28 +0100	[thread overview]
Message-ID: <200712021332.29074.sr@denx.de> (raw)
In-Reply-To: <20071130061155.41D71DDF5F@ozlabs.org>

Hi Ben,

On Friday 30 November 2007, Benjamin Herrenschmidt wrote:
> This adds to the previous 2 patches the support for the 4xx PCI Express
> cells as found in the 440SPe revA, revB and 405EX.
>
> Unfortunately, due to significant differences between these, and other
> interesting "features" of those pieces of HW, the code isn't as simple
> as it is for PCI and PCI-X and some of the functions differ significantly
> between the 3 implementations. Thus, not only this code can only support
> those 3 implementations for now and will refuse to operate on any other,
> but there are added ifdef's to avoid the bloat of building a fairly large
> amount of code on platforms that don't need it.
>
> Also, this code currently only supports fully initializing root complex
> nodes, not endpoint. Some more code will have to be lifted from the
> arch/ppc implementation to add the endpoint support, though it's mostly
> differences in memory mapping, and the question on how to represent
> endpoint mode PCI in the device-tree is thus open.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>
> 440SPeA is untested, 440SPeB is slightly tested (with a sky2 network card
> on port 0 only for now) and 405EX is untested.

As already mentioned I'm experiencing some problems with this current version. 
At least what's available in Josh's 2.6.25-candidates branch. The kernel 
crashes in the first ppc4xx_pciex_read_config() call upon (after I fixed the 
small problem mentioned further down below):

	BUG_ON(hose != port->hose);

So before digging into this deeper, I wanted to check if you don't have a 
slightly "better" version which passed your tests with the sky2 PCIe card.

One further comment below.

>  arch/powerpc/Kconfig             |    1
>  arch/powerpc/sysdev/Kconfig      |    8
>  arch/powerpc/sysdev/ppc4xx_pci.c |  927
> ++++++++++++++++++++++++++++++++++++++- arch/powerpc/sysdev/ppc4xx_pci.h | 
> 237 +++++++++
>  4 files changed, 1172 insertions(+), 1 deletion(-)
>
> Index: linux-work/arch/powerpc/sysdev/ppc4xx_pci.c

<snip>

> +static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port
> *port) +{
> +	struct resource dma_window;
> +	struct pci_controller *hose = NULL;
> +	const int *bus_range;
> +	int primary, busses;
> +	void __iomem *mbase = NULL, *cfg_data = NULL;
> +
> +	/* XXX FIXME: Handle endpoint mode properly */
> +	if (port->endpoint)
> +		return;
> +
> +	/* Check if primary bridge */
> +	if (of_get_property(port->node, "primary", NULL))
> +		primary = 1;
> +
> +	/* Get bus range if any */
> +	bus_range = of_get_property(port->node, "bus-range", NULL);
> +
> +	/* Allocate the host controller data structure */
> +	hose = pcibios_alloc_controller(port->node);
> +	if (!hose)
> +		goto fail;
> +
> +	/* We stick the port number in "indirect_type" so the config space
> +	 * ops can retrieve the port data structure easily
> +	 */
> +	hose->indirect_type = port->index;
> +
> +	/* Get bus range */
> +	hose->first_busno = bus_range ? bus_range[0] : 0x0;
> +	hose->last_busno = bus_range ? bus_range[1] : 0xff;
> +
> +	/* Because of how big mapping the config space is (1M per bus), we
> +	 * limit how many busses we support. In the long run, we could replace
> +	 * that with something akin to kmap_atomic instead. We set aside 1 bus
> +	 * for the host itself too.
> +	 */
> +	busses = hose->last_busno - hose->first_busno; /* This is off by 1 */
> +	if (busses > MAX_PCIE_BUS_MAPPED) {
> +		busses = MAX_PCIE_BUS_MAPPED;
> +		hose->last_busno = hose->first_busno + busses;
> +	}
> +
> +	/* We map the external config space in cfg_data and the host config
> +	 * space in cfg_addr. External space is 1M per bus, internal space
> +	 * is 4K
> +	 */
> +	cfg_data = ioremap(port->cfg_space.start +
> +				 (hose->first_busno + 1) * 0x100000,
> +				 busses * 0x100000);
> +	mbase = ioremap(port->cfg_space.start + 0x10000000, 0x1000);
> +	if (cfg_data == NULL || mbase == NULL) {
> +		printk(KERN_ERR "%s: Can't map config space !",
> +		       port->node->full_name);
> +		goto fail;
> +	}
> +
> +	hose->cfg_data = cfg_data;
> +	hose->cfg_addr = mbase;
> +
> +#ifdef CONFIG_40x
> +	/*
> +	 * 405EX needs this offset in the PCIe config cycles
> +	 * need a little more debugging to see if this can be handled
> +	 * differently.				sr, 2007-10
> +	 */
> +	if (of_device_is_compatible(port->node, "ibm,plb-pciex-405ex"))
> +		hose->cfg_data -= 0x8000;
> +#endif /* CONFIG_40x */
> +
> +	pr_debug("PCIE %s, bus %d..%d\n", port->node->full_name,
> +		 hose->first_busno, hose->last_busno);
> +	pr_debug("     config space mapped at: root @0x%p, other @0x%p\n",
> +		 hose->cfg_addr, hose->cfg_data);
> +
> +	/* Setup config space */
> +	hose->ops = &ppc4xx_pciex_pci_ops;
> +	port->hose = hose;
> +	mbase = (void __iomem *)hose->cfg_addr;
> +
> +	/*
> +	 * Set bus numbers on our root port
> +	 */
> +	out_8(mbase + PCI_PRIMARY_BUS, hose->first_busno);
> +	out_8(mbase + PCI_SECONDARY_BUS, hose->first_busno + 1);
> +	out_8(mbase + PCI_SUBORDINATE_BUS, hose->last_busno);
> +
> +	/*
> +	 * OMRs are already reset, also disable PIMs
> +	 */
> +	out_le32(mbase + PECFG_PIMEN, 0);
> +
> +	/* Parse outbound mapping resources */
> +	pci_process_bridge_OF_ranges(hose, port->node, primary);
> +
> +	/* Parse inbound mapping resources */
> +	if (ppc4xx_parse_dma_ranges(hose, mbase, &dma_window) != 0)
> +		goto fail;
> +
> +	/* Configure outbound ranges POMs */
> +	ppc4xx_configure_pciex_POMs(port, hose, mbase);
> +
> +	/* Configure inbound ranges PIMs */
> +	ppc4xx_configure_pciex_PIMs(port, hose, mbase, &dma_window);
> +
> +	/* The root complex doesn't show up if we don't set some vendor
> +	 * and device IDs into it. Those are the same bogus one that the
> +	 * initial code in arch/ppc add. We might want to change that.
> +	 */
> +	out_le16(mbase + 0x200, 0xaaa0 + port->index);
> +	out_le16(mbase + 0x202, 0xbed0 + port->index);
> +
> +	/* Set Class Code to PCI-PCI bridge and Revision Id to 1 */
> +	out_le32(mbase + 0x208, 0x06040001);
> +
> +	printk(KERN_INFO "PCIE%d: successfully set as root-complex\n",
> +	       port->index);
> +	return;
> + fail:
> +	if (hose)
> +		pcibios_free_controller(hose);
> +	if (fg_data)

Should be "cfg_data". I suspect you you have a newer version that compiles 
clean.

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office@denx.de
=====================================================================

  parent reply	other threads:[~2007-12-02 12:37 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-30  6:10 [PATCH 0/24] powerpc: 4xx PCI, PCI-X and PCI-Express support among others Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 1/24] powerpc: Make isa_mem_base common to 32 and 64 bits Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 2/24] powerpc: Merge pci_process_bridge_OF_ranges() Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 3/24] powerpc: Fix powerpc 32 bits resource fixup for 64 bits resources Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 4/24] powerpc: Fix 440/440A machine check handling Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 5/24] powerpc: Fix 440SPE machine check Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 6/24] powerpc: Add xmon function to dump 44x TLB Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 7/24] powerpc: Change 32 bits PCI message about resource allocation Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 8/24] powerpc: Add of_translate_dma_address Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 9/24] powerpc: Improve support for 4xx indirect DCRs Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 10/24] powerpc: 4xx PLB to PCI-X support Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 11/24] powerpc: 4xx PLB to PCI 2.x support Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 12/24] powerpc: 4xx PLB to PCI Express support Benjamin Herrenschmidt
2007-11-30  9:18   ` Kumar Gala
2007-11-30  9:26     ` Benjamin Herrenschmidt
2007-12-02 12:32   ` Stefan Roese [this message]
2007-12-02 14:17     ` Josh Boyer
2007-12-02 20:33     ` Benjamin Herrenschmidt
2007-12-02 22:01       ` Stefan Roese
2007-11-30  6:10 ` [PATCH 13/24] powerpc: PCI support for 4xx Ebony board Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 14/24] powerpc: Add early udbg support for 40x processors Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 15/24] powerpc: early debug forces console log level to max Benjamin Herrenschmidt
2007-11-30 19:10   ` T Ziomek
2007-11-30 20:56     ` Benjamin Herrenschmidt
2007-11-30 22:11       ` T Ziomek
2007-11-30 22:14         ` Scott Wood
2007-11-30 22:15         ` Benjamin Herrenschmidt
2007-11-30 22:30           ` T Ziomek
2007-11-30  6:10 ` [PATCH 16/24] powerpc: EP405 boards support for arch/powerpc Benjamin Herrenschmidt
2007-11-30  6:10 ` [PATCH 17/24] powerpc: Add PCI to Walnut platform Benjamin Herrenschmidt
2007-11-30  6:11 ` [PATCH 18/24] powerpc: Base support for 440GX Taishan eval board Benjamin Herrenschmidt
2007-11-30 20:08   ` Josh Boyer
2007-11-30 20:57     ` Benjamin Herrenschmidt
2007-11-30 21:32       ` Josh Boyer
2007-11-30 21:44         ` Benjamin Herrenschmidt
2007-11-30  6:11 ` [PATCH 19/24] powerpc: Wire up PCI on Bamboo board Benjamin Herrenschmidt
2007-11-30  6:11 ` [PATCH 20/24] powerpc: Wire up 440EP USB controlle support to " Benjamin Herrenschmidt
2007-11-30  6:11 ` [PATCH 21/24] powerpc: Adds decoding of 440SPE memory size to boot wrapper library Benjamin Herrenschmidt
2007-11-30  6:11 ` [PATCH 22/24] powerpc: Add mfspr/mtspr inline macros to 4xx bootwrapper Benjamin Herrenschmidt
2007-11-30  6:11 ` [PATCH 23/24] powerpc: Rework 4xx clock probing in boot wrapper Benjamin Herrenschmidt
2007-11-30  6:11 ` [PATCH 24/24] powerpc: Base support for 440SPe "Katmai" eval board Benjamin Herrenschmidt
2007-11-30  7:59   ` Benjamin Herrenschmidt
2007-11-30 14:59   ` Olof Johansson
2007-11-30 20:16   ` Josh Boyer
2007-12-02 12:23   ` Stefan Roese
2007-12-02 12:35     ` Stefan Roese
2007-11-30 14:15 ` [PATCH 0/24] powerpc: 4xx PCI, PCI-X and PCI-Express support among others Olof Johansson
2007-11-30 15:12   ` Kumar Gala
2007-11-30 15:27     ` Olof Johansson
2007-11-30 16:11       ` Jon Loeliger
2007-12-01  0:53         ` Josh Boyer
2007-12-01  1:18           ` Doug Maxey
2007-12-03  4:18           ` Grant Likely
2007-11-30 20:54   ` Benjamin Herrenschmidt
2007-11-30 21:22     ` Olof Johansson
2007-11-30 20:17 ` Josh Boyer
2007-12-03  3:24   ` Benjamin Herrenschmidt
2007-12-03  4:20     ` Josh Boyer

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=200712021332.29074.sr@denx.de \
    --to=sr@denx.de \
    --cc=linuxppc-dev@ozlabs.org \
    /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).