qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: Julia Suvorova <jusual@redhat.com>, qemu-devel@nongnu.org
Cc: "Igor Mammedov" <imammedo@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2 1/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot
Date: Sun, 3 May 2020 10:46:32 +0300	[thread overview]
Message-ID: <2aa78889-043e-32af-e30f-f6d337f26d3f@gmail.com> (raw)
In-Reply-To: <20200427182440.92433-2-jusual@redhat.com>



On 4/27/20 9:24 PM, Julia Suvorova wrote:
> Raise an error when trying to hot-plug/unplug a device through QMP to a device
> with disabled hot-plug capability. This makes the device behaviour more
> consistent and provides an explanation of the failure in the case of
> asynchronous unplug.
>
> Signed-off-by: Julia Suvorova <jusual@redhat.com>
> ---
> v2:
>      * Change error text [Igor, Michael]
>      * Move cleanup to a separate patch [Marcel]
>
>   hw/pci/pcie.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 0eb3a2a5d2..6b48d04d2c 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
>   {
>       PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
>       uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
> +    uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
>       PCIDevice *pci_dev = PCI_DEVICE(dev);
>   
>       /* Don't send event when device is enabled during qemu machine creation:
> @@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
>           return;
>       }
>   
> +    /* Check if hot-plug is disabled on the slot */
> +    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
> +        error_setg(errp, "Hot-plug failed: unsupported by the port device '%s'",
> +                         DEVICE(hotplug_pdev)->id);
> +        return;
> +    }
> +
>       /* To enable multifunction hot-plug, we just ensure the function
>        * 0 added last. When function 0 is added, we set the sltsta and
>        * inform OS via event notification.
> @@ -470,6 +478,17 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
>       Error *local_err = NULL;
>       PCIDevice *pci_dev = PCI_DEVICE(dev);
>       PCIBus *bus = pci_get_bus(pci_dev);
> +    PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
> +    uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
> +    uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
> +
> +    /* Check if hot-unplug is disabled on the slot */
> +    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
> +        error_setg(errp, "Hot-unplug failed: "
> +                         "unsupported by the port device '%s'",
> +                         DEVICE(hotplug_pdev)->id);
> +        return;
> +    }
>   
>       pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
>       if (local_err) {

Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>

Thanks,
Marcel



  reply	other threads:[~2020-05-03  7:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 18:24 [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot Julia Suvorova
2020-04-27 18:24 ` [PATCH v2 1/2] " Julia Suvorova
2020-05-03  7:46   ` Marcel Apfelbaum [this message]
2020-04-27 18:24 ` [PATCH v2 2/2] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable Julia Suvorova
2020-05-03  7:47   ` Marcel Apfelbaum
2020-04-27 20:10 ` [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot no-reply
2020-04-28 18:10   ` Julia Suvorova

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=2aa78889-043e-32af-e30f-f6d337f26d3f@gmail.com \
    --to=marcel.apfelbaum@gmail.com \
    --cc=berrange@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jusual@redhat.com \
    --cc=mst@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).