diff options
author | Alex Waterman <alexw@nvidia.com> | 2018-05-30 12:16:06 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-06-27 11:42:52 -0400 |
commit | 2ac6fb4253fa815ed17f09a01141b938c826dac9 (patch) | |
tree | 71e65d7fbd090459d628d7024cda4ca52cbc60c5 | |
parent | 0b0b8209114e4ec7f916b55150eb1bbb99c35c4f (diff) |
gpu: nvgpu: posix: Fix ffs() and fls() impl in POSIX
The GCC builtins act slightly differently than the Linux versions
of these functions. This patch adds the necessary glue to emulate
the Linux versions identically.
JIRA NVGPU-525
Change-Id: Idadbecdfd516c68f3d3eb20eca495dc1eaa02c5b
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1741951
GVS: Gerrit_Virtual_Submit
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r-- | drivers/gpu/nvgpu/common/posix/bitmap.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/common/posix/bitmap.c b/drivers/gpu/nvgpu/common/posix/bitmap.c index b45838df..f25f6e64 100644 --- a/drivers/gpu/nvgpu/common/posix/bitmap.c +++ b/drivers/gpu/nvgpu/common/posix/bitmap.c | |||
@@ -29,14 +29,15 @@ | |||
29 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | 29 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) |
30 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) | 30 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) |
31 | 31 | ||
32 | unsigned long __nvgpu_posix_fls(unsigned long word) | 32 | unsigned long __nvgpu_posix_ffs(unsigned long word) |
33 | { | 33 | { |
34 | return __builtin_clzl(word); | 34 | return (__builtin_ffsl(word) - 1) & |
35 | ((sizeof(unsigned long) * 8UL) - 1UL); | ||
35 | } | 36 | } |
36 | 37 | ||
37 | unsigned long __nvgpu_posix_ffs(unsigned long word) | 38 | unsigned long __nvgpu_posix_fls(unsigned long word) |
38 | { | 39 | { |
39 | return __builtin_ffsl(word); | 40 | return ((sizeof(unsigned long) * 8UL) - 1UL) - __builtin_clzl(word); |
40 | } | 41 | } |
41 | 42 | ||
42 | static unsigned long __find_next_bit(const unsigned long *addr, | 43 | static unsigned long __find_next_bit(const unsigned long *addr, |