diff options
author | Lingfeng Yang <lfy@google.com> | 2018-01-17 10:38:19 -0800 |
---|---|---|
committer | Lingfeng Yang <lfy@google.com> | 2018-01-17 12:41:33 -0800 |
commit | 7a5ca8b779574ff15d3b14f8d810159298777ab3 (patch) | |
tree | 999284db6b97ba0dd82178da61d43865c65769ac | |
parent | e980c7a4de6cc56e63fd013ce7811bcdeeabb57c (diff) | |
download | device_generic_goldfish-opengl-7a5ca8b779574ff15d3b14f8d810159298777ab3.tar.gz device_generic_goldfish-opengl-7a5ca8b779574ff15d3b14f8d810159298777ab3.tar.bz2 device_generic_goldfish-opengl-7a5ca8b779574ff15d3b14f8d810159298777ab3.zip |
goldfish_sync: detect when running on a 64-bit kernel
bug: 71861550
The goldfish sync ioctl cmd for QUEUE_WORK is different when running a
64-bit kernel. Use that magic number instead if we get a negative return
code and ENOTTY from ioctl.
Change-Id: I23b1f6d0d8be9e97f3d14105882d4c8d9c4435df
-rw-r--r-- | system/egl/goldfish_sync.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/system/egl/goldfish_sync.h b/system/egl/goldfish_sync.h index 6b30fe5b..5dcc449e 100644 --- a/system/egl/goldfish_sync.h +++ b/system/egl/goldfish_sync.h @@ -47,6 +47,11 @@ static __inline__ int goldfish_sync_close(int sync_fd) { return close(sync_fd); } +static unsigned int sQueueWorkIoctlCmd = GOLDFISH_SYNC_IOC_QUEUE_WORK; + +// If we are running on a 64-bit kernel. +static unsigned int sQueueWorkIoctlCmd64Kernel = 0xc0184000; + static __inline__ int goldfish_sync_queue_work(int goldfish_sync_fd, uint64_t host_glsync, uint64_t host_thread, @@ -59,7 +64,15 @@ static __inline__ int goldfish_sync_queue_work(int goldfish_sync_fd, info.host_syncthread_handle_in = host_thread; info.fence_fd_out = -1; - err = ioctl(goldfish_sync_fd, GOLDFISH_SYNC_IOC_QUEUE_WORK, &info); + err = ioctl(goldfish_sync_fd, sQueueWorkIoctlCmd, &info); + + if (err < 0 && errno == ENOTTY) { + sQueueWorkIoctlCmd = sQueueWorkIoctlCmd64Kernel; + err = ioctl(goldfish_sync_fd, sQueueWorkIoctlCmd, &info); + if (err < 0) { + sQueueWorkIoctlCmd = GOLDFISH_SYNC_IOC_QUEUE_WORK; + } + } if (fd_out) *fd_out = info.fence_fd_out; |