From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Alex Williamson <alex.williamson@redhat.com>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
Gavin Shan <gwshan@linux.vnet.ibm.com>,
Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [RFC PATCH v2 11/13] spapr_pci_vfio: Enable DDW
Date: Tue, 26 Aug 2014 18:16:51 +1000 [thread overview]
Message-ID: <53FC4273.2000703@ozlabs.ru> (raw)
In-Reply-To: <20140826071919.GX9923@voom.redhat.com>
On 08/26/2014 05:19 PM, David Gibson wrote:
> On Fri, Aug 15, 2014 at 08:12:33PM +1000, Alexey Kardashevskiy wrote:
>> This implements DDW for VFIO. Host kernel support is required for this.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>> Changes:
>> v2:
>> * remove()/reset() callbacks use spapr_pci's ones
>> ---
>> hw/ppc/spapr_pci_vfio.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 86 insertions(+)
>>
>> diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
>> index 11b4272..79df716 100644
>> --- a/hw/ppc/spapr_pci_vfio.c
>> +++ b/hw/ppc/spapr_pci_vfio.c
>> @@ -71,6 +71,88 @@ static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)
>> spapr_tce_get_iommu(tcet));
>>
>> object_unref(OBJECT(tcet));
>> +
>> + if (sphb->ddw_enabled) {
>> + sphb->ddw_enabled = !!(info.flags & VFIO_IOMMU_SPAPR_TCE_FLAG_DDW);
>
> This overrides an explicit ddw= set by the user, which is a bit
> counter-intuitive.
For the user it is rather "try ddw when available" than "do ddw". This was
suggested by Alex Graf or I misunderstood his suggestion :)
>
>> + }
>> +}
>> +
>> +static int spapr_pci_vfio_ddw_query(sPAPRPHBState *sphb,
>> + uint32_t *windows_available,
>> + uint32_t *page_size_mask)
>> +{
>> + sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
>> + struct vfio_iommu_spapr_tce_query query = { .argsz = sizeof(query) };
>> + int ret;
>> +
>> + ret = vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid,
>> + VFIO_IOMMU_SPAPR_TCE_QUERY, &query);
>> + if (ret) {
>> + return ret;
>> + }
>> +
>> + *windows_available = query.windows_available;
>> + *page_size_mask = query.page_size_mask;
>> +
>> + return ret;
>> +}
>> +
>> +static int spapr_pci_vfio_ddw_create(sPAPRPHBState *sphb, uint32_t page_shift,
>> + uint32_t window_shift, uint32_t liobn,
>> + sPAPRTCETable **ptcet)
>> +{
>> + sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
>> + struct vfio_iommu_spapr_tce_create create = {
>> + .argsz = sizeof(create),
>> + .page_shift = page_shift,
>> + .window_shift = window_shift,
>> + .start_addr = 0
>> + };
>> + int ret;
>> +
>> + ret = vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid,
>> + VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
>> + if (ret) {
>> + return ret;
>> + }
>> +
>> + *ptcet = spapr_tce_new_table(DEVICE(sphb), liobn,
>> + create.start_addr, page_shift,
>> + 1ULL << (window_shift - page_shift),
>> + true);
>> + memory_region_add_subregion(&sphb->iommu_root, (*ptcet)->bus_offset,
>> + spapr_tce_get_iommu(*ptcet));
>> +
>> + return ret;
>> +}
>> +
>> +static int spapr_pci_vfio_ddw_remove(sPAPRPHBState *sphb, sPAPRTCETable *tcet)
>> +{
>> + sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
>> + struct vfio_iommu_spapr_tce_remove remove = {
>> + .argsz = sizeof(remove),
>> + .start_addr = tcet->bus_offset
>> + };
>> + int ret;
>> +
>> + spapr_pci_ddw_remove(sphb, tcet);
>> + ret = vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid,
>> + VFIO_IOMMU_SPAPR_TCE_REMOVE, &remove);
>> +
>> + return ret;
>> +}
>> +
>> +static int spapr_pci_vfio_ddw_reset(sPAPRPHBState *sphb)
>> +{
>> + sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
>> + struct vfio_iommu_spapr_tce_reset reset = { .argsz = sizeof(reset) };
>> + int ret;
>> +
>> + spapr_pci_ddw_reset(sphb);
>> + ret = vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid,
>> + VFIO_IOMMU_SPAPR_TCE_RESET, &reset);
>
> Unlike the non-VFIO version, this doesn't appear to reset ddw_num.
>
> Also, there isn't call to explicitly call DDW reset on system reset.
> Is that handled in kernel by the overall VFIO reset?
"[RFC PATCH v2 09/13] spapr_pci_vfio: Call spapr_pci::reset on reset"
effectively enables spapr_phb_reset() as a reset handler for VFIO PHB and
that function does spc->ddw_reset(). This was the real trigger-reason for
the 09/13 patch.
>> + return ret;
>> }
>>
>> static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data)
>> @@ -80,6 +162,10 @@ static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data)
>>
>> dc->props = spapr_phb_vfio_properties;
>> spc->finish_realize = spapr_phb_vfio_finish_realize;
>> + spc->ddw_query = spapr_pci_vfio_ddw_query;
>> + spc->ddw_create = spapr_pci_vfio_ddw_create;
>> + spc->ddw_remove = spapr_pci_vfio_ddw_remove;
>> + spc->ddw_reset = spapr_pci_vfio_ddw_reset;
>> }
>>
>> static const TypeInfo spapr_phb_vfio_info = {
>
--
Alexey
next prev parent reply other threads:[~2014-08-26 8:17 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-15 10:12 [Qemu-devel] [RFC PATCH v2 00/13] spapr: vfio: Enable Dynamic DMA windows (DDW) Alexey Kardashevskiy
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 01/13] qom: Make object_child_foreach safe for objects removal Alexey Kardashevskiy
2014-08-19 0:39 ` David Gibson
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 02/13] spapr_iommu: Disable in-kernel IOMMU tables for >4GB windows Alexey Kardashevskiy
2014-08-19 0:43 ` David Gibson
2014-08-20 8:09 ` Alexey Kardashevskiy
2014-08-27 9:27 ` Alexander Graf
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 03/13] spapr_pci: Make find_phb()/find_dev() public Alexey Kardashevskiy
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 04/13] spapr_iommu: Make spapr_tce_find_by_liobn() public Alexey Kardashevskiy
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 05/13] spapr_pci: Introduce a liobn number generating macros Alexey Kardashevskiy
2014-08-19 0:44 ` David Gibson
2014-08-27 9:29 ` Alexander Graf
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 06/13] spapr_iommu: Implement free_table() helper Alexey Kardashevskiy
2014-08-26 6:16 ` David Gibson
2014-08-26 7:04 ` Alexey Kardashevskiy
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 07/13] spapr_rtas: Add Dynamic DMA windows (DDW) RTAS calls support Alexey Kardashevskiy
2014-08-26 7:06 ` David Gibson
2014-08-27 9:36 ` Alexander Graf
2014-08-27 13:56 ` Alexey Kardashevskiy
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 08/13] spapr_pci: Enable DDW Alexey Kardashevskiy
2014-08-26 7:14 ` David Gibson
2014-08-26 8:11 ` Alexey Kardashevskiy
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 09/13] spapr_pci_vfio: Call spapr_pci::reset on reset Alexey Kardashevskiy
2014-08-26 6:55 ` David Gibson
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 10/13] linux headers update for DDW Alexey Kardashevskiy
2014-08-18 17:42 ` Alex Williamson
2014-08-20 7:49 ` Alexey Kardashevskiy
2014-08-20 19:44 ` Alex Williamson
2014-08-21 2:47 ` Alexey Kardashevskiy
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 11/13] spapr_pci_vfio: Enable DDW Alexey Kardashevskiy
2014-08-26 7:19 ` David Gibson
2014-08-26 8:16 ` Alexey Kardashevskiy [this message]
2014-08-27 8:25 ` David Gibson
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 12/13] vfio: Enable DDW ioctls to VFIO IOMMU driver Alexey Kardashevskiy
2014-08-26 7:20 ` David Gibson
2014-08-26 8:20 ` Alexey Kardashevskiy
2014-08-27 8:42 ` David Gibson
2014-08-15 10:12 ` [Qemu-devel] [RFC PATCH v2 13/13] spapr: Add pseries-2.2 machine with default "ddw" option Alexey Kardashevskiy
2014-08-27 9:44 ` Alexander Graf
2014-08-27 14:24 ` Alexey Kardashevskiy
2014-08-27 9:44 ` Alexander Graf
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=53FC4273.2000703@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=gwshan@linux.vnet.ibm.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).