nve4: fix uploading unaligned sized input buffers
authorKarol Herbst <kherbst@redhat.com>
Sun, 22 Apr 2018 00:01:18 +0000 (02:01 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 19 Aug 2020 18:11:42 +0000 (18:11 +0000)
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Pierre Moreau <dev@pmoreau.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6367>

src/gallium/drivers/nouveau/nouveau_winsys.h
src/gallium/drivers/nouveau/nvc0/nve4_compute.c

index e0ed0af3eaa3fa2013d142efcc4618999f573239..792c9ea1547ffee29d53c4d403ee240ef4490060 100644 (file)
@@ -45,6 +45,13 @@ PUSH_DATAp(struct nouveau_pushbuf *push, const void *data, uint32_t size)
    push->cur += size;
 }
 
+static inline void
+PUSH_DATAb(struct nouveau_pushbuf *push, const void *data, uint32_t size)
+{
+   memcpy(push->cur, data, size);
+   push->cur += DIV_ROUND_UP(size, 4);
+}
+
 static inline void
 PUSH_DATAf(struct nouveau_pushbuf *push, float f)
 {
index ebbc410184bd80806f115146a5d56ccc03095630..8994be65ce4438b43e76b764398be90d9bd3c7b6 100644 (file)
@@ -530,9 +530,9 @@ nve4_compute_upload_input(struct nvc0_context *nvc0,
       BEGIN_NVC0(push, NVE4_CP(UPLOAD_LINE_LENGTH_IN), 2);
       PUSH_DATA (push, cp->parm_size);
       PUSH_DATA (push, 0x1);
-      BEGIN_1IC0(push, NVE4_CP(UPLOAD_EXEC), 1 + (cp->parm_size / 4));
+      BEGIN_1IC0(push, NVE4_CP(UPLOAD_EXEC), 1 + DIV_ROUND_UP(cp->parm_size, 4));
       PUSH_DATA (push, NVE4_COMPUTE_UPLOAD_EXEC_LINEAR | (0x20 << 1));
-      PUSH_DATAp(push, info->input, cp->parm_size / 4);
+      PUSH_DATAb(push, info->input, cp->parm_size);
    }
    BEGIN_NVC0(push, NVE4_CP(UPLOAD_DST_ADDRESS_HIGH), 2);
    PUSH_DATAh(push, address + NVC0_CB_AUX_GRID_INFO(0));