pvr: Move heap initialisation out of pvr_winsys_helper.
This code will not be used by the new KMD, so it is being moved out of this shared code area. Signed-off-by: Donald Robson <donald.robson@imgtec.com> Reviewed-by: Frank Binns <frank.binns@imgtec.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22826>
This commit is contained in:
@@ -63,67 +63,6 @@ int pvr_winsys_helper_display_buffer_destroy(int master_fd, uint32_t handle)
|
||||
return drmIoctl(master_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &args);
|
||||
}
|
||||
|
||||
/* reserved_size can be 0 when no reserved area is needed. reserved_address must
|
||||
* be 0 if reserved_size is 0.
|
||||
*/
|
||||
VkResult pvr_winsys_helper_winsys_heap_init(
|
||||
struct pvr_winsys *const ws,
|
||||
pvr_dev_addr_t base_address,
|
||||
uint64_t size,
|
||||
pvr_dev_addr_t reserved_address,
|
||||
uint64_t reserved_size,
|
||||
uint32_t log2_page_size,
|
||||
const struct pvr_winsys_static_data_offsets *const static_data_offsets,
|
||||
struct pvr_winsys_heap *const heap)
|
||||
{
|
||||
const bool reserved_area_bottom_of_heap = reserved_address.addr ==
|
||||
base_address.addr;
|
||||
const pvr_dev_addr_t vma_heap_begin_addr =
|
||||
reserved_area_bottom_of_heap
|
||||
? PVR_DEV_ADDR_OFFSET(base_address, reserved_size)
|
||||
: base_address;
|
||||
const uint64_t vma_heap_size = size - reserved_size;
|
||||
|
||||
assert(base_address.addr);
|
||||
assert(reserved_size <= size);
|
||||
|
||||
/* As per the reserved_base powervr-km uapi documentation the reserved
|
||||
* region can only be at the beginning of the heap or at the end.
|
||||
* reserved_address is 0 if there is no reserved region.
|
||||
* pvrsrv-km doesn't explicitly provide this info and it's assumed that it's
|
||||
* always at the beginning.
|
||||
*/
|
||||
assert(reserved_area_bottom_of_heap ||
|
||||
reserved_address.addr + reserved_size == base_address.addr + size ||
|
||||
(!reserved_address.addr && !reserved_size));
|
||||
|
||||
heap->ws = ws;
|
||||
heap->base_addr = base_address;
|
||||
heap->reserved_addr = reserved_address;
|
||||
|
||||
heap->size = size;
|
||||
heap->reserved_size = reserved_size;
|
||||
|
||||
heap->page_size = 1 << log2_page_size;
|
||||
heap->log2_page_size = log2_page_size;
|
||||
|
||||
util_vma_heap_init(&heap->vma_heap, vma_heap_begin_addr.addr, vma_heap_size);
|
||||
|
||||
heap->vma_heap.alloc_high = false;
|
||||
|
||||
/* It's expected that the heap destroy function to be the last thing that's
|
||||
* called, so we start the ref_count at 0.
|
||||
*/
|
||||
p_atomic_set(&heap->ref_count, 0);
|
||||
|
||||
if (pthread_mutex_init(&heap->lock, NULL))
|
||||
return vk_error(NULL, VK_ERROR_INITIALIZATION_FAILED);
|
||||
|
||||
heap->static_data_offsets = *static_data_offsets;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
bool pvr_winsys_helper_winsys_heap_finish(struct pvr_winsys_heap *const heap)
|
||||
{
|
||||
if (p_atomic_read(&heap->ref_count) != 0)
|
||||
|
||||
@@ -45,15 +45,6 @@ int pvr_winsys_helper_display_buffer_create(int master_fd,
|
||||
uint32_t *const handle_out);
|
||||
int pvr_winsys_helper_display_buffer_destroy(int master_fd, uint32_t handle);
|
||||
|
||||
VkResult pvr_winsys_helper_winsys_heap_init(
|
||||
struct pvr_winsys *const ws,
|
||||
pvr_dev_addr_t base_address,
|
||||
uint64_t size,
|
||||
pvr_dev_addr_t reserved_address,
|
||||
uint64_t reserved_size,
|
||||
uint32_t log2_page_size,
|
||||
const struct pvr_winsys_static_data_offsets *const static_data_offsets,
|
||||
struct pvr_winsys_heap *const heap);
|
||||
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,
|
||||
|
||||
@@ -53,6 +53,67 @@
|
||||
/* Amount of space used to hold sync prim values (in bytes). */
|
||||
#define PVR_SRV_SYNC_PRIM_VALUE_SIZE 4U
|
||||
|
||||
/* reserved_size can be 0 when no reserved region is needed. reserved_address
|
||||
* must be 0 if reserved_size is 0.
|
||||
*/
|
||||
static VkResult pvr_winsys_heap_init(
|
||||
struct pvr_winsys *const ws,
|
||||
pvr_dev_addr_t base_address,
|
||||
uint64_t size,
|
||||
pvr_dev_addr_t reserved_address,
|
||||
uint64_t reserved_size,
|
||||
uint32_t log2_page_size,
|
||||
const struct pvr_winsys_static_data_offsets *const static_data_offsets,
|
||||
struct pvr_winsys_heap *const heap)
|
||||
{
|
||||
const bool reserved_area_bottom_of_heap = reserved_address.addr ==
|
||||
base_address.addr;
|
||||
const pvr_dev_addr_t vma_heap_begin_addr =
|
||||
reserved_area_bottom_of_heap
|
||||
? PVR_DEV_ADDR_OFFSET(base_address, reserved_size)
|
||||
: base_address;
|
||||
const uint64_t vma_heap_size = size - reserved_size;
|
||||
|
||||
assert(base_address.addr);
|
||||
assert(reserved_size <= size);
|
||||
|
||||
/* As per the reserved_base powervr-km uapi documentation the reserved
|
||||
* region can only be at the beginning of the heap or at the end.
|
||||
* reserved_address is 0 if there is no reserved region.
|
||||
* pvrsrv-km doesn't explicitly provide this info and it's assumed that it's
|
||||
* always at the beginning.
|
||||
*/
|
||||
assert(reserved_area_bottom_of_heap ||
|
||||
reserved_address.addr + reserved_size == base_address.addr + size ||
|
||||
(!reserved_address.addr && !reserved_size));
|
||||
|
||||
heap->ws = ws;
|
||||
heap->base_addr = base_address;
|
||||
heap->reserved_addr = reserved_address;
|
||||
|
||||
heap->size = size;
|
||||
heap->reserved_size = reserved_size;
|
||||
|
||||
heap->page_size = 1 << log2_page_size;
|
||||
heap->log2_page_size = log2_page_size;
|
||||
|
||||
util_vma_heap_init(&heap->vma_heap, vma_heap_begin_addr.addr, vma_heap_size);
|
||||
|
||||
heap->vma_heap.alloc_high = false;
|
||||
|
||||
/* It's expected that the heap destroy function to be the last thing that's
|
||||
* called, so we start the ref_count at 0.
|
||||
*/
|
||||
p_atomic_set(&heap->ref_count, 0);
|
||||
|
||||
if (pthread_mutex_init(&heap->lock, NULL))
|
||||
return vk_error(NULL, VK_ERROR_INITIALIZATION_FAILED);
|
||||
|
||||
heap->static_data_offsets = *static_data_offsets;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum PB free list size supported by RGX and Services.
|
||||
*
|
||||
@@ -95,14 +156,14 @@ static VkResult pvr_srv_heap_init(
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
result = pvr_winsys_helper_winsys_heap_init(&srv_ws->base,
|
||||
base_address,
|
||||
size,
|
||||
base_address,
|
||||
reserved_size,
|
||||
log2_page_size,
|
||||
static_data_offsets,
|
||||
&srv_heap->base);
|
||||
result = pvr_winsys_heap_init(&srv_ws->base,
|
||||
base_address,
|
||||
size,
|
||||
base_address,
|
||||
reserved_size,
|
||||
log2_page_size,
|
||||
static_data_offsets,
|
||||
&srv_heap->base);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user