All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <treding@nvidia.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] pci: tegra: Fix port information parsing
Date: Wed, 21 Jan 2015 09:59:35 +0100	[thread overview]
Message-ID: <20150121085933.GA26340@ulmo.nvidia.com> (raw)
In-Reply-To: <CAPnjgZ2Y3km965KuUFh7MFffzu+yVFxzzf1CuFU57Sx=vcxP7Q@mail.gmail.com>

On Tue, Jan 20, 2015 at 12:05:40PM -0700, Simon Glass wrote:
> Hi Sjoerd,
> 
> On 20 January 2015 at 10:06, Sjoerd Simons
> <sjoerd.simons@collabora.co.uk> wrote:
> > commit a62e84d7b1824a202dd incorrectly changed the tegra pci code to the
> > new fdtdec pci helpers. To get the device index of the root port, the
> > "reg" property should be parsed from the dtb (as was previously the
> > case).
> >
> > With this patch i can successfully network boot my jetson tk1
> >
> > Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> > ---
> >  drivers/pci/pci_tegra.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> Can you also please take a look at this patch?
> 
> http://patchwork.ozlabs.org/patch/430815/
> 
> It tries to support both options.

Only that patch isn't sufficient because tegra_pcie_parse_port_info()
then never calls fdtdec_get_pci_addr() so the index returned will be
undefined (as in whatever happened to be on the stack - 1).

I use the below patch to fix networking on Jetson TK1. It's kind of a
mix between both 430815 and this one, so I didn't feel like making it a
proper patch because I assume you'll want to fix this in fdtdec and the
Tegra bits in a follow-up patch?

Thierry
-------------- next part --------------
diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c
index d344673cc549..0ad959e598c6 100644
--- a/drivers/pci/pci_tegra.c
+++ b/drivers/pci/pci_tegra.c
@@ -479,6 +479,12 @@ static int tegra_pcie_parse_port_info(const void *fdt, int node,
 	pci_dev_t bdf;
 	int err;
 
+	err = fdtdec_get_pci_addr(fdt, node, 0, "reg", &addr);
+	if (err < 0) {
+		error("failed to parse \"reg\" property");
+		return err;
+	}
+
 	err = fdtdec_get_int(fdt, node, "nvidia,num-lanes", 0);
 	if (err < 0) {
 		error("failed to parse \"nvidia,num-lanes\" property");
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 487122eebcf6..77e694d6f53f 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -224,13 +224,13 @@ int fdtdec_get_pci_bdf(const void *blob, int node,
 	u16 dt_vendor, dt_device, vendor, device;
 	int ret;
 
+	/* extract the bdf from fdt_pci_addr */
+	*bdf = addr->phys_hi & 0xffff00;
+
 	/* get vendor id & device id from the compatible string */
 	ret = fdtdec_get_pci_vendev(blob, node, &dt_vendor, &dt_device);
 	if (ret)
-		return ret;
-
-	/* extract the bdf from fdt_pci_addr */
-	*bdf = addr->phys_hi & 0xffff00;
+		return 0;
 
 	/* read vendor id & device id based on bdf */
 	pci_read_config_word(*bdf, PCI_VENDOR_ID, &vendor);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150121/12a77553/attachment.pgp>

  parent reply	other threads:[~2015-01-21  8:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 17:06 [U-Boot] [PATCH] pci: tegra: Fix port information parsing Sjoerd Simons
2015-01-20 19:05 ` Simon Glass
2015-01-21  2:37   ` Bin Meng
2015-01-21  8:24     ` Thierry Reding
2015-01-21  9:15       ` Bin Meng
2015-01-21  9:40         ` Thierry Reding
2015-01-21 16:04           ` Bin Meng
2015-01-23 10:19             ` Thierry Reding
2015-01-23 16:49               ` Stephen Warren
2015-01-24  4:37                 ` Bin Meng
2015-01-24  6:35                   ` Stephen Warren
2015-01-24 13:24                     ` Simon Glass
2015-01-26 17:44                       ` Stephen Warren
2015-01-26 18:18                         ` Simon Glass
2015-01-24  4:19               ` Bin Meng
2015-01-30 12:24                 ` Thierry Reding
2015-01-30 16:29                   ` Simon Glass
2015-01-31 14:41                   ` Bin Meng
2015-01-21  9:19       ` Sjoerd Simons
2015-01-21  8:59   ` Thierry Reding [this message]
2015-01-21  9:50 ` Thierry Reding
2015-01-21 16:07   ` Bin Meng
2015-01-22 16:37     ` Simon Glass
2015-01-24  3:33       ` Simon Glass

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=20150121085933.GA26340@ulmo.nvidia.com \
    --to=treding@nvidia.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.