From fa7394037c94205e5645b5565deeae978c458ba5 Mon Sep 17 00:00:00 2001 From: Philip Elcan Date: Mon, 17 Sep 2018 11:42:33 -0400 Subject: gpu: nvgpu: unit: posix_bitops: fix fls() tests The fls() test assumed fls(1)=0, but really fls(1)=1, etc. Bug found as result of JIRA NVGPU-1042. Change-Id: I8d0ffe53277f4923a970b46788165ef03b385703 Signed-off-by: Philip Elcan Reviewed-on: https://git-master.nvidia.com/r/1828362 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- userspace/units/posix-bitops/posix-bitops.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'userspace/units/posix-bitops') diff --git a/userspace/units/posix-bitops/posix-bitops.c b/userspace/units/posix-bitops/posix-bitops.c index c808e777..22386a9b 100644 --- a/userspace/units/posix-bitops/posix-bitops.c +++ b/userspace/units/posix-bitops/posix-bitops.c @@ -110,20 +110,20 @@ static int test_fls(struct unit_module *m, struct gk20a *g, void *args) unsigned long i; CHECK_FLS_WORD(single_ulong_maps[0], 0UL); - CHECK_FLS_WORD(single_ulong_maps[1], BITS_PER_LONG - 1UL); - CHECK_FLS_WORD(single_ulong_maps[2], 31UL); - CHECK_FLS_WORD(single_ulong_maps[3], 23UL); - CHECK_FLS_WORD(single_ulong_maps[4], 31UL); - CHECK_FLS_WORD(single_ulong_maps[5], 15UL); - CHECK_FLS_WORD(single_ulong_maps[6], 31UL); - CHECK_FLS_WORD(single_ulong_maps[7], 0UL); - CHECK_FLS_WORD(single_ulong_maps[8], 31UL); - CHECK_FLS_WORD(single_ulong_maps[9], 16UL); + CHECK_FLS_WORD(single_ulong_maps[1], BITS_PER_LONG); + CHECK_FLS_WORD(single_ulong_maps[2], 32UL); + CHECK_FLS_WORD(single_ulong_maps[3], 24UL); + CHECK_FLS_WORD(single_ulong_maps[4], 32UL); + CHECK_FLS_WORD(single_ulong_maps[5], 16UL); + CHECK_FLS_WORD(single_ulong_maps[6], 32UL); + CHECK_FLS_WORD(single_ulong_maps[7], 1UL); + CHECK_FLS_WORD(single_ulong_maps[8], 32UL); + CHECK_FLS_WORD(single_ulong_maps[9], 17UL); #undef CHECK_FLS_WORD for (i = 0; i < BITS_PER_LONG; i++) { - if (fls(BIT(i)) != i) + if (fls(BIT(i)) != (i+1)) unit_return_fail(m, "fls(1 << %lu) != %lu! [%lu]\n", i, i, fls(BIT(i))); } -- cgit v1.2.2