From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Yury Norov <yury.norov@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
linux-sh@vger.kernel.org, Jan Kara <jack@suse.cz>,
Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>,
Matthew Wilcox <willy@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>,
Alexey Klimov <klimov.linux@gmail.com>,
Bart Van Assche <bvanassche@acm.org>,
Sergey Shtylyov <s.shtylyov@omp.ru>
Subject: Re: [PATCH v2 35/35] sh: mach-x3proto: rework ilsel_enable()
Date: Fri, 19 Jan 2024 09:48:47 +0100 [thread overview]
Message-ID: <CAMuHMdWHxesM-EOOMtrrw3Caz+5Wux35QiKOjvwA=vwQpRe26Q@mail.gmail.com> (raw)
In-Reply-To: <20231203193307.542794-34-yury.norov@gmail.com>
On Sun, Dec 3, 2023 at 8:34 PM Yury Norov <yury.norov@gmail.com> wrote:
> Fix opencoded find_and_set_bit(), which also suppresses potential
> KCSAN warning.
>
> CC: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> --- a/arch/sh/boards/mach-x3proto/ilsel.c
> +++ b/arch/sh/boards/mach-x3proto/ilsel.c
> @@ -99,8 +99,8 @@ int ilsel_enable(ilsel_source_t set)
> }
>
> do {
> - bit = find_first_zero_bit(&ilsel_level_map, ILSEL_LEVELS);
> - } while (test_and_set_bit(bit, &ilsel_level_map));
> + bit = find_and_set_bit(&ilsel_level_map, ILSEL_LEVELS);
> + } while (bit >= ILSEL_LEVELS);
>
> __ilsel_enable(set, bit);
BTW, I don't think the old code worked as intended: the first time no
free bit is found, bit would have been ILSEL_LEVELS, and
test_and_set_bit() would have returned false, thus terminating the loop,
and continuing with an out-of-range bit value? Hence to work correctly,
bit ILSEL_LEVELS of ilsel_level_map should have been initialized to one?
Or am I missing something?
The new code does not have that issue.
Anyway, this should probably never happen in real life.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2024-01-19 8:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-03 19:23 [PATCH v2 00/35] bitops: add atomic find_bit() operations Yury Norov
2023-12-03 19:23 ` [PATCH v2 01/35] lib/find: add atomic find_bit() primitives Yury Norov
2023-12-03 19:32 ` [PATCH v2 02/35] lib/find: add test for atomic find_bit() ops Yury Norov
2023-12-03 19:33 ` [PATCH v2 35/35] sh: mach-x3proto: rework ilsel_enable() Yury Norov
2024-01-19 8:48 ` Geert Uytterhoeven [this message]
2023-12-04 13:07 ` [PATCH v2 00/35] bitops: add atomic find_bit() operations Andy Shevchenko
2023-12-04 18:51 ` Jan Kara
2023-12-06 5:22 ` Yury Norov
2023-12-07 9:10 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMuHMdWHxesM-EOOMtrrw3Caz+5Wux35QiKOjvwA=vwQpRe26Q@mail.gmail.com' \
--to=geert@linux-m68k.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bvanassche@acm.org \
--cc=dalias@libc.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=jack@suse.cz \
--cc=klimov.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=maxim.kuvyrkov@linaro.org \
--cc=mirsad.todorovac@alu.unizg.hr \
--cc=s.shtylyov@omp.ru \
--cc=willy@infradead.org \
--cc=ysato@users.sourceforge.jp \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).