From: Alex Williamson <alex.williamson@redhat.com>
To: Cao jin <caoj.fnst@cn.fujitsu.com>
Cc: chen.fan.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com,
qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 09/11] vfio: vote a device to do host bus reset
Date: Wed, 9 Mar 2016 09:37:17 -0700 [thread overview]
Message-ID: <20160309093717.2150687a@t450s.home> (raw)
In-Reply-To: <1457320984-6540-10-git-send-email-caoj.fnst@cn.fujitsu.com>
On Mon, 7 Mar 2016 11:23:02 +0800
Cao jin <caoj.fnst@cn.fujitsu.com> wrote:
> From: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
>
> Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> ---
> hw/vfio/pci.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> hw/vfio/pci.h | 1 +
> 2 files changed, 58 insertions(+)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 24848c9..8e902d2 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -1937,6 +1937,8 @@ static void vfio_check_host_bus_reset(VFIOPCIDevice *vdev, Error **errp)
> /* List all affected devices by bus reset */
> devices = &info->devices[0];
>
> + vdev->single_depend_dev = (info->count == 1);
> +
> /* Verify that we have all the groups required */
> for (i = 0; i < info->count; i++) {
> PCIHostDeviceAddress host;
> @@ -2998,6 +3000,49 @@ static void vfio_exitfn(PCIDevice *pdev)
> vfio_unregister_bars(vdev);
> }
>
> +static VFIOPCIDevice *vfio_pci_get_do_reset_device(VFIOPCIDevice *vdev)
> +{
> + struct vfio_pci_hot_reset_info *info = NULL;
> + struct vfio_pci_dependent_device *devices;
> + VFIOGroup *group;
> + VFIODevice *vbasedev_iter;
> + int ret;
> +
> + ret = vfio_get_hot_reset_info(vdev, &info);
> + if (ret) {
> + error_report("vfio: Cannot enable AER for device %s,"
> + " device does not support hot reset.",
> + vdev->vbasedev.name);
> + return NULL;
Isn't this path called for all devices, not just those trying to
support AER?
> + }
> +
> + devices = &info->devices[0];
> +
> + QLIST_FOREACH(group, &vfio_group_list, next) {
> + if (group->groupid == devices[0].group_id) {
> + break;
> + }
> + }
> +
> + if (!group) {
> + error_report("vfio: Cannot enable AER for device %s, "
> + "depends on group %d which is not owned.",
> + vdev->vbasedev.name, devices[0].group_id);
> + return NULL;
Same here, we're not in an AER specific code path and we haven't even
tested if the device is trying to support AER.
> + }
> +
> + QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
> + if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI ||
> + !(vdev->features & VFIO_FEATURE_ENABLE_AER)) {
> + continue;
> + }
> +
> + return container_of(vbasedev_iter, VFIOPCIDevice, vbasedev);
So the reset device is simply the first device in the group list, this
needs to be documented, but DMA isolation (grouping) and bus isolation
are separate things and we can have more than one group per bus...
often an IOMMU group is a single device, so have we really solved
anything here? If the next device is on the same bus but in a separate
group, we're going to hot reset again, right? Thanks,
Alex
> + }
> +
> + return NULL;
> +}
> +
> static void vfio_pci_reset(DeviceState *dev)
> {
> PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);
> @@ -3005,6 +3050,18 @@ static void vfio_pci_reset(DeviceState *dev)
>
> trace_vfio_pci_reset(vdev->vbasedev.name);
>
> + if (pdev->bus->in_hot_reset) {
> + VFIOPCIDevice *tmp;
> +
> + tmp = vfio_pci_get_do_reset_device(vdev);
> + if (tmp) {
> + if (tmp == vdev) {
> + vfio_pci_hot_reset(vdev, vdev->single_depend_dev);
> + }
> + return;
> + }
> + }
> +
> vfio_pci_pre_reset(vdev);
>
> if (vdev->resetfn && !vdev->resetfn(vdev)) {
> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
> index aff46c2..32bd31f 100644
> --- a/hw/vfio/pci.h
> +++ b/hw/vfio/pci.h
> @@ -143,6 +143,7 @@ typedef struct VFIOPCIDevice {
> bool no_kvm_intx;
> bool no_kvm_msi;
> bool no_kvm_msix;
> + bool single_depend_dev;
> } VFIOPCIDevice;
>
> uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len);
next prev parent reply other threads:[~2016-03-09 16:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-07 3:22 [Qemu-devel] [PATCH v2 Resend 00/11] vfio-pci: pass the aer error to guest, part2 Cao jin
2016-03-07 3:22 ` [Qemu-devel] [PATCH v2 01/11] vfio: extract vfio_get_hot_reset_info as a single function Cao jin
2016-03-07 3:22 ` [Qemu-devel] [PATCH v2 02/11] vfio: squeeze out vfio_pci_do_hot_reset for support bus reset Cao jin
2016-03-07 3:22 ` [Qemu-devel] [PATCH v2 03/11] vfio: add pcie extended capability support Cao jin
2016-03-07 3:22 ` [Qemu-devel] [PATCH v2 04/11] vfio: add aer support for vfio device Cao jin
2016-03-08 22:55 ` Alex Williamson
2016-03-09 1:21 ` Chen Fan
2016-03-07 3:22 ` [Qemu-devel] [PATCH v2 05/11] vfio: add check host bus reset is support or not Cao jin
2016-03-08 22:55 ` Alex Williamson
2016-03-09 1:26 ` Chen Fan
2016-03-09 16:47 ` Michael S. Tsirkin
2016-03-09 16:59 ` Alex Williamson
2016-03-09 17:21 ` Michael S. Tsirkin
2016-03-07 3:22 ` [Qemu-devel] [PATCH v2 06/11] pci: add a is_valid_func callback to check device if complete Cao jin
2016-03-09 16:22 ` Michael S. Tsirkin
2016-03-09 16:50 ` Alex Williamson
2016-03-09 17:14 ` Michael S. Tsirkin
2016-03-10 2:00 ` Chen Fan
2016-03-07 3:23 ` [Qemu-devel] [PATCH v2 07/11] vfio: add check aer functionality for hotplug device Cao jin
2016-03-07 3:23 ` [Qemu-devel] [PATCH v2 08/11] pci: introduce pci bus pre reset Cao jin
2016-03-07 3:23 ` [Qemu-devel] [PATCH v2 09/11] vfio: vote a device to do host bus reset Cao jin
2016-03-09 10:07 ` Michael S. Tsirkin
2016-03-09 16:37 ` Alex Williamson [this message]
2016-03-10 6:15 ` Chen Fan
2016-03-10 14:16 ` Michael S. Tsirkin
2016-03-09 16:39 ` Michael S. Tsirkin
2016-03-09 17:09 ` Alex Williamson
2016-03-09 17:31 ` Michael S. Tsirkin
2016-03-07 3:23 ` [Qemu-devel] [PATCH v2 10/11] vfio-pci: pass the aer error to guest Cao jin
2016-03-07 3:23 ` [Qemu-devel] [PATCH v2 11/11] vfio: add 'aer' property to expose aercap Cao jin
-- strict thread matches above, loose matches on Subject: below --
2016-02-19 10:42 [Qemu-devel] [PATCH v2 00/11] vfio-pci: pass the aer error to guest, part2 Cao jin
2016-02-19 10:42 ` [Qemu-devel] [PATCH v2 09/11] vfio: vote a device to do host bus reset Cao jin
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=20160309093717.2150687a@t450s.home \
--to=alex.williamson@redhat.com \
--cc=caoj.fnst@cn.fujitsu.com \
--cc=chen.fan.fnst@cn.fujitsu.com \
--cc=izumi.taku@jp.fujitsu.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).