From: Bjorn Helgaas <bhelgaas@google.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Yinghai Lu <yinghai@kernel.org>, "Jan C. Nordholz" <jckn@gmx.net>,
Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
Rajat Jain <rajatxjain@gmail.com>,
linux-pci@vger.kernel.org, Myron Stowe <myron.stowe@redhat.com>
Subject: Re: [PATCH RFC 2/4] PCI: pciehp: Wait for hotplug command completion lazily
Date: Mon, 1 Jun 2015 16:43:22 -0500 [thread overview]
Message-ID: <20150601214322.GA3631@google.com> (raw)
In-Reply-To: <1432939534.5794.56.camel@redhat.com>
On Fri, May 29, 2015 at 04:45:34PM -0600, Alex Williamson wrote:
>
> Sorry, I'm digging up and old patch here and this RFC was the only copy
> I could find in my mailbox.
>
> On Sat, 2014-06-14 at 15:21 -0600, Bjorn Helgaas wrote:
> > Previously we issued a hotplug command and waited for it to complete. But
> > there's no need to wait until we're ready to issue the *next* command. The
> > next command will probably be much later, so the first one may have already
> > completed and we may not have to actually wait at all.
>
> I'm seeing a regression as a result of this patch. Consider the
> following function:
>
> int pciehp_reset_slot(struct slot *slot, int probe)
> {
> ...
> pcie_write_cmd(ctrl, 0, ctrl_mask);
> ...
> pci_reset_bridge_secondary_bus(ctrl->pcie->port);
>
> Our command write is clearing bits that control whether the slot has
> presence detection and link layer state change enabled. These are the
> things that we're trying to clear to prevent a secondary bus reset from
> turning into a surprise hotplug. If we don't wait for the command to
> complete, what state are when in as we initiate the secondary bus reset?
> On my system, it's like we never issued the write command at all, the
> previous behavior where the hotplug controller detects the link down as
> a surprise hotplug returns. So I'm afraid we do need to wait until
> we're ready to issue the *next* command, because it's our only
> indication that the current command has completed.
I think that's a bug. If we do something that depends on a command
completion, we'll have to wait for it.
> pciehp_set_attention_status
> pciehp_green_led_on
> pciehp_green_led_off
> pciehp_green_led_blink
> pciehp_power_on_slot
> pciehp_power_off_slot
> pcie_enable_notification
> pcie_disable_notification
>
> The slot power ones concern me the same as the reset issue. In the 'on'
> case, we immediately call link enable, so the slot better have
> acknowledged the power on command. In the 'off' case, it seems pretty
> bad to complete the 'off' function, but we don't know if the slot is
> actually off yet.
I agree.
> For notifications, I can imagine that the caller of
> those functions is going to want on or off at the completion of those
> functions, not some in-between state.
These control interrupt generation by the hotplug controller in the switch.
When disabling interrupt generation, I think we should wait for completion
before we call free_irq(); waiting should prevent spurious interrupts.
When enabling interrupt generation, we've already hooked up the ISR before
we enable interrupt generation, so I don't see a need to wait.
> Even in the case of the LED
> functions, where do we want the error to occur, at the time the command
> is issued, or maybe some time in the future when the next unrelated
> command comes through.
The only error here is the "Timeout on hotplug command" message, and we
don't do anything other than print the message, so I'm not too worried
about this one.
> So, rather than posting a new patch adding a flush everywhere that it
> seems a little scary, should we consider scrapping this patch altogether
> as unsafe? We need to wait, not only to issue the next command, but to
> have any sort of acknowledgment that the current command has completed.
I definitely screwed up by assuming that completion was only useful for
pacing writes to the command register. I think lazy checking is fine for
command pacing, but we certainly need to know about completions for other
things, too.
If we added calls to pcie_wait_cmd() in these places:
pciehp_power_on_slot
pciehp_power_off_slot
pcie_disable_notification
pciehp_reset_slot
do you think that would be enough?
> > Because of hardware errata, some controllers generate command completion
> > events for some commands but not others. In the case of Intel CF118 (see
> > spec update reference), the controller indicates command completion only
> > for Slot Control writes that change the value of the following bits:
> >
> > Power Controller Control
> > Power Indicator Control
> > Attention Indicator Control
> > Electromechanical Interlock Control
> >
> > Changes to other bits, e.g., the interrupt enable bits, do not cause the
> > Command Completed bit to be set. Controllers from AMD and Nvidia are
> > reported to have similar errata.
> >
> > These errata cause timeouts when pcie_enable_notification() enables
> > interrupts. Previously that timeout occurred at boot-time. With this
> > change, the timeout occurs later, when we change the state of the slot
> > power, indicators, or interlock. This speeds up boot but causes a timeout
> > at the first hotplug event on the slot. Subsequent events don't timeout
> > because only the first (boot-time) hotplug command updates Slot Control
> > without touching the power/indicator/interlock controls.
>
> It sounds like we need some sort of completion mask to handle devices
> like this, instead of effectively removing the write-barrier for the
> general case. Thanks,
You mean some quirk-based solution, where we know certain devices don't
indicate command completion for certain events? That seems hard because I
think there are many devices that have this erratum. It was difficult to
extract this out of Intel, and I'm pretty sure other vendors have the same
issue.
Bjorn
next prev parent reply other threads:[~2015-06-01 21:43 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-55211-13546@https.bugzilla.kernel.org/>
[not found] ` <20130317155023.5B2EB11FB81@bugzilla.kernel.org>
2013-03-17 17:19 ` [Bug 55211] pci_disable_link_state PCIE_LINK_STATE_L0S no longer disables ASPM for ath5k Yinghai Lu
2013-03-18 17:37 ` [PATCH] PCI: Remove not needed check in disable aspm link Yinghai Lu
2013-03-27 22:56 ` Bjorn Helgaas
2013-03-28 7:41 ` Yinghai Lu
2013-03-28 12:46 ` Bjorn Helgaas
2013-03-28 20:21 ` Yinghai Lu
2013-03-28 20:24 ` Yinghai Lu
2013-03-28 20:24 ` Yinghai Lu
2013-03-29 3:22 ` Bjorn Helgaas
[not found] ` <CAE9FiQVu5QyxaKsYzzQoroQD=TvsziHzDOtoeg=FvhZ8HyN5yw@mail.gmail.com>
2013-03-29 12:24 ` Bjorn Helgaas
2013-03-29 18:02 ` Yinghai Lu
2013-03-29 18:04 ` Yinghai Lu
2013-04-01 23:52 ` Bjorn Helgaas
2013-04-02 0:03 ` Yinghai Lu
2013-04-02 20:10 ` Bjorn Helgaas
2013-06-12 6:20 ` Yinghai Lu
2013-06-12 17:05 ` Bjorn Helgaas
2013-06-12 19:41 ` Yinghai Lu
2013-06-13 3:50 ` Bjorn Helgaas
2013-06-13 4:11 ` Jiang Liu (Gerry)
2013-06-13 13:57 ` Bjorn Helgaas
2013-06-13 5:47 ` Yinghai Lu
2013-06-13 12:04 ` Rafael J. Wysocki
2013-06-14 14:11 ` Bjorn Helgaas
2013-06-14 16:17 ` Yinghai Lu
2013-06-14 16:33 ` Bjorn Helgaas
2013-06-14 16:57 ` Yinghai Lu
2013-06-14 17:44 ` Bjorn Helgaas
2013-06-14 18:26 ` Yinghai Lu
2013-06-14 21:26 ` Bjorn Helgaas
2013-06-14 21:30 ` Matthew Garrett
2013-06-14 22:17 ` Yinghai Lu
2013-06-14 22:27 ` Matthew Garrett
2013-06-14 22:40 ` Yinghai Lu
2013-06-14 22:48 ` Matthew Garrett
2013-06-14 23:00 ` Yinghai Lu
2014-06-14 21:21 ` [PATCH RFC 0/4] PCI: pciehp: Fix Command Completion handling Bjorn Helgaas
2014-06-14 21:21 ` [PATCH RFC 1/4] PCI: pciehp: Make pcie_wait_cmd() self-contained Bjorn Helgaas
2014-06-14 21:21 ` [PATCH RFC 2/4] PCI: pciehp: Wait for hotplug command completion lazily Bjorn Helgaas
2015-05-29 22:45 ` Alex Williamson
2015-06-01 21:43 ` Bjorn Helgaas [this message]
2015-06-01 22:02 ` Alex Williamson
2015-06-01 22:12 ` Bjorn Helgaas
2014-06-14 21:21 ` [PATCH RFC 3/4] PCI: pciehp: Compute timeout from hotplug command start time Bjorn Helgaas
2014-06-15 2:18 ` Yinghai Lu
2014-06-17 0:13 ` Bjorn Helgaas
2014-06-17 17:33 ` Yinghai Lu
2014-06-14 21:21 ` [PATCH RFC 4/4] PCI: pciehp: Remove assumptions about which commands cause completion events Bjorn Helgaas
2014-06-17 3:25 ` Rajat Jain
2014-06-16 1:26 ` [PATCH RFC 0/4] PCI: pciehp: Fix Command Completion handling Rajat Jain
2014-08-15 22:05 ` Yinghai Lu
2014-08-15 23:35 ` Bjorn Helgaas
2013-04-02 0:10 ` [PATCH] PCI: Remove not needed check in disable aspm link Rafael J. Wysocki
2013-03-29 18:11 ` Roman Yepishev
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=20150601214322.GA3631@google.com \
--to=bhelgaas@google.com \
--cc=alex.williamson@redhat.com \
--cc=jckn@gmx.net \
--cc=kaneshige.kenji@jp.fujitsu.com \
--cc=linux-pci@vger.kernel.org \
--cc=myron.stowe@redhat.com \
--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 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).