* [Qemu-devel] [PULL 0/1] VFIO fixes 2017-07-17
@ 2017-07-17 20:39 Alex Williamson
2017-07-17 20:39 ` [Qemu-devel] [PULL 1/1] vfio-pci, ppc64/spapr: Reorder group-to-container attaching Alex Williamson
2017-07-18 16:54 ` [Qemu-devel] [PULL 0/1] VFIO fixes 2017-07-17 Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: Alex Williamson @ 2017-07-17 20:39 UTC (permalink / raw)
To: qemu-devel
The following changes since commit ca4e667dbf431d4a2a5a619cde79d30dd2ac3eb2:
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20170717-pull-request'
into staging (2017-07-17 17:54:17 +0100)
are available in the git repository at:
git://github.com/awilliam/qemu-vfio.git tags/vfio-updates-20170717.0
for you to fetch changes up to 8c37faa475f35d158622422788fe8e5aef3118e1:
vfio-pci, ppc64/spapr: Reorder group-to-container attaching (2017-07-17
12:39:09 -0600)
----------------------------------------------------------------
VFIO fixes 2017-07-17
- Init re-order to better support hot-add on SPAR (Alexey Kardashevskiy)
----------------------------------------------------------------
Alexey Kardashevskiy (1):
vfio-pci, ppc64/spapr: Reorder group-to-container attaching
hw/vfio/common.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PULL 1/1] vfio-pci, ppc64/spapr: Reorder group-to-container attaching
2017-07-17 20:39 [Qemu-devel] [PULL 0/1] VFIO fixes 2017-07-17 Alex Williamson
@ 2017-07-17 20:39 ` Alex Williamson
2017-07-18 16:54 ` [Qemu-devel] [PULL 0/1] VFIO fixes 2017-07-17 Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2017-07-17 20:39 UTC (permalink / raw)
To: qemu-devel
From: Alexey Kardashevskiy <aik@ozlabs.ru>
At the moment VFIO PCI device initialization works as follows:
vfio_realize
vfio_get_group
vfio_connect_container
register memory listeners (1)
update QEMU groups lists
vfio_kvm_device_add_group
Then (example for pseries) the machine reset hook triggers region_add()
for all regions where listeners from (1) are listening:
ppc_spapr_reset
spapr_phb_reset
spapr_tce_table_enable
memory_region_add_subregion
vfio_listener_region_add
vfio_spapr_create_window
This scheme works fine until we need to handle VFIO PCI device hotplug
and we want to enable PPC64/sPAPR in-kernel TCE acceleration on,
i.e. after PCI hotplug we need a place to call
ioctl(vfio_kvm_device_fd, KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE).
Since the ioctl needs a LIOBN fd (from sPAPRTCETable) and a IOMMU group fd
(from VFIOGroup), vfio_listener_region_add() seems to be the only place
for this ioctl().
However this only works during boot time because the machine reset
happens strictly after all devices are finalized. When hotplug happens,
vfio_listener_region_add() is called when a memory listener is registered
but when this happens:
1. new group is not added to the container->group_list yet;
2. VFIO KVM device is unaware of the new IOMMU group.
This moves bits around to have all necessary VFIO infrastructure
in place for both initial startup and hotplug cases.
[aw: ie, register vfio groups with kvm prior to memory listener
registration such that kvm-vfio pseudo device ioctls are available
during the region_add callback]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/common.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index c1bb6d429a4e..7b2924c0ef19 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1109,6 +1109,14 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
goto free_container_exit;
}
+ vfio_kvm_device_add_group(group);
+
+ QLIST_INIT(&container->group_list);
+ QLIST_INSERT_HEAD(&space->containers, container, next);
+
+ group->container = container;
+ QLIST_INSERT_HEAD(&container->group_list, group, container_next);
+
container->listener = vfio_memory_listener;
memory_listener_register(&container->listener, container->space->as);
@@ -1122,14 +1130,11 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
container->initialized = true;
- QLIST_INIT(&container->group_list);
- QLIST_INSERT_HEAD(&space->containers, container, next);
-
- group->container = container;
- QLIST_INSERT_HEAD(&container->group_list, group, container_next);
-
return 0;
listener_release_exit:
+ QLIST_REMOVE(group, container_next);
+ QLIST_REMOVE(container, next);
+ vfio_kvm_device_del_group(group);
vfio_listener_release(container);
free_container_exit:
@@ -1234,8 +1239,6 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp)
QLIST_INSERT_HEAD(&vfio_group_list, group, next);
- vfio_kvm_device_add_group(group);
-
return group;
close_fd_exit:
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PULL 0/1] VFIO fixes 2017-07-17
2017-07-17 20:39 [Qemu-devel] [PULL 0/1] VFIO fixes 2017-07-17 Alex Williamson
2017-07-17 20:39 ` [Qemu-devel] [PULL 1/1] vfio-pci, ppc64/spapr: Reorder group-to-container attaching Alex Williamson
@ 2017-07-18 16:54 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2017-07-18 16:54 UTC (permalink / raw)
To: Alex Williamson; +Cc: QEMU Developers
On 17 July 2017 at 21:39, Alex Williamson <alex.williamson@redhat.com> wrote:
> The following changes since commit ca4e667dbf431d4a2a5a619cde79d30dd2ac3eb2:
>
> Merge remote-tracking branch 'remotes/kraxel/tags/usb-20170717-pull-request'
> into staging (2017-07-17 17:54:17 +0100)
>
> are available in the git repository at:
>
>
> git://github.com/awilliam/qemu-vfio.git tags/vfio-updates-20170717.0
>
> for you to fetch changes up to 8c37faa475f35d158622422788fe8e5aef3118e1:
>
> vfio-pci, ppc64/spapr: Reorder group-to-container attaching (2017-07-17
> 12:39:09 -0600)
>
> ----------------------------------------------------------------
> VFIO fixes 2017-07-17
>
> - Init re-order to better support hot-add on SPAR (Alexey Kardashevskiy)
>
> ----------------------------------------------------------------
> Alexey Kardashevskiy (1):
> vfio-pci, ppc64/spapr: Reorder group-to-container attaching
>
> hw/vfio/common.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-18 16:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-17 20:39 [Qemu-devel] [PULL 0/1] VFIO fixes 2017-07-17 Alex Williamson
2017-07-17 20:39 ` [Qemu-devel] [PULL 1/1] vfio-pci, ppc64/spapr: Reorder group-to-container attaching Alex Williamson
2017-07-18 16:54 ` [Qemu-devel] [PULL 0/1] VFIO fixes 2017-07-17 Peter Maydell
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).