linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Ley Foon Tan <lftan@altera.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-pci <linux-pci@vger.kernel.org>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Jon Mason <jonmason@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com
Subject: Re: [PATCH v2] PCI: altera: Retrain link in rootport mode only
Date: Wed, 24 Aug 2016 12:54:31 -0500	[thread overview]
Message-ID: <20160824175431.GC23914@localhost> (raw)
In-Reply-To: <CAFiDJ5_PnZ-oEj748ZY8dZhnFWMzK-bUYCti2ySFk5ZvLh6idw@mail.gmail.com>

[+cc Ray, Scott, Jon, bcm-kernel-feedback-list]

On Wed, Aug 24, 2016 at 03:07:52PM +0800, Ley Foon Tan wrote:
> On Mon, Aug 22, 2016 at 11:47 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Fri, Aug 19, 2016 at 04:24:38PM +0800, Ley Foon Tan wrote:
> >> Altera PCIe IP can be configured as rootport or device and they might have
> >> same vendor ID. It will cause the system hang issue if Altera PCIe is in
> >> endpoint mode and work with other PCIe rootport that from other vendors.
> >> So, add the rootport mode checking in link retrain fixup function.
> >>
> >> Signed-off-by: Ley Foon Tan <lftan@altera.com>
> >> ---
> >> v2: change to check PCIe type is PCI_EXP_TYPE_ROOT_PORT
> >> ---
> >>  drivers/pci/host/pcie-altera.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
> >> index 58eef99..33b6968 100644
> >> --- a/drivers/pci/host/pcie-altera.c
> >> +++ b/drivers/pci/host/pcie-altera.c
> >> @@ -139,6 +139,9 @@ static void altera_pcie_retrain(struct pci_dev *dev)
> >>       u16 linkcap, linkstat;
> >>       struct altera_pcie *pcie = dev->bus->sysdata;
> >>
> >> +     if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT)
> >> +             return;
> >> +
> >>       if (!altera_pcie_link_is_up(pcie))
> >>               return;
> >
> > Instead of making this a PCI fixup, can you make an
> > altera_pcie_host_init() function, call it from altera_pcie_probe(),
> > and do the link retrain there?  Then you wouldn't need to worry about
> > whether this is a Root Port or an Endpoint, plus it would make the
> > altera driver structure more like the other drivers.
> >
> > You would call altera_pcie_host_init() before pci_scan_root_bus(), so
> > you wouldn't have a pci_dev yet, so you wouldn't be able to use
> > pcie_capability_set_word() to set the PCI_EXP_LNKCTL_RL bit.  But I
> > assume there's some device-dependent way to access it using
> > cra_writel()?
> We can't use cra_write() to set PCI_EXP_LNKCTL_RL bit. 

Why not?  I don't mean it has to be cra_write(), but isn't there some
way you can write that bit before we scan the root bus?  It doesn't
make sense that we have to scan the bus before we can train the link.

We want to be able to tell the PCI core "all the device-specific root
complex initialization has been done, here are the config accessors
you need, please scan for devices."  I want to keep device-specific
things like this quirk directly in the driver and out of the
enumeration process.

> We can use
> pci_bus_find_capability() and pci_bus_read_config_word() with struct
> pci_bus instead.
> But this only can be called after pci_scan_root_bus().

> Found
> iproc_pcie_check_link() have similar implementation.

You're right, and I don't like iproc_pcie_check_link() either, for the
same reasons.

The iproc_pcie_check_link() is a little better because it's called
before enumeration:

  pci_create_root_bus()
  iproc_pcie_check_link()
  pci_scan_child_bus()

But it would be a lot better if iproc_pcie_check_link() were done
first, before pci_create_root_bus().  Then it would be more like the
structure of other drivers, and we could use pci_scan_root_bus()
instead.

Comments, iproc folks?

Bjorn

  reply	other threads:[~2016-08-24 17:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-19  8:24 [PATCH v2] PCI: altera: Retrain link in rootport mode only Ley Foon Tan
2016-08-22 15:47 ` Bjorn Helgaas
2016-08-24  7:07   ` Ley Foon Tan
2016-08-24 17:54     ` Bjorn Helgaas [this message]
2016-08-24 18:40       ` Scott Branden
2016-08-25  5:42       ` Ley Foon Tan
2016-08-30  0:37       ` Ray Jui
2016-08-30 13:37         ` Bjorn Helgaas
2016-08-30 16:36           ` Ray Jui
2016-08-30 17:00             ` Bjorn Helgaas
2016-08-30 17:04               ` Ray Jui
2016-09-08  0:10                 ` Ray Jui

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=20160824175431.GC23914@localhost \
    --to=helgaas@kernel.org \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=jonmason@broadcom.com \
    --cc=lftan@altera.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.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).