spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)
commitae4de14cd36b6a899d83df9595be3971ac0802d4
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 4 Jul 2016 03:33:07 +0000 (4 13:33 +1000)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 5 Jul 2016 04:31:08 +0000 (5 14:31 +1000)
treee3e9945a88b52683a79d6edc68c8e6e5783e803d
parent2e4109de8e589beecd69996ee14f24021b991c0d
spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)

This adds support for Dynamic DMA Windows (DDW) option defined by
the SPAPR specification which allows to have additional DMA window(s)

The "ddw" property is enabled by default on a PHB but for compatibility
the pseries-2.6 machine and older disable it.
This also creates a single DMA window for the older machines to
maintain backward migration.

This implements DDW for PHB with emulated and VFIO devices. The host
kernel support is required. The advertised IOMMU page sizes are 4K and
64K; 16M pages are supported but not advertised by default, in order to
enable them, the user has to specify "pgsz" property for PHB and
enable huge pages for RAM.

The existing linux guests try creating one additional huge DMA window
with 64K or 16MB pages and map the entire guest RAM to. If succeeded,
the guest switches to dma_direct_ops and never calls TCE hypercalls
(H_PUT_TCE,...) again. This enables VFIO devices to use the entire RAM
and not waste time on map/unmap later. This adds a "dma64_win_addr"
property which is a bus address for the 64bit window and by default
set to 0x800.0000.0000.0000 as this is what the modern POWER8 hardware
uses and this allows having emulated and VFIO devices on the same bus.

This adds 4 RTAS handlers:
* ibm,query-pe-dma-window
* ibm,create-pe-dma-window
* ibm,remove-pe-dma-window
* ibm,reset-pe-dma-window
These are registered from type_init() callback.

These RTAS handlers are implemented in a separate file to avoid polluting
spapr_iommu.c with PCI.

This changes sPAPRPHBState::dma_liobn to an array to allow 2 LIOBNs
and updates all references to dma_liobn. However this does not add
64bit LIOBN to the migration stream as in fact even 32bit LIOBN is
rather pointless there (as it is a PHB property and the management
software can/should pass LIOBNs via CLI) but we keep it for the backward
migration support.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/Makefile.objs
hw/ppc/spapr.c
hw/ppc/spapr_pci.c
hw/ppc/spapr_rtas_ddw.c [new file with mode: 0644]
hw/ppc/trace-events
include/hw/pci-host/spapr.h
include/hw/ppc/spapr.h