[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v3 16/18] spapr_pci_vfio: Enable DDW
From: |
Alexey Kardashevskiy |
Subject: |
[Qemu-devel] [RFC PATCH v3 16/18] spapr_pci_vfio: Enable DDW |
Date: |
Fri, 29 Aug 2014 20:12:20 +1000 |
This implements DDW for VFIO. Host kernel support is required for this.
After this patch DDW will be enabled on all machines but pseries-2.1.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
Changes:
v2:
* remove()/reset() callbacks use spapr_pci's ones
---
hw/ppc/spapr_pci_vfio.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
index e53880e..94e1361 100644
--- a/hw/ppc/spapr_pci_vfio.c
+++ b/hw/ppc/spapr_pci_vfio.c
@@ -73,6 +73,77 @@ static void spapr_phb_vfio_finish_realize(sPAPRPHBState
*sphb, Error **errp)
object_unref(OBJECT(tcet));
sphb->windows_num = 1;
+
+ if (sphb->ddw_enabled) {
+ sphb->ddw_enabled = !!(info.flags & VFIO_IOMMU_SPAPR_TCE_FLAG_DDW);
+ }
+}
+
+static int spapr_pci_vfio_ddw_query(sPAPRPHBState *sphb,
+ uint32_t *windows_available,
+ uint32_t *page_size_mask)
+{
+ sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
+ struct vfio_iommu_spapr_tce_info info = { .argsz = sizeof(info) };
+ int ret;
+
+ ret = vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid,
+ VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info);
+ if (ret) {
+ return ret;
+ }
+
+ *windows_available = info.windows_available;
+ *page_size_mask = info.page_size_mask;
+
+ return ret;
+}
+
+static int spapr_pci_vfio_ddw_create(sPAPRPHBState *sphb, uint32_t page_shift,
+ uint32_t window_shift, uint32_t liobn,
+ sPAPRTCETable **ptcet)
+{
+ sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
+ struct vfio_iommu_spapr_tce_create create = {
+ .argsz = sizeof(create),
+ .page_shift = page_shift,
+ .window_shift = window_shift,
+ .start_addr = 0
+ };
+ int ret;
+
+ ret = vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid,
+ VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
+ if (ret) {
+ return ret;
+ }
+
+ *ptcet = spapr_tce_new_table(DEVICE(sphb), liobn,
+ create.start_addr, page_shift,
+ 1ULL << (window_shift - page_shift),
+ true);
+ memory_region_add_subregion(&sphb->iommu_root, (*ptcet)->bus_offset,
+ spapr_tce_get_iommu(*ptcet));
+
+ ++sphb->windows_num;
+
+ return ret;
+}
+
+static int spapr_pci_vfio_ddw_remove(sPAPRPHBState *sphb, sPAPRTCETable *tcet)
+{
+ sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
+ struct vfio_iommu_spapr_tce_remove remove = {
+ .argsz = sizeof(remove),
+ .start_addr = tcet->bus_offset
+ };
+ int ret;
+
+ spapr_pci_ddw_remove(sphb, tcet);
+ ret = vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid,
+ VFIO_IOMMU_SPAPR_TCE_REMOVE, &remove);
+
+ return ret;
}
static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data)
@@ -82,6 +153,9 @@ static void spapr_phb_vfio_class_init(ObjectClass *klass,
void *data)
dc->props = spapr_phb_vfio_properties;
spc->finish_realize = spapr_phb_vfio_finish_realize;
+ spc->ddw_query = spapr_pci_vfio_ddw_query;
+ spc->ddw_create = spapr_pci_vfio_ddw_create;
+ spc->ddw_remove = spapr_pci_vfio_ddw_remove;
}
static const TypeInfo spapr_phb_vfio_info = {
--
2.0.0
- [Qemu-devel] [RFC PATCH v3 08/18] spapr_iommu: Implement free_table() helper, (continued)
- [Qemu-devel] [RFC PATCH v3 08/18] spapr_iommu: Implement free_table() helper, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 09/18] spapr_rtas: Reserve DDW RTAS token numbers, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 17/18] vfio: Enable DDW ioctls to VFIO IOMMU driver, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 11/18] spapr_pci: Add windows counter, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 06/18] spapr_pci: Make find_phb()/find_dev() public, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 02/18] qom: Make object_child_foreach safe for objects removal, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 12/18] spapr_rtas: Add Dynamic DMA windows (DDW) RTAS calls support, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 14/18] spapr_pci_vfio: Call spapr_pci::reset on reset, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 10/18] spapr_pci: Define DDW callbacks, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 18/18] spapr: Add pseries-2.2 machine, Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 16/18] spapr_pci_vfio: Enable DDW,
Alexey Kardashevskiy <=
- [Qemu-devel] [RFC PATCH v3 15/18] linux headers update for SPAPR (DDW + EEH), Alexey Kardashevskiy, 2014/08/29
- [Qemu-devel] [RFC PATCH v3 13/18] spapr_pci: Enable DDW, Alexey Kardashevskiy, 2014/08/29