[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v03 07/10] arm: introduce remoteproc_mmu_translate_pagetable mem subops call



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.

Signed-off-by: Andrii Tseglytskyi <andrii.tseglytskyi@xxxxxxxxxxxxxxx>
---
 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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.