From: Alexander Graf <agraf@suse.de>
To: Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>, qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH 09/10] spapr_pci_vfio: Enable DDW
Date: Tue, 12 Aug 2014 11:37:59 +0200 [thread overview]
Message-ID: <53E9E077.1040804@suse.de> (raw)
In-Reply-To: <53E959DA.3020206@ozlabs.ru>
On 12.08.14 02:03, Alexey Kardashevskiy wrote:
> On 08/12/2014 03:30 AM, Alexander Graf wrote:
>> On 11.08.14 17:01, Alexey Kardashevskiy wrote:
>>> On 08/11/2014 10:02 PM, Alexander Graf wrote:
>>>> On 31.07.14 11:34, Alexey Kardashevskiy wrote:
>>>>> This implements DDW for VFIO. Host kernel support is required for this.
>>>>>
>>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>>>> ---
>>>>> hw/ppc/spapr_pci_vfio.c | 75
>>>>> +++++++++++++++++++++++++++++++++++++++++++++++++
>>>>> 1 file changed, 75 insertions(+)
>>>>>
>>>>> diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
>>>>> index d3bddf2..dc443e2 100644
>>>>> --- a/hw/ppc/spapr_pci_vfio.c
>>>>> +++ b/hw/ppc/spapr_pci_vfio.c
>>>>> @@ -69,6 +69,77 @@ static void
>>>>> spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)
>>>>> /* Register default 32bit DMA window */
>>>>> memory_region_add_subregion(&sphb->iommu_root, tcet->bus_offset,
>>>>> spapr_tce_get_iommu(tcet));
>>>>> +
>>>>> + sphb->ddw_supported = !!(info.flags & VFIO_IOMMU_SPAPR_TCE_FLAG_DDW);
>>>>> +}
>>>>> +
>>>>> +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, 1 << (window_shift -
>>>>> page_shift),
>>>> I spot a 1 without ULL again - this time it might work out ok, but please
>>>> just always use ULL when you pass around addresses.
>>> My bad. I keep forgetting this, I'll adjust my own checkpatch.py :)
>>>
>>>
>>>> Please walk me though the abstraction levels on what each page size
>>>> honoration means. If I use THP, what page size granularity can I use for
>>>> TCE entries?
>>> [RFC PATCH 06/10] spapr_rtas: Add Dynamic DMA windows (DDW) RTAS calls
>>> support
>>>
>>> + const struct { int shift; uint32_t mask; } masks[] = {
>>> + { 12, DDW_PGSIZE_4K },
>>> + { 16, DDW_PGSIZE_64K },
>>> + { 24, DDW_PGSIZE_16M },
>>> + { 25, DDW_PGSIZE_32M },
>>> + { 26, DDW_PGSIZE_64M },
>>> + { 27, DDW_PGSIZE_128M },
>>> + { 28, DDW_PGSIZE_256M },
>>> + { 34, DDW_PGSIZE_16G },
>>> + };
>>>
>>>
>>> Supported page sizes are returned by the host kernel via "query". For 16MB
>>> pages, page shift will return DDW_PGSIZE_4K|DDW_PGSIZE_64K|DDW_PGSIZE_16M.
>>> Or I did not understand the question...
>> Why do we care about the sizes? Anything bigger than what we support should
>> always work, no? What happens if the guest creates a 16MB map but my pages
>> are 4kb mapped? Wouldn't the same logic be able to deal with 16G pages?
> It is DMA memory, if I split "virtual" 16M page to a bunch of real 4K
> pages, I have to make sure these 16M are continuous - there will be one TCE
> entry for it and no more translations besides IOMMU. What do I miss now?
Who does the shadow translation where? Does it exist at all?
Alex
next prev parent reply other threads:[~2014-08-12 9:38 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 ` [Qemu-devel] [RFC PATCH 08/10] spapr_pci: Enable DDW Alexey Kardashevskiy
2014-08-11 11:59 ` 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 [this message]
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=53E9E077.1040804@suse.de \
--to=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).