From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxiwc-0006DK-Rx for qemu-devel@nongnu.org; Wed, 27 May 2015 17:32:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yxiwb-0002RX-Sa for qemu-devel@nongnu.org; Wed, 27 May 2015 17:32:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxiwb-0002RI-L5 for qemu-devel@nongnu.org; Wed, 27 May 2015 17:32:57 -0400 Message-ID: <1432762376.24271.95.camel@redhat.com> From: Alex Williamson Date: Wed, 27 May 2015 15:32:56 -0600 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v8.1 09/13] vfio: add sec_bus_reset notifier to notify physical bus reset is needed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chen Fan Cc: izumi.taku@jp.fujitsu.com, qemu-devel@nongnu.org On Wed, 2015-05-27 at 10:46 +0800, Chen Fan wrote: > Signed-off-by: Chen Fan > --- > hw/vfio/pci.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > index 91ad9ad..a8c5988 100644 > --- a/hw/vfio/pci.c > +++ b/hw/vfio/pci.c > @@ -156,6 +156,7 @@ typedef struct VFIOPCIDevice { > PCIHostDeviceAddress host; > EventNotifier err_notifier; > EventNotifier req_notifier; > + Notifier sec_bus_reset_notifier; > int (*resetfn)(struct VFIOPCIDevice *); > uint32_t features; > #define VFIO_FEATURE_ENABLE_VGA_BIT 0 > @@ -172,6 +173,7 @@ typedef struct VFIOPCIDevice { > bool has_flr; > bool has_pm_reset; > bool has_bus_reset; > + bool needs_bus_reset; > bool rom_read_failed; > } VFIOPCIDevice; > > @@ -3828,6 +3830,17 @@ static Notifier machine_notifier = { > .notify = vfio_pci_machine_done_notify, > }; > > +static void vfio_pci_host_needs_bus_reset(Notifier *n, void *opaque) > +{ > + VFIOPCIDevice *vdev = container_of(n, VFIOPCIDevice, sec_bus_reset_notifier); > + VFIODevice *vbasedev = &vdev->vbasedev; > + > + if (vdev->has_bus_reset) { > + vdev->needs_bus_reset = true; > + vbasedev->needs_reset = true; We really can't trust has_bus_reset, so this could really just be features & AER, which then begs the question why we register a notifier for devices that don't support the AER feature. > + } > +} > + > static int vfio_initfn(PCIDevice *pdev) > { > VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev); > @@ -3978,6 +3991,9 @@ static int vfio_initfn(PCIDevice *pdev) > vfio_register_req_notifier(vdev); > vfio_setup_resetfn(vdev); > > + vdev->sec_bus_reset_notifier.notify = vfio_pci_host_needs_bus_reset; > + pci_bus_add_reset_notifier(pdev->bus, &vdev->sec_bus_reset_notifier); > + > return 0; > > out_teardown: > @@ -4006,6 +4022,7 @@ static void vfio_exitfn(PCIDevice *pdev) > > vfio_unregister_req_notifier(vdev); > vfio_unregister_err_notifier(vdev); > + pci_bus_remove_reset_notifier(&vdev->sec_bus_reset_notifier); > pci_device_set_intx_routing_notifier(&vdev->pdev, NULL); > vfio_disable_interrupts(vdev); > if (vdev->intx.mmap_timer) {