All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Rajat Jain <rajatxjain@gmail.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: Re: [PATCH v4] pciehp: only wait command complete for real hotplug control
Date: Fri, 30 May 2014 17:14:21 -0600	[thread overview]
Message-ID: <20140530231421.GH4607@google.com> (raw)
In-Reply-To: <CAE9FiQWCsKwb3aqUQ96x__xwR_+K=k5LzjxWCCS1+xz2Wd5baA@mail.gmail.com>

On Fri, May 30, 2014 at 03:28:16PM -0700, Yinghai Lu wrote:
> On Tue, May 20, 2014 at 1:53 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> > On Thu, May 01, 2014 at 10:40:55AM -0700, Yinghai Lu wrote:
> 
> >> With that we could save 16 seconds during booting, later with 32 sockets system
> >> with 64 pcie hotplug slots we could save 64 seconds.
> >
> > Doesn't this just move a timeout out of the boot path and into a future
> > hotplug event?
> 
> Both. But not affect real Hotplug events (EIC, PCC, PIC, AIC).
> 
> >
> > These controllers do not set the "No Command Completed Support" bit, so
> > pciehp expects that they will generate Command Completed events after they
> > process commands.
> >
> > During initialization, pcie_enable_notification() writes a command to set
> > the DLLSCE, ABPE, PDCE, MRLSCE, HPIE, CCIE bits.  The (EIC, PCC, PIC, AIC)
> > bits aren't changed, so per CF118, the controller will not set the Command
> > Completed bit.
> >
> > Later, when we turn on power to the slot, ctrl->cmd_busy will still be set,
> > so won't we timeout waiting for the Command Completed bit?
> 
> If it is real hotplug events, cmd_busy will be cleared by pcie_isr.
> 
> If it is not real hotplug events, cmd_busy is still set, and but CC is not set.

The first command is not a "real" hotplug event (it doesn't change (EIC,
PCC, PIC, AIC)).  So these broken controllers won't set CC.  The second
command probably *will* be a real hotplug event.  But we have to wait for
CC to be set before we can issue it, and on these broken controllers, that
wait will time out.

> later before we try to write cmd again, but only cmd_busy is set &&
> CC is not set, that means previous write cmd is not real hotplug event.
> so we should not wait.

It means no such thing.  If cmd_busy is set and CC is not set, that means
we've written a command to SLTCTL, but it hasn't completed yet, and we
can't issue another command until either CC is set or a timeout period has
elapsed.

> > (I think there's a bug in your patch (see below) that would explain why you
> > wouldn't see this timeout in testing.)
> >
> >>       /*
> >>        * Wait for command completion.
> >>        */
> >> -     if (!ctrl->no_cmd_complete) {
> >> +     if (!ctrl->no_cmd_complete && (slot_status & PCI_EXP_SLTSTA_CC) &&
> >> +         ctrl->cmd_busy) {
> >
> > I don't understand this change.  Why do you test "slot_status &
> > PCI_EXP_SLTSTA_CC" here?  Did you mean to write this:
> >
> >   if (!ctrl->no_cmd_complete && !(slot_status & PCI_EXP_SLTSTA_CC) && ...
> >
> > instead?  I think we want to wait if (1) the controller generates Command
> > Complete events and (2) Slot Status indicates that a command is still in
> > progress.
> 
> Yes. your logic is right for those real hotplug event, that means
> CC is not set, and isr is not called to clear cmd_busy.
> 
> but it will wait for real or non-real cmd right after non-real hotplug cmd.
> 
> looks like we need to start one timer for non-real hotplug to clear cmd_busy?

I think your current patch is incorrect because you wait if the previous
command has completed, and you write a new command if the previous one is
still in progress.  That's backwards.

The code has to work correctly for spec-compliant hardware.  If we have to
wait for timeouts on hardware with errata, that's unfortunate, but at least
things will still work correctly.

If you can make it work correctly with no timeouts on both working and
broken hardware, that's obviously ideal.

Bjorn

  parent reply	other threads:[~2014-05-30 23:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-01 17:40 [PATCH v4] pciehp: only wait command complete for real hotplug control Yinghai Lu
2014-05-01 17:56 ` Rajat Jain
2014-05-01 17:59   ` Bjorn Helgaas
     [not found] ` <20140520205340.GA22821@google.com>
2014-05-30 22:28   ` Yinghai Lu
2014-05-30 22:50     ` Yinghai Lu
2014-05-30 23:08       ` Yinghai Lu
2014-05-30 23:14     ` Bjorn Helgaas [this message]
2014-05-31  1:25       ` Yinghai Lu

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=20140530231421.GH4607@google.com \
    --to=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=rajatxjain@gmail.com \
    --cc=yinghai@kernel.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.