From: Bogdan Purcareata <bogdan.purcareata@nxp.com>
To: eric.auger@linaro.org, crosthwaite.peter@gmail.com,
agraf@suse.de, peter.maydell@linaro.org
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent
Date: Thu, 2 Jun 2016 12:26:22 +0000 [thread overview]
Message-ID: <1464870382-385-3-git-send-email-bogdan.purcareata@nxp.com> (raw)
In-Reply-To: <1464870382-385-1-git-send-email-bogdan.purcareata@nxp.com>
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 <bogdan.purcareata@nxp.com>
---
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
next prev parent reply other threads:[~2016-06-02 12:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 12:26 [Qemu-devel] [PATCH 0/2] arm/virt: Propagate pcie DMA coherency Bogdan Purcareata
2016-06-02 12:26 ` [Qemu-devel] [PATCH 1/2] device_tree: introduce qemu_fdt_node_path_prop Bogdan Purcareata
2016-06-02 12:26 ` Bogdan Purcareata [this message]
2016-06-02 12:32 ` [Qemu-devel] [PATCH 2/2] arm/virt: Mark pcie controller node as dma-coherent Peter Maydell
2016-06-02 12:45 ` Alexander Graf
2016-06-07 7:58 ` Auger Eric
2016-06-16 13:58 ` Ard Biesheuvel
2016-06-28 14:16 ` Peter Maydell
2016-06-29 7:52 ` Bogdan Purcareata
2016-06-03 14:22 ` Mihai Claudiu Caraman
2016-06-03 14:37 ` Peter Maydell
2016-06-03 15:02 ` agraf
2016-06-03 15:16 ` Mihai Claudiu Caraman
2016-06-03 15:25 ` Alexander Graf
2016-06-03 16:44 ` Mihai Claudiu Caraman
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=1464870382-385-3-git-send-email-bogdan.purcareata@nxp.com \
--to=bogdan.purcareata@nxp.com \
--cc=agraf@suse.de \
--cc=crosthwaite.peter@gmail.com \
--cc=eric.auger@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--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).