From: "Marek Behún" <kabel@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Marek Behún" <kabel@kernel.org>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Arnd Bergmann" <arnd@arndb.de>,
soc@kernel.org, arm@kernel.org,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH v8 3/9] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs
Date: Sun, 5 May 2024 10:12:46 +0200 [thread overview]
Message-ID: <20240505081217.kkzcf2lzp63u76kd@kandell> (raw)
In-Reply-To: <ZjUf5TDbgRxbkYSv@smile.fi.intel.com>
On Fri, May 03, 2024 at 08:33:25PM +0300, Andy Shevchenko wrote:
> On Fri, May 03, 2024 at 10:43:06AM +0200, Marek Behún wrote:
> > On Fri, May 03, 2024 at 07:05:34AM +0300, Andy Shevchenko wrote:
>
> ...
>
> > > > + err = omnia_cmd_read(client, cmd, &reply, (__fls(bits) >> 3) + 1);
> > >
> > > Perhaps a helper for this (__fls(x) >> 3 + (y)) ? It seems it's used
> > > in a few places.
> >
> > It is used 3 times:
> > rlen = ((__fls(rising) >> 3) << 1) + 1;
> > flen = ((__fls(falling) >> 3) << 1) + 2;
> > err = omnia_cmd_read(client, cmd, &reply, (__fls(bits) >> 3) + 1);
> >
> > The last one is not compatible with the first two (because of the "<< 1").
> >
> > The first two instances are contained within a function that is dedicated
> > to "computing needed reply length".
> >
> > I could probably do something like
> >
> > static inline unsigned int
> > omnia_compute_reply_len(uin32_t mask, bool interleaved, unsigned int offset)
> > {
> > return ((__fls(mask) >> 3) << interleaved) + 1 + offset;
> > }
> >
> > Then the 3 instances would become
> >
> > rlen = omnia_compute_reply_len(rising, true, 0);
> > flen = omnia_compute_reply_len(falling, true, 1);
> > err = omnia_cmd_read(client, cmd, &reply,
> > omnia_compute_reply_len(bits, false, 0));
> >
> > What do you think?
>
> Fine, but think about these bit operations, I believe it can be optimised.
I will try something, altough I fear it might need 64-bit operations,
which may be even more suboptimal since the driver is supposed to run on
armv7.
Also, isn't this premature optimization? Since the computed length is then
passed as a parameter to I2C reading, and the I2C bus is orders of
magnitudes slower and the handling of I2C requests in Marvell I2C driver
will kill any optimization I do here...
prev parent reply other threads:[~2024-05-05 8:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 11:51 [PATCH v8 0/9] Turris Omnia MCU driver Marek Behún
2024-04-30 11:51 ` [PATCH v8 2/9] platform: cznic: Add preliminary support for Turris Omnia MCU Marek Behún
2024-04-30 12:53 ` Andy Shevchenko
2024-04-30 14:05 ` Marek Behún
2024-04-30 15:10 ` Dan Carpenter
2024-04-30 15:17 ` Andy Shevchenko
2024-05-02 18:40 ` Marek Behún
2024-05-02 18:47 ` Andy Shevchenko
2024-05-02 19:17 ` Marek Behún
2024-05-03 3:59 ` Andy Shevchenko
2024-05-03 6:51 ` Marek Behún
2024-04-30 15:31 ` Ilpo Järvinen
2024-05-02 19:19 ` Marek Behún
2024-04-30 11:51 ` [PATCH v8 3/9] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs Marek Behún
2024-05-03 4:05 ` Andy Shevchenko
2024-05-03 8:28 ` Marek Behún
2024-05-03 18:51 ` Andy Shevchenko
2024-05-05 8:18 ` Marek Behún
2024-05-05 13:34 ` Andy Shevchenko
2024-05-07 17:44 ` Marek Behún
2024-05-03 8:43 ` Marek Behún
2024-05-03 17:33 ` Andy Shevchenko
2024-05-05 8:12 ` Marek Behún [this message]
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=20240505081217.kkzcf2lzp63u76kd@kandell \
--to=kabel@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=arm@kernel.org \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=gregory.clement@bootlin.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=soc@kernel.org \
/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).