From 5c2eb7f03ffd864e23edc8769c7c8b0ee9411751 Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Fri, 18 Mar 2016 11:31:30 +0800 Subject: [PATCH] MGS-1630 5.0.11.p8 driver can't pass build with kernel 4.1 on Android M6.0 It has converted sync to fence api in kernel_imx/drivers/staging/android/sync.h, so make it done in gpu driver to match kernel. Signed-off-by: Meng Mingming Signed-off-by: Richard Liu (cherry picked from commit d69c57557a2ef782d0daa617a30945f41a608fd5) --- .../hal/os/linux/kernel/gc_hal_kernel_os.c | 39 ++++++++++++++----- .../hal/os/linux/kernel/gc_hal_kernel_sync.c | 14 ++++++- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c index 8e9d762f5116..936fa61eb06b 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c @@ -8500,7 +8500,7 @@ gckOS_CreateNativeFence( /* Cast timeline. */ timeline = (struct viv_sync_timeline *) Timeline; - fd = get_unused_fd(); + fd = get_unused_fd_flags(O_CLOEXEC); if (fd < 0) { @@ -8562,7 +8562,6 @@ gckOS_WaitNativeFence( ) { struct sync_timeline * timeline; - struct list_head *pos; struct sync_fence * fence; gctBOOL wait = gcvFALSE; gceSTATUS status = gcvSTATUS_OK; @@ -8581,18 +8580,40 @@ gckOS_WaitNativeFence( gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); } - list_for_each(pos, &fence->pt_list_head) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) { - struct sync_pt * pt = - container_of(pos, struct sync_pt, pt_list); + int i; - /* Do not need to wait on same timeline. */ - if (pt->parent != timeline) + for (i = 0; i < fence->num_fences; i++) { - wait = gcvTRUE; - break; + struct fence *f = fence->cbs[i].sync_pt; + struct sync_pt *pt = container_of(f, struct sync_pt, base); + + /* Do not need to wait on same timeline. */ + if ((sync_pt_parent(pt) != timeline) && !fence_is_signaled(f)) + { + wait = gcvTRUE; + break; + } } } +#else + { + struct list_head *pos; + list_for_each(pos, &fence->pt_list_head) + { + struct sync_pt * pt = + container_of(pos, struct sync_pt, pt_list); + + /* Do not need to wait on same timeline. */ + if (pt->parent != timeline) + { + wait = gcvTRUE; + break; + } + } + } +#endif if (wait) { diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.c index fcde100fa626..21f4f69be18b 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.c +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.c @@ -79,7 +79,11 @@ viv_sync_pt_dup( struct viv_sync_timeline *obj; src = (struct viv_sync_pt *) sync_pt; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + obj = (struct viv_sync_timeline *) sync_pt_parent(sync_pt); +#else obj = (struct viv_sync_timeline *) sync_pt->parent; +#endif /* Create the new sync_pt. */ pt = (struct viv_sync_pt *) @@ -111,7 +115,11 @@ viv_sync_pt_has_signaled( struct viv_sync_timeline * obj; pt = (struct viv_sync_pt *)sync_pt; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + obj = (struct viv_sync_timeline *) sync_pt_parent(sync_pt); +#else obj = (struct viv_sync_timeline *)sync_pt->parent; +#endif status = gckOS_QuerySyncPoint(obj->os, pt->sync, &state); @@ -150,7 +158,11 @@ viv_sync_pt_free( struct viv_sync_timeline * obj; pt = (struct viv_sync_pt *) sync_pt; - obj = (struct viv_sync_timeline *) sync_pt->parent; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + obj = (struct viv_sync_timeline *) sync_pt_parent(sync_pt); +#else + obj = (struct viv_sync_timeline *)sync_pt->parent; +#endif gckOS_DestroySyncPoint(obj->os, pt->sync); } -- 2.17.1