Message ID | 7c0410f150d78bae49c1d8ae0d918b56c2b0c7de.1610115608.git.rahul.singh@arm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xen/arm: Add support for SMMUv3 driver | expand |
On Fri, 8 Jan 2021, Rahul Singh wrote: > Implement the ffsll based on built-in function "__builtin_ffsll()" > > ffsll will return one plus the index of the least significant 1-bit in > doublewords or if doublewords is zero, returns zero. > > Signed-off-by: Rahul Singh <rahul.singh@arm.com> > --- > Changes in V4: > - This patch is introduce in this verison. > --- > xen/include/asm-arm/bitops.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h > index 71ae14cab3..7f83ee1828 100644 > --- a/xen/include/asm-arm/bitops.h > +++ b/xen/include/asm-arm/bitops.h > @@ -170,6 +170,18 @@ static inline unsigned int find_first_set_bit(unsigned long word) > return ffsl(word) - 1; > } > > +/** > + * ffsll - find the first least significant set bit > + * @doubleword: double word to search > + * > + * Returns one plus the index of the least significant 1-bit in @doubleword > + * or if doubleword is zero, returns zero. > + */ > +static inline int ffsll(long long doubleword) > +{ > + return __builtin_ffsll(doubleword); > +} This compiles fine with my old 4.9 compiler and in gitlab too, so I am OK with this, even better because it is less code to maintain. Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Hi, > On 8 Jan 2021, at 14:46, Rahul Singh <Rahul.Singh@arm.com> wrote: > > Implement the ffsll based on built-in function "__builtin_ffsll()" > > ffsll will return one plus the index of the least significant 1-bit in > doublewords or if doublewords is zero, returns zero. > > Signed-off-by: Rahul Singh <rahul.singh@arm.com> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> Cheers Bertrand > --- > Changes in V4: > - This patch is introduce in this verison. > --- > xen/include/asm-arm/bitops.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h > index 71ae14cab3..7f83ee1828 100644 > --- a/xen/include/asm-arm/bitops.h > +++ b/xen/include/asm-arm/bitops.h > @@ -170,6 +170,18 @@ static inline unsigned int find_first_set_bit(unsigned long word) > return ffsl(word) - 1; > } > > +/** > + * ffsll - find the first least significant set bit > + * @doubleword: double word to search > + * > + * Returns one plus the index of the least significant 1-bit in @doubleword > + * or if doubleword is zero, returns zero. > + */ > +static inline int ffsll(long long doubleword) > +{ > + return __builtin_ffsll(doubleword); > +} > + > /** > * hweightN - returns the hamming weight of a N-bit word > * @x: the word to weigh > -- > 2.17.1 >
Hi Rahul, On 08/01/2021 14:46, Rahul Singh wrote: > Implement the ffsll based on built-in function "__builtin_ffsll()" > > ffsll will return one plus the index of the least significant 1-bit in > doublewords or if doublewords is zero, returns zero. > > Signed-off-by: Rahul Singh <rahul.singh@arm.com> > --- > Changes in V4: > - This patch is introduce in this verison. > --- > xen/include/asm-arm/bitops.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h > index 71ae14cab3..7f83ee1828 100644 > --- a/xen/include/asm-arm/bitops.h > +++ b/xen/include/asm-arm/bitops.h > @@ -170,6 +170,18 @@ static inline unsigned int find_first_set_bit(unsigned long word) > return ffsl(word) - 1; > } > > +/** > + * ffsll - find the first least significant set bit > + * @doubleword: double word to search > + * > + * Returns one plus the index of the least significant 1-bit in @doubleword > + * or if doubleword is zero, returns zero. > + */ > +static inline int ffsll(long long doubleword) If I am not mistaken, we already have an helper doing exactly the same (see ffs64() in xen/bitops.h). Can you check if it is effectively the case and use it? Cheers,
Hello Julien, > On 15 Jan 2021, at 12:16 pm, Julien Grall <julien@xen.org> wrote: > > Hi Rahul, > > On 08/01/2021 14:46, Rahul Singh wrote: >> Implement the ffsll based on built-in function "__builtin_ffsll()" >> ffsll will return one plus the index of the least significant 1-bit in >> doublewords or if doublewords is zero, returns zero. >> Signed-off-by: Rahul Singh <rahul.singh@arm.com> >> --- >> Changes in V4: >> - This patch is introduce in this verison. >> --- >> xen/include/asm-arm/bitops.h | 12 ++++++++++++ >> 1 file changed, 12 insertions(+) >> diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h >> index 71ae14cab3..7f83ee1828 100644 >> --- a/xen/include/asm-arm/bitops.h >> +++ b/xen/include/asm-arm/bitops.h >> @@ -170,6 +170,18 @@ static inline unsigned int find_first_set_bit(unsigned long word) >> return ffsl(word) - 1; >> } >> +/** >> + * ffsll - find the first least significant set bit >> + * @doubleword: double word to search >> + * >> + * Returns one plus the index of the least significant 1-bit in @doubleword >> + * or if doubleword is zero, returns zero. >> + */ >> +static inline int ffsll(long long doubleword) > > If I am not mistaken, we already have an helper doing exactly the same (see ffs64() in xen/bitops.h). > > Can you check if it is effectively the case and use it? I checked we can use the ffs64() for SMMUv3 driver as it is doing exactly the same as ffsll(). I will modify the code to use the ffs64() in place of ffsll(). Regards, Rahul > > Cheers, > > -- > Julien Grall
diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h index 71ae14cab3..7f83ee1828 100644 --- a/xen/include/asm-arm/bitops.h +++ b/xen/include/asm-arm/bitops.h @@ -170,6 +170,18 @@ static inline unsigned int find_first_set_bit(unsigned long word) return ffsl(word) - 1; } +/** + * ffsll - find the first least significant set bit + * @doubleword: double word to search + * + * Returns one plus the index of the least significant 1-bit in @doubleword + * or if doubleword is zero, returns zero. + */ +static inline int ffsll(long long doubleword) +{ + return __builtin_ffsll(doubleword); +} + /** * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh
Implement the ffsll based on built-in function "__builtin_ffsll()" ffsll will return one plus the index of the least significant 1-bit in doublewords or if doublewords is zero, returns zero. Signed-off-by: Rahul Singh <rahul.singh@arm.com> --- Changes in V4: - This patch is introduce in this verison. --- xen/include/asm-arm/bitops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)