All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Andrii Tseglytskyi <andrii.tseglytskyi@globallogic.com>
Cc: Julien Grall <julien.grall@linaro.org>,
	Stefano Stabellini <stefano.stabellini@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH v03 07/10] arm: introduce remoteproc_mmu_translate_pagetable mem subops call
Date: Sat, 13 Sep 2014 01:04:13 +0100	[thread overview]
Message-ID: <alpine.DEB.2.02.1409130101060.15953@kaball.uk.xensource.com> (raw)
In-Reply-To: <1409672770-23164-8-git-send-email-andrii.tseglytskyi@globallogic.com>

On Tue, 2 Sep 2014, Andrii Tseglytskyi wrote:
> The reason of the patch is the following - some remoteprocs
> are quite complicated, and their MMUs can handle several
> pagetables. Good example is a OMAP5 GPU, which allocates
> several pagetables during it work. Additional requirement
> is that not all pagetable physical addresses are stored
> in MMU registers. Some pagetables may be allocated and
> then their physical addresses are sent to GPU using private
> message loop between GPU kernel driver and GPU remoteproc.
> 
> Patch is developed to handle this. At any moment of time
> kernel can perform translation of such pagetables, before
> sending their addresses to GPU remoteproc.

Of course this approach assumes that the kernel driver can be modified
to be able to call the new hypercall.
If so, what stops you from using this hypercall in all the other cases
too?


> Signed-off-by: Andrii Tseglytskyi <andrii.tseglytskyi@globallogic.com>
> ---
>  xen/arch/arm/mm.c                          |  8 ++++++++
>  xen/arch/arm/remoteproc/remoteproc_iommu.c | 31 ++++++++++++++++++++++++++++++
>  xen/include/asm-arm/remoteproc_iommu.h     |  3 +++
>  xen/include/public/memory.h                | 14 +++++++++++++-
>  4 files changed, 55 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 0a243b0..f848ebb 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -40,6 +40,10 @@
>  #include <xsm/xsm.h>
>  #include <xen/pfn.h>
>  
> +#ifdef HAS_REMOTEPROC
> +#include <asm/remoteproc_iommu.h>
> +#endif
> +
>  struct domain *dom_xen, *dom_io, *dom_cow;
>  
>  /* Static start-of-day pagetables that we use before the allocators
> @@ -1117,6 +1121,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)
>      case XENMEM_get_sharing_shared_pages:
>      case XENMEM_get_sharing_freed_pages:
>          return 0;
> +#ifdef HAS_REMOTEPROC
> +    case XENMEM_translate_remote_pagetable:
> +        return remoteproc_iommu_translate_pagetable(arg);
> +#endif
>  
>      default:
>          return -ENOSYS;
> diff --git a/xen/arch/arm/remoteproc/remoteproc_iommu.c b/xen/arch/arm/remoteproc/remoteproc_iommu.c
> index c691619..d0a90a7 100644
> --- a/xen/arch/arm/remoteproc/remoteproc_iommu.c
> +++ b/xen/arch/arm/remoteproc/remoteproc_iommu.c
> @@ -23,6 +23,7 @@
>  #include <xen/init.h>
>  #include <xen/sched.h>
>  #include <xen/stdbool.h>
> +#include <public/memory.h>
>  #include <asm/system.h>
>  #include <asm/current.h>
>  #include <asm/io.h>
> @@ -288,6 +289,36 @@ paddr_t remoteproc_iommu_translate_second_level(struct mmu_info *mmu,
>      return __pa(hyp_pte_table);
>  }
>  
> +long remoteproc_iommu_translate_pagetable(XEN_GUEST_HANDLE_PARAM(void) pgt_addr)
> +{
> +    struct xen_mem_pagetable_addr pgt;
> +    struct mmu_info *mmu = NULL;
> +    int res;
> +
> +    /* check is domain allowed to access remoteproc MMU */
> +    res = xsm_domctl(XSM_HOOK, current->domain, XEN_DOMCTL_access_remote_pagetable);
> +    if ( res )
> +    {
> +        printk(XENLOG_ERR "dom %u is not allowed to access remoteproc MMU res (%d)",
> +               current->domain->domain_id, res);
> +        return -EPERM;
> +    }
> +
> +    if ( copy_from_guest(&pgt, pgt_addr, 1) )
> +        return -EFAULT;
> +
> +    mmu = mmu_lookup(pgt.reg);
> +    if ( !mmu )
> +    {
> +        pr_mmu(mmu, "can't get mmu for addr 0x%"PRIpaddr"", pgt.reg);
> +        return -EINVAL;
> +    }
> +
> +    pgt.maddr = mmu_translate_pagetable(mmu, pgt.paddr);
> +
> +    return copy_to_guest(pgt_addr, &pgt, 1);
> +}
> +
>  static int mmu_init(struct mmu_info *mmu, u32 data)
>  {
>      ASSERT(mmu);
> diff --git a/xen/include/asm-arm/remoteproc_iommu.h b/xen/include/asm-arm/remoteproc_iommu.h
> index 4983505..6aa441a 100644
> --- a/xen/include/asm-arm/remoteproc_iommu.h
> +++ b/xen/include/asm-arm/remoteproc_iommu.h
> @@ -19,6 +19,7 @@
>  #define _REMOTEPROC_IOMMU_H_
>  
>  #include <asm/types.h>
> +#include <xen/guest_access.h>
>  
>  #define MMU_SECTION_SIZE(shift)     (1UL << (shift))
>  #define MMU_SECTION_MASK(shift)     (~(MMU_SECTION_SIZE(shift) - 1))
> @@ -79,6 +80,8 @@ paddr_t remoteproc_iommu_translate_second_level(struct mmu_info *mmu,
>                                                   struct mmu_pagetable *pgt,
>                                                   paddr_t maddr, paddr_t hyp_addr);
>  
> +long remoteproc_iommu_translate_pagetable(XEN_GUEST_HANDLE_PARAM(void) pgt_addr);
> +
>  extern struct mmu_info omap_ipu_mmu;
>  extern struct mmu_info omap_gpu_mmu;
>  
> diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
> index 2c57aa0..2ca8429 100644
> --- a/xen/include/public/memory.h
> +++ b/xen/include/public/memory.h
> @@ -523,7 +523,19 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_sharing_op_t);
>  
>  #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
>  
> -/* Next available subop number is 26 */
> +#ifdef HAS_REMOTEPROC
> +struct xen_mem_pagetable_addr {
> +	paddr_t reg;    /* IN:  device base address */
> +	paddr_t paddr;  /* IN:  pagetable physical address */
> +	paddr_t maddr;  /* OUT: pagetable machine address */
> +};
> +typedef struct xen_mem_pagetable_addr xen_mem_pagetable_addr_t;
> +DEFINE_XEN_GUEST_HANDLE(xen_mem_pagetable_addr_t);
> +
> +#define XENMEM_translate_remote_pagetable   26
> +#endif
> +
> +/* Next available subop number is 27 */
>  
>  #endif /* __XEN_PUBLIC_MEMORY_H__ */
>  
> -- 
> 1.9.1
> 

  parent reply	other threads:[~2014-09-13  0:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02 15:46 [PATCH v03 00/10] arm: introduce remoteprocessor iommu module Andrii Tseglytskyi
2014-09-02 15:46 ` [PATCH v03 01/10] xen: implement guest_physmap_pin_range Andrii Tseglytskyi
2014-09-03  9:43   ` Jan Beulich
2014-09-11  1:12   ` Julien Grall
2014-09-02 15:46 ` [PATCH v03 02/10] domctl: introduce access_remote_pagetable call Andrii Tseglytskyi
2014-09-03  9:46   ` Jan Beulich
2014-09-02 15:46 ` [PATCH v03 03/10] xsm: arm: create domU_rpc_t security label Andrii Tseglytskyi
2014-09-02 15:46 ` [PATCH v03 04/10] arm: introduce remoteprocessor iommu module Andrii Tseglytskyi
2014-09-11  0:41   ` Julien Grall
2014-09-02 15:46 ` [PATCH v03 05/10] arm: omap: introduce iommu translation for IPU remoteproc Andrii Tseglytskyi
2014-09-02 15:46 ` [PATCH v03 06/10] arm: omap: introduce iommu translation for GPU remoteproc Andrii Tseglytskyi
2014-09-02 15:46 ` [PATCH v03 07/10] arm: introduce remoteproc_mmu_translate_pagetable mem subops call Andrii Tseglytskyi
2014-09-03  9:48   ` Jan Beulich
2014-09-13  0:04   ` Stefano Stabellini [this message]
2014-09-02 15:46 ` [PATCH v03 08/10] arm: add trap for remoteproc mmio accesses Andrii Tseglytskyi
2014-09-03  9:52   ` Jan Beulich
2014-09-02 15:46 ` [PATCH v03 09/10] arm: omap: introduce print pagetable function for IPU remoteproc Andrii Tseglytskyi
2014-09-02 15:46 ` [PATCH v03 10/10] arm: omap: introduce print pagetable function for GPU remoteproc 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=alpine.DEB.2.02.1409130101060.15953@kaball.uk.xensource.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=andrii.tseglytskyi@globallogic.com \
    --cc=ian.campbell@citrix.com \
    --cc=julien.grall@linaro.org \
    --cc=stefano.stabellini@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.