turnip: Fix bo allocation after we stopped using libdrm_freedreno ...
authorBas Nieuwenhuizen <basni@chromium.org>
Thu, 20 Dec 2018 21:57:07 +0000 (22:57 +0100)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 11 Mar 2019 17:01:41 +0000 (10:01 -0700)
Al this figuring out new errors is why I don't like reinventing the
wheel.

src/freedreno/vulkan/tu_device.c
src/freedreno/vulkan/tu_gem.c

index 588f2e83f91c9fde930948edd02c938cd7c8b2a3..4d676d9147af3303b4014f7a25479d0357637f55 100644 (file)
@@ -89,11 +89,11 @@ tu_bo_init_new(struct tu_device *dev, struct tu_bo *bo, uint64_t size)
     */
 
    /* TODO: Do we need 'offset' if we have 'iova'? */
-   uint64_t offset = tu_gem_info_offset(dev, bo->gem_handle);
+   uint64_t offset = tu_gem_info_offset(dev, gem_handle);
    if (!offset)
       goto fail_info;
 
-   uint64_t iova = tu_gem_info_iova(dev, bo->gem_handle);
+   uint64_t iova = tu_gem_info_iova(dev, gem_handle);
    if (!iova)
       goto fail_info;
 
@@ -1312,7 +1312,7 @@ tu_alloc_memory(struct tu_device *device,
       return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
 
    result = tu_bo_init_new(device, &mem->bo, pAllocateInfo->allocationSize);
-   if (!result) {
+   if (result != VK_SUCCESS) {
       vk_free2(&device->alloc, pAllocator, mem);
       return result;
    }
index ba302a7634ff394704b6b63dccddbd933d0c1fdf..b8a4c6f8a98a13e1a6289ebf1b00267f1f1f1d5f 100644 (file)
 
 #include "tu_private.h"
 
-static int
-tu_ioctl(int fd, unsigned long request, void *arg)
-{
-   int ret;
-
-   do {
-      ret = ioctl(fd, request, arg);
-   } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
-
-   return ret;
-}
+#include "xf86drm.h"
 
 /**
  * Return gem handle on success. Return 0 on failure.
@@ -54,7 +44,8 @@ tu_gem_new(struct tu_device *dev, uint64_t size, uint32_t flags)
    };
 
 
-   int ret = tu_ioctl(dev->physical_device->local_fd, DRM_MSM_GEM_NEW, &req);
+   int ret = drmCommandWriteRead(dev->physical_device->local_fd, DRM_MSM_GEM_NEW,
+                                 &req, sizeof(req));
    if (ret)
       return 0;
 
@@ -68,7 +59,7 @@ tu_gem_close(struct tu_device *dev, uint32_t gem_handle)
       .handle = gem_handle,
    };
 
-   tu_ioctl(dev->physical_device->local_fd, DRM_IOCTL_GEM_CLOSE, &req);
+   drmIoctl(dev->physical_device->local_fd, DRM_IOCTL_GEM_CLOSE, &req);
 }
 
 /** Return UINT64_MAX on error. */
@@ -80,7 +71,8 @@ tu_gem_info(struct tu_device *dev, uint32_t gem_handle, uint32_t flags)
       .flags = flags,
    };
 
-   int ret = tu_ioctl(dev->physical_device->local_fd, DRM_MSM_GEM_INFO, &req);
+   int ret = drmCommandWriteRead(dev->physical_device->local_fd, DRM_MSM_GEM_INFO,
+                                 &req, sizeof(req));
    if (ret == -1)
       return UINT64_MAX;