From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: Cao jin <caoj.fnst@cn.fujitsu.com>, qemu-devel@nongnu.org
Cc: chen.fan.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com,
alex.williamson@redhat.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH v16 09/14] add check reset mechanism when hotplug vfio device
Date: Mon, 18 Jan 2016 13:03:24 +0200 [thread overview]
Message-ID: <569CC67C.4030307@gmail.com> (raw)
In-Reply-To: <de8047c47180d9ca903d52e8e021693f739d6ede.1452564770.git.chen.fan.fnst@cn.fujitsu.com>
On 01/12/2016 04:43 AM, Cao jin wrote:
> From: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
>
> Since we support multi-function hotplug. the function 0 indicate
I think you wanted , instead of ., also I would suggest
"..., function 0 indicates..."
> the closure of the slot, so we have the chance to do the check.
>
> Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> ---
> hw/pci/pci.c | 29 +++++++++++++++++++++++++++++
> hw/vfio/pci.c | 19 +++++++++++++++++++
> hw/vfio/pci.h | 2 ++
> include/hw/pci/pci_bus.h | 5 +++++
> 4 files changed, 55 insertions(+)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 168b9cc..f6ca6ef 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -81,6 +81,7 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
> PCIBus *bus = PCI_BUS(qbus);
>
> vmstate_register(NULL, -1, &vmstate_pcibus, bus);
> + notifier_with_return_list_init(&bus->hotplug_notifiers);
> }
>
> static void pci_bus_unrealize(BusState *qbus, Error **errp)
> @@ -1835,6 +1836,22 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn)
> return bus->devices[devfn];
> }
>
> +void pci_bus_add_hotplug_notifier(PCIBus *bus, NotifierWithReturn *notify)
> +{
> + notifier_with_return_list_add(&bus->hotplug_notifiers, notify);
> +}
> +
> +void pci_bus_remove_hotplug_notifier(NotifierWithReturn *notifier)
> +{
> + notifier_with_return_remove(notifier);
> +}
> +
> +static int pci_bus_hotplug_notifier(PCIBus *bus, void *opaque)
Maybe pci_bus_hotplug_notify instead of pci_bus_hotplug_notifier
Thanks,
Marcel
> +{
> + return notifier_with_return_list_notify(&bus->hotplug_notifiers,
> + opaque);
> +}
> +
> static void pci_qdev_realize(DeviceState *qdev, Error **errp)
> {
> PCIDevice *pci_dev = (PCIDevice *)qdev;
> @@ -1877,6 +1894,18 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
> pci_qdev_unrealize(DEVICE(pci_dev), NULL);
> return;
> }
> +
> + /*
> + * If the function is func 0, indicate the closure of the slot.
> + * signal the callback.
> + */
> + if (DEVICE(pci_dev)->hotplugged &&
> + pci_get_function_0(pci_dev) == pci_dev &&
> + pci_bus_hotplug_notifier(bus, pci_dev)) {
> + error_setg(errp, "failed to hotplug function 0");
> + pci_qdev_unrealize(DEVICE(pci_dev), NULL);
> + return;
> + }
> }
>
> static void pci_default_realize(PCIDevice *dev, Error **errp)
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 16ab0e3..ff25c9b 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2044,6 +2044,19 @@ static int vfio_check_devices_host_bus_reset(void)
> return 0;
> }
>
> +static int vfio_check_bus_reset(NotifierWithReturn *n, void *opaque)
> +{
> + VFIOPCIDevice *vdev = container_of(n, VFIOPCIDevice, hotplug_notifier);
> + PCIDevice *pci_dev = PCI_DEVICE(vdev);
> + PCIDevice *pci_func0 = opaque;
> +
> + if (pci_get_function_0(pci_dev) != pci_func0) {
> + return 0;
> + }
> +
> + return vfio_check_host_bus_reset(vdev);
> +}
> +
> static int vfio_setup_aer(VFIOPCIDevice *vdev, uint8_t cap_ver,
> int pos, uint16_t size)
> {
> @@ -2091,6 +2104,9 @@ static int vfio_setup_aer(VFIOPCIDevice *vdev, uint8_t cap_ver,
> pdev->exp.aer_log.log_max = 0;
> }
>
> + vdev->hotplug_notifier.notify = vfio_check_bus_reset;
> + pci_bus_add_hotplug_notifier(pdev->bus, &vdev->hotplug_notifier);
> +
> pcie_cap_deverr_init(pdev);
> return pcie_aer_init(pdev, pos, size);
>
> @@ -2972,6 +2988,9 @@ static void vfio_exitfn(PCIDevice *pdev)
> vfio_unregister_req_notifier(vdev);
> vfio_unregister_err_notifier(vdev);
> pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
> + if (vdev->features & VFIO_FEATURE_ENABLE_AER) {
> + pci_bus_remove_hotplug_notifier(&vdev->hotplug_notifier);
> + }
> vfio_disable_interrupts(vdev);
> if (vdev->intx.mmap_timer) {
> timer_free(vdev->intx.mmap_timer);
> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
> index 59ae194..b385f07 100644
> --- a/hw/vfio/pci.h
> +++ b/hw/vfio/pci.h
> @@ -142,6 +142,8 @@ typedef struct VFIOPCIDevice {
> bool no_kvm_intx;
> bool no_kvm_msi;
> bool no_kvm_msix;
> +
> + NotifierWithReturn hotplug_notifier;
> } VFIOPCIDevice;
>
> uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len);
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index 403fec6..7812fa9 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -39,8 +39,13 @@ struct PCIBus {
> Keep a count of the number of devices with raised IRQs. */
> int nirq;
> int *irq_count;
> +
> + NotifierWithReturnList hotplug_notifiers;
> };
>
> +void pci_bus_add_hotplug_notifier(PCIBus *bus, NotifierWithReturn *notify);
> +void pci_bus_remove_hotplug_notifier(NotifierWithReturn *notify);
> +
> typedef struct PCIBridgeWindows PCIBridgeWindows;
>
> /*
>
next prev parent reply other threads:[~2016-01-18 11:03 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 2:43 [Qemu-devel] [PATCH v16 00/14] vfio-pci: pass the aer error to guest Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 01/14] vfio: extract vfio_get_hot_reset_info as a single function Cao jin
2016-01-17 12:48 ` Marcel Apfelbaum
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 02/14] vfio: squeeze out vfio_pci_do_hot_reset for support bus reset Cao jin
2016-01-17 13:01 ` Marcel Apfelbaum
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 03/14] pcie: modify the capability size assert Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 04/14] vfio: make the 4 bytes aligned for capability size Cao jin
2016-01-17 12:30 ` Marcel Apfelbaum
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 05/14] vfio: add pcie extanded capability support Cao jin
2016-01-17 13:22 ` Marcel Apfelbaum
2016-01-19 9:44 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 06/14] aer: impove pcie_aer_init to support vfio device Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 07/14] vfio: add aer support for " Cao jin
2016-01-18 9:12 ` Marcel Apfelbaum
2016-01-19 9:47 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 08/14] vfio: add check host bus reset is support or not Cao jin
2016-01-18 10:32 ` Marcel Apfelbaum
2016-01-19 9:55 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 09/14] add check reset mechanism when hotplug vfio device Cao jin
2016-01-18 11:03 ` Marcel Apfelbaum [this message]
2016-01-19 1:46 ` Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 10/14] pci: introduce pci bus pre reset Cao jin
2016-01-14 20:36 ` Alex Williamson
2016-01-19 10:15 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 11/14] vfio: introduce last reset sequence id Cao jin
2016-01-14 20:43 ` Alex Williamson
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 12/14] pcie_aer: expose pcie_aer_msg() interface Cao jin
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 13/14] vfio-pci: pass the aer error to guest Cao jin
2016-01-18 10:45 ` Marcel Apfelbaum
2016-01-19 9:27 ` Chen Fan
2016-01-12 2:43 ` [Qemu-devel] [PATCH v16 14/14] vfio: add 'aer' property to expose aercap Cao jin
2016-01-18 10:46 ` Marcel Apfelbaum
2016-01-16 18:34 ` [Qemu-devel] [PATCH v16 00/14] vfio-pci: pass the aer error to guest Michael S. Tsirkin
2016-01-19 9:09 ` Chen Fan
2016-02-03 8:54 ` Chen Fan
2016-02-03 13:57 ` Michael S. Tsirkin
2016-02-04 2:04 ` Chen Fan
2016-02-04 11:21 ` Michael S. Tsirkin
2016-02-04 17:46 ` Alex Williamson
2016-02-04 18:09 ` Michael S. Tsirkin
2016-02-04 20:15 ` Alex Williamson
2016-02-04 21:58 ` 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=569CC67C.4030307@gmail.com \
--to=marcel.apfelbaum@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=caoj.fnst@cn.fujitsu.com \
--cc=chen.fan.fnst@cn.fujitsu.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=marcel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.