From: Kent Gibson <warthog618@gmail.com>
To: Yury Norov <yury.norov@gmail.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>,
"Srinivas Neeli" <srinivas.neeli@amd.com>,
"Michal Simek" <michal.simek@amd.com>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Andy Shevchenko" <andy@kernel.org>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Marek Behún" <kabel@kernel.org>
Subject: Re: [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs
Date: Wed, 27 Sep 2023 14:48:28 +0800 [thread overview]
Message-ID: <ZRPQPL97T2DXbAHv@sol> (raw)
In-Reply-To: <ZRN7FRWvZnmpDD/v@yury-ThinkPad>
On Tue, Sep 26, 2023 at 05:46:07PM -0700, Yury Norov wrote:
> On Tue, Sep 26, 2023 at 08:20:07AM +0300, Andy Shevchenko wrote:
> > Currently we have a few bitmap calls that are open coded in the library
> > module. Let's convert them to use generic bitmap APIs instead.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > + bitmap_from_arr64(mask, &lv->mask, GPIO_V2_LINES_MAX);
> > + bitmap_from_arr64(bits, &lv->bits, GPIO_V2_LINES_MAX);
> > +
> > + num_set = bitmap_gather(vals, bits, mask, lr->num_lines);
>
> It looks like GPIO_V2_LINES_MAX is always 64, and so I wonder: is
> my understanding correct that all bits in ->mask and ->bits beyond
> lr->num_lines are clear?
>
The lv fields come from userspace and so cannot be guaranteed to be
zeroed beyond lr->num_lines. Any set bits beyond that must be ignored,
one way or another.
> If so, you can seemingly pass the GPIO_V2_LINES_MAX instead of
> lr->num_lines, and that way it will be small_cons_nbits()-optimized.
>
But that would be decidedly non-optimal for the most common case where
lr->num_lines == 1.
Cheers,
Kent.
WARNING: multiple messages have this Message-ID (diff)
From: Kent Gibson <warthog618@gmail.com>
To: Yury Norov <yury.norov@gmail.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>,
"Srinivas Neeli" <srinivas.neeli@amd.com>,
"Michal Simek" <michal.simek@amd.com>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
"Andy Shevchenko" <andy@kernel.org>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Marek Behún" <kabel@kernel.org>
Subject: Re: [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs
Date: Wed, 27 Sep 2023 14:48:28 +0800 [thread overview]
Message-ID: <ZRPQPL97T2DXbAHv@sol> (raw)
In-Reply-To: <ZRN7FRWvZnmpDD/v@yury-ThinkPad>
On Tue, Sep 26, 2023 at 05:46:07PM -0700, Yury Norov wrote:
> On Tue, Sep 26, 2023 at 08:20:07AM +0300, Andy Shevchenko wrote:
> > Currently we have a few bitmap calls that are open coded in the library
> > module. Let's convert them to use generic bitmap APIs instead.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > + bitmap_from_arr64(mask, &lv->mask, GPIO_V2_LINES_MAX);
> > + bitmap_from_arr64(bits, &lv->bits, GPIO_V2_LINES_MAX);
> > +
> > + num_set = bitmap_gather(vals, bits, mask, lr->num_lines);
>
> It looks like GPIO_V2_LINES_MAX is always 64, and so I wonder: is
> my understanding correct that all bits in ->mask and ->bits beyond
> lr->num_lines are clear?
>
The lv fields come from userspace and so cannot be guaranteed to be
zeroed beyond lr->num_lines. Any set bits beyond that must be ignored,
one way or another.
> If so, you can seemingly pass the GPIO_V2_LINES_MAX instead of
> lr->num_lines, and that way it will be small_cons_nbits()-optimized.
>
But that would be decidedly non-optimal for the most common case where
lr->num_lines == 1.
Cheers,
Kent.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-09-27 6:48 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 5:20 [PATCH v1 0/5] bitmap: get rid of bitmap_remap() and bitmap_biremap() uses Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-26 5:20 ` [PATCH v1 1/5] lib/test_bitmap: Excape space symbols when printing input string Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-26 10:35 ` Kent Gibson
2023-09-26 10:35 ` Kent Gibson
2023-09-26 10:39 ` Kent Gibson
2023-09-26 10:39 ` Kent Gibson
2023-09-26 5:20 ` [PATCH v1 2/5] lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-27 0:25 ` Yury Norov
2023-09-27 0:25 ` Yury Norov
2023-09-27 2:10 ` Yury Norov
2023-09-27 2:10 ` Yury Norov
2023-09-27 12:10 ` Andy Shevchenko
2023-09-27 12:10 ` Andy Shevchenko
2023-09-27 12:02 ` Andy Shevchenko
2023-09-27 12:02 ` Andy Shevchenko
2023-10-02 4:06 ` Yury Norov
2023-10-02 4:06 ` Yury Norov
2023-10-02 8:23 ` Andy Shevchenko
2023-10-02 8:23 ` Andy Shevchenko
2023-09-26 5:20 ` [PATCH v1 3/5] gpio: xilinx: Switch to use new bitmap_scatter() helper Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-26 5:20 ` [PATCH v1 4/5] gpio: xilinx: Replace bitmap_bitremap() calls Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-26 10:41 ` Kent Gibson
2023-09-26 10:41 ` Kent Gibson
2023-09-26 11:11 ` Andy Shevchenko
2023-09-26 11:11 ` Andy Shevchenko
2023-09-26 11:17 ` Kent Gibson
2023-09-26 11:17 ` Kent Gibson
2023-09-26 5:20 ` [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs Andy Shevchenko
2023-09-26 5:20 ` Andy Shevchenko
2023-09-27 0:46 ` Yury Norov
2023-09-27 0:46 ` Yury Norov
2023-09-27 6:48 ` Kent Gibson [this message]
2023-09-27 6:48 ` Kent Gibson
2023-09-27 1:32 ` Kent Gibson
2023-09-27 1:32 ` Kent Gibson
2023-09-27 12:17 ` Andy Shevchenko
2023-09-27 12:17 ` Andy Shevchenko
2023-09-27 13:49 ` Kent Gibson
2023-09-27 13:49 ` Kent Gibson
2023-09-27 13:59 ` Andy Shevchenko
2023-09-27 13:59 ` Andy Shevchenko
2023-09-27 14:23 ` Kent Gibson
2023-09-27 14:23 ` Kent Gibson
2023-10-02 9:05 ` Andy Shevchenko
2023-10-02 9:05 ` Andy Shevchenko
2023-10-02 9:25 ` Kent Gibson
2023-10-02 9:25 ` Kent Gibson
2023-10-02 9:32 ` Andy Shevchenko
2023-10-02 9:32 ` Andy Shevchenko
2023-10-02 9:42 ` Kent Gibson
2023-10-02 9:42 ` Kent Gibson
2023-09-26 8:52 ` [PATCH v1 0/5] bitmap: get rid of bitmap_remap() and bitmap_biremap() uses Linus Walleij
2023-09-26 8:52 ` Linus Walleij
2023-09-26 11:16 ` Andy Shevchenko
2023-09-26 11:16 ` Andy Shevchenko
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=ZRPQPL97T2DXbAHv@sol \
--to=warthog618@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=kabel@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=michal.simek@amd.com \
--cc=shubhrajyoti.datta@amd.com \
--cc=srinivas.neeli@amd.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.