From: Lukas Wunner <lukas@wunner.de>
To: Keith Busch <kbusch@kernel.org>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Xiongfeng Wang <wangxiongfeng2@huawei.com>
Subject: Re: [PATCH] PCI: pciehp: Avoid returning prematurely from sysfs requests
Date: Sat, 10 Aug 2019 12:12:32 +0200 [thread overview]
Message-ID: <20190810101232.3fdqrbi3tdd27dwx@wunner.de> (raw)
In-Reply-To: <20190809202815.4jtpdsnnmztins34@wunner.de>
On Fri, Aug 09, 2019 at 10:28:15PM +0200, Lukas Wunner wrote:
> On Fri, Aug 09, 2019 at 01:32:16PM -0600, Keith Busch wrote:
> > On Fri, Aug 09, 2019 at 12:28:43PM +0200, Lukas Wunner wrote:
> > > A sysfs request to enable or disable a PCIe hotplug slot should not
> > > return before it has been carried out. That is sought to be achieved
> > > by waiting until the controller's "pending_events" have been cleared.
> > >
> > > However the IRQ thread pciehp_ist() clears the "pending_events" before
> > > it acts on them. If pciehp_sysfs_enable_slot() / _disable_slot() happen
> > > to check the "pending_events" after they have been cleared but while
> > > pciehp_ist() is still running, the functions may return prematurely
> > > with an incorrect return value.
> > >
> > > Fix by introducing an "ist_running" flag which must be false before a
> > > sysfs request is allowed to return.
> >
> > Can you instead just call synchronize_irq(ctrl->pcie->irq) after the
> > pending events is cleared?
>
> You mean call synchronize_irq() from pciehp_sysfs_enable_slot() /
> disable_slot()? That's a good idea, let me think that through and
> try to make it work that way.
After a bit of thinking:
synchronize_irq() doesn't work for poll mode.
A secondary concern is that if the IRQ is shared, synchronize_irq()
waits for all the other (unrelated) IRQ threads to finish,
i.e. longer than necessary.
So I can't think of a better way to solve this.
Thanks,
Lukas
next prev parent reply other threads:[~2019-08-10 10:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-09 10:28 [PATCH] PCI: pciehp: Avoid returning prematurely from sysfs requests Lukas Wunner
2019-08-09 17:28 ` sathyanarayanan kuppuswamy
2019-08-09 18:28 ` Lukas Wunner
2019-08-09 19:32 ` Keith Busch
2019-08-09 20:28 ` Lukas Wunner
2019-08-10 10:12 ` Lukas Wunner [this message]
2019-10-04 20:41 ` Bjorn Helgaas
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=20190810101232.3fdqrbi3tdd27dwx@wunner.de \
--to=lukas@wunner.de \
--cc=helgaas@kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=wangxiongfeng2@huawei.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).