Revert "Implement VkFence with a semaphore."

This reverts commit cad3ae5848e99e778b1b9b2687375d9f21cce44a.

Reason for revert: <INSERT REASONING HERE>

Change-Id: I8a2a81b4f468730dd3bb61178285ba8a867c21e4
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index e811260..af78d65 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -29,7 +29,6 @@
 #include <sys/mman.h>
 #include <unistd.h>
 
-
 #include "anv_private.h"
 // TODO(MA-95) - do we need this
 //#include "anv_timestamp.h"
@@ -1182,8 +1181,7 @@
 
    if (fence) {
       struct anv_bo *fence_bo = &fence->bo;
-      anv_platform_reset_semaphore(fence->semaphore);
-      result = anv_device_execbuf(device, &fence->execbuf, &fence_bo, 0, NULL, 1, &fence->semaphore);
+      result = anv_device_execbuf(device, &fence->execbuf, &fence_bo, 0, NULL, 0, NULL);
       if (result != VK_SUCCESS)
          goto out;
 
@@ -1582,13 +1580,10 @@
    fence->execbuf.rsvd1 = device->context_id;
    fence->execbuf.rsvd2 = 0;
 
-   anv_platform_create_semaphore(device, &fence->semaphore);
    if (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT) {
       fence->state = ANV_FENCE_STATE_SIGNALED;
-      anv_platform_signal_semaphore(fence->semaphore);
    } else {
       fence->state = ANV_FENCE_STATE_RESET;
-      anv_platform_reset_semaphore(fence->semaphore);
    }
 
    *pFence = anv_fence_to_handle(fence);
@@ -1609,8 +1604,6 @@
 
    assert(fence->bo.map == fence);
    anv_bo_pool_free(&device->batch_bo_pool, &fence->bo);
-
-   anv_platform_destroy_semaphore(device, fence->semaphore);
 }
 
 VkResult anv_ResetFences(
@@ -1618,12 +1611,9 @@
     uint32_t                                    fenceCount,
     const VkFence*                              pFences)
 {
-   ANV_FROM_HANDLE(anv_device, device, _device);
-
    for (uint32_t i = 0; i < fenceCount; i++) {
       ANV_FROM_HANDLE(anv_fence, fence, pFences[i]);
       fence->state = ANV_FENCE_STATE_RESET;
-      anv_platform_reset_semaphore(fence->semaphore);
    }
 
    return VK_SUCCESS;
@@ -1635,7 +1625,7 @@
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
    ANV_FROM_HANDLE(anv_fence, fence, _fence);
-   uint64_t t = 0;
+   int64_t t = 0;
    int ret;
 
    switch (fence->state) {
@@ -1649,9 +1639,8 @@
 
    case ANV_FENCE_STATE_SUBMITTED:
       /* It's been submitted to the GPU but we don't know if it's done yet. */
-      ret = anv_platform_wait_semaphore(fence->semaphore, t);
+      ret = anv_gem_wait(device, fence->bo.gem_handle, &t);
       if (ret == 0) {
-         anv_platform_signal_semaphore(fence->semaphore);
          fence->state = ANV_FENCE_STATE_SIGNALED;
          return VK_SUCCESS;
       } else {
@@ -1684,7 +1673,6 @@
     */
    int64_t timeout = MIN2(_timeout, INT64_MAX);
 
-
    uint32_t pending_fences = fenceCount;
    while (pending_fences) {
       pending_fences = 0;
@@ -1713,16 +1701,13 @@
             /* These are the fences we really care about.  Go ahead and wait
              * on it until we hit a timeout.
              */
-
-            ret = anv_platform_wait_semaphore(
-                fence->semaphore, _timeout == UINT64_MAX ? UINT64_MAX : _timeout / 1000000);
-            if (ret == -ETIME) {
+            ret = anv_gem_wait(device, fence->bo.gem_handle, &timeout);
+            if (ret == -1 && errno == ETIME) {
                return VK_TIMEOUT;
-            } else if (ret < 0) {
+            } else if (ret == -1) {
                /* We don't know the real error. */
                return vk_errorf(VK_ERROR_DEVICE_LOST, "gem wait failed: %m");
             } else {
-               anv_platform_signal_semaphore(fence->semaphore);
                fence->state = ANV_FENCE_STATE_SIGNALED;
                signaled_fences = true;
                if (!waitAll)
diff --git a/src/intel/vulkan/anv_platform.cc b/src/intel/vulkan/anv_platform.cc
index 698aa65..68e9d81 100644
--- a/src/intel/vulkan/anv_platform.cc
+++ b/src/intel/vulkan/anv_platform.cc
@@ -3,7 +3,6 @@
 // found in the LICENSE file.
 
 #include "anv_private.h"
-#include "magma_util/dlog.h"
 #include "magma_util/macros.h"
 #include "platform_futex.h"
 #include "magma_system.h"
@@ -29,7 +28,6 @@
 
 int anv_platform_create_semaphore(anv_device* device, anv_semaphore_t* semaphore_out)
 {
-   DLOG("anv_platform_create_semaphore");
    magma_semaphore_t semaphore;
    magma_status_t status = magma_system_create_semaphore(device->connection, &semaphore);
    if (status != MAGMA_STATUS_OK)
@@ -38,38 +36,8 @@
    return 0;
 }
 
-uint64_t anv_platform_get_semaphore_id(anv_semaphore_t semaphore){
-  return magma_system_get_semaphore_id(reinterpret_cast<magma_semaphore_t>(semaphore));
-}
-
 void anv_platform_destroy_semaphore(anv_device* device, anv_semaphore_t semaphore)
 {
-   DLOG("anv_platform_destroy_semaphore");
-   magma_system_destroy_semaphore(device->connection, reinterpret_cast<magma_semaphore_t>(semaphore));
-}
-
-void anv_platform_signal_semaphore(anv_semaphore_t semaphore)
-{
-   DLOG("anv_platform_signal_semaphore");
-   magma_system_signal_semaphore(reinterpret_cast<magma_semaphore_t>(semaphore));
-}
-
-void anv_platform_reset_semaphore(anv_semaphore_t semaphore)
-{
-   DLOG("anv_platform_reset_semaphore");
-   magma_system_reset_semaphore(reinterpret_cast<magma_semaphore_t>(semaphore));
-}
-
-int anv_platform_wait_semaphore(anv_semaphore_t semaphore, uint64_t timeout)
-{
-   DLOG("anv_platform_wait_semaphore");
-   magma_status_t status =
-       magma_system_wait_semaphore(reinterpret_cast<magma_semaphore_t>(semaphore), timeout);
-   switch (status) {
-   case MAGMA_STATUS_OK:
-      return 0;
-   case MAGMA_STATUS_TIMED_OUT:
-      return -ETIME;
-   }
-   return DRET_MSG(-EINVAL, "unhandled magma status: %d", status);
+   magma_system_destroy_semaphore(device->connection,
+                                  reinterpret_cast<magma_semaphore_t>(semaphore));
 }
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index a0d93af..9d2fdf5 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -640,11 +640,6 @@
 
 int anv_platform_create_semaphore(struct anv_device* device, anv_semaphore_t* semaphore_out);
 void anv_platform_destroy_semaphore(struct anv_device* device, anv_semaphore_t semaphore);
-void anv_platform_reset_semaphore(anv_semaphore_t semaphore);
-int anv_platform_wait_semaphore(anv_semaphore_t semaphore, uint64_t timeout);
-void anv_platform_signal_semaphore(anv_semaphore_t semaphore);
-uint64_t anv_platform_get_semaphore_id(anv_semaphore_t semaphore);
-
 
 VkResult anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size);
 
@@ -1306,7 +1301,6 @@
    struct drm_i915_gem_execbuffer2 execbuf;
    struct drm_i915_gem_exec_object2 exec2_objects[1];
    enum anv_fence_state state;
-   anv_semaphore_t semaphore;
 };
 
 struct anv_event {