All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Shreeya Patel <shreeya.patel@collabora.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh+dt@kernel.org>,
	Zhigang.Shi@liteon.com, krisman@collabora.com,
	linux-iio <linux-iio@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Collabora Kernel ML <kernel@collabora.com>,
	alvaro.soliverez@collabora.com
Subject: Re: [PATCH v7 2/2] iio: light: Add support for ltrf216a sensor
Date: Mon, 11 Jul 2022 16:22:37 +0200	[thread overview]
Message-ID: <CAHp75VcMsa+s9Lrp6fF_nzJ9RgsVnbCCDjvLW=-hdFpAs69pgA@mail.gmail.com> (raw)
In-Reply-To: <68de450f-da22-02e3-e863-7e17582ee03f@collabora.com>

On Mon, Jul 11, 2022 at 4:04 PM Dmitry Osipenko
<dmitry.osipenko@collabora.com> wrote:
> On 7/11/22 16:41, Andy Shevchenko wrote:
> > On Mon, Jul 11, 2022 at 3:39 PM Shreeya Patel
> > <shreeya.patel@collabora.com> wrote:
> >> On 11/07/22 18:36, Andy Shevchenko wrote:
> >>> On Mon, Jul 11, 2022 at 1:30 PM Shreeya Patel

...

> >>>> +static const struct regmap_config ltrf216a_regmap_config = {
> >>>> +       .name = LTRF216A_DRV_NAME,
> >>>> +       .reg_bits = 8,
> >>>> +       .val_bits = 8,
> >>>> +       .max_register = LTRF216A_MAX_REG,
> >>> Why do you use regmap locking? What for?
> >>
> >> Why do we want to skip the internal locking if it doesn't bring any
> >> benefits?
> >
> > Can you elaborate on the "no benefits" part, please?
>
> Since the regmap's lock will never be contended, thus it's free to keep

I'm skeptical about "free" here. My concerns are:
1) grosser code base;
2) slower code flow (even nop takes time to process).

> using it. If later on we will need to change the driver's code such that
> the lock will become needed, then we won't need to bother with
> re-enabling it. The comment to the driver's mutex states clearly that
> it's intended to protect the cached value.
>
> Hence what is point in disabling the regmap's lock? There are very few
> drivers that disable the regmap's lock and most of them do that for the
> good reason.

Most of the drivers that have its own lock _and_ regmap lock took the
locking scheme wrong. It is 101 when writing a driver to have a clear
picture of what lock protects what data (or I/O).

Even if lock is _almost_ free, it's still required to provide
understanding of how each of the locks is being used in the code.

That said, the main point of my review comment is to make the author
think about it, or just elaborate if it has been thought through
already.

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2022-07-11 14:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11 11:28 [PATCH v7 0/2] Add LTRF216A Driver Shreeya Patel
2022-07-11 11:28 ` [PATCH v7 1/2] dt-bindings: Document ltrf216a light sensor bindings Shreeya Patel
2022-07-11 11:29 ` [PATCH v7 2/2] iio: light: Add support for ltrf216a sensor Shreeya Patel
2022-07-11 13:06   ` Andy Shevchenko
2022-07-11 13:39     ` Shreeya Patel
2022-07-11 13:41       ` Andy Shevchenko
2022-07-11 14:04         ` Dmitry Osipenko
2022-07-11 14:22           ` Andy Shevchenko [this message]
2022-07-11 14:50             ` Dmitry Osipenko

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='CAHp75VcMsa+s9Lrp6fF_nzJ9RgsVnbCCDjvLW=-hdFpAs69pgA@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=Zhigang.Shi@liteon.com \
    --cc=alvaro.soliverez@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=jic23@kernel.org \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=shreeya.patel@collabora.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.