summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuigi Santivetti <luigi.santivetti@imgtec.com>2023-04-03 10:02:02 +0100
committerMarge Bot <emma+marge@anholt.net>2023-05-10 13:13:07 +0000
commit4a1614eedd44daf6d1de4a6dbd3f064ed3bb870c (patch)
treeefcf31f2d4a5e07601145866c50a652e6b0cc6e0
parent5ea7a41607111b0fbd06083dd218495fec44a3e6 (diff)
pvr: add GUARD_SIZE_DEFAULT for CDM and VDM control stream links 1 and 2
Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com> Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22631>
-rw-r--r--src/imagination/csbgen/rogue_cdm.xml2
-rw-r--r--src/imagination/csbgen/rogue_vdm.xml2
-rw-r--r--src/imagination/vulkan/pvr_csb.c29
3 files changed, 22 insertions, 11 deletions
diff --git a/src/imagination/csbgen/rogue_cdm.xml b/src/imagination/csbgen/rogue_cdm.xml
index 766c065e7d7..83cf0e89253 100644
--- a/src/imagination/csbgen/rogue_cdm.xml
+++ b/src/imagination/csbgen/rogue_cdm.xml
@@ -25,6 +25,8 @@ SOFTWARE.
<csbgen name="ROGUE" prefix="CDMCTRL">
+ <define name="GUARD_SIZE_DEFAULT" value="64"/>
+
<enum name="BLOCK_TYPE">
<value name="COMPUTE_KERNEL" value="0"/>
<value name="STREAM_LINK" value="1"/>
diff --git a/src/imagination/csbgen/rogue_vdm.xml b/src/imagination/csbgen/rogue_vdm.xml
index ca62b5c6cfa..f6a8a84a9e6 100644
--- a/src/imagination/csbgen/rogue_vdm.xml
+++ b/src/imagination/csbgen/rogue_vdm.xml
@@ -25,6 +25,8 @@ SOFTWARE.
<csbgen name="ROGUE" prefix="VDMCTRL">
+ <define name="GUARD_SIZE_DEFAULT" value="64"/>
+
<enum name="BLOCK_TYPE">
<value name="PPP_STATE_UPDATE" value="0"/>
<value name="PDS_STATE_UPDATE" value="1"/>
diff --git a/src/imagination/vulkan/pvr_csb.c b/src/imagination/vulkan/pvr_csb.c
index e8007d1b4fa..29e208c9537 100644
--- a/src/imagination/vulkan/pvr_csb.c
+++ b/src/imagination/vulkan/pvr_csb.c
@@ -151,11 +151,12 @@ VkResult pvr_csb_bake(struct pvr_csb *const csb,
* using STREAM_LINK dwords and updates csb object to use the new buffer.
*
* To make sure that we have enough space to emit STREAM_LINK dwords in the
- * current buffer, a few bytes are reserved at the end, every time a buffer is
- * created. Every time we allocate a new buffer we fix the current buffer in use
- * to emit the stream link dwords. This makes sure that when
- * #pvr_csb_alloc_dwords() is called from #pvr_csb_emit() to add STREAM_LINK0
- * and STREAM_LINK1, it succeeds without trying to allocate new pages.
+ * current buffer, a few bytes including guard padding size are reserved at the
+ * end, every time a buffer is created. Every time we allocate a new buffer we
+ * fix the current buffer in use to emit the stream link dwords. This makes sure
+ * that when #pvr_csb_alloc_dwords() is called from #pvr_csb_emit() to add
+ * STREAM_LINK0 and STREAM_LINK1, it succeeds without trying to allocate new
+ * pages.
*
* \param[in] csb Control Stream Builder object to extend.
* \return true on success and false otherwise.
@@ -165,6 +166,8 @@ static bool pvr_csb_buffer_extend(struct pvr_csb *csb)
const uint8_t stream_link_space =
PVR_DW_TO_BYTES(pvr_cmd_length(VDMCTRL_STREAM_LINK0) +
pvr_cmd_length(VDMCTRL_STREAM_LINK1));
+ const uint8_t stream_reserved_space =
+ stream_link_space + PVRX(VDMCTRL_GUARD_SIZE_DEFAULT);
const uint32_t cache_line_size =
rogue_get_slc_cache_line_size(&csb->device->pdevice->dev_info);
struct pvr_bo *pvr_bo;
@@ -178,6 +181,9 @@ static bool pvr_csb_buffer_extend(struct pvr_csb *csb)
(pvr_cmd_length(CDMCTRL_STREAM_LINK0) +
pvr_cmd_length(CDMCTRL_STREAM_LINK1)));
+ STATIC_ASSERT(PVRX(VDMCTRL_GUARD_SIZE_DEFAULT) ==
+ PVRX(CDMCTRL_GUARD_SIZE_DEFAULT));
+
result = pvr_bo_alloc(csb->device,
csb->device->heaps.general_heap,
PVR_CMD_BUFFER_CSB_BO_SIZE,
@@ -201,10 +207,10 @@ static bool pvr_csb_buffer_extend(struct pvr_csb *csb)
csb->pvr_bo = pvr_bo;
csb->start = pvr_bo->bo->map;
- /* Reserve stream link size at the end to make sure we don't run out of
- * space when a stream link is required.
+ /* Reserve space at the end, including the default guard padding, to make
+ * sure we don't run out of space when a stream link is required.
*/
- csb->end = csb->start + pvr_bo->bo->size - stream_link_space;
+ csb->end = csb->start + pvr_bo->bo->size - stream_reserved_space;
csb->next = csb->start;
list_addtail(&pvr_bo->link, &csb->pvr_bo_list);
@@ -273,9 +279,10 @@ void *pvr_csb_alloc_dwords(struct pvr_csb *csb, uint32_t num_dwords)
*/
VkResult pvr_csb_copy(struct pvr_csb *csb_dst, struct pvr_csb *csb_src)
{
- const uint8_t stream_link_space =
+ const uint8_t stream_reserved_space =
PVR_DW_TO_BYTES(pvr_cmd_length(VDMCTRL_STREAM_LINK0) +
- pvr_cmd_length(VDMCTRL_STREAM_LINK1));
+ pvr_cmd_length(VDMCTRL_STREAM_LINK1)) +
+ PVRX(VDMCTRL_GUARD_SIZE_DEFAULT);
const uint32_t size =
util_dynarray_num_elements(&csb_src->deferred_cs_mem, char);
const uint8_t *start = util_dynarray_begin(&csb_src->deferred_cs_mem);
@@ -287,7 +294,7 @@ VkResult pvr_csb_copy(struct pvr_csb *csb_dst, struct pvr_csb *csb_src)
/* Only graphics control stream supported as dst. */
assert(csb_dst->stream_type == PVR_CMD_STREAM_TYPE_GRAPHICS);
- if (size >= (PVR_CMD_BUFFER_CSB_BO_SIZE - stream_link_space)) {
+ if (size >= (PVR_CMD_BUFFER_CSB_BO_SIZE - stream_reserved_space)) {
/* TODO: For now we don't support deferred streams bigger than one csb
* buffer object size.
*