mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-25 02:52:51 +03:00
gpu: nvgpu: fix issues with ffs and __fls
The LSB is position 1 for ffs and LSB is position 0 for __fls. Fix the issue with the return values of ffs and __fls to follow the mentioned bit positions. Jira NVGPU-2149 Change-Id: I4deab420c62217f8ad90683397c38530f88467d2 Signed-off-by: ajesh <akv@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2107276 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: Ankur Kishore <ankkishore@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
@@ -50,18 +50,16 @@
|
||||
(bit) < (size); \
|
||||
(bit) = find_next_bit((addr), (size), (bit) + 1U))
|
||||
|
||||
#define ffs(word) __ffs(word)
|
||||
unsigned long nvgpu_posix_ffs(unsigned long word);
|
||||
unsigned long nvgpu_posix_fls(unsigned long word);
|
||||
|
||||
#define ffs(word) nvgpu_posix_ffs(word)
|
||||
#define fls(word) nvgpu_posix_fls(word)
|
||||
|
||||
#define __ffs(word) ((ffs(word)) - 1)
|
||||
#define __fls(word) ((fls(word)) - 1)
|
||||
|
||||
#define ffz(word) __ffs(~(word))
|
||||
#define fls(word) __fls(word)
|
||||
|
||||
/*
|
||||
* Clashes with symbols in libc it seems.
|
||||
*/
|
||||
#define __ffs(word) __nvgpu_posix_ffs(word)
|
||||
#define __fls(word) __nvgpu_posix_fls(word)
|
||||
|
||||
unsigned long __nvgpu_posix_ffs(unsigned long word);
|
||||
unsigned long __nvgpu_posix_fls(unsigned long word);
|
||||
|
||||
unsigned long find_first_bit(const unsigned long *addr, unsigned long size);
|
||||
unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
|
||||
|
||||
@@ -7,10 +7,10 @@ __nvgpu_kmalloc
|
||||
__nvgpu_kzalloc
|
||||
__nvgpu_log_dbg
|
||||
__nvgpu_log_msg
|
||||
__nvgpu_posix_ffs
|
||||
__nvgpu_posix_fls
|
||||
__nvgpu_readl
|
||||
__nvgpu_set_pte
|
||||
nvgpu_posix_ffs
|
||||
nvgpu_posix_fls
|
||||
bitmap_clear
|
||||
bitmap_find_next_zero_area_off
|
||||
bitmap_set
|
||||
|
||||
@@ -30,13 +30,12 @@
|
||||
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
|
||||
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
||||
|
||||
unsigned long __nvgpu_posix_ffs(unsigned long word)
|
||||
unsigned long nvgpu_posix_ffs(unsigned long word)
|
||||
{
|
||||
return ((unsigned long)__builtin_ffsl(word) - 1UL) &
|
||||
(((unsigned long)sizeof(unsigned long) * 8UL) - 1UL);
|
||||
return (unsigned long)__builtin_ffsl(word);
|
||||
}
|
||||
|
||||
unsigned long __nvgpu_posix_fls(unsigned long word)
|
||||
unsigned long nvgpu_posix_fls(unsigned long word)
|
||||
{
|
||||
unsigned long ret;
|
||||
|
||||
@@ -104,7 +103,7 @@ static unsigned long __find_next_bit(const unsigned long *addr,
|
||||
w = addr[idx] ^ invert_mask;
|
||||
}
|
||||
|
||||
return min(n, ffs(w) + idx * BITS_PER_LONG);
|
||||
return min(n, __ffs(w) + idx * BITS_PER_LONG);
|
||||
}
|
||||
|
||||
unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
|
||||
|
||||
Reference in New Issue
Block a user