* [PATCH 0/4] Modify bitmap_set_value() to suppress compiler warning @ 2020-11-20 17:42 Syed Nayyar Waris 2020-11-20 17:44 ` [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length Syed Nayyar Waris ` (3 more replies) 0 siblings, 4 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 17:42 UTC (permalink / raw) To: akpm Cc: andriy.shevchenko, vilhelm.gray, michal.simek, arnd, rrichter, linus.walleij, bgolaszewski, yamada.masahiro, rui.zhang, daniel.lezcano, amit.kucheria, linux-arch, linux-gpio, linux-kernel, linux-arm-kernel, linux-pm Hi All, The purpose of this patchset is to suppress the compiler warning (-Wtype-limits). In function bitmap_set_value(), add explicit check to see if the value being written into the bitmap does not fall outside the bitmap. The situation that it is falling outside is never possible in the code because the boundaries are required to be correct before the function is called. The responsibility is on the caller for ensuring the boundaries are correct. The code change is simply to silence the GCC warning messages because GCC is not aware that the boundaries have already been checked. As such, we're better off using __builtin_unreachable() here because we can avoid the latency of the conditional check entirely. Michal, What do you think of [PATCH 4/4]? Is the conditional check needed, and also whether returning -EINVAL looks good? Syed Nayyar Waris (4): bitmap: Modify bitmap_set_value() to check bitmap length lib/test_bitmap.c: Modify for_each_set_clump test gpio: xilinx: Modify bitmap_set_value() calls gpio: xilinx: Add extra check if sum of widths exceed 64 drivers/gpio/gpio-xilinx.c | 18 ++++++++++++------ include/linux/bitmap.h | 35 +++++++++++++++++++++-------------- lib/test_bitmap.c | 4 ++-- 3 files changed, 35 insertions(+), 22 deletions(-) base-commit: b640c4e12bbe1f0b6383c3ef788a89e5427c763f -- 2.29.0 ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length 2020-11-20 17:42 [PATCH 0/4] Modify bitmap_set_value() to suppress compiler warning Syed Nayyar Waris @ 2020-11-20 17:44 ` Syed Nayyar Waris 2020-11-20 17:59 ` William Breathitt Gray 2020-11-20 18:43 ` [RESEND PATCH " Syed Nayyar Waris 2020-11-20 17:45 ` [PATCH 2/4] lib/test_bitmap.c: Modify for_each_set_clump test Syed Nayyar Waris ` (2 subsequent siblings) 3 siblings, 2 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 17:44 UTC (permalink / raw) To: akpm; +Cc: andriy.shevchenko, vilhelm.gray, arnd, linux-arch, linux-kernel Add explicit check to see if the value being written into the bitmap does not fall outside the bitmap. The situation that it is falling outside would never be possible in the code because the boundaries are required to be correct before the function is called. The responsibility is on the caller for ensuring the boundaries are correct. This is just to suppress the GCC -Wtype-limits warnings. Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> --- include/linux/bitmap.h | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 386d08777342..efb6199ea1e7 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -78,8 +78,9 @@ * bitmap_get_value(map, start, nbits) Get bit value of size * 'nbits' from map at start * bitmap_set_value8(map, value, start) Set 8bit value to map at start - * bitmap_set_value(map, value, start, nbits) Set bit value of size 'nbits' - * of map at start + * bitmap_set_value(map, nbits, value, value_width, start) + * Set bit value of size value_width + * to map at start * * Note, bitmap_zero() and bitmap_fill() operate over the region of * unsigned longs, that is, bits behind bitmap till the unsigned long @@ -610,30 +611,36 @@ static inline void bitmap_set_value8(unsigned long *map, unsigned long value, } /** - * bitmap_set_value - set n-bit value within a memory region + * bitmap_set_value - set value within a memory region * @map: address to the bitmap memory region - * @value: value of nbits - * @start: bit offset of the n-bit value - * @nbits: size of value in bits (must be between 1 and BITS_PER_LONG inclusive). + * @nbits: size of map in bits + * @value: value of clump + * @value_width: size of value in bits (must be between 1 and BITS_PER_LONG inclusive) + * @start: bit offset of the value */ -static inline void bitmap_set_value(unsigned long *map, - unsigned long value, - unsigned long start, unsigned long nbits) +static inline void bitmap_set_value(unsigned long *map, unsigned long nbits, + unsigned long value, unsigned long value_width, + unsigned long start) { - const size_t index = BIT_WORD(start); + const unsigned long index = BIT_WORD(start); + const unsigned long length = BIT_WORD(nbits); const unsigned long offset = start % BITS_PER_LONG; const unsigned long ceiling = round_up(start + 1, BITS_PER_LONG); const unsigned long space = ceiling - start; - value &= GENMASK(nbits - 1, 0); + value &= GENMASK(value_width - 1, 0); - if (space >= nbits) { - map[index] &= ~(GENMASK(nbits - 1, 0) << offset); + if (space >= value_width) { + map[index] &= ~(GENMASK(value_width - 1, 0) << offset); map[index] |= value << offset; } else { map[index + 0] &= ~BITMAP_FIRST_WORD_MASK(start); map[index + 0] |= value << offset; - map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits); + + if (index + 1 >= length) + __builtin_unreachable(); + + map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + value_width); map[index + 1] |= value >> space; } } -- 2.29.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length 2020-11-20 17:44 ` [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length Syed Nayyar Waris @ 2020-11-20 17:59 ` William Breathitt Gray 2020-11-20 18:02 ` Syed Nayyar Waris 2020-11-20 18:43 ` [RESEND PATCH " Syed Nayyar Waris 1 sibling, 1 reply; 13+ messages in thread From: William Breathitt Gray @ 2020-11-20 17:59 UTC (permalink / raw) To: Syed Nayyar Waris; +Cc: akpm, andriy.shevchenko, arnd, linux-arch, linux-kernel [-- Attachment #1: Type: text/plain, Size: 3980 bytes --] On Fri, Nov 20, 2020 at 11:14:16PM +0530, Syed Nayyar Waris wrote: > Add explicit check to see if the value being written into the bitmap > does not fall outside the bitmap. > The situation that it is falling outside would never be possible in the > code because the boundaries are required to be correct before the function > is called. The responsibility is on the caller for ensuring the boundaries > are correct. > This is just to suppress the GCC -Wtype-limits warnings. Hi Syed, This commit message sounds a bit strange without the context of our earlier discussion thread. Would you be able to reword the commit message to explain the motivation for using __builtin_unreachable()? Thanks, William Breathitt Gray > > Cc: Arnd Bergmann <arnd@arndb.de> > Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> > Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> > --- > include/linux/bitmap.h | 35 +++++++++++++++++++++-------------- > 1 file changed, 21 insertions(+), 14 deletions(-) > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > index 386d08777342..efb6199ea1e7 100644 > --- a/include/linux/bitmap.h > +++ b/include/linux/bitmap.h > @@ -78,8 +78,9 @@ > * bitmap_get_value(map, start, nbits) Get bit value of size > * 'nbits' from map at start > * bitmap_set_value8(map, value, start) Set 8bit value to map at start > - * bitmap_set_value(map, value, start, nbits) Set bit value of size 'nbits' > - * of map at start > + * bitmap_set_value(map, nbits, value, value_width, start) > + * Set bit value of size value_width > + * to map at start > * > * Note, bitmap_zero() and bitmap_fill() operate over the region of > * unsigned longs, that is, bits behind bitmap till the unsigned long > @@ -610,30 +611,36 @@ static inline void bitmap_set_value8(unsigned long *map, unsigned long value, > } > > /** > - * bitmap_set_value - set n-bit value within a memory region > + * bitmap_set_value - set value within a memory region > * @map: address to the bitmap memory region > - * @value: value of nbits > - * @start: bit offset of the n-bit value > - * @nbits: size of value in bits (must be between 1 and BITS_PER_LONG inclusive). > + * @nbits: size of map in bits > + * @value: value of clump > + * @value_width: size of value in bits (must be between 1 and BITS_PER_LONG inclusive) > + * @start: bit offset of the value > */ > -static inline void bitmap_set_value(unsigned long *map, > - unsigned long value, > - unsigned long start, unsigned long nbits) > +static inline void bitmap_set_value(unsigned long *map, unsigned long nbits, > + unsigned long value, unsigned long value_width, > + unsigned long start) > { > - const size_t index = BIT_WORD(start); > + const unsigned long index = BIT_WORD(start); > + const unsigned long length = BIT_WORD(nbits); > const unsigned long offset = start % BITS_PER_LONG; > const unsigned long ceiling = round_up(start + 1, BITS_PER_LONG); > const unsigned long space = ceiling - start; > > - value &= GENMASK(nbits - 1, 0); > + value &= GENMASK(value_width - 1, 0); > > - if (space >= nbits) { > - map[index] &= ~(GENMASK(nbits - 1, 0) << offset); > + if (space >= value_width) { > + map[index] &= ~(GENMASK(value_width - 1, 0) << offset); > map[index] |= value << offset; > } else { > map[index + 0] &= ~BITMAP_FIRST_WORD_MASK(start); > map[index + 0] |= value << offset; > - map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits); > + > + if (index + 1 >= length) > + __builtin_unreachable(); > + > + map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + value_width); > map[index + 1] |= value >> space; > } > } > -- > 2.29.0 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length 2020-11-20 17:59 ` William Breathitt Gray @ 2020-11-20 18:02 ` Syed Nayyar Waris 0 siblings, 0 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 18:02 UTC (permalink / raw) To: William Breathitt Gray Cc: Andrew Morton, Andy Shevchenko, Arnd Bergmann, Linux-Arch, Linux Kernel Mailing List On Fri, Nov 20, 2020 at 11:29 PM William Breathitt Gray <vilhelm.gray@gmail.com> wrote: > > On Fri, Nov 20, 2020 at 11:14:16PM +0530, Syed Nayyar Waris wrote: > > Add explicit check to see if the value being written into the bitmap > > does not fall outside the bitmap. > > The situation that it is falling outside would never be possible in the > > code because the boundaries are required to be correct before the function > > is called. The responsibility is on the caller for ensuring the boundaries > > are correct. > > This is just to suppress the GCC -Wtype-limits warnings. > > Hi Syed, > > This commit message sounds a bit strange without the context of our > earlier discussion thread. Would you be able to reword the commit > message to explain the motivation for using __builtin_unreachable()? > > Thanks, > > William Breathitt Gray Hi William, Actually I explained the motivation for using __builtin_unreachable() in the cover letter. So, left it here in this patch. I am sending this patch again updating the commit message. Regards Syed Nayyar Waris > > > > > Cc: Arnd Bergmann <arnd@arndb.de> > > Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> > > Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> > > --- > > include/linux/bitmap.h | 35 +++++++++++++++++++++-------------- > > 1 file changed, 21 insertions(+), 14 deletions(-) > > > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > > index 386d08777342..efb6199ea1e7 100644 > > --- a/include/linux/bitmap.h > > +++ b/include/linux/bitmap.h > > @@ -78,8 +78,9 @@ > > * bitmap_get_value(map, start, nbits) Get bit value of size > > * 'nbits' from map at start > > * bitmap_set_value8(map, value, start) Set 8bit value to map at start > > - * bitmap_set_value(map, value, start, nbits) Set bit value of size 'nbits' > > - * of map at start > > + * bitmap_set_value(map, nbits, value, value_width, start) > > + * Set bit value of size value_width > > + * to map at start > > * > > * Note, bitmap_zero() and bitmap_fill() operate over the region of > > * unsigned longs, that is, bits behind bitmap till the unsigned long > > @@ -610,30 +611,36 @@ static inline void bitmap_set_value8(unsigned long *map, unsigned long value, > > } > > > > /** > > - * bitmap_set_value - set n-bit value within a memory region > > + * bitmap_set_value - set value within a memory region > > * @map: address to the bitmap memory region > > - * @value: value of nbits > > - * @start: bit offset of the n-bit value > > - * @nbits: size of value in bits (must be between 1 and BITS_PER_LONG inclusive). > > + * @nbits: size of map in bits > > + * @value: value of clump > > + * @value_width: size of value in bits (must be between 1 and BITS_PER_LONG inclusive) > > + * @start: bit offset of the value > > */ > > -static inline void bitmap_set_value(unsigned long *map, > > - unsigned long value, > > - unsigned long start, unsigned long nbits) > > +static inline void bitmap_set_value(unsigned long *map, unsigned long nbits, > > + unsigned long value, unsigned long value_width, > > + unsigned long start) > > { > > - const size_t index = BIT_WORD(start); > > + const unsigned long index = BIT_WORD(start); > > + const unsigned long length = BIT_WORD(nbits); > > const unsigned long offset = start % BITS_PER_LONG; > > const unsigned long ceiling = round_up(start + 1, BITS_PER_LONG); > > const unsigned long space = ceiling - start; > > > > - value &= GENMASK(nbits - 1, 0); > > + value &= GENMASK(value_width - 1, 0); > > > > - if (space >= nbits) { > > - map[index] &= ~(GENMASK(nbits - 1, 0) << offset); > > + if (space >= value_width) { > > + map[index] &= ~(GENMASK(value_width - 1, 0) << offset); > > map[index] |= value << offset; > > } else { > > map[index + 0] &= ~BITMAP_FIRST_WORD_MASK(start); > > map[index + 0] |= value << offset; > > - map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits); > > + > > + if (index + 1 >= length) > > + __builtin_unreachable(); > > + > > + map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + value_width); > > map[index + 1] |= value >> space; > > } > > } > > -- > > 2.29.0 > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* [RESEND PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length 2020-11-20 17:44 ` [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length Syed Nayyar Waris 2020-11-20 17:59 ` William Breathitt Gray @ 2020-11-20 18:43 ` Syed Nayyar Waris 1 sibling, 0 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 18:43 UTC (permalink / raw) To: akpm Cc: andriy.shevchenko, vilhelm.gray, michal.simek, arnd, rrichter, linus.walleij, bgolaszewski, yamada.masahiro, rui.zhang, daniel.lezcano, amit.kucheria, linux-arch, linux-gpio, linux-kernel, linux-arm-kernel, linux-pm Add explicit check to see if the value being written into the bitmap does not fall outside the bitmap. The situation that it is falling outside would never be possible in the code because the boundaries are required to be correct before the function is called. The responsibility is on the caller for ensuring the boundaries are correct. The code change is simply to silence the GCC warning messages because GCC is not aware that the boundaries have already been checked. As such, we're better off using __builtin_unreachable() here because we can avoid the latency of the conditional check entirely. Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> --- include/linux/bitmap.h | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 386d08777342..efb6199ea1e7 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -78,8 +78,9 @@ * bitmap_get_value(map, start, nbits) Get bit value of size * 'nbits' from map at start * bitmap_set_value8(map, value, start) Set 8bit value to map at start - * bitmap_set_value(map, value, start, nbits) Set bit value of size 'nbits' - * of map at start + * bitmap_set_value(map, nbits, value, value_width, start) + * Set bit value of size value_width + * to map at start * * Note, bitmap_zero() and bitmap_fill() operate over the region of * unsigned longs, that is, bits behind bitmap till the unsigned long @@ -610,30 +611,36 @@ static inline void bitmap_set_value8(unsigned long *map, unsigned long value, } /** - * bitmap_set_value - set n-bit value within a memory region + * bitmap_set_value - set value within a memory region * @map: address to the bitmap memory region - * @value: value of nbits - * @start: bit offset of the n-bit value - * @nbits: size of value in bits (must be between 1 and BITS_PER_LONG inclusive). + * @nbits: size of map in bits + * @value: value of clump + * @value_width: size of value in bits (must be between 1 and BITS_PER_LONG inclusive) + * @start: bit offset of the value */ -static inline void bitmap_set_value(unsigned long *map, - unsigned long value, - unsigned long start, unsigned long nbits) +static inline void bitmap_set_value(unsigned long *map, unsigned long nbits, + unsigned long value, unsigned long value_width, + unsigned long start) { - const size_t index = BIT_WORD(start); + const unsigned long index = BIT_WORD(start); + const unsigned long length = BIT_WORD(nbits); const unsigned long offset = start % BITS_PER_LONG; const unsigned long ceiling = round_up(start + 1, BITS_PER_LONG); const unsigned long space = ceiling - start; - value &= GENMASK(nbits - 1, 0); + value &= GENMASK(value_width - 1, 0); - if (space >= nbits) { - map[index] &= ~(GENMASK(nbits - 1, 0) << offset); + if (space >= value_width) { + map[index] &= ~(GENMASK(value_width - 1, 0) << offset); map[index] |= value << offset; } else { map[index + 0] &= ~BITMAP_FIRST_WORD_MASK(start); map[index + 0] |= value << offset; - map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits); + + if (index + 1 >= length) + __builtin_unreachable(); + + map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + value_width); map[index + 1] |= value >> space; } } -- 2.29.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/4] lib/test_bitmap.c: Modify for_each_set_clump test 2020-11-20 17:42 [PATCH 0/4] Modify bitmap_set_value() to suppress compiler warning Syed Nayyar Waris 2020-11-20 17:44 ` [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length Syed Nayyar Waris @ 2020-11-20 17:45 ` Syed Nayyar Waris 2020-11-20 18:44 ` [RESEND PATCH " Syed Nayyar Waris 2020-11-20 17:46 ` [PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls Syed Nayyar Waris 2020-11-20 17:48 ` [PATCH 4/4] gpio: xilinx: Add extra check to see if sum of widths exceed 64 Syed Nayyar Waris 3 siblings, 1 reply; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 17:45 UTC (permalink / raw) To: akpm; +Cc: andriy.shevchenko, vilhelm.gray, linux-kernel Modify the test where bitmap_set_value() is called. bitmap_set_value() now takes an extra bitmap-width as second argument and the width of value is now present as the fourth argument. Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> --- lib/test_bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 1c5791ff02cb..7fafe6a0bc08 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -656,8 +656,8 @@ static void __init prepare_test_data(unsigned int index) unsigned long width = 0; for (i = 0; i < clump_test_data[index].count; i++) { - bitmap_set_value(clump_test_data[index].data, - clump_bitmap_data[(clump_test_data[index].offset)++], width, 32); + bitmap_set_value(clump_test_data[index].data, 256, + clump_bitmap_data[(clump_test_data[index].offset)++], 32, width); width += 32; } } -- 2.29.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RESEND PATCH 2/4] lib/test_bitmap.c: Modify for_each_set_clump test 2020-11-20 17:45 ` [PATCH 2/4] lib/test_bitmap.c: Modify for_each_set_clump test Syed Nayyar Waris @ 2020-11-20 18:44 ` Syed Nayyar Waris 0 siblings, 0 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 18:44 UTC (permalink / raw) To: akpm Cc: andriy.shevchenko, vilhelm.gray, michal.simek, arnd, rrichter, linus.walleij, bgolaszewski, yamada.masahiro, rui.zhang, daniel.lezcano, amit.kucheria, linux-arch, linux-gpio, linux-kernel, linux-arm-kernel, linux-pm Modify the test where bitmap_set_value() is called. bitmap_set_value() now takes an extra bitmap-width as second argument and the width of value is now present as the fourth argument. Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> --- lib/test_bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 1c5791ff02cb..7fafe6a0bc08 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -656,8 +656,8 @@ static void __init prepare_test_data(unsigned int index) unsigned long width = 0; for (i = 0; i < clump_test_data[index].count; i++) { - bitmap_set_value(clump_test_data[index].data, - clump_bitmap_data[(clump_test_data[index].offset)++], width, 32); + bitmap_set_value(clump_test_data[index].data, 256, + clump_bitmap_data[(clump_test_data[index].offset)++], 32, width); width += 32; } } -- 2.29.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls 2020-11-20 17:42 [PATCH 0/4] Modify bitmap_set_value() to suppress compiler warning Syed Nayyar Waris 2020-11-20 17:44 ` [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length Syed Nayyar Waris 2020-11-20 17:45 ` [PATCH 2/4] lib/test_bitmap.c: Modify for_each_set_clump test Syed Nayyar Waris @ 2020-11-20 17:46 ` Syed Nayyar Waris 2020-11-20 18:45 ` [RESEND PATCH " Syed Nayyar Waris 2020-12-01 15:33 ` Bartosz Golaszewski 2020-11-20 17:48 ` [PATCH 4/4] gpio: xilinx: Add extra check to see if sum of widths exceed 64 Syed Nayyar Waris 3 siblings, 2 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 17:46 UTC (permalink / raw) To: akpm Cc: andriy.shevchenko, vilhelm.gray, bgolaszewski, michal.simek, linux-gpio, linux-arm-kernel, linux-kernel Modify the bitmap_set_value() calls. bitmap_set_value() now takes an extra bitmap width as second argument and the width of value is now present as the fourth argument. Cc: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> --- drivers/gpio/gpio-xilinx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index ad4ee4145db4..05dae086c4d0 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -151,16 +151,16 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, spin_lock_irqsave(&chip->gpio_lock[0], flags); spin_lock(&chip->gpio_lock[1]); - bitmap_set_value(old, state[0], 0, width[0]); - bitmap_set_value(old, state[1], width[0], width[1]); + bitmap_set_value(old, 64, state[0], width[0], 0); + bitmap_set_value(old, 64, state[1], width[1], width[0]); bitmap_replace(new, old, bits, mask, gc->ngpio); - bitmap_set_value(old, state[0], 0, 32); - bitmap_set_value(old, state[1], 32, 32); + bitmap_set_value(old, 64, state[0], 32, 0); + bitmap_set_value(old, 64, state[1], 32, 32); state[0] = bitmap_get_value(new, 0, width[0]); state[1] = bitmap_get_value(new, width[0], width[1]); - bitmap_set_value(new, state[0], 0, 32); - bitmap_set_value(new, state[1], 32, 32); + bitmap_set_value(new, 64, state[0], 32, 0); + bitmap_set_value(new, 64, state[1], 32, 32); bitmap_xor(changed, old, new, 64); if (((u32 *)changed)[0]) -- 2.29.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RESEND PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls 2020-11-20 17:46 ` [PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls Syed Nayyar Waris @ 2020-11-20 18:45 ` Syed Nayyar Waris 2020-12-01 15:33 ` Bartosz Golaszewski 1 sibling, 0 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 18:45 UTC (permalink / raw) To: akpm Cc: andriy.shevchenko, vilhelm.gray, michal.simek, arnd, rrichter, linus.walleij, bgolaszewski, yamada.masahiro, rui.zhang, daniel.lezcano, amit.kucheria, linux-arch, linux-gpio, linux-kernel, linux-arm-kernel, linux-pm Modify the bitmap_set_value() calls. bitmap_set_value() now takes an extra bitmap width as second argument and the width of value is now present as the fourth argument. Cc: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> --- drivers/gpio/gpio-xilinx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index ad4ee4145db4..05dae086c4d0 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -151,16 +151,16 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, spin_lock_irqsave(&chip->gpio_lock[0], flags); spin_lock(&chip->gpio_lock[1]); - bitmap_set_value(old, state[0], 0, width[0]); - bitmap_set_value(old, state[1], width[0], width[1]); + bitmap_set_value(old, 64, state[0], width[0], 0); + bitmap_set_value(old, 64, state[1], width[1], width[0]); bitmap_replace(new, old, bits, mask, gc->ngpio); - bitmap_set_value(old, state[0], 0, 32); - bitmap_set_value(old, state[1], 32, 32); + bitmap_set_value(old, 64, state[0], 32, 0); + bitmap_set_value(old, 64, state[1], 32, 32); state[0] = bitmap_get_value(new, 0, width[0]); state[1] = bitmap_get_value(new, width[0], width[1]); - bitmap_set_value(new, state[0], 0, 32); - bitmap_set_value(new, state[1], 32, 32); + bitmap_set_value(new, 64, state[0], 32, 0); + bitmap_set_value(new, 64, state[1], 32, 32); bitmap_xor(changed, old, new, 64); if (((u32 *)changed)[0]) -- 2.29.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [RESEND PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls 2020-11-20 17:46 ` [PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls Syed Nayyar Waris 2020-11-20 18:45 ` [RESEND PATCH " Syed Nayyar Waris @ 2020-12-01 15:33 ` Bartosz Golaszewski 2020-12-12 9:39 ` Syed Nayyar Waris 1 sibling, 1 reply; 13+ messages in thread From: Bartosz Golaszewski @ 2020-12-01 15:33 UTC (permalink / raw) To: Syed Nayyar Waris Cc: Andrew Morton, Andy Shevchenko, William Breathitt Gray, Michal Simek, Arnd Bergmann, rrichter, Linus Walleij, Masahiro Yamada, Zhang Rui, Daniel Lezcano, Amit Kucheria, linux-arch, linux-gpio, LKML, arm-soc, linux-pm On Fri, Nov 20, 2020 at 7:46 PM Syed Nayyar Waris <syednwaris@gmail.com> wrote: > > Modify the bitmap_set_value() calls. bitmap_set_value() > now takes an extra bitmap width as second argument and the width of > value is now present as the fourth argument. > > Cc: Michal Simek <michal.simek@xilinx.com> > Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> > --- > drivers/gpio/gpio-xilinx.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c > index ad4ee4145db4..05dae086c4d0 100644 > --- a/drivers/gpio/gpio-xilinx.c > +++ b/drivers/gpio/gpio-xilinx.c > @@ -151,16 +151,16 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, > spin_lock_irqsave(&chip->gpio_lock[0], flags); > spin_lock(&chip->gpio_lock[1]); > > - bitmap_set_value(old, state[0], 0, width[0]); > - bitmap_set_value(old, state[1], width[0], width[1]); > + bitmap_set_value(old, 64, state[0], width[0], 0); > + bitmap_set_value(old, 64, state[1], width[1], width[0]); > bitmap_replace(new, old, bits, mask, gc->ngpio); > > - bitmap_set_value(old, state[0], 0, 32); > - bitmap_set_value(old, state[1], 32, 32); > + bitmap_set_value(old, 64, state[0], 32, 0); > + bitmap_set_value(old, 64, state[1], 32, 32); > state[0] = bitmap_get_value(new, 0, width[0]); > state[1] = bitmap_get_value(new, width[0], width[1]); > - bitmap_set_value(new, state[0], 0, 32); > - bitmap_set_value(new, state[1], 32, 32); > + bitmap_set_value(new, 64, state[0], 32, 0); > + bitmap_set_value(new, 64, state[1], 32, 32); > bitmap_xor(changed, old, new, 64); > > if (((u32 *)changed)[0]) > -- > 2.29.0 > This series is not bisectable because you modify the interface - breaking existing users - and you only fix them later. Please squash those changes into a single commit. Bartosz ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RESEND PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls 2020-12-01 15:33 ` Bartosz Golaszewski @ 2020-12-12 9:39 ` Syed Nayyar Waris 0 siblings, 0 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-12-12 9:39 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Andrew Morton, Andy Shevchenko, William Breathitt Gray, Michal Simek, Arnd Bergmann, Robert Richter, Linus Walleij, Masahiro Yamada, Zhang Rui, Daniel Lezcano, Amit Kucheria, Linux-Arch, linux-gpio, LKML, arm-soc, linux-pm On Tue, Dec 1, 2020 at 9:03 PM Bartosz Golaszewski <bgolaszewski@baylibre.com> wrote: > > On Fri, Nov 20, 2020 at 7:46 PM Syed Nayyar Waris <syednwaris@gmail.com> wrote: > > > > Modify the bitmap_set_value() calls. bitmap_set_value() > > now takes an extra bitmap width as second argument and the width of > > value is now present as the fourth argument. > > > > Cc: Michal Simek <michal.simek@xilinx.com> > > Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> > > --- > > drivers/gpio/gpio-xilinx.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c > > index ad4ee4145db4..05dae086c4d0 100644 > > --- a/drivers/gpio/gpio-xilinx.c > > +++ b/drivers/gpio/gpio-xilinx.c > > @@ -151,16 +151,16 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, > > spin_lock_irqsave(&chip->gpio_lock[0], flags); > > spin_lock(&chip->gpio_lock[1]); > > > > - bitmap_set_value(old, state[0], 0, width[0]); > > - bitmap_set_value(old, state[1], width[0], width[1]); > > + bitmap_set_value(old, 64, state[0], width[0], 0); > > + bitmap_set_value(old, 64, state[1], width[1], width[0]); > > bitmap_replace(new, old, bits, mask, gc->ngpio); > > > > - bitmap_set_value(old, state[0], 0, 32); > > - bitmap_set_value(old, state[1], 32, 32); > > + bitmap_set_value(old, 64, state[0], 32, 0); > > + bitmap_set_value(old, 64, state[1], 32, 32); > > state[0] = bitmap_get_value(new, 0, width[0]); > > state[1] = bitmap_get_value(new, width[0], width[1]); > > - bitmap_set_value(new, state[0], 0, 32); > > - bitmap_set_value(new, state[1], 32, 32); > > + bitmap_set_value(new, 64, state[0], 32, 0); > > + bitmap_set_value(new, 64, state[1], 32, 32); > > bitmap_xor(changed, old, new, 64); > > > > if (((u32 *)changed)[0]) > > -- > > 2.29.0 > > > > This series is not bisectable because you modify the interface - > breaking existing users - and you only fix them later. Please squash > those changes into a single commit. > > Bartosz Hi Bartosz, I have squashed the changes and have sent a new patchset v2. Regards Syed Nayyar Waris ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/4] gpio: xilinx: Add extra check to see if sum of widths exceed 64 2020-11-20 17:42 [PATCH 0/4] Modify bitmap_set_value() to suppress compiler warning Syed Nayyar Waris ` (2 preceding siblings ...) 2020-11-20 17:46 ` [PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls Syed Nayyar Waris @ 2020-11-20 17:48 ` Syed Nayyar Waris 2020-11-20 18:46 ` [RESEND PATCH 4/4] gpio: xilinx: Add extra check " Syed Nayyar Waris 3 siblings, 1 reply; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 17:48 UTC (permalink / raw) To: akpm Cc: andriy.shevchenko, vilhelm.gray, bgolaszewski, michal.simek, linux-gpio, linux-arm-kernel, linux-kernel Add extra check to see if sum of widths does not exceed 64. If it exceeds then return -EINVAL alongwith appropriate error message. Cc: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> --- drivers/gpio/gpio-xilinx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 05dae086c4d0..a2e92a1cf50b 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -340,6 +340,12 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.base = -1; chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; + + if (chip->gc.ngpio > 64) { + dev_err(&pdev->dev, "invalid configuration: number of GPIO is greater than 64"); + return -EINVAL; + } + chip->gc.parent = &pdev->dev; chip->gc.direction_input = xgpio_dir_in; chip->gc.direction_output = xgpio_dir_out; -- 2.29.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RESEND PATCH 4/4] gpio: xilinx: Add extra check if sum of widths exceed 64 2020-11-20 17:48 ` [PATCH 4/4] gpio: xilinx: Add extra check to see if sum of widths exceed 64 Syed Nayyar Waris @ 2020-11-20 18:46 ` Syed Nayyar Waris 0 siblings, 0 replies; 13+ messages in thread From: Syed Nayyar Waris @ 2020-11-20 18:46 UTC (permalink / raw) To: akpm Cc: andriy.shevchenko, vilhelm.gray, michal.simek, arnd, rrichter, linus.walleij, bgolaszewski, yamada.masahiro, rui.zhang, daniel.lezcano, amit.kucheria, linux-arch, linux-gpio, linux-kernel, linux-arm-kernel, linux-pm Add extra check to see if sum of widths does not exceed 64. If it exceeds then return -EINVAL alongwith appropriate error message. Cc: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com> --- drivers/gpio/gpio-xilinx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 05dae086c4d0..a2e92a1cf50b 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -340,6 +340,12 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.base = -1; chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; + + if (chip->gc.ngpio > 64) { + dev_err(&pdev->dev, "invalid configuration: number of GPIO is greater than 64"); + return -EINVAL; + } + chip->gc.parent = &pdev->dev; chip->gc.direction_input = xgpio_dir_in; chip->gc.direction_output = xgpio_dir_out; -- 2.29.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-12-12 10:12 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-11-20 17:42 [PATCH 0/4] Modify bitmap_set_value() to suppress compiler warning Syed Nayyar Waris 2020-11-20 17:44 ` [PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length Syed Nayyar Waris 2020-11-20 17:59 ` William Breathitt Gray 2020-11-20 18:02 ` Syed Nayyar Waris 2020-11-20 18:43 ` [RESEND PATCH " Syed Nayyar Waris 2020-11-20 17:45 ` [PATCH 2/4] lib/test_bitmap.c: Modify for_each_set_clump test Syed Nayyar Waris 2020-11-20 18:44 ` [RESEND PATCH " Syed Nayyar Waris 2020-11-20 17:46 ` [PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls Syed Nayyar Waris 2020-11-20 18:45 ` [RESEND PATCH " Syed Nayyar Waris 2020-12-01 15:33 ` Bartosz Golaszewski 2020-12-12 9:39 ` Syed Nayyar Waris 2020-11-20 17:48 ` [PATCH 4/4] gpio: xilinx: Add extra check to see if sum of widths exceed 64 Syed Nayyar Waris 2020-11-20 18:46 ` [RESEND PATCH 4/4] gpio: xilinx: Add extra check " Syed Nayyar Waris
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).