From: Thierry Reding <thierry.reding@gmail.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Stephen Warren <swarren@wwwdotorg.org>,
Alexandre Courbot <gnurou@gmail.com>,
linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v4 2/2] PCI: tegra: Support per-lane PHYs
Date: Mon, 11 Apr 2016 13:11:19 +0200 [thread overview]
Message-ID: <20160411111119.GB17743@ulmo.ba.sec> (raw)
In-Reply-To: <20160408180528.GC15034@localhost>
[-- Attachment #1: Type: text/plain, Size: 2986 bytes --]
On Fri, Apr 08, 2016 at 01:05:28PM -0500, Bjorn Helgaas wrote:
> Hi Thierry,
>
> I think there are a couple typos (one in a message and one that
> actually looks important), and one question below.
>
> On Fri, Apr 08, 2016 at 06:13:14PM +0200, Thierry Reding wrote:
[...]
> > +static int tegra_pcie_phy_power_off(struct tegra_pcie *pcie)
> > +{
> > + struct tegra_pcie_port *port;
> > + int err;
> > +
> > + if (pcie->legacy_phy) {
> > + if (pcie->phy)
> > + err = phy_power_on(pcie->phy);
>
> s/phy_power_on/phy_power_off/
Good catch. Fixed.
> > @@ -899,13 +1025,9 @@ 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);
> > -
> > + err = tegra_pcie_phy_power_on(pcie);
> > if (err < 0) {
> > - dev_err(pcie->dev, "failed to power on PHY: %d\n", err);
> > + dev_err(pcie->dev, "failed to power off PHY(s): %d\n", err);
>
> s/off/on/
Fixed.
> > +static int tegra_pcie_phys_get(struct tegra_pcie *pcie)
> > +{
> > + struct tegra_pcie_port *port;
> > + int err;
> > +
> > + if (of_get_property(pcie->dev->of_node, "phys", NULL) != NULL)
> > + return tegra_pcie_phys_get_legacy(pcie);
> > +
> > + list_for_each_entry(port, &pcie->ports, list) {
> > + err = tegra_pcie_port_get_phys(port);
> > + if (err < 0) {
> > + return err;
> > + }
> > + }
>
> This seems backwards: if I'm reading this right, you first check for
> the legacy property ("phys") and use it if you find it. If there is
> no legacy property, you look for the new per-lane PHYs.
>
> The usual pattern would be "look for the new stuff, and if you don't
> find it, fall back to the old stuff." Is there a configuration that
> could be described either way, e.g., something with only one lane and
> only one PHY?
>
> I'm not sure whether it matters, but if it *could* use the "new, fall
> back to old" pattern, that would be nice and would keep people from
> wondering whether it's safe to do it backwards.
The reason why I wrote it this way is to special case the legacy code.
The alternative would be to do:
if (of_get_property(...) == NULL) {
list_for_each_entry(port, &pcie->ports, list) {
err = tegra_pcie_port_get_phys(port);
if (err < 0)
return err;
}
}
return tegra_pcie_phys_get_legacy(pcie);
Which is better in the way you describe (fall back to legacy if new
binding is not found). But like I said, it makes, from the code flow,
the new binding the exception, which looks odd to me as well.
Perhaps this could be somewhat mitigated by wrapping the new code into
a separate function:
if (of_get_property(...) == NULL)
return tegra_pcie_phys_get_per_lane(pcie);
return tegra_pcie_phys_get_legacy(pcie);
I don't feel very strongly in either direction. Do you have a
preference?
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-04-11 11:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 16:13 [PATCH v4 1/2] dt-bindings: pci: tegra: Update for per-lane PHYs Thierry Reding
2016-04-08 16:13 ` [PATCH v4 2/2] PCI: tegra: Support " Thierry Reding
2016-04-08 16:13 ` Thierry Reding
2016-04-08 18:05 ` Bjorn Helgaas
2016-04-08 18:05 ` Bjorn Helgaas
2016-04-11 11:11 ` Thierry Reding [this message]
2016-04-11 17:41 ` Stephen Warren
2016-04-08 16:48 ` [PATCH v4 1/2] dt-bindings: pci: tegra: Update for " Bjorn Helgaas
2016-04-08 16:48 ` Bjorn Helgaas
2016-04-11 10:23 ` Thierry Reding
2016-04-11 10:23 ` Thierry Reding
2016-04-08 19:11 ` Bjorn Helgaas
2016-04-08 19:11 ` Bjorn Helgaas
2016-04-11 11:26 ` Thierry Reding
2016-04-11 11:26 ` Thierry Reding
2016-04-11 16:55 ` Stephen Warren
2016-04-11 16:55 ` Stephen Warren
2016-04-11 17:38 ` Stephen Warren
2016-04-11 17:38 ` Stephen Warren
2016-04-13 16:23 ` Thierry Reding
2016-04-13 16:23 ` Thierry Reding
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=20160411111119.GB17743@ulmo.ba.sec \
--to=thierry.reding@gmail.com \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=gnurou@gmail.com \
--cc=helgaas@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=swarren@wwwdotorg.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 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.