From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Alex Williamson <alex.williamson@redhat.com>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH v4 18/18] vfio: Enable in-kernel acceleration via VFIO KVM device
Date: Thu, 5 Feb 2015 15:49:27 +1100 [thread overview]
Message-ID: <20150205044927.GQ25675@voom.fritz.box> (raw)
In-Reply-To: <1422523650-2888-19-git-send-email-aik@ozlabs.ru>
[-- Attachment #1: Type: text/plain, Size: 4851 bytes --]
On Thu, Jan 29, 2015 at 08:27:30PM +1100, Alexey Kardashevskiy wrote:
> TCE hypercalls (H_PUT_TCE, H_PUT_TCE_INDIRECT, H_STUFF_TCE) use a logical bus
> number (LIOBN) to identify which TCE table the request is addressed to.
> However VFIO kernel driver operates with IOMMU group IDs and has no idea
> about which LIOBN corresponds to which group. If the host kernel supports
> in-kernel acceleration for TCE calls, we have to provide the LIOBN to IOMMU
> mapping information.
>
> This makes use of a VFIO KVM device's
> KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE_LIOBN attribute to set the link
> between LIOBN and IOMMU group.
>
> The vfio_container_spapr_set_liobn() helper is implemented completely
> in vfio.c because kvm_vfio_spapr_tce_liobn needs a group fd and
> we do not want to share resources likes that outside vfio.c.
I thought you'd moved away from the idea of in-kernel TCE
acceleration, since big DMA windows made it unnecessary.
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> hw/ppc/spapr_iommu.c | 1 +
> hw/ppc/spapr_pci_vfio.c | 11 +++++++++++
> hw/vfio/common.c | 33 +++++++++++++++++++++++++++++++++
> include/hw/vfio/vfio.h | 4 ++++
> 4 files changed, 49 insertions(+)
>
> diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
> index 258f837..3de95d7 100644
> --- a/hw/ppc/spapr_iommu.c
> +++ b/hw/ppc/spapr_iommu.c
> @@ -142,6 +142,7 @@ static int spapr_tce_table_realize(DeviceState *dev)
> if (!tcet->table) {
> size_t table_size = tcet->nb_table * sizeof(uint64_t);
> tcet->table = g_malloc0(table_size);
> + tcet->vfio_accel = false;
This should probably have a qdev prop so that it can be explicitly
disabled on a per-device basis for testing.
> }
>
> trace_spapr_iommu_new_table(tcet->liobn, tcet, tcet->table, tcet->fd);
> diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
> index 257181d..2078187 100644
> --- a/hw/ppc/spapr_pci_vfio.c
> +++ b/hw/ppc/spapr_pci_vfio.c
> @@ -21,6 +21,7 @@
> #include "hw/pci-host/spapr.h"
> #include "linux/vfio.h"
> #include "hw/vfio/vfio.h"
> +#include "qemu/error-report.h"
>
> static Property spapr_phb_vfio_properties[] = {
> DEFINE_PROP_INT32("iommu", sPAPRPHBVFIOState, iommugroupid, -1),
> @@ -80,6 +81,16 @@ static int spapr_pci_vfio_ddw_create(sPAPRPHBState *sphb, uint32_t liobn,
> memory_region_add_subregion(&sphb->iommu_root, (*ptcet)->bus_offset,
> spapr_tce_get_iommu(*ptcet));
>
> + if (!(*ptcet)->vfio_accel) {
> + return 0;
> + }
> + ret = vfio_container_spapr_set_liobn(&sphb->iommu_as,
> + liobn, (*ptcet)->bus_offset);
> + if (ret) {
> + error_report("spapr-vfio: failed to create link to IOMMU");
> + ret = 0;
> + }
> +
> return ret;
> }
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index a26cbae..ec778d0 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1053,3 +1053,36 @@ int vfio_container_ioctl(AddressSpace *as,
>
> return vfio_container_do_ioctl(as, req, param);
> }
> +
> +int vfio_container_spapr_set_liobn(AddressSpace *as,
> + uint64_t liobn,
> + uint64_t start_addr)
> +{
> +#ifdef CONFIG_KVM
> + int ret;
> + struct kvm_vfio_spapr_tce_liobn param = {
> + .argsz = sizeof(param),
> + .liobn = liobn,
> + .start_addr = start_addr
> + };
> + struct kvm_device_attr attr = {
> + .group = KVM_DEV_VFIO_GROUP,
> + .attr = KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE_LIOBN,
> + .addr = (uint64_t)(unsigned long)¶m,
> + };
> +
> + if (vfio_kvm_device_fd < 0) {
> + return 0;
> + }
> +
> + ret = ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr);
> + if (ret) {
> + error_report("vfio: failed to setup liobn for a group: %s",
> + strerror(errno));
> + }
> +
> + return ret;
> +#else
> + return 0;
> +#endif
> +}
> diff --git a/include/hw/vfio/vfio.h b/include/hw/vfio/vfio.h
> index 76b5744..8457933 100644
> --- a/include/hw/vfio/vfio.h
> +++ b/include/hw/vfio/vfio.h
> @@ -6,4 +6,8 @@
> extern int vfio_container_ioctl(AddressSpace *as,
> int req, void *param);
>
> +extern int vfio_container_spapr_set_liobn(AddressSpace *as,
> + uint64_t liobn,
> + uint64_t start_addr);
> +
> #endif
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-02-05 4:49 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 9:27 [Qemu-devel] [PATCH v4 00/18] spapr: vfio: Enable Dynamic DMA windows (DDW) Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 01/18] spapr_iommu: Disable in-kernel IOMMU tables for >4GB windows Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 02/18] spapr_iommu: Make H_PUT_TCE_INDIRECT endian-safe Alexey Kardashevskiy
2015-02-02 6:30 ` David Gibson
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 03/18] spapr_pci: Introduce a liobn number generating macros Alexey Kardashevskiy
2015-02-04 15:31 ` Alexander Graf
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 04/18] spapr_vio: " Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 05/18] spapr_pci: Make find_phb()/find_dev() public Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 06/18] spapr_iommu: Make spapr_tce_find_by_liobn() public Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 07/18] spapr_iommu: Implement free_table() helper Alexey Kardashevskiy
2015-02-02 6:37 ` David Gibson
2015-02-03 1:32 ` Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 08/18] vfio: Add DMA memory registering Alexey Kardashevskiy
2015-02-02 7:04 ` David Gibson
2015-02-17 2:14 ` Alexey Kardashevskiy
2015-02-17 23:53 ` David Gibson
2015-02-17 2:20 ` [Qemu-devel] [PATCH v4 08/18] vfio: Add DMA memory registering [repost] Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 09/18] spapr_rtas: Reserve DDW RTAS token numbers Alexey Kardashevskiy
2015-02-02 7:09 ` David Gibson
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 10/18] spapr_pci: Define DDW callbacks Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 11/18] spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW) Alexey Kardashevskiy
2015-02-05 3:51 ` David Gibson
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 12/18] spapr_rtas: Add Dynamic DMA windows (DDW) RTAS handlers Alexey Kardashevskiy
2015-02-05 4:05 ` David Gibson
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 13/18] spapr_pci: Advertise dynamic DMA windows to guest Alexey Kardashevskiy
2015-02-05 4:10 ` David Gibson
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 14/18] vfio: Enable DDW ioctls to VFIO IOMMU driver Alexey Kardashevskiy
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 15/18] spapr_pci_vfio: Enable multiple groups per container Alexey Kardashevskiy
2015-02-05 4:19 ` David Gibson
2015-02-17 0:34 ` Alexey Kardashevskiy
2015-02-17 23:52 ` David Gibson
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 16/18] spapr_rtas_ddw: Workaround broken LE guests Alexey Kardashevskiy
2015-02-05 4:23 ` David Gibson
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 17/18] target-ppc: kvm: make use of KVM_CREATE_SPAPR_TCE_64 Alexey Kardashevskiy
2015-02-05 4:30 ` David Gibson
2015-01-29 9:27 ` [Qemu-devel] [PATCH v4 18/18] vfio: Enable in-kernel acceleration via VFIO KVM device Alexey Kardashevskiy
2015-02-05 4:49 ` David Gibson [this message]
2015-02-17 2:36 ` Alexey Kardashevskiy
2015-02-17 23:56 ` David Gibson
2015-01-30 4:01 ` [Qemu-devel] [PATCH v4 00/18] spapr: vfio: Enable Dynamic DMA windows (DDW) 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=20150205044927.GQ25675@voom.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--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).