qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: jusual@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/1] pci/pcie: refuse another hotplug/unplug event if attention button is pending
Date: Thu, 30 Jul 2020 12:04:08 -0400	[thread overview]
Message-ID: <20200730120153-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20200722161722.51416-2-mlevitsk@redhat.com>

On Wed, Jul 22, 2020 at 07:17:22PM +0300, Maxim Levitsky wrote:
> Curently it is possible to hotplug a device and then immediatly
> hotunplug it before the OS notices, and that will result
> in missed unplug event since we can only send one attention button event.
> 
> Moreover the device will stuck in unplugging state forever.
> 
> Error out in such cases and rely on the caller (e.g libvirt) to retry
> the unplug a bit later
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  hw/pci/pcie.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 5b48bae0f6..9e836cf2f4 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -402,6 +402,17 @@ static void pcie_cap_slot_plug_common(PCIDevice *hotplug_dev, DeviceState *dev,
>           */
>          error_setg_errno(errp, EBUSY, "slot is electromechanically locked");
>      }
> +
> +    if (sltsta & PCI_EXP_SLTSTA_ABP) {
> +        /*
> +         * Attention button is pressed, thus we can't send another
> +         * hotpplug event

typo

> +         */
> +        error_setg_errno(errp, EBUSY,
> +                         "attention button is already pressed, can't "
> +                         "send another hotplug event");
> +    }
> +
>  }

It would be neater if we could queue the event up
in qemu. Alternatively - can we clean up the unhandled
event so guest does not even notice the device
briefly appeared?

>  
>  void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
> -- 
> 2.26.2



  parent reply	other threads:[~2020-07-30 16:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 16:17 [PATCH 0/1] RFC: pcie: parital fix for missing unplug events Maxim Levitsky
2020-07-22 16:17 ` [PATCH 1/1] pci/pcie: refuse another hotplug/unplug event if attention button is pending Maxim Levitsky
2020-07-22 16:19   ` Maxim Levitsky
2020-07-29  5:09     ` Maxim Levitsky
2020-07-30 11:38       ` Igor Mammedov
2020-07-30 16:04   ` Michael S. Tsirkin [this message]
2020-07-30 16:05 ` [PATCH 0/1] RFC: pcie: parital fix for missing unplug events Michael S. Tsirkin

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=20200730120153-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jusual@redhat.com \
    --cc=mlevitsk@redhat.com \
    --cc=qemu-devel@nongnu.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).