MGS-3448: gpu-viv: fix 6.2.4 remaning issues
authorXianzhong <xianzhong.li@nxp.com>
Fri, 24 Nov 2017 14:57:33 +0000 (22:57 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:55:41 +0000 (15:55 -0500)
include more GPU bug-fxings for Android DRM feature

Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
drivers/mxc/gpu-viv/hal/kernel/arch/gc_hal_kernel_hardware.c
drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c
drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h
drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c
drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_driver.h
drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_drm.h
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_drm.c
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.h

index 6d802df..61217eb 100644 (file)
@@ -1070,9 +1070,6 @@ _QueryFeatureDatabase(
         {
             available = gcvFALSE;
         }
-#if !gcdDVFS
-        available = gcvFALSE;
-#endif
         break;
 
     case gcvFEATURE_ACE:
@@ -2536,19 +2533,26 @@ gckHARDWARE_InitializeHardware(
                                      0x0010C,
                                      &data));
 
-#if gcdDVFS
         /* Disable internal DFS. */
-        data = ((((gctUINT32) (data)) & ~(((gctUINT32) (((gctUINT32) ((((1 ?
+        data =
+#if gcdDVFS
+            ((((gctUINT32) (data)) & ~(((gctUINT32) (((gctUINT32) ((((1 ?
  18:18) - (0 ? 18:18) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 18:18) - (0 ?
  18:18) + 1))))))) << (0 ? 18:18))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ?
  18:18) - (0 ? 18:18) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 18:18) - (0 ?
- 18:18) + 1))))))) << (0 ? 18:18)));
-
-#else
-        /* Disable externl DVFS and auto-gating*/
-        data &= ~0x50000;
-        data |=  0x20000;
+ 18:18) + 1))))))) << (0 ? 18:18))) |
 #endif
+            ((((gctUINT32) (data)) & ~(((gctUINT32) (((gctUINT32) ((((1 ?
+ 16:16) - (0 ? 16:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 16:16) - (0 ?
+ 16:16) + 1))))))) << (0 ? 16:16))) | (((gctUINT32) ((gctUINT32) (0) & ((gctUINT32) ((((1 ?
+ 16:16) - (0 ? 16:16) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 16:16) - (0 ?
+ 16:16) + 1))))))) << (0 ? 16:16))) |
+            ((((gctUINT32) (data)) & ~(((gctUINT32) (((gctUINT32) ((((1 ?
+ 17:17) - (0 ? 17:17) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:17) - (0 ?
+ 17:17) + 1))))))) << (0 ? 17:17))) | (((gctUINT32) ((gctUINT32) (1) & ((gctUINT32) ((((1 ?
+ 17:17) - (0 ? 17:17) + 1) == 32) ? ~0U : (~(~0U << ((1 ? 17:17) - (0 ?
+ 17:17) + 1))))))) << (0 ? 17:17)));
+
         gcmkONERROR(gckOS_WriteRegisterEx(Hardware->os,
                                       Hardware->core,
                                       0x0010C,
index 9251dfa..20f45b4 100644 (file)
@@ -3189,7 +3189,8 @@ gckKERNEL_Dispatch(
     case gcvHAL_WRAP_USER_MEMORY:
         gcmkONERROR(gckVIDMEM_NODE_WrapUserMemory(Kernel,
                                                   &Interface->u.WrapUserMemory.desc,
-                                                  &Interface->u.WrapUserMemory.node));
+                                                  &Interface->u.WrapUserMemory.node,
+                                                  &Interface->u.WrapUserMemory.bytes));
 
         gcmkONERROR(
             gckKERNEL_AddProcessDB(Kernel,
index 2786506..f6d5d8b 100644 (file)
@@ -1316,7 +1316,8 @@ gceSTATUS
 gckVIDMEM_NODE_WrapUserMemory(
     IN gckKERNEL Kernel,
     IN gcsUSER_MEMORY_DESC_PTR Desc,
-    OUT gctUINT32 * Handle
+    OUT gctUINT32 * Handle,
+    OUT gctUINT64 * Bytes
     );
 
 gceSTATUS
index 386468d..0573116 100644 (file)
@@ -3248,7 +3248,8 @@ gceSTATUS
 gckVIDMEM_NODE_WrapUserMemory(
     IN gckKERNEL Kernel,
     IN gcsUSER_MEMORY_DESC_PTR Desc,
-    OUT gctUINT32 * Handle
+    OUT gctUINT32 * Handle,
+    OUT gctUINT64 * Bytes
     )
 {
     gceSTATUS status = gcvSTATUS_OK;
@@ -3260,6 +3261,7 @@ gckVIDMEM_NODE_WrapUserMemory(
     gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
     gcmkVERIFY_ARGUMENT(Desc);
     gcmkVERIFY_ARGUMENT(Handle);
+    gcmkVERIFY_ARGUMENT(Bytes);
 
 #if defined(CONFIG_DMA_SHARED_BUFFER)
     if (Desc->flag & gcvALLOC_FLAG_DMABUF)
@@ -3295,6 +3297,8 @@ gckVIDMEM_NODE_WrapUserMemory(
                 /* Allocate a handle for current process. */
                 gcmkERR_BREAK(gckVIDMEM_HANDLE_Allocate(Kernel, nodeObject, Handle));
                 found = gcvTRUE;
+
+                *Bytes = (gctUINT64)dmabuf->size;
             }
             while (gcvFALSE);
 
@@ -3333,6 +3337,8 @@ gckVIDMEM_NODE_WrapUserMemory(
                 gcvPOOL_VIRTUAL,
                 Handle
                 ));
+
+            *Bytes = (gctUINT64)node->Virtual.bytes;
         }
         while (gcvFALSE);
 
index f2c5cb3..b4f09bb 100644 (file)
@@ -1266,6 +1266,8 @@ typedef struct _gcsHAL_INTERFACE
             /* Output video mmory node. */
             OUT gctUINT32               node;
 
+            /* size of the node in bytes */
+            OUT gctUINT64               bytes;
         }
         WrapUserMemory;
 
index 9167e70..cbdbb20 100644 (file)
 *
 *****************************************************************************/
 
+#ifndef __VIVNATE_DRM_H__
+#define __VIVNATE_DRM_H__
 
-#ifndef __GC_HAL_DRM_H__
-#define __GC_HAL_DRM_H__
+#if !defined(__KERNEL__)
+#include <drm.h>
+#endif
 
 #if defined(__cplusplus)
 extern "C" {
 #endif
 
 /* creation flag bits. */
-#define DRM_VIV_GEM_CONTIGUOUS      0x01
-#define DRM_VIV_GEM_CACHED          0x02
-#define DRM_VIV_GEM_SECURE          0x04
+#define DRM_VIV_GEM_CONTIGUOUS      (1u << 0)
+#define DRM_VIV_GEM_CACHED          (1u << 1)
+#define DRM_VIV_GEM_SECURE          (1u << 2)
+#define DRM_VIV_GEM_CMA_LIMIT       (1u << 3)
 
 struct drm_viv_gem_create {
     __u64 size;
@@ -191,4 +195,4 @@ struct drm_viv_gem_ref_node {
 }
 #endif
 
-#endif /* __GC_HAL_DRM_H__ */
+#endif /* __VIVNATE_DRM_H__ */
index 4b7644e..81d0d1d 100644 (file)
@@ -186,6 +186,10 @@ static int viv_ioctl_gem_create(struct drm_device *drm, void *data,
     {
         flags |= gcvALLOC_FLAG_SECURITY;
     }
+    if (args->flags & DRM_VIV_GEM_CMA_LIMIT)
+    {   
+        flags |= gcvALLOC_FLAG_CMA_LIMIT;
+    } 
 
     gckOS_ZeroMemory(&iface, sizeof(iface));
     iface.command = gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY;
index 0aad204..43df251 100644 (file)
 #  include "gc_hal_kernel_sync.h"
 #endif
 
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+#include <linux/dma-buf.h>
+#endif
+
 #if defined(CONFIG_ARM) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
 #include <dma.h>
 #endif
@@ -3608,7 +3612,7 @@ gckOS_MapPagesEx(
 #endif
         {
             /* remove LSB. */
-            phys &= ~(4096ul - 1);
+            phys &= ~(4096ull - 1);
 
 #if gcdENABLE_VG
             if (Core == gcvCORE_VG)
@@ -7824,6 +7828,7 @@ gckOS_WrapMemory(
     gceSTATUS status = gcvSTATUS_OUT_OF_MEMORY;
     gckALLOCATOR allocator;
     gcsATTACH_DESC desc;
+    gctSIZE_T bytes = 0;
 
     gcmkHEADER_ARG("Os=0x%X ", Os);
 
@@ -7840,12 +7845,20 @@ gckOS_WrapMemory(
     if (Desc->flag & gcvALLOC_FLAG_DMABUF)
     {
         desc.dmaBuf.dmabuf = gcmUINT64_TO_PTR(Desc->dmabuf);
+
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+        {
+            struct dma_buf *dmabuf = (struct dma_buf*)desc.dmaBuf.dmabuf;
+            bytes = dmabuf->size;
+        }
+#endif
     }
     else if (Desc->flag & gcvALLOC_FLAG_USERMEMORY)
     {
         desc.userMem.memory   = gcmUINT64_TO_PTR(Desc->logical);
         desc.userMem.physical = Desc->physical;
         desc.userMem.size     = Desc->size;
+        bytes                 = Desc->size;
     }
     else if (Desc->flag & gcvALLOC_FLAG_EXTERNAL_MEMORY)
     {
@@ -7895,7 +7908,7 @@ gckOS_WrapMemory(
     mdl->dmaHandle  = 0;
     mdl->addr       = 0;
 
-    *Bytes = mdl->numPages * PAGE_SIZE;
+    *Bytes = bytes ? bytes : mdl->numPages * PAGE_SIZE;
 
     /* Return physical address. */
     *Physical = (gctPHYS_ADDR) mdl;
index 4fcf696..f1c39a0 100644 (file)
@@ -89,9 +89,6 @@ struct _LINUX_MDL
     /* Private data used by allocator. */
     void *                  priv;
 
-    /* exported dma_buf */
-    void *                  dmabuf;
-
     uint                    gid;
 
     struct list_head        link;