summaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan
diff options
context:
space:
mode:
authorKristian H. Kristensen <[email protected]>2019-01-16 11:02:38 -0800
committerChia-I Wu <[email protected]>2019-03-11 10:01:41 -0700
commit0801019d335c6584716cb99fc7b8ca42cc0064b0 (patch)
tree3830a12fce3bfee38ac952f7998a6e600e5522f8 /src/freedreno/vulkan
parent23d6f0f9700d326f135f6d927b23563c9fd98acc (diff)
turnip: Only get bo offset when we need to mmap
The offset we get from MSM_INFO_GET_OFFSET is an offset into the drm fd for the purpose of mmaping the buffer.
Diffstat (limited to 'src/freedreno/vulkan')
-rw-r--r--src/freedreno/vulkan/tu_device.c21
-rw-r--r--src/freedreno/vulkan/tu_private.h1
2 files changed, 5 insertions, 17 deletions
diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index 11d200e2f03..7ff1e5a4f62 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -83,20 +83,6 @@ tu_bo_init_new(struct tu_device *dev, struct tu_bo *bo, uint64_t size)
if (!gem_handle)
goto fail_new;
- /* Calling DRM_MSM_GEM_INFO forces the kernel to allocate backing pages. We
- * want immediate backing pages because vkAllocateMemory and friends must
- * not lazily fail.
- *
- * TODO(chadv): Must we really call DRM_MSM_GEM_INFO to acquire backing
- * pages? I infer so from reading comments in msm_bo.c:bo_allocate(), but
- * maybe I misunderstand.
- */
-
- /* TODO: Do we need 'offset' if we have 'iova'? */
- uint64_t offset = tu_gem_info_offset(dev, gem_handle);
- if (!offset)
- goto fail_info;
-
uint64_t iova = tu_gem_info_iova(dev, gem_handle);
if (!iova)
goto fail_info;
@@ -104,7 +90,6 @@ tu_bo_init_new(struct tu_device *dev, struct tu_bo *bo, uint64_t size)
*bo = (struct tu_bo) {
.gem_handle = gem_handle,
.size = size,
- .offset = offset,
.iova = iova,
};
@@ -122,9 +107,13 @@ tu_bo_map(struct tu_device *dev, struct tu_bo *bo)
if (bo->map)
return VK_SUCCESS;
+ uint64_t offset = tu_gem_info_offset(dev, bo->gem_handle);
+ if (!offset)
+ return vk_error(dev->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
+
/* TODO: Should we use the wrapper os_mmap() like Freedreno does? */
void *map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
- dev->physical_device->local_fd, bo->offset);
+ dev->physical_device->local_fd, offset);
if (map == MAP_FAILED)
return vk_error(dev->instance, VK_ERROR_MEMORY_MAP_FAILED);
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 53f493a61aa..a112bbcb781 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -432,7 +432,6 @@ struct tu_bo
{
uint32_t gem_handle;
uint64_t size;
- uint64_t offset;
uint64_t iova;
void *map;
};