[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH 1/7] vfio: Remove unneeded union from VFIOContaine
From: |
Thomas Huth |
Subject: |
Re: [Qemu-ppc] [PATCH 1/7] vfio: Remove unneeded union from VFIOContainer |
Date: |
Thu, 24 Sep 2015 18:10:29 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 24/09/15 06:33, David Gibson wrote:
> Currently the VFIOContainer iommu_data field contains a union with
> different information for different host iommu types. However:
> * It only actually contains information for the x86-like "Type1" iommu
> * Because we have a common listener the Type1 fields are actually used
> on all IOMMU types, including the SPAPR TCE type as well
> * There's no tag in the VFIOContainer to tell you which union member is
> valid anyway.
>
> In fact we now have a general structure for the listener which is unlikely
> to ever need per-iommu-type information, so this patch removes the union.
>
> In a similar way we can unify the setup of the vfio memory listener in
> vfio_connect_container() that is currently split across a switch on iommu
> type, but is effectively the same in both cases.
>
> The iommu_data.release pointer was only needed as a cleanup function
> which would handle potentially different data in the union. With the
> union gone, it too can be removed.
>
> Signed-off-by: David Gibson <address@hidden>
> ---
[...]
> QLIST_FOREACH_SAFE(giommu, &container->giommu_list, giommu_next,
> tmp) {
> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
> index 9b9901f..fbbe6de 100644
> --- a/include/hw/vfio/vfio-common.h
> +++ b/include/hw/vfio/vfio-common.h
> @@ -59,22 +59,12 @@ typedef struct VFIOAddressSpace {
>
> struct VFIOGroup;
>
> -typedef struct VFIOType1 {
> - MemoryListener listener;
> - int error;
> - bool initialized;
> -} VFIOType1;
> -
> typedef struct VFIOContainer {
> VFIOAddressSpace *space;
> int fd; /* /dev/vfio/vfio, empowered by the attached groups */
> - struct {
> - /* enable abstraction to support various iommu backends */
> - union {
> - VFIOType1 type1;
> - };
> - void (*release)(struct VFIOContainer *);
> - } iommu_data;
> + MemoryListener listener;
> + int error;
> + bool initialized;
Hmmm, maybe it's just bikeshed painting, but would it make sense to
rename the field with a "iommu_" prefix now, e.g. "iommu_error" instead
of "error", so that it is more clear that "error" refers to the IOMMU
stuff? (sorry for coming up with this now after suggesting to remove the
"iommu_data" container which made this clear ... but sometimes you have
to see the code first...)
Thomas
> QLIST_HEAD(, VFIOGuestIOMMU) giommu_list;
> QLIST_HEAD(, VFIOGroup) group_list;
> QLIST_ENTRY(VFIOContainer) next;
>
- Re: [Qemu-ppc] [PATCH 5/7] memory: Allow replay of IOMMU mapping notifications, (continued)
[Qemu-ppc] [PATCH 7/7] vfio: Expose a VFIO PCI device's group for EEH, David Gibson, 2015/09/24
[Qemu-ppc] [PATCH 3/7] vfio: Check guest IOVA ranges against host IOMMU capabilities, David Gibson, 2015/09/24
[Qemu-ppc] [PATCH 6/7] vfio: Allow hotplug of containers onto existing guest IOMMU mappings, David Gibson, 2015/09/24
[Qemu-ppc] [PATCH 1/7] vfio: Remove unneeded union from VFIOContainer, David Gibson, 2015/09/24