From ddd82c3ab8ced10b99ea87c444d4c0fa19f2fee6 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 9 Sep 2020 10:46:03 +0200 Subject: [PATCH] panfrost: gen_pack: Fix __gen_unpack_uint() The mask should be a 64-bit value and we should promote cl bytes to u64 before shifting them. Fixes: 75cc5b8c2922 ("panfrost: Adopt gen_pack_header.py via v3d") Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/lib/gen_pack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panfrost/lib/gen_pack.py b/src/panfrost/lib/gen_pack.py index 2dbf2d0..3cf96eb 100644 --- a/src/panfrost/lib/gen_pack.py +++ b/src/panfrost/lib/gen_pack.py @@ -102,10 +102,10 @@ __gen_unpack_uint(const uint8_t *restrict cl, uint32_t start, uint32_t end) { uint64_t val = 0; const int width = end - start + 1; - const uint32_t mask = (width == 32 ? ~0 : (1 << width) - 1 ); + const uint64_t mask = (width == 64 ? ~0 : (1ull << width) - 1 ); for (int byte = start / 8; byte <= end / 8; byte++) { - val |= cl[byte] << ((byte - start / 8) * 8); + val |= ((uint64_t) cl[byte]) << ((byte - start / 8) * 8); } return (val >> (start % 8)) & mask; -- 2.7.4