nvk/heap: Set the right pitch for heap resize copies

Otherwise, once we need to grow past 2^17 B, we attempt to copy two
lines, the hardware errors out, and we get left with a junk heap.
While we're here, re-arrange the code a bit so we keep all the P_FOO
together.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand 2023-05-02 22:01:10 -05:00 committed by Marge Bot
parent 729b34be8a
commit 6334cac288

View file

@ -96,7 +96,16 @@ nvk_heap_grow_locked(struct nvk_device *dev, struct nvk_heap *heap)
assert(heap->bo_count == 1);
struct nouveau_ws_bo *old_bo = heap->bos[0].bo;
uint32_t push_dw[10];
assert(util_is_power_of_two_nonzero(heap->total_size));
assert(heap->total_size >= NVK_HEAP_MIN_SIZE);
assert(heap->total_size <= old_bo->size);
assert(heap->total_size < new_bo_size);
unsigned line_bytes = MIN2(heap->total_size, 1 << 17);
assert(heap->total_size % line_bytes == 0);
unsigned line_count = heap->total_size / line_bytes;
uint32_t push_dw[12];
struct nv_push push;
nv_push_init(&push, push_dw, ARRAY_SIZE(push_dw));
struct nv_push *p = &push;
@ -106,18 +115,10 @@ nvk_heap_grow_locked(struct nvk_device *dev, struct nvk_heap *heap)
P_NV90B5_OFFSET_IN_LOWER(p, old_bo->offset & 0xffffffff);
P_NV90B5_OFFSET_OUT_UPPER(p, new_bo->offset >> 32);
P_NV90B5_OFFSET_OUT_LOWER(p, new_bo->offset & 0xffffffff);
assert(util_is_power_of_two_nonzero(heap->total_size));
assert(heap->total_size >= NVK_HEAP_MIN_SIZE);
assert(heap->total_size <= old_bo->size);
assert(heap->total_size < new_bo_size);
unsigned line_bytes = MIN2(heap->total_size, 1 << 17);
assert(heap->total_size % line_bytes == 0);
P_MTHD(p, NV90B5, LINE_LENGTH_IN);
P_NV90B5_PITCH_IN(p, line_bytes);
P_NV90B5_PITCH_OUT(p, line_bytes);
P_NV90B5_LINE_LENGTH_IN(p, line_bytes);
P_NV90B5_LINE_COUNT(p, heap->total_size / line_bytes);
P_NV90B5_LINE_COUNT(p, line_count);
P_IMMD(p, NV90B5, LAUNCH_DMA, {
.data_transfer_type = DATA_TRANSFER_TYPE_NON_PIPELINED,