From: Stuart Hayes <stuart.w.hayes@gmail.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Austin Bolen <austin_bolen@dell.com>,
keith.busch@intel.com, Alexandru Gagniuc <mr.nuke.me@gmail.com>,
"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
"Gustavo A . R . Silva" <gustavo@embeddedor.com>,
Sinan Kaya <okaya@kernel.org>,
Oza Pawandeep <poza@codeaurora.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: pciehp: Make sure pciehp_isr clears interrupt events
Date: Wed, 13 Nov 2019 15:58:51 -0600 [thread overview]
Message-ID: <0712ed46-e4ba-46d0-05b5-81b258829f38@gmail.com> (raw)
In-Reply-To: <20191113045939.hhmzfbx46vkgmsvn@wunner.de>
On 11/12/19 10:59 PM, Lukas Wunner wrote:
> On Tue, Nov 12, 2019 at 04:59:38PM -0500, Stuart Hayes wrote:
>> The pciehp interrupt handler pciehp_isr() will read the slot status
>> register and then write back to it to clear just the bits that caused the
>> interrupt. If a different interrupt event bit gets set between the read and
>> the write, pciehp_isr() will exit without having cleared all of the
>> interrupt event bits, so we will never get another hotplug interrupt from
>> that device.
>
> The IRQ is masked when it occurs and unmasked after it's been handled.
> See the invocation of mask_ack_irq() in handle_edge_irq() and
> handle_level_irq() in kernel/irq/chip.c.
>
> If the IRQ has fired in-between, the IRQ chip is expected to invoke
> the IRQ handler again. There is some support for IRQ chips not
> capable of replaying interrupts in kernel/irq/resend.c, but in general,
> if you do not get another hotplug interrupt, the hardware is broken.
> What kind of IRQ chip are you using and what kind of chip is the
> hotplug port built into?
>
> I'm not opposed to quirks to support such broken hardware but the
> commit message shouldn't purport that it's normal behavior and the
> quirk should only be executed where necessary and be made explicit
> in the code to be a quirk.
>
> Thanks,
>
> Lukas
Thank you for the feedback!
The hotplug port I'm seeing the issue with is an AMD "Starship/Matisse GPP
Bridge" (1022/1483), which uses an MSI interrupt (PCI-MSI chip).
I don't think that the masking and unmasking will make any difference in this
case, because this pciehp port does not support MSI per-vector masking.
The PCI spec says:
"If the Port is enabled for edge-triggered interrupt signaling using MSI or MSI-X,
an interrupt message must be sent every time the logical AND of the following
conditions transitions from FALSE to TRUE:
• The associated vector is unmasked (not applicable if MSI does not support PVM).
• The Hot-Plug Interrupt Enable bit in the Slot Control register is set to 1b.
• At least one hot-plug event status bit in the Slot Status register and its
associated enable bit in the Slot Control register are both set to 1b."
Because the AMD port does not support PVM (per vector masking), the first
condition will always be true.
Because the hot-plug interrupt enable bit isn't cleared on each interrupt, the
second condition is true.
And because individual event enable bits in the slot control register aren't
cleared on each interrupt, I interpret this to mean that an interrupt message
will be sent every time that the event status bits in the slot status register
transition from all zeros to at least one event status bit being 1. Once one
of those event status bits is 1, the logical AND of the three conditions above
will not transition from FALSE to TRUE again until all of the (enabled) event
status bits in the slot status register all go to zero, which is what my patch
is intended to ensure.
(I noticed too late that I have a compile warning with the ctrl_warn() call, so
I'll have to make a V2 of the patch for that, at least.)
Thanks,
Stuart
next prev parent reply other threads:[~2019-11-13 21:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-12 21:59 [PATCH] PCI: pciehp: Make sure pciehp_isr clears interrupt events Stuart Hayes
2019-11-13 4:59 ` Lukas Wunner
2019-11-13 21:58 ` Stuart Hayes [this message]
2019-11-14 2:50 ` Lukas Wunner
2019-11-13 12:13 ` kbuild test robot
2019-11-25 21:03 ` Stuart Hayes
2019-11-26 23:37 ` Bjorn Helgaas
2019-11-27 0:06 ` Stuart Hayes
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=0712ed46-e4ba-46d0-05b5-81b258829f38@gmail.com \
--to=stuart.w.hayes@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=austin_bolen@dell.com \
--cc=bhelgaas@google.com \
--cc=gustavo@embeddedor.com \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mika.westerberg@linux.intel.com \
--cc=mr.nuke.me@gmail.com \
--cc=okaya@kernel.org \
--cc=poza@codeaurora.org \
--cc=rafael.j.wysocki@intel.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