All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Tseglytskyi <andrii.tseglytskyi@globallogic.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH v02 2/7] arm: omap: introduce iommu translation for IPU remoteproc
Date: Tue, 22 Jul 2014 19:56:34 +0300	[thread overview]
Message-ID: <CAH_mUMPY0JPOQxCmk8Cn11X9wPfNifb=QsdJtn+FfKNorS7+sQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1407041500120.27641@kaball.uk.xensource.com>

On Fri, Jul 4, 2014 at 5:01 PM, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> On Thu, 26 Jun 2014, Andrii Tseglytskyi wrote:
>> The following patch introduced platform specific MMU data
>> definitions and pagetable translation function for OMAP5 IPU
>> remoteproc. This MMU is a bit specific - it typically performs
>> one level translation and map a big chunks of memory. 16 Mb
>> supersections and 1 Mb sections are mapped instead of 4 Kb pages.
>> Introduced algorithm performs internal remapping of big sections
>> to small 4 Kb pages.
>>
>> Change-Id: If20449f07e22f780e1fded67fed4f79cbe1fc156
>> Signed-off-by: Andrii Tseglytskyi <andrii.tseglytskyi@globallogic.com>
>> ---
>>  xen/arch/arm/platforms/Makefile     |    1 +
>>  xen/arch/arm/platforms/omap_iommu.c |  247 +++++++++++++++++++++++++++++++++++
>>  xen/arch/arm/remoteproc_iommu.c     |    1 +
>>  xen/include/xen/remoteproc_iommu.h  |    2 +
>>  4 files changed, 251 insertions(+)
>>  create mode 100644 xen/arch/arm/platforms/omap_iommu.c
>>
>> diff --git a/xen/arch/arm/platforms/Makefile b/xen/arch/arm/platforms/Makefile
>> index 080ea9a..f224f08 100644
>> --- a/xen/arch/arm/platforms/Makefile
>> +++ b/xen/arch/arm/platforms/Makefile
>> @@ -4,4 +4,5 @@ obj-$(CONFIG_ARM_32) += midway.o
>>  obj-$(CONFIG_ARM_32) += omap5.o
>>  obj-$(CONFIG_ARM_32) += dra7xx.o
>>  obj-$(CONFIG_ARM_32) += sunxi.o
>> +obj-$(CONFIG_ARM_32) += omap_iommu.o
>>  obj-$(CONFIG_ARM_64) += xgene-storm.o
>> diff --git a/xen/arch/arm/platforms/omap_iommu.c b/xen/arch/arm/platforms/omap_iommu.c
>> new file mode 100644
>> index 0000000..e0c4633
>> --- /dev/null
>> +++ b/xen/arch/arm/platforms/omap_iommu.c
>> @@ -0,0 +1,247 @@
>> +/*
>> + * xen/arch/arm/platforms/omap_iommu.c
>> + *
>> + * Andrii Tseglytskyi <andrii.tseglytskyi@globallogic.com>
>> + * Copyright (c) 2014 GlobalLogic
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <xen/lib.h>
>> +#include <xen/errno.h>
>> +#include <xen/stdbool.h>
>> +#include <xen/mm.h>
>> +#include <xen/vmap.h>
>> +#include <xen/sched.h>
>> +#include <xen/remoteproc_iommu.h>
>> +
>> +#include <asm/p2m.h>
>> +
>> +/*
>> + * "L2 table" address mask and size definitions.
>> + */
>> +
>> +/* register where address of pagetable is stored */
>> +#define MMU_IPU_TTB_OFFSET          0x4c
>> +
>> +/* 1st level translation */
>> +#define MMU_OMAP_PGD_SHIFT          20
>> +#define MMU_OMAP_SUPER_SHIFT        24       /* "supersection" - 16 Mb */
>> +#define MMU_OMAP_SECTION_SHIFT      20       /* "section"  - 1 Mb */
>> +#define MMU_OMAP_SECOND_LEVEL_SHIFT 10
>> +
>> +/* 2nd level translation */
>> +#define MMU_OMAP_PTE_SMALL_SHIFT    12       /* "small page" - 4Kb */
>> +#define MMU_OMAP_PTE_LARGE_SHIFT    16       /* "large page" - 64 Kb */
>> +
>> +/*
>> + * some descriptor attributes.
>> + */
>> +#define PGD_TABLE       (1 << 0)
>> +#define PGD_SECTION     (2 << 0)
>> +#define PGD_SUPER       (1 << 18 | 2 << 0)
>> +
>> +#define ipu_pgd_is_table(x)     (((x) & 3) == PGD_TABLE)
>> +#define ipu_pgd_is_section(x)   (((x) & (1 << 18 | 3)) == PGD_SECTION)
>> +#define ipu_pgd_is_super(x)     (((x) & (1 << 18 | 3)) == PGD_SUPER)
>> +
>> +#define PTE_SMALL       (2 << 0)
>> +#define PTE_LARGE       (1 << 0)
>> +
>> +#define      OMAP_IPU_MMU_MEM_BASE   0x55082000
>> +
>> +static u32 mmu_ipu_translate_pagetable(struct mmu_info *mmu, struct mmu_pagetable *pgt);
>> +
>> +static u32 ipu_trap_offsets[] = {
>> +    MMU_IPU_TTB_OFFSET,
>> +};
>> +
>> +static const struct pagetable_data pagetable_ipu_data = {
>> +    .pgd_shift          = MMU_OMAP_PGD_SHIFT,
>> +    .super_shift        = MMU_OMAP_SUPER_SHIFT,
>> +    .section_shift      = MMU_OMAP_SECTION_SHIFT,
>> +    .pte_shift          = MMU_OMAP_PTE_SMALL_SHIFT,
>> +    .pte_large_shift    = MMU_OMAP_PTE_LARGE_SHIFT,
>> +};
>> +
>> +struct mmu_info omap_ipu_mmu = {
>> +    .name           = "IPU_L2_MMU",
>> +    .pg_data        = &pagetable_ipu_data,
>> +    .trap_offsets   = ipu_trap_offsets,
>> +    .mem_start      = OMAP_IPU_MMU_MEM_BASE,
>> +    .mem_size       = 0x1000,
>> +    .num_traps          = ARRAY_SIZE(ipu_trap_offsets),
>> +    .translate_pfunc = mmu_ipu_translate_pagetable,
>> +};
>> +
>> +static bool translate_supersections_to_pages = true;
>> +static bool translate_sections_to_pages = true;
>> +
>> +static u32 mmu_pte_table_alloc(struct mmu_info *mmu, u32 pgd, u32 sect_num,
>> +                               struct mmu_pagetable *pgt, u32 hyp_addr)
>> +{
>> +    u32 *pte = NULL;
>> +    u32 i;
>> +
>> +    /* allocate pte table once */
>> +    if ( 0 == hyp_addr )
>> +    {
>> +        pte = xzalloc_bytes(PAGE_SIZE);
>> +        if ( !pte )
>> +        {
>> +            pr_mmu("failed to alloc 2nd level table");
>> +            return 0;
>> +        }
>> +    }
>> +    else
>> +    {
>> +        pte = __va(hyp_addr & MMU_SECTION_MASK(mmu->pg_data->pte_shift));
>> +    }
>> +
>> +    ASSERT(256 == MMU_PTRS_PER_PTE(mmu));
>> +
>> +    for ( i = 0; i < MMU_PTRS_PER_PTE(mmu); i++ )
>> +    {
>> +        u32 paddr, maddr;
>> +
>> +        paddr = pgd + (i * PAGE_SIZE);
>> +        maddr = p2m_lookup(current->domain, paddr, NULL);
>
> Here is where you would need to make sure that paddr->maddr doesn't
> change in the future by pinning the mapping.
>

OK.

Regards,
Andrii


-- 

Andrii Tseglytskyi | Embedded Dev
GlobalLogic
www.globallogic.com

  reply	other threads:[~2014-07-22 16:56 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 11:06 [PATCH v02 0/7] arm: introduce remoteprocessor iommu module Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 1/7] " Andrii Tseglytskyi
2014-06-29 18:00   ` Julien Grall
2014-07-22 15:20     ` Andrii Tseglytskyi
2014-07-22 16:29       ` Julien Grall
2014-07-31 11:59       ` Andrii Tseglytskyi
2014-07-31 12:11         ` Julien Grall
2014-07-31 12:49           ` Andrii Tseglytskyi
2014-07-04 13:59   ` Stefano Stabellini
2014-07-16 15:19     ` Ian Campbell
2014-07-22 12:42       ` Stefano Stabellini
2014-07-22 13:29         ` Julien Grall
2014-07-22 16:31           ` Andrii Tseglytskyi
2014-07-22 17:22         ` Andrii Tseglytskyi
2014-07-23 10:32           ` Stefano Stabellini
2014-07-23 10:54             ` Andrii Tseglytskyi
2014-07-22 15:40       ` Andrii Tseglytskyi
2014-07-22 15:32     ` Andrii Tseglytskyi
2014-08-01 10:06       ` Andrii Tseglytskyi
2014-08-01 10:32         ` Julien Grall
2014-08-01 10:34           ` Andrii Tseglytskyi
2014-08-01 10:37             ` Julien Grall
2014-08-01 10:43               ` Andrii Tseglytskyi
2014-08-20 19:40     ` Andrii Tseglytskyi
2014-08-21 15:30       ` Andrii Tseglytskyi
2014-08-21 23:41         ` Stefano Stabellini
2014-08-21 23:43       ` Stefano Stabellini
2014-07-16 15:29   ` Ian Campbell
2014-07-16 15:34     ` Ian Campbell
2014-07-22 16:24       ` Andrii Tseglytskyi
2014-07-22 16:14     ` Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 2/7] arm: omap: introduce iommu translation for IPU remoteproc Andrii Tseglytskyi
2014-07-04 14:01   ` Stefano Stabellini
2014-07-22 16:56     ` Andrii Tseglytskyi [this message]
2014-07-04 14:30   ` Julien Grall
2014-07-22 16:58     ` Andrii Tseglytskyi
2014-07-16 15:36   ` Ian Campbell
2014-07-22 17:16     ` Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 3/7] arm: omap: introduce iommu translation for GPU remoteproc Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 4/7] arm: omap: introduce print pagetable function for IPU remoteproc Andrii Tseglytskyi
2014-07-16 15:38   ` Ian Campbell
2014-07-22 16:55     ` Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 5/7] arm: omap: introduce print pagetable function for GPU remoteproc Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 6/7] arm: introduce do_translate_pagetable hypercall Andrii Tseglytskyi
2014-07-04 14:05   ` Stefano Stabellini
2014-07-16 15:42     ` Ian Campbell
2014-07-22 16:47       ` Andrii Tseglytskyi
2014-07-22 16:37     ` Andrii Tseglytskyi
2014-07-04 14:35   ` Julien Grall
2014-07-16 15:43     ` Ian Campbell
2014-07-22 16:50       ` Andrii Tseglytskyi
2014-07-22 16:39     ` Andrii Tseglytskyi
2014-07-22 16:44       ` Julien Grall
2014-07-22 16:48         ` Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 7/7] arm: add trap for remoteproc mmio accesses Andrii Tseglytskyi
2014-06-26 16:52   ` Julien Grall
2014-06-27  8:36     ` Andrii Tseglytskyi

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='CAH_mUMPY0JPOQxCmk8Cn11X9wPfNifb=QsdJtn+FfKNorS7+sQ@mail.gmail.com' \
    --to=andrii.tseglytskyi@globallogic.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.