From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
Alex Williamson <alex.williamson@redhat.com>,
qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [RFC PATCH 08/10] spapr_pci: Enable DDW
Date: Thu, 31 Jul 2014 19:34:12 +1000 [thread overview]
Message-ID: <1406799254-25223-9-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1406799254-25223-1-git-send-email-aik@ozlabs.ru>
This implements DDW for emulated PHB.
This advertises DDW in device tree.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
The DDW has not been tested as QEMU does not implement any 64bit DMA capable
device and existing linux guests do not use DDW for 32bit DMA.
---
hw/ppc/spapr_pci.c | 65 +++++++++++++++++++++++++++++++++++++++++++++
include/hw/pci-host/spapr.h | 5 ++++
2 files changed, 70 insertions(+)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 230b59c..d1f4c86 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include "sysemu/sysemu.h"
#include "hw/hw.h"
#include "hw/pci/pci.h"
#include "hw/pci/msi.h"
@@ -650,6 +651,8 @@ static void spapr_phb_finish_realize(sPAPRPHBState *sphb, Error **errp)
/* Register default 32bit DMA window */
memory_region_add_subregion(&sphb->iommu_root, 0,
spapr_tce_get_iommu(tcet));
+
+ sphb->ddw_supported = true;
}
static int spapr_phb_children_reset(Object *child, void *opaque)
@@ -781,6 +784,42 @@ static const char *spapr_phb_root_bus_path(PCIHostState *host_bridge,
return sphb->dtbusname;
}
+static int spapr_pci_ddw_query(sPAPRPHBState *sphb,
+ uint32_t *windows_available,
+ uint32_t *page_size_mask)
+{
+ *windows_available = 1;
+ *page_size_mask = DDW_PGSIZE_16M;
+
+ return 0;
+}
+
+static int spapr_pci_ddw_create(sPAPRPHBState *sphb, uint32_t page_shift,
+ uint32_t window_shift, uint32_t liobn,
+ sPAPRTCETable **ptcet)
+{
+ *ptcet = spapr_tce_new_table(DEVICE(sphb), liobn, SPAPR_PCI_TCE64_START,
+ page_shift, 1 << (window_shift - page_shift),
+ true);
+ if (!*ptcet) {
+ return -1;
+ }
+ memory_region_add_subregion(&sphb->iommu_root, (*ptcet)->bus_offset,
+ spapr_tce_get_iommu(*ptcet));
+
+ return 0;
+}
+
+static int spapr_pci_ddw_remove(sPAPRPHBState *sphb, sPAPRTCETable *tcet)
+{
+ return 0;
+}
+
+static int spapr_pci_ddw_reset(sPAPRPHBState *sphb)
+{
+ return 0;
+}
+
static void spapr_phb_class_init(ObjectClass *klass, void *data)
{
PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
@@ -795,6 +834,10 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data)
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
dc->cannot_instantiate_with_device_add_yet = false;
spc->finish_realize = spapr_phb_finish_realize;
+ spc->ddw_query = spapr_pci_ddw_query;
+ spc->ddw_create = spapr_pci_ddw_create;
+ spc->ddw_remove = spapr_pci_ddw_remove;
+ spc->ddw_reset = spapr_pci_ddw_reset;
}
static const TypeInfo spapr_phb_info = {
@@ -878,6 +921,14 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
uint32_t interrupt_map_mask[] = {
cpu_to_be32(b_ddddd(-1)|b_fff(0)), 0x0, 0x0, cpu_to_be32(-1)};
uint32_t interrupt_map[PCI_SLOT_MAX * PCI_NUM_PINS][7];
+ uint32_t ddw_applicable[] = {
+ RTAS_IBM_QUERY_PE_DMA_WINDOW,
+ RTAS_IBM_CREATE_PE_DMA_WINDOW,
+ RTAS_IBM_REMOVE_PE_DMA_WINDOW
+ };
+ uint32_t ddw_extensions[] = { 1, RTAS_IBM_RESET_PE_DMA_WINDOW };
+ sPAPRPHBClass *spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(phb);
+ QemuOpts *machine_opts = qemu_get_machine_opts();
/* Start populating the FDT */
sprintf(nodename, "pci@%" PRIx64, phb->buid);
@@ -907,6 +958,20 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
_FDT(fdt_setprop_cell(fdt, bus_off, "ibm,pci-config-space-type", 0x1));
_FDT(fdt_setprop_cell(fdt, bus_off, "ibm,pe-total-#msi", XICS_IRQS));
+ /* Dynamic DMA window */
+ if (qemu_opt_get_bool(machine_opts, "ddw", true) &&
+ phb->ddw_supported &&
+ spc->ddw_query && spc->ddw_create && spc->ddw_remove) {
+ _FDT(fdt_setprop(fdt, bus_off, "ibm,ddw-applicable", &ddw_applicable,
+ sizeof(ddw_applicable)));
+
+ if (spc->ddw_reset) {
+ /* When enabled, the guest will remove the default 32bit window */
+ _FDT(fdt_setprop(fdt, bus_off, "ibm,ddw-extensions",
+ &ddw_extensions, sizeof(ddw_extensions)));
+ }
+ }
+
/* Build the interrupt-map, this must matches what is done
* in pci_spapr_map_irq
*/
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index 119d326..2046356 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -103,6 +103,8 @@ struct sPAPRPHBState {
int32_t msi_devs_num;
spapr_pci_msi_mig *msi_devs;
+ bool ddw_supported;
+
QLIST_ENTRY(sPAPRPHBState) list;
};
@@ -125,6 +127,9 @@ struct sPAPRPHBVFIOState {
#define SPAPR_PCI_MEM_WIN_BUS_OFFSET 0x80000000ULL
+/* Default 64bit dynamic window offset */
+#define SPAPR_PCI_TCE64_START 0x8000000000000000ULL
+
static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin)
{
return xics_get_qirq(spapr->icp, phb->lsi_table[pin].irq);
--
2.0.0
next prev parent reply other threads:[~2014-07-31 9:34 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 9:34 [Qemu-devel] [RFC PATCH 00/10] spapr: vfio: Enable Dynamic DMA windows (DDW) Alexey Kardashevskiy
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 01/10] qom: Make object_child_foreach safe for objects removal Alexey Kardashevskiy
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 02/10] spapr_iommu: Disable in-kernel IOMMU tables for >4GB windows Alexey Kardashevskiy
2014-08-12 1:17 ` David Gibson
2014-08-12 7:32 ` Alexey Kardashevskiy
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 03/10] spapr_pci: Make find_phb()/find_dev() public Alexey Kardashevskiy
2014-08-11 11:39 ` Alexander Graf
2014-08-11 14:56 ` Alexey Kardashevskiy
2014-08-11 17:16 ` Alexander Graf
2014-08-12 1:19 ` David Gibson
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 04/10] spapr_iommu: Make spapr_tce_find_by_liobn() public Alexey Kardashevskiy
2014-08-12 1:19 ` David Gibson
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 05/10] linux headers update for DDW Alexey Kardashevskiy
2014-08-12 1:20 ` David Gibson
2014-08-12 7:16 ` Alexey Kardashevskiy
2014-08-13 3:23 ` David Gibson
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 06/10] spapr_rtas: Add Dynamic DMA windows (DDW) RTAS calls support Alexey Kardashevskiy
2014-08-11 11:51 ` Alexander Graf
2014-08-11 15:34 ` Alexey Kardashevskiy
2014-08-12 1:45 ` David Gibson
2014-08-12 7:25 ` Alexey Kardashevskiy
2014-08-13 3:27 ` David Gibson
2014-08-14 8:29 ` Alexey Kardashevskiy
2014-08-15 0:04 ` David Gibson
2014-08-15 3:09 ` Alexey Kardashevskiy
2014-08-15 4:20 ` David Gibson
2014-08-15 5:27 ` Alexey Kardashevskiy
2014-08-15 5:30 ` David Gibson
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 07/10] spapr: Add "ddw" machine option Alexey Kardashevskiy
2014-07-31 9:34 ` Alexey Kardashevskiy [this message]
2014-08-11 11:59 ` [Qemu-devel] [RFC PATCH 08/10] spapr_pci: Enable DDW Alexander Graf
2014-08-11 15:26 ` Alexey Kardashevskiy
2014-08-11 17:29 ` Alexander Graf
2014-08-12 0:13 ` Alexey Kardashevskiy
2014-08-12 3:59 ` Alexey Kardashevskiy
2014-08-12 9:36 ` Alexander Graf
2014-08-12 2:10 ` David Gibson
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 09/10] spapr_pci_vfio: " Alexey Kardashevskiy
2014-08-11 12:02 ` Alexander Graf
2014-08-11 15:01 ` Alexey Kardashevskiy
2014-08-11 17:30 ` Alexander Graf
2014-08-12 0:03 ` Alexey Kardashevskiy
2014-08-12 9:37 ` Alexander Graf
2014-08-12 15:10 ` Alexey Kardashevskiy
2014-08-12 15:28 ` Alexander Graf
2014-08-13 0:18 ` Alexey Kardashevskiy
2014-08-14 13:38 ` Alexander Graf
2014-08-15 0:09 ` David Gibson
2014-08-15 3:22 ` Alexey Kardashevskiy
2014-08-15 3:16 ` Alexey Kardashevskiy
2014-08-15 7:37 ` Alexander Graf
2014-08-12 2:14 ` David Gibson
2014-07-31 9:34 ` [Qemu-devel] [RFC PATCH 10/10] vfio: Enable DDW ioctls to VFIO IOMMU driver Alexey Kardashevskiy
2014-08-05 1:30 ` [Qemu-devel] [RFC PATCH 00/10] spapr: vfio: Enable Dynamic DMA windows (DDW) Alexey Kardashevskiy
2014-08-10 23:50 ` Alexey Kardashevskiy
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=1406799254-25223-9-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).