[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-cohere
From: |
Bogdan Purcareata |
Subject: |
[Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent |
Date: |
Thu, 2 Jun 2016 12:26:22 +0000 |
A PCI device is marked either as coherent or non-coherent based on the pcie
controller "dma-coherent" property. This is further used when configuring the
IOMMU ops for the device DMA resources (e.g. descriptor rings, for e1000e).
This dma-coherent property needs to be configured in the guest environment,
in case there's a directly assigned VFIO PCI device. Since the guest only
receives one emulated pcie controller bus - regardless of the host
configuration - add this property if there's at least one host pcie host
controller that is DMA coherent (this implies that the host interconnect
is coherent as well).
Signed-off-by: Bogdan Purcareata <address@hidden>
---
hw/arm/virt.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 371e3a7..b640174 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -867,6 +867,32 @@ static void create_pcie_irq_map(const VirtBoardInfo *vbi,
uint32_t gic_phandle,
0x7 /* PCI irq */);
}
+static bool is_host_pcie_dma_coherent(void)
+{
+ void *host_fdt;
+ char **node_path;
+ bool ret = false;
+
+ host_fdt = load_device_tree_from_sysfs();
+
+ node_path = qemu_fdt_node_path_prop(host_fdt, "pcie", "dma-coherent",
+ NULL, 0, &error_fatal);
+
+ /* no pcie controllers found on host, therefore non dma-coherent */
+ if (!node_path || !node_path[0]) {
+ goto out;
+ }
+
+ /* for now, if at least one pcie node is dma-coherent,
+ * it is considered that the host is dma-coherent with respect to pcie */
+ ret = true;
+
+out:
+ g_strfreev(node_path);
+ g_free(host_fdt);
+ return ret;
+}
+
static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
bool use_highmem)
{
@@ -981,6 +1007,11 @@ static void create_pcie(const VirtBoardInfo *vbi,
qemu_irq *pic,
}
qemu_fdt_setprop_cell(vbi->fdt, nodename, "#interrupt-cells", 1);
+
+ if (is_host_pcie_dma_coherent()) {
+ qemu_fdt_setprop(vbi->fdt, nodename, "dma-coherent", NULL, 0);
+ }
+
create_pcie_irq_map(vbi, vbi->gic_phandle, irq, nodename);
g_free(nodename);
--
1.9.1
- [Qemu-arm] [PATCH 0/2] arm/virt: Propagate pcie DMA coherency, Bogdan Purcareata, 2016/06/02
- [Qemu-arm] [PATCH 1/2] device_tree: introduce qemu_fdt_node_path_prop, Bogdan Purcareata, 2016/06/02
- [Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent,
Bogdan Purcareata <=
- Re: [Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Peter Maydell, 2016/06/02
- Re: [Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Alexander Graf, 2016/06/02
- Re: [Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Auger Eric, 2016/06/07
- Re: [Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Ard Biesheuvel, 2016/06/16
- Re: [Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Peter Maydell, 2016/06/28
- Re: [Qemu-arm] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Bogdan Purcareata, 2016/06/29
- Re: [Qemu-arm] [Qemu-devel] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Mihai Claudiu Caraman, 2016/06/03
- Re: [Qemu-arm] [Qemu-devel] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Peter Maydell, 2016/06/03
- Re: [Qemu-arm] [Qemu-devel] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, agraf, 2016/06/03
- Re: [Qemu-arm] [Qemu-devel] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent, Mihai Claudiu Caraman, 2016/06/03