From: "Michael S. Tsirkin" <mst@redhat.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pciehp: fast unplug for virtual machines
Date: Sun, 14 Nov 2021 12:24:43 -0500 [thread overview]
Message-ID: <20211114122249-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20211114163958.GA7211@wunner.de>
On Sun, Nov 14, 2021 at 05:39:58PM +0100, Lukas Wunner wrote:
> On Thu, Nov 11, 2021 at 10:02:24AM +0100, Gerd Hoffmann wrote:
> > The PCIe specification asks the OS to wait five seconds after the
>
> The spec reference Bjorn asked for is: PCIe r5.0, sec. 6.7.1.5
>
> > attention button has been pressed before actually un-plugging the
> > device. This gives the operator the chance to cancel the operation
> > by pressing the attention button again within those five seconds.
> >
> > For physical hardware this makes sense. Picking the wrong button
> > by accident can easily happen and it can be corrected that way.
> >
> > For virtual hardware the benefits are questionable. Typically
> > users find the five second delay annoying.
>
> Why does virtual hardware implement the Attention Button if it's
> perceived as annoying? Just amend qemu so that it doesn't advertise
> presence of an Attention Button to get rid of the delay. (Clear the
> Attention Button Present bit in the Slot Capabilities register.)
Because we want ability to request device removal from outside the
guest.
> An Attention Button doesn't make any sense for virtual hardware
> except to test or debug support for it in the kernel. Just make
> presence of the Attention Button optional and be done with it.
>
> You'll still be able to bring down the slot in software via the
> "remove" attribute in sysfs.
This requires guest specific code though. Emulating the attention button
works in a guest independent way.
> Same for the 1 second delay in remove_board(). That's mandated by
> PCIe r5.0, sec. 6.7.1.8, but it's only observed if a Power Controller
> is present. So just clear the Power Controller Present bit in the
> Slot Capabilities register and the delay is gone.
>
>
> > @@ -109,6 +110,8 @@ struct controller {
> > unsigned int ist_running;
> > int request_result;
> > wait_queue_head_t requester;
> > +
> > + bool is_virtual;
> > };
>
> This is a quirk for a specific device, so please move it further up to the
> /* capabilities and quirks */ section of struct controller.
>
>
> > @@ -227,6 +227,11 @@ static int pciehp_probe(struct pcie_device *dev)
> > goto err_out_shutdown_notification;
> > }
> >
> > + if (dev->port->vendor == PCI_VENDOR_ID_REDHAT &&
> > + dev->port->device == 0x000c)
> > + /* qemu pcie root port */
> > + ctrl->is_virtual = true;
> > +
>
> Move this to pcie_init() in pciehp_hpc.c below the existing quirks for
> hotplug_user_indicators and is_thunderbolt.
>
>
> > +static bool fast_virtual_unplug = true;
> > +module_param(fast_virtual_unplug, bool, 0644);
>
> An integer parameter to configure a custom delay would be nicer IMO.
> Of course, anything else than 5 sec deviates from the spec.
>
> Thanks,
>
> Lukas
next prev parent reply other threads:[~2021-11-14 17:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 9:02 [PATCH] pciehp: fast unplug for virtual machines Gerd Hoffmann
2021-11-11 17:00 ` Michael S. Tsirkin
2021-11-12 9:56 ` Gerd Hoffmann
2021-11-12 10:09 ` Michael S. Tsirkin
2021-11-11 21:50 ` Bjorn Helgaas
2021-11-12 11:28 ` Gerd Hoffmann
2021-11-12 0:00 ` Krzysztof Wilczyński
2021-11-14 16:39 ` Lukas Wunner
2021-11-14 17:24 ` Michael S. Tsirkin [this message]
2021-11-14 18:06 ` Lukas Wunner
2021-11-14 22:37 ` Michael S. Tsirkin
2021-11-15 9:59 ` Gerd Hoffmann
2021-11-15 7:45 ` Lukas Wunner
2021-11-15 10:09 ` Gerd Hoffmann
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=20211114122249-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=bhelgaas@google.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
/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).