mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
pvr: Propagate errors as VkResults from ioctls through winsys
Partially fixes: dEQP-VK.api.device_init .create_instance_device_intentional_alloc_fail.basic Signed-off-by: Matt Coster <matt.coster@imgtec.com> Reviewed-by: Frank Binns <frank.binns@imgtec.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23023>
This commit is contained in:
parent
438433e131
commit
c0b4359113
8 changed files with 178 additions and 130 deletions
|
|
@ -347,15 +347,16 @@ VkResult pvr_bo_alloc(struct pvr_device *device,
|
|||
struct pvr_bo **const pvr_bo_out)
|
||||
{
|
||||
struct pvr_bo *pvr_bo;
|
||||
pvr_dev_addr_t addr;
|
||||
VkResult result;
|
||||
|
||||
if (PVR_IS_DEBUG_SET(ZERO_BOS))
|
||||
flags |= PVR_BO_ALLOC_FLAG_ZERO_ON_ALLOC;
|
||||
|
||||
pvr_bo = pvr_bo_alloc_bo(device);
|
||||
if (!pvr_bo)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
if (!pvr_bo) {
|
||||
result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
pvr_bo->ref_count = 1;
|
||||
|
||||
|
|
@ -379,17 +380,13 @@ VkResult pvr_bo_alloc(struct pvr_device *device,
|
|||
VG(VALGRIND_MAKE_MEM_DEFINED(map, pvr_bo->bo->size));
|
||||
}
|
||||
|
||||
pvr_bo->vma = device->ws->ops->heap_alloc(heap, size, alignment);
|
||||
if (!pvr_bo->vma) {
|
||||
result = VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
result = device->ws->ops->heap_alloc(heap, size, alignment, &pvr_bo->vma);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_buffer_unmap;
|
||||
}
|
||||
|
||||
addr = device->ws->ops->vma_map(pvr_bo->vma, pvr_bo->bo, 0, size);
|
||||
if (!addr.addr) {
|
||||
result = VK_ERROR_MEMORY_MAP_FAILED;
|
||||
result = device->ws->ops->vma_map(pvr_bo->vma, pvr_bo->bo, 0, size, NULL);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_heap_free;
|
||||
}
|
||||
|
||||
pvr_bo_store_insert(device->bo_store, pvr_bo);
|
||||
*pvr_bo_out = pvr_bo;
|
||||
|
|
@ -409,6 +406,7 @@ err_buffer_destroy:
|
|||
err_free_bo:
|
||||
pvr_bo_free_bo(device, pvr_bo);
|
||||
|
||||
err_out:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -343,7 +343,6 @@ static VkResult pvr_physical_device_init(struct pvr_physical_device *pdevice,
|
|||
struct vk_physical_device_dispatch_table dispatch_table;
|
||||
const char *primary_path;
|
||||
VkResult result;
|
||||
int ret;
|
||||
|
||||
if (!getenv("PVR_I_WANT_A_BROKEN_VULKAN_DRIVER")) {
|
||||
return vk_errorf(instance,
|
||||
|
|
@ -422,13 +421,11 @@ static VkResult pvr_physical_device_init(struct pvr_physical_device *pdevice,
|
|||
|
||||
pdevice->vk.supported_sync_types = pdevice->ws->sync_types;
|
||||
|
||||
ret = pdevice->ws->ops->device_info_init(pdevice->ws,
|
||||
&pdevice->dev_info,
|
||||
&pdevice->dev_runtime_info);
|
||||
if (ret) {
|
||||
result = VK_ERROR_INITIALIZATION_FAILED;
|
||||
result = pdevice->ws->ops->device_info_init(pdevice->ws,
|
||||
&pdevice->dev_info,
|
||||
&pdevice->dev_runtime_info);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_pvr_winsys_destroy;
|
||||
}
|
||||
|
||||
result = pvr_physical_device_init_uuids(pdevice);
|
||||
if (result != VK_SUCCESS)
|
||||
|
|
@ -2284,6 +2281,7 @@ VkResult pvr_bind_memory(struct pvr_device *device,
|
|||
size + (offset & (device->heaps.general_heap->page_size - 1));
|
||||
struct pvr_winsys_vma *vma;
|
||||
pvr_dev_addr_t dev_addr;
|
||||
VkResult result;
|
||||
|
||||
/* Valid usage:
|
||||
*
|
||||
|
|
@ -2298,22 +2296,27 @@ VkResult pvr_bind_memory(struct pvr_device *device,
|
|||
assert(offset % alignment == 0);
|
||||
assert(offset < mem->bo->size);
|
||||
|
||||
vma = device->ws->ops->heap_alloc(device->heaps.general_heap,
|
||||
virt_size,
|
||||
alignment);
|
||||
if (!vma)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
result = device->ws->ops->heap_alloc(device->heaps.general_heap,
|
||||
virt_size,
|
||||
alignment,
|
||||
&vma);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_out;
|
||||
|
||||
dev_addr = device->ws->ops->vma_map(vma, mem->bo, offset, size);
|
||||
if (!dev_addr.addr) {
|
||||
device->ws->ops->heap_free(vma);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
}
|
||||
result = device->ws->ops->vma_map(vma, mem->bo, offset, size, &dev_addr);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_free_vma;
|
||||
|
||||
*dev_addr_out = dev_addr;
|
||||
*vma_out = vma;
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
||||
err_free_vma:
|
||||
device->ws->ops->heap_free(vma);
|
||||
|
||||
err_out:
|
||||
return result;
|
||||
}
|
||||
|
||||
void pvr_unbind_memory(struct pvr_device *device, struct pvr_winsys_vma *vma)
|
||||
|
|
@ -2491,7 +2494,7 @@ VkResult pvr_CreateBuffer(VkDevice _device,
|
|||
|
||||
/* We check against (ULONG_MAX - alignment) to prevent overflow issues */
|
||||
if (pCreateInfo->size >= ULONG_MAX - alignment)
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
|
||||
buffer =
|
||||
vk_buffer_create(&device->vk, pCreateInfo, pAllocator, sizeof(*buffer));
|
||||
|
|
|
|||
|
|
@ -389,9 +389,9 @@ struct pvr_winsys_render_submit_info {
|
|||
|
||||
struct pvr_winsys_ops {
|
||||
void (*destroy)(struct pvr_winsys *ws);
|
||||
int (*device_info_init)(struct pvr_winsys *ws,
|
||||
struct pvr_device_info *dev_info,
|
||||
struct pvr_device_runtime_info *runtime_info);
|
||||
VkResult (*device_info_init)(struct pvr_winsys *ws,
|
||||
struct pvr_device_info *dev_info,
|
||||
struct pvr_device_runtime_info *runtime_info);
|
||||
void (*get_heaps_info)(struct pvr_winsys *ws,
|
||||
struct pvr_winsys_heaps *heaps);
|
||||
|
||||
|
|
@ -411,15 +411,17 @@ struct pvr_winsys_ops {
|
|||
void *(*buffer_map)(struct pvr_winsys_bo *bo);
|
||||
void (*buffer_unmap)(struct pvr_winsys_bo *bo);
|
||||
|
||||
struct pvr_winsys_vma *(*heap_alloc)(struct pvr_winsys_heap *heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment);
|
||||
VkResult (*heap_alloc)(struct pvr_winsys_heap *heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma **vma_out);
|
||||
void (*heap_free)(struct pvr_winsys_vma *vma);
|
||||
|
||||
pvr_dev_addr_t (*vma_map)(struct pvr_winsys_vma *vma,
|
||||
struct pvr_winsys_bo *bo,
|
||||
uint64_t offset,
|
||||
uint64_t size);
|
||||
VkResult (*vma_map)(struct pvr_winsys_vma *vma,
|
||||
struct pvr_winsys_bo *bo,
|
||||
uint64_t offset,
|
||||
uint64_t size,
|
||||
pvr_dev_addr_t *dev_addr_out);
|
||||
void (*vma_unmap)(struct pvr_winsys_vma *vma);
|
||||
|
||||
VkResult (*free_list_create)(
|
||||
|
|
|
|||
|
|
@ -34,33 +34,40 @@
|
|||
#include "util/u_atomic.h"
|
||||
#include "vk_log.h"
|
||||
|
||||
int pvr_winsys_helper_display_buffer_create(int master_fd,
|
||||
uint64_t size,
|
||||
uint32_t *const handle_out)
|
||||
VkResult pvr_winsys_helper_display_buffer_create(int master_fd,
|
||||
uint64_t size,
|
||||
uint32_t *const handle_out)
|
||||
{
|
||||
struct drm_mode_create_dumb args = {
|
||||
.width = size,
|
||||
.height = 1,
|
||||
.bpp = 8,
|
||||
};
|
||||
int ret;
|
||||
VkResult result;
|
||||
|
||||
ret = drmIoctl(master_fd, DRM_IOCTL_MODE_CREATE_DUMB, &args);
|
||||
if (ret)
|
||||
return ret;
|
||||
result = pvr_ioctl(master_fd,
|
||||
DRM_IOCTL_MODE_CREATE_DUMB,
|
||||
&args,
|
||||
VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
*handle_out = args.handle;
|
||||
|
||||
return 0;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
int pvr_winsys_helper_display_buffer_destroy(int master_fd, uint32_t handle)
|
||||
VkResult pvr_winsys_helper_display_buffer_destroy(int master_fd,
|
||||
uint32_t handle)
|
||||
{
|
||||
struct drm_mode_destroy_dumb args = {
|
||||
.handle = handle,
|
||||
};
|
||||
|
||||
return drmIoctl(master_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &args);
|
||||
return pvr_ioctl(master_fd,
|
||||
DRM_IOCTL_MODE_DESTROY_DUMB,
|
||||
&args,
|
||||
VK_ERROR_UNKNOWN);
|
||||
}
|
||||
|
||||
bool pvr_winsys_helper_winsys_heap_finish(struct pvr_winsys_heap *const heap)
|
||||
|
|
@ -74,10 +81,10 @@ bool pvr_winsys_helper_winsys_heap_finish(struct pvr_winsys_heap *const heap)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool pvr_winsys_helper_heap_alloc(struct pvr_winsys_heap *const heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma *const vma_out)
|
||||
VkResult pvr_winsys_helper_heap_alloc(struct pvr_winsys_heap *const heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma *const vma_out)
|
||||
{
|
||||
struct pvr_winsys_vma vma = {
|
||||
.heap = heap,
|
||||
|
|
@ -101,16 +108,14 @@ bool pvr_winsys_helper_heap_alloc(struct pvr_winsys_heap *const heap,
|
|||
PVR_DEV_ADDR(util_vma_heap_alloc(&heap->vma_heap, size, heap->page_size));
|
||||
pthread_mutex_unlock(&heap->lock);
|
||||
|
||||
if (!vma.dev_addr.addr) {
|
||||
vk_error(NULL, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
return false;
|
||||
}
|
||||
if (!vma.dev_addr.addr)
|
||||
return vk_error(NULL, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
|
||||
p_atomic_inc(&heap->ref_count);
|
||||
|
||||
*vma_out = vma;
|
||||
|
||||
return true;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void pvr_winsys_helper_heap_free(struct pvr_winsys_vma *const vma)
|
||||
|
|
@ -142,7 +147,6 @@ pvr_buffer_create_and_map(struct pvr_winsys *const ws,
|
|||
{
|
||||
struct pvr_winsys_vma *vma;
|
||||
struct pvr_winsys_bo *bo;
|
||||
pvr_dev_addr_t addr;
|
||||
VkResult result;
|
||||
|
||||
/* Address should not be NULL, this function is used to allocate and map
|
||||
|
|
@ -157,19 +161,15 @@ pvr_buffer_create_and_map(struct pvr_winsys *const ws,
|
|||
PVR_WINSYS_BO_FLAG_CPU_ACCESS,
|
||||
&bo);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
goto err_out;
|
||||
|
||||
vma = heap_alloc_reserved(heap, dev_addr, size, alignment);
|
||||
if (!vma) {
|
||||
result = VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
result = heap_alloc_reserved(heap, dev_addr, size, alignment, &vma);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_pvr_winsys_buffer_destroy;
|
||||
}
|
||||
|
||||
addr = ws->ops->vma_map(vma, bo, 0, size);
|
||||
if (!addr.addr) {
|
||||
result = VK_ERROR_MEMORY_MAP_FAILED;
|
||||
result = ws->ops->vma_map(vma, bo, 0, size, NULL);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_pvr_winsys_heap_free;
|
||||
}
|
||||
|
||||
/* Note this won't destroy bo as its being used by VMA, once vma is
|
||||
* unmapped, bo will be destroyed automatically.
|
||||
|
|
@ -186,6 +186,7 @@ err_pvr_winsys_heap_free:
|
|||
err_pvr_winsys_buffer_destroy:
|
||||
ws->ops->buffer_destroy(bo);
|
||||
|
||||
err_out:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -223,7 +224,7 @@ VkResult pvr_winsys_helper_allocate_static_memory(
|
|||
general_heap->page_size,
|
||||
&general_vma);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
goto err_out;
|
||||
|
||||
result = pvr_buffer_create_and_map(ws,
|
||||
heap_alloc_reserved,
|
||||
|
|
@ -257,6 +258,7 @@ err_pvr_buffer_destroy_and_unmap_pds:
|
|||
err_pvr_buffer_destroy_and_unmap_general:
|
||||
pvr_buffer_destroy_and_unmap(general_vma);
|
||||
|
||||
err_out:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -320,8 +322,10 @@ pvr_winsys_helper_fill_static_memory(struct pvr_winsys *const ws,
|
|||
VkResult result;
|
||||
|
||||
general_ptr = ws->ops->buffer_map(general_vma->bo);
|
||||
if (!general_ptr)
|
||||
return VK_ERROR_MEMORY_MAP_FAILED;
|
||||
if (!general_ptr) {
|
||||
result = VK_ERROR_MEMORY_MAP_FAILED;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
pds_ptr = ws->ops->buffer_map(pds_vma->bo);
|
||||
if (!pds_ptr) {
|
||||
|
|
@ -355,5 +359,6 @@ err_pvr_srv_winsys_buffer_unmap_pds:
|
|||
err_pvr_srv_winsys_buffer_unmap_general:
|
||||
ws->ops->buffer_unmap(general_vma->bo);
|
||||
|
||||
err_out:
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,21 +24,26 @@
|
|||
#ifndef PVR_WINSYS_HELPER_H
|
||||
#define PVR_WINSYS_HELPER_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <xf86drm.h>
|
||||
|
||||
#include "pvr_types.h"
|
||||
#include "vk_log.h"
|
||||
|
||||
struct pvr_winsys;
|
||||
struct pvr_winsys_heap;
|
||||
struct pvr_winsys_static_data_offsets;
|
||||
struct pvr_winsys_vma;
|
||||
|
||||
typedef struct pvr_winsys_vma *(*const heap_alloc_reserved_func)(
|
||||
typedef VkResult (*const heap_alloc_reserved_func)(
|
||||
struct pvr_winsys_heap *const heap,
|
||||
const pvr_dev_addr_t reserved_dev_addr,
|
||||
uint64_t size,
|
||||
uint64_t alignment);
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma **vma_out);
|
||||
|
||||
int pvr_winsys_helper_display_buffer_create(int master_fd,
|
||||
uint64_t size,
|
||||
|
|
@ -47,10 +52,10 @@ int pvr_winsys_helper_display_buffer_destroy(int master_fd, uint32_t handle);
|
|||
|
||||
bool pvr_winsys_helper_winsys_heap_finish(struct pvr_winsys_heap *const heap);
|
||||
|
||||
bool pvr_winsys_helper_heap_alloc(struct pvr_winsys_heap *const heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma *const vma);
|
||||
VkResult pvr_winsys_helper_heap_alloc(struct pvr_winsys_heap *const heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma *const vma);
|
||||
void pvr_winsys_helper_heap_free(struct pvr_winsys_vma *const vma);
|
||||
|
||||
VkResult pvr_winsys_helper_allocate_static_memory(
|
||||
|
|
@ -73,4 +78,26 @@ pvr_winsys_helper_fill_static_memory(struct pvr_winsys *const ws,
|
|||
struct pvr_winsys_vma *const pds_vma,
|
||||
struct pvr_winsys_vma *const usc_vma);
|
||||
|
||||
#define pvr_ioctlf(fd, request, arg, error, fmt, args...) \
|
||||
({ \
|
||||
VkResult _result = VK_SUCCESS; \
|
||||
int _ret; \
|
||||
\
|
||||
_ret = drmIoctl(fd, request, arg); \
|
||||
if (_ret) { \
|
||||
_ret = errno; \
|
||||
_result = vk_errorf(NULL, \
|
||||
error, \
|
||||
fmt " (errno %d: %s)", \
|
||||
##args, \
|
||||
_ret, \
|
||||
strerror(_ret)); \
|
||||
} \
|
||||
\
|
||||
_result; \
|
||||
})
|
||||
|
||||
#define pvr_ioctl(fd, request, arg, error) \
|
||||
pvr_ioctlf(fd, request, arg, error, "ioctl " #request " failed")
|
||||
|
||||
#endif /* PVR_WINSYS_HELPER_H */
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ pvr_srv_get_cdm_max_local_mem_size_regs(const struct pvr_device_info *dev_info)
|
|||
ROGUE_MAX_PER_KERNEL_LOCAL_MEM_SIZE_REGS);
|
||||
}
|
||||
|
||||
static int
|
||||
static VkResult
|
||||
pvr_srv_winsys_device_info_init(struct pvr_winsys *ws,
|
||||
struct pvr_device_info *dev_info,
|
||||
struct pvr_device_runtime_info *runtime_info)
|
||||
|
|
@ -575,12 +575,13 @@ pvr_srv_winsys_device_info_init(struct pvr_winsys *ws,
|
|||
|
||||
ret = pvr_device_info_init(dev_info, srv_ws->bvnc);
|
||||
if (ret) {
|
||||
mesa_logw("Unsupported BVNC: %u.%u.%u.%u\n",
|
||||
PVR_BVNC_UNPACK_B(srv_ws->bvnc),
|
||||
PVR_BVNC_UNPACK_V(srv_ws->bvnc),
|
||||
PVR_BVNC_UNPACK_N(srv_ws->bvnc),
|
||||
PVR_BVNC_UNPACK_C(srv_ws->bvnc));
|
||||
return ret;
|
||||
return vk_errorf(NULL,
|
||||
VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"Unsupported BVNC: %u.%u.%u.%u\n",
|
||||
PVR_BVNC_UNPACK_B(srv_ws->bvnc),
|
||||
PVR_BVNC_UNPACK_V(srv_ws->bvnc),
|
||||
PVR_BVNC_UNPACK_N(srv_ws->bvnc),
|
||||
PVR_BVNC_UNPACK_C(srv_ws->bvnc));
|
||||
}
|
||||
|
||||
runtime_info->min_free_list_size = pvr_srv_get_min_free_list_size(dev_info);
|
||||
|
|
@ -600,7 +601,7 @@ pvr_srv_winsys_device_info_init(struct pvr_winsys *ws,
|
|||
NULL,
|
||||
&runtime_info->core_count);
|
||||
if (result != VK_SUCCESS)
|
||||
return -ENODEV;
|
||||
return result;
|
||||
} else {
|
||||
runtime_info->core_count = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ static VkResult pvr_srv_alloc_display_pmr(struct pvr_srv_winsys *srv_ws,
|
|||
int ret;
|
||||
int fd;
|
||||
|
||||
ret =
|
||||
result =
|
||||
pvr_winsys_helper_display_buffer_create(srv_ws->master_fd, size, &handle);
|
||||
if (ret)
|
||||
return vk_error(NULL, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
ret = drmPrimeHandleToFD(srv_ws->master_fd, handle, O_CLOEXEC, &fd);
|
||||
if (ret) {
|
||||
|
|
@ -361,11 +361,11 @@ void pvr_srv_winsys_buffer_unmap(struct pvr_winsys_bo *bo)
|
|||
* used internally only. This also means whoever is using it, must know what
|
||||
* they are doing.
|
||||
*/
|
||||
struct pvr_winsys_vma *
|
||||
pvr_srv_heap_alloc_reserved(struct pvr_winsys_heap *heap,
|
||||
const pvr_dev_addr_t reserved_dev_addr,
|
||||
uint64_t size,
|
||||
uint64_t alignment)
|
||||
VkResult pvr_srv_heap_alloc_reserved(struct pvr_winsys_heap *heap,
|
||||
const pvr_dev_addr_t reserved_dev_addr,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma **const vma_out)
|
||||
{
|
||||
struct pvr_srv_winsys_heap *srv_heap = to_pvr_srv_winsys_heap(heap);
|
||||
struct pvr_srv_winsys *srv_ws = to_pvr_srv_winsys(heap->ws);
|
||||
|
|
@ -386,8 +386,8 @@ pvr_srv_heap_alloc_reserved(struct pvr_winsys_heap *heap,
|
|||
8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
||||
if (!srv_vma) {
|
||||
vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return NULL;
|
||||
result = vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
/* Just check address is correct and aligned, locking is not required as
|
||||
|
|
@ -396,8 +396,10 @@ pvr_srv_heap_alloc_reserved(struct pvr_winsys_heap *heap,
|
|||
if (reserved_dev_addr.addr < heap->base_addr.addr ||
|
||||
reserved_dev_addr.addr + size >
|
||||
heap->base_addr.addr + heap->reserved_size ||
|
||||
reserved_dev_addr.addr & ((srv_ws->base.page_size) - 1))
|
||||
reserved_dev_addr.addr & ((srv_ws->base.page_size) - 1)) {
|
||||
result = vk_error(NULL, VK_ERROR_INITIALIZATION_FAILED);
|
||||
goto err_vk_free_srv_vma;
|
||||
}
|
||||
|
||||
/* Reserve the virtual range in the MMU and create a mapping structure */
|
||||
result = pvr_srv_int_reserve_addr(srv_ws->render_fd,
|
||||
|
|
@ -415,35 +417,38 @@ pvr_srv_heap_alloc_reserved(struct pvr_winsys_heap *heap,
|
|||
|
||||
p_atomic_inc(&srv_heap->base.ref_count);
|
||||
|
||||
return &srv_vma->base;
|
||||
*vma_out = &srv_vma->base;
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
||||
err_vk_free_srv_vma:
|
||||
vk_free(srv_ws->alloc, srv_vma);
|
||||
|
||||
return NULL;
|
||||
err_out:
|
||||
return result;
|
||||
}
|
||||
|
||||
struct pvr_winsys_vma *pvr_srv_winsys_heap_alloc(struct pvr_winsys_heap *heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment)
|
||||
VkResult pvr_srv_winsys_heap_alloc(struct pvr_winsys_heap *heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma **const vma_out)
|
||||
{
|
||||
struct pvr_srv_winsys_heap *const srv_heap = to_pvr_srv_winsys_heap(heap);
|
||||
struct pvr_srv_winsys *const srv_ws = to_pvr_srv_winsys(heap->ws);
|
||||
struct pvr_srv_winsys_vma *srv_vma;
|
||||
VkResult result;
|
||||
bool ret;
|
||||
|
||||
srv_vma = vk_alloc(srv_ws->alloc,
|
||||
sizeof(*srv_vma),
|
||||
8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
||||
if (!srv_vma) {
|
||||
vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return NULL;
|
||||
result = vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
ret = pvr_winsys_helper_heap_alloc(heap, size, alignment, &srv_vma->base);
|
||||
if (!ret)
|
||||
result = pvr_winsys_helper_heap_alloc(heap, size, alignment, &srv_vma->base);
|
||||
if (result != VK_SUCCESS)
|
||||
goto err_pvr_srv_free_vma;
|
||||
|
||||
/* Reserve the virtual range in the MMU and create a mapping structure. */
|
||||
|
|
@ -455,7 +460,9 @@ struct pvr_winsys_vma *pvr_srv_winsys_heap_alloc(struct pvr_winsys_heap *heap,
|
|||
if (result != VK_SUCCESS)
|
||||
goto err_pvr_srv_free_allocation;
|
||||
|
||||
return &srv_vma->base;
|
||||
*vma_out = &srv_vma->base;
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
||||
err_pvr_srv_free_allocation:
|
||||
pvr_winsys_helper_heap_free(&srv_vma->base);
|
||||
|
|
@ -463,7 +470,8 @@ err_pvr_srv_free_allocation:
|
|||
err_pvr_srv_free_vma:
|
||||
vk_free(srv_ws->alloc, srv_vma);
|
||||
|
||||
return NULL;
|
||||
err_out:
|
||||
return result;
|
||||
}
|
||||
|
||||
void pvr_srv_winsys_heap_free(struct pvr_winsys_vma *vma)
|
||||
|
|
@ -495,10 +503,11 @@ void pvr_srv_winsys_heap_free(struct pvr_winsys_vma *vma)
|
|||
* * The offset passed in is unchanged and can be used to calculate the extra
|
||||
* size that needs to be mapped and final device virtual address.
|
||||
*/
|
||||
pvr_dev_addr_t pvr_srv_winsys_vma_map(struct pvr_winsys_vma *vma,
|
||||
struct pvr_winsys_bo *bo,
|
||||
uint64_t offset,
|
||||
uint64_t size)
|
||||
VkResult pvr_srv_winsys_vma_map(struct pvr_winsys_vma *vma,
|
||||
struct pvr_winsys_bo *bo,
|
||||
uint64_t offset,
|
||||
uint64_t size,
|
||||
pvr_dev_addr_t *const dev_addr_out)
|
||||
{
|
||||
struct pvr_srv_winsys_vma *srv_vma = to_pvr_srv_winsys_vma(vma);
|
||||
struct pvr_srv_winsys_bo *srv_bo = to_pvr_srv_winsys_bo(bo);
|
||||
|
|
@ -519,8 +528,7 @@ pvr_dev_addr_t pvr_srv_winsys_vma_map(struct pvr_winsys_vma *vma,
|
|||
/* In case of display buffers, we only support to map whole PMR */
|
||||
if (offset != 0 || bo->size != ALIGN_POT(size, srv_ws->base.page_size) ||
|
||||
vma->size != bo->size) {
|
||||
vk_error(NULL, VK_ERROR_MEMORY_MAP_FAILED);
|
||||
return PVR_DEV_ADDR_INVALID;
|
||||
return vk_error(NULL, VK_ERROR_MEMORY_MAP_FAILED);
|
||||
}
|
||||
|
||||
/* Map the requested pmr */
|
||||
|
|
@ -540,8 +548,7 @@ pvr_dev_addr_t pvr_srv_winsys_vma_map(struct pvr_winsys_vma *vma,
|
|||
/* Check if bo and vma can accommodate the given size and offset */
|
||||
if (ALIGN_POT(offset + size, vma->heap->page_size) > bo->size ||
|
||||
aligned_virt_size > vma->size) {
|
||||
vk_error(NULL, VK_ERROR_MEMORY_MAP_FAILED);
|
||||
return PVR_DEV_ADDR_INVALID;
|
||||
return vk_error(NULL, VK_ERROR_MEMORY_MAP_FAILED);
|
||||
}
|
||||
|
||||
/* Map the requested pages */
|
||||
|
|
@ -555,7 +562,7 @@ pvr_dev_addr_t pvr_srv_winsys_vma_map(struct pvr_winsys_vma *vma,
|
|||
}
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
return PVR_DEV_ADDR_INVALID;
|
||||
return result;
|
||||
|
||||
buffer_acquire(srv_bo);
|
||||
|
||||
|
|
@ -563,7 +570,10 @@ pvr_dev_addr_t pvr_srv_winsys_vma_map(struct pvr_winsys_vma *vma,
|
|||
vma->bo_offset = offset;
|
||||
vma->mapped_size = aligned_virt_size;
|
||||
|
||||
return PVR_DEV_ADDR_OFFSET(vma->dev_addr, virt_offset);
|
||||
if (dev_addr_out)
|
||||
*dev_addr_out = PVR_DEV_ADDR_OFFSET(vma->dev_addr, virt_offset);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void pvr_srv_winsys_vma_unmap(struct pvr_winsys_vma *vma)
|
||||
|
|
|
|||
|
|
@ -159,20 +159,22 @@ VkResult pvr_srv_winsys_buffer_get_fd(struct pvr_winsys_bo *bo,
|
|||
void *pvr_srv_winsys_buffer_map(struct pvr_winsys_bo *bo);
|
||||
void pvr_srv_winsys_buffer_unmap(struct pvr_winsys_bo *bo);
|
||||
|
||||
struct pvr_winsys_vma *
|
||||
pvr_srv_heap_alloc_reserved(struct pvr_winsys_heap *heap,
|
||||
const pvr_dev_addr_t reserved_dev_addr,
|
||||
uint64_t size,
|
||||
uint64_t alignment);
|
||||
struct pvr_winsys_vma *pvr_srv_winsys_heap_alloc(struct pvr_winsys_heap *heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment);
|
||||
VkResult pvr_srv_heap_alloc_reserved(struct pvr_winsys_heap *heap,
|
||||
const pvr_dev_addr_t reserved_dev_addr,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma **vma_out);
|
||||
VkResult pvr_srv_winsys_heap_alloc(struct pvr_winsys_heap *heap,
|
||||
uint64_t size,
|
||||
uint64_t alignment,
|
||||
struct pvr_winsys_vma **vma_out);
|
||||
void pvr_srv_winsys_heap_free(struct pvr_winsys_vma *vma);
|
||||
|
||||
pvr_dev_addr_t pvr_srv_winsys_vma_map(struct pvr_winsys_vma *vma,
|
||||
struct pvr_winsys_bo *bo,
|
||||
uint64_t offset,
|
||||
uint64_t size);
|
||||
VkResult pvr_srv_winsys_vma_map(struct pvr_winsys_vma *vma,
|
||||
struct pvr_winsys_bo *bo,
|
||||
uint64_t offset,
|
||||
uint64_t size,
|
||||
pvr_dev_addr_t *dev_addr_out);
|
||||
void pvr_srv_winsys_vma_unmap(struct pvr_winsys_vma *vma);
|
||||
|
||||
/*******************************************
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue