'winsys/pvrsrvkm/pvr_srv_job_render.c',
'winsys/pvrsrvkm/pvr_srv_job_transfer.c',
'winsys/pvrsrvkm/pvr_srv_sync.c',
+ 'winsys/pvrsrvkm/pvr_srv_sync_prim.c',
)
pvr_flags += '-DPVR_SUPPORT_SERVICES_DRIVER'
endif
#include "pvr_srv_job_transfer.h"
#include "pvr_srv_public.h"
#include "pvr_srv_sync.h"
+#include "pvr_srv_sync_prim.h"
#include "pvr_srv_job_null.h"
#include "pvr_types.h"
#include "pvr_winsys.h"
#include "util/log.h"
#include "util/macros.h"
#include "util/os_misc.h"
+#include "util/u_atomic.h"
#include "vk_log.h"
#include "vk_sync.h"
#include "vk_sync_timeline.h"
-/* 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.
*/
pvr_srv_int_ctx_destroy(srv_ws->render_fd, srv_ws->server_memctx);
}
-static VkResult pvr_srv_sync_prim_block_init(struct pvr_srv_winsys *srv_ws)
-{
- /* We don't currently make use of this value, but we're required to provide
- * a valid pointer to pvr_srv_alloc_sync_primitive_block.
- */
- void *sync_block_pmr;
-
- return pvr_srv_alloc_sync_primitive_block(srv_ws->render_fd,
- &srv_ws->sync_block_handle,
- &sync_block_pmr,
- &srv_ws->sync_block_size,
- &srv_ws->sync_block_fw_addr);
-}
-
-static void pvr_srv_sync_prim_block_finish(struct pvr_srv_winsys *srv_ws)
-{
- pvr_srv_free_sync_primitive_block(srv_ws->render_fd,
- srv_ws->sync_block_handle);
- srv_ws->sync_block_handle = NULL;
-}
-
static void pvr_srv_winsys_destroy(struct pvr_winsys *ws)
{
struct pvr_srv_winsys *srv_ws = to_pvr_srv_winsys(ws);
return NULL;
}
-struct pvr_srv_sync_prim *pvr_srv_sync_prim_alloc(struct pvr_srv_winsys *srv_ws)
-{
- struct pvr_srv_sync_prim *sync_prim;
-
- if (p_atomic_read(&srv_ws->sync_block_offset) == srv_ws->sync_block_size) {
- vk_error(NULL, VK_ERROR_UNKNOWN);
- return NULL;
- }
-
- sync_prim = vk_alloc(srv_ws->alloc,
- sizeof(*sync_prim),
- 8,
- VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
- if (!sync_prim) {
- vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
- return NULL;
- }
-
- /* p_atomic_add_return() returns the new value rather than the old one, so
- * we have to subtract PVR_SRV_SYNC_PRIM_VALUE_SIZE to get the old value.
- */
- sync_prim->offset = p_atomic_add_return(&srv_ws->sync_block_offset,
- PVR_SRV_SYNC_PRIM_VALUE_SIZE);
- sync_prim->offset -= PVR_SRV_SYNC_PRIM_VALUE_SIZE;
- if (sync_prim->offset == srv_ws->sync_block_size) {
- /* FIXME: need to free offset back to srv_ws->sync_block_offset. */
- vk_free(srv_ws->alloc, sync_prim);
-
- vk_error(NULL, VK_ERROR_UNKNOWN);
-
- return NULL;
- }
-
- sync_prim->srv_ws = srv_ws;
-
- return sync_prim;
-}
-
-/* FIXME: Add support for freeing offsets back to the sync block. */
-void pvr_srv_sync_prim_free(struct pvr_srv_sync_prim *sync_prim)
-{
- if (sync_prim) {
- struct pvr_srv_winsys *srv_ws = sync_prim->srv_ws;
-
- vk_free(srv_ws->alloc, sync_prim);
- }
-}
-
static VkResult pvr_srv_create_presignaled_sync(struct pvr_device *device,
struct pvr_srv_sync **out_sync)
{
#include <vulkan/vulkan.h>
#include "pvr_srv_sync.h"
+#include "pvr_srv_sync_prim.h"
#include "pvr_winsys.h"
#include "util/macros.h"
#include "util/vma.h"
struct pvr_winsys_vma *usc_vma;
struct pvr_winsys_vma *general_vma;
- /* Sync block used for allocating sync primitives. */
- void *sync_block_handle;
- uint32_t sync_block_size;
- uint32_t sync_block_fw_addr;
- uint16_t sync_block_offset;
-};
-
-struct pvr_srv_sync_prim {
- struct pvr_srv_winsys *srv_ws;
- uint32_t offset;
- uint32_t value;
+ struct pvr_srv_sync_prim_ctx sync_prim_ctx;
};
/*******************************************
functions
*******************************************/
-struct pvr_srv_sync_prim *
-pvr_srv_sync_prim_alloc(struct pvr_srv_winsys *srv_ws);
-void pvr_srv_sync_prim_free(struct pvr_srv_sync_prim *sync_prim);
-
-static inline uint32_t
-pvr_srv_sync_prim_get_fw_addr(const struct pvr_srv_sync_prim *const sync_prim)
-{
- return sync_prim->srv_ws->sync_block_fw_addr + sync_prim->offset;
-}
-
VkResult pvr_srv_sync_get_presignaled_sync(struct pvr_device *device,
struct pvr_srv_sync **out_sync);
#include "pvr_srv_job_common.h"
#include "pvr_srv_job_render.h"
#include "pvr_srv_sync.h"
+#include "pvr_srv_sync_prim.h"
#include "pvr_types.h"
#include "pvr_winsys.h"
#include "util/log.h"
err_srv_sync_prim_free:
for (uint32_t i = 0; i < ARRAY_SIZE(srv_rt_dataset->rt_datas); i++) {
- pvr_srv_sync_prim_free(srv_rt_dataset->rt_datas[i].sync_prim);
+ pvr_srv_sync_prim_free(srv_ws, srv_rt_dataset->rt_datas[i].sync_prim);
if (srv_rt_dataset->rt_datas[i].handle) {
pvr_srv_rgx_destroy_hwrt_dataset(srv_ws->render_fd,
to_pvr_srv_winsys_rt_dataset(rt_dataset);
for (uint32_t i = 0; i < ARRAY_SIZE(srv_rt_dataset->rt_datas); i++) {
- pvr_srv_sync_prim_free(srv_rt_dataset->rt_datas[i].sync_prim);
+ pvr_srv_sync_prim_free(srv_ws, srv_rt_dataset->rt_datas[i].sync_prim);
if (srv_rt_dataset->rt_datas[i].handle) {
pvr_srv_rgx_destroy_hwrt_dataset(srv_ws->render_fd,
NULL,
NULL,
1,
- &sync_prim->srv_ws->sync_block_handle,
+ &sync_prim->ctx->block_handle,
&sync_prim->offset,
&sync_prim->value,
0,
NULL,
NULL,
NULL,
- sync_prim->srv_ws->sync_block_handle,
+ sync_prim->ctx->block_handle,
sync_prim->offset,
sync_prim->value,
in_geom_fd,
--- /dev/null
+/*
+ * Copyright © 2023 Imagination Technologies Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <vulkan/vulkan_core.h>
+
+#include "pvr_srv.h"
+#include "pvr_srv_bridge.h"
+#include "pvr_srv_sync_prim.h"
+#include "util/u_atomic.h"
+#include "vk_alloc.h"
+#include "vk_log.h"
+
+/* Amount of space used to hold sync prim values (in bytes). */
+#define PVR_SRV_SYNC_PRIM_VALUE_SIZE 4
+
+VkResult pvr_srv_sync_prim_block_init(struct pvr_srv_winsys *srv_ws)
+{
+ /* We don't currently make use of this value, but we're required to provide
+ * a valid pointer to pvr_srv_alloc_sync_primitive_block.
+ */
+ void *sync_block_pmr;
+
+ return pvr_srv_alloc_sync_primitive_block(
+ srv_ws->render_fd,
+ &srv_ws->sync_prim_ctx.block_handle,
+ &sync_block_pmr,
+ &srv_ws->sync_prim_ctx.block_size,
+ &srv_ws->sync_prim_ctx.block_fw_addr);
+}
+
+void pvr_srv_sync_prim_block_finish(struct pvr_srv_winsys *srv_ws)
+{
+ pvr_srv_free_sync_primitive_block(srv_ws->render_fd,
+ srv_ws->sync_prim_ctx.block_handle);
+ srv_ws->sync_prim_ctx.block_handle = NULL;
+}
+
+struct pvr_srv_sync_prim *pvr_srv_sync_prim_alloc(struct pvr_srv_winsys *srv_ws)
+{
+ struct pvr_srv_sync_prim *sync_prim;
+
+ if (p_atomic_read(&srv_ws->sync_prim_ctx.block_offset) ==
+ srv_ws->sync_prim_ctx.block_size) {
+ vk_error(NULL, VK_ERROR_UNKNOWN);
+ return NULL;
+ }
+
+ sync_prim = vk_alloc(srv_ws->alloc,
+ sizeof(*sync_prim),
+ 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
+ if (!sync_prim) {
+ vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
+ return NULL;
+ }
+
+ /* p_atomic_add_return() returns the new value rather than the old one, so
+ * we have to subtract PVR_SRV_SYNC_PRIM_VALUE_SIZE to get the old value.
+ */
+ sync_prim->offset = p_atomic_add_return(&srv_ws->sync_prim_ctx.block_offset,
+ PVR_SRV_SYNC_PRIM_VALUE_SIZE);
+ sync_prim->offset -= PVR_SRV_SYNC_PRIM_VALUE_SIZE;
+ if (sync_prim->offset == srv_ws->sync_prim_ctx.block_size) {
+ /* FIXME: need to free offset back to srv_ws->sync_block_offset. */
+ vk_free(srv_ws->alloc, sync_prim);
+
+ vk_error(NULL, VK_ERROR_UNKNOWN);
+
+ return NULL;
+ }
+
+ sync_prim->ctx = &srv_ws->sync_prim_ctx;
+
+ return sync_prim;
+}
+
+/* FIXME: Add support for freeing offsets back to the sync block. */
+void pvr_srv_sync_prim_free(struct pvr_srv_winsys *srv_ws,
+ struct pvr_srv_sync_prim *sync_prim)
+{
+ vk_free(srv_ws->alloc, sync_prim);
+}
--- /dev/null
+/*
+ * Copyright © 2023 Imagination Technologies Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef PVR_SRV_SYNC_PRIM_H
+#define PVR_SRV_SYNC_PRIM_H
+
+#include <stdint.h>
+#include <vulkan/vulkan_core.h>
+
+struct pvr_srv_winsys;
+
+struct pvr_srv_sync_prim_ctx {
+ /* Sync block used for allocating sync primitives. */
+ void *block_handle;
+ uint32_t block_size;
+ uint32_t block_fw_addr;
+ uint16_t block_offset;
+};
+
+struct pvr_srv_sync_prim {
+ struct pvr_srv_sync_prim_ctx *ctx;
+ uint32_t offset;
+ uint32_t value;
+};
+
+VkResult pvr_srv_sync_prim_block_init(struct pvr_srv_winsys *srv_ws);
+void pvr_srv_sync_prim_block_finish(struct pvr_srv_winsys *srv_ws);
+
+struct pvr_srv_sync_prim *
+pvr_srv_sync_prim_alloc(struct pvr_srv_winsys *srv_ws);
+void pvr_srv_sync_prim_free(struct pvr_srv_winsys *srv_ws,
+ struct pvr_srv_sync_prim *sync_prim);
+
+static inline uint32_t
+pvr_srv_sync_prim_get_fw_addr(const struct pvr_srv_sync_prim *const sync_prim)
+{
+ return sync_prim->ctx->block_fw_addr + sync_prim->offset;
+}
+
+#endif /* PVR_SRV_SYNC_PRIM_H */