devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
	linux-tegra@vger.kernel.org
Subject: Re: [PATCH v3 2/2] PCI: tegra: Support per-lane PHYs
Date: Fri, 11 Mar 2016 17:54:27 -0600	[thread overview]
Message-ID: <20160311235427.GI4725@localhost> (raw)
In-Reply-To: <1457452094-5409-2-git-send-email-thierry.reding@gmail.com>

Stephen, you had some comments on the previous version.  What do you
think about this one?

On Tue, Mar 08, 2016 at 04:48:14PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> The current XUSB pad controller bindings are insufficient to describe
> PHY devices attached to USB controllers. New bindings have been created
> to overcome these restrictions. As a side-effect each root port now is
> assigned a set of PHY devices, one for each lane associated with the
> root port. This has the benefit of allowing fine-grained control of the
> power management for each lane.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ...

>  static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
>  {
>  	const struct tegra_pcie_soc_data *soc = pcie->soc_data;
> @@ -883,14 +905,24 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
>  		afi_writel(pcie, value, AFI_FUSE);
>  	}
>  
> -	if (!pcie->phy)
> -		err = tegra_pcie_phy_enable(pcie);
> -	else
> -		err = phy_power_on(pcie->phy);
> +	if (!pcie->legacy_phy) {
> +		list_for_each_entry(port, &pcie->ports, list) {
> +			err = tegra_pcie_port_phy_power_on(port);
> +			if (err < 0) {
> +				dev_err(pcie->dev,
> +					"failed to power on PCIe port: %d\n",
> +					err);
> +				return err;
> +			}
> +		}
> +	} else {
> +		if (!pcie->phy)
> +			err = tegra_pcie_phy_enable(pcie);
> +		else
> +			err = phy_power_on(pcie->phy);
>  
> -	if (err < 0) {
> -		dev_err(pcie->dev, "failed to power on PHY: %d\n", err);
> -		return err;
> +		if (err < 0)
> +			dev_err(pcie->dev, "failed to power on PHY: %d\n", err);

In the legacy_phy case, we used to bail out if tegra_pcie_phy_enable()
or phy_power_on() failed, but now we don't.  I assume this is an
unintentional change.

I would personally write this as follows because I hate reading
"if (!xxx) ... else ..." (this patch applies on top of the one you
posted).  Note that this restores the legacy_phy error path also.


diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 625db7d..139b9ca 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -882,6 +882,31 @@ static int tegra_pcie_port_phy_power_on(struct tegra_pcie_port *port)
 	return 0;
 }
 
+static int tegra_pcie_port_phy_enable(struct tegra_pcie *pcie)
+{
+	if (pcie->legacy_phy) {
+		if (pcie->phy)
+			err = phy_power_on(pcie->phy);
+		else
+			err = tegra_pcie_phy_enable(pcie);
+
+		if (err < 0)
+			dev_err(pcie->dev, "failed to power on PHY: %d\n", err);
+
+		return err;
+	}
+
+	list_for_each_entry(port, &pcie->ports, list) {
+		err = tegra_pcie_port_phy_power_on(port);
+		if (err < 0) {
+			dev_err(pcie->dev, "failed to power on PCIe port: %d\n",
+				err);
+			return err;
+		}
+	}
+	return 0;
+}
+
 static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
 {
 	const struct tegra_pcie_soc_data *soc = pcie->soc_data;
@@ -921,25 +946,9 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
 		afi_writel(pcie, value, AFI_FUSE);
 	}
 
-	if (!pcie->legacy_phy) {
-		list_for_each_entry(port, &pcie->ports, list) {
-			err = tegra_pcie_port_phy_power_on(port);
-			if (err < 0) {
-				dev_err(pcie->dev,
-					"failed to power on PCIe port: %d\n",
-					err);
-				return err;
-			}
-		}
-	} else {
-		if (!pcie->phy)
-			err = tegra_pcie_phy_enable(pcie);
-		else
-			err = phy_power_on(pcie->phy);
-
-		if (err < 0)
-			dev_err(pcie->dev, "failed to power on PHY: %d\n", err);
-	}
+	err = tegra_pcie_port_phy_enable(pcie);
+	if (err < 0)
+		return err;
 
 	/* take the PCIe interface module out of reset */
 	reset_control_deassert(pcie->pcie_xrst);

  reply	other threads:[~2016-03-11 23:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08 15:48 [PATCH 1/2] dt-bindings: pci: tegra: Update for per-lane PHYs Thierry Reding
     [not found] ` <1457452094-5409-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-03-08 15:48   ` [PATCH v3 2/2] PCI: tegra: Support " Thierry Reding
2016-03-11 23:54     ` Bjorn Helgaas [this message]
     [not found]     ` <1457452094-5409-2-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-03-16 17:01       ` Stephen Warren
     [not found]         ` <56E9915F.9040608-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2016-04-13 16:01           ` Thierry Reding
2016-04-13 17:01             ` Stephen Warren
2016-04-14 15:26               ` Thierry Reding
2016-04-05 17:07       ` Bjorn Helgaas
2016-03-16 16:51   ` [PATCH 1/2] dt-bindings: pci: tegra: Update for " Stephen Warren
2016-04-13 16:22     ` Thierry Reding
2016-04-13 17:04       ` Stephen Warren
2016-04-14 15:29         ` Thierry Reding
     [not found]           ` <20160414152905.GB3366-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-04-18 14:48             ` Thierry Reding
2016-03-17 16:26   ` Rob Herring

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=20160311235427.GI4725@localhost \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gnurou@gmail.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=swarren@wwwdotorg.org \
    --cc=thierry.reding@gmail.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).