From: Jonathan Cameron <jic23@kernel.org>
To: "Ondřej Jirman" <megi@xff.cz>
Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Aren Moynihan" <aren@peacevolution.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Chen-Yu Tsai" <wens@csie.org>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Samuel Holland" <samuel@sholland.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev,
"Willow Barraco" <contact@willowbarraco.fr>
Subject: Re: [PATCH v2 2/6] iio: light: stk3310: Implement vdd supply and power it off during suspend
Date: Sun, 28 Apr 2024 17:48:07 +0100 [thread overview]
Message-ID: <20240428174807.2051e3cd@jic23-huawei> (raw)
In-Reply-To: <yl4b23gclij2jqyxlqkmfmct4vlz6gotwfgbpkisgz2fuuh7uv@rbynxmitzjog>
On Wed, 24 Apr 2024 22:00:46 +0200
Ondřej Jirman <megi@xff.cz> wrote:
> On Wed, Apr 24, 2024 at 08:31:27PM GMT, Andy Shevchenko wrote:
> > On Wed, Apr 24, 2024 at 7:14 PM Ondřej Jirman <megi@xff.cz> wrote:
> > > On Wed, Apr 24, 2024 at 06:20:41PM GMT, Andy Shevchenko wrote:
> > > > On Wed, Apr 24, 2024 at 3:59 PM Ondřej Jirman <megi@xff.cz> wrote:
> > > > > On Wed, Apr 24, 2024 at 02:16:06AM GMT, Andy Shevchenko wrote:
> > > > > > On Wed, Apr 24, 2024 at 1:41 AM Aren Moynihan <aren@peacevolution.org> wrote:
> >
> > ...
> >
> > > > > > > ret = stk3310_init(indio_dev);
> > > > > > > if (ret < 0)
> > > > > > > - return ret;
> > > > > > > + goto err_vdd_disable;
> > > > > >
> > > > > > This is wrong. You will have the regulator being disabled _before_
> > > > > > IRQ. Note, that the original code likely has a bug which sets states
> > > > > > before disabling IRQ and removing a handler.
> > > > >
> > > > > How so? stk3310_init is called before enabling the interrupt.
> > > >
> > > > Exactly, IRQ is registered with devm and hence the error path and
> > > > remove stages will got it in a wrong order.
> > >
> > > Makes no sense.
> >
> > Huh?!
> >
> > > IRQ is not enabled here, yet. So in error path, the code will
> > > just disable the regulator and devm will unref it later on. IRQ doesn't enter
> > > the picture here at all in the error path.
> >
> > Error path _after_ IRQ handler has been _successfully_ installed.
> > And complete ->remove() stage.
>
> Allright. So fixing the other issue I mentioned will fix this one too, because
> there will be no error path after IRQ enable, then.
Don't do reorder stuff past iio_device_register.
It generates a bunch of it's own issues wrt to functionality.
The iio_device_register() call is the last one because the device must be in a
state to correctly deal with all userspace actions by the time they are made
available.
Harden the driver to not call IIO core functions for false events if that
is easy to do, but there shouldn't be an issue if you do (if there is we should
address that in the IIO core).
Jonathan
>
> kind regards,
> o.
>
> > > > > Original code has a bug that IRQ is enabled before registering the
> > > > > IIO device,
> > > >
> > > > Indeed, but this is another bug.
> > > >
> > > > > so if IRQ is triggered before registration, iio_push_event
> > > > > from IRQ handler may be called on a not yet registered IIO device.
> > > > >
> > > > > Never saw it happen, though. :)
> > > >
> > > > Because nobody cares enough to enable DEBUG_SHIRQ.
> > >
> > > Nice debug tool. I bet it makes quite a mess when enabled. :)
> >
> > FWIW, I have had it enabled for ages, but I have only a few devices,
> > so I fixed a few cases in the past WRT shared IRQ issues.
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
_______________________________________________
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:[~2024-04-28 16:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 22:33 [PATCH v2 0/6] iio: light: stk3310: support powering off during suspend Aren Moynihan
2024-04-23 22:33 ` [PATCH v2 1/6] dt-bindings: iio: light: stk33xx: add vdd and leda regulators Aren Moynihan
2024-04-24 4:28 ` Krzysztof Kozlowski
2024-04-23 22:33 ` [PATCH v2 2/6] iio: light: stk3310: Implement vdd supply and power it off during suspend Aren Moynihan
2024-04-23 23:16 ` Andy Shevchenko
2024-04-24 12:59 ` Ondřej Jirman
2024-04-24 15:20 ` Andy Shevchenko
2024-04-24 16:14 ` Ondřej Jirman
2024-04-24 17:31 ` Andy Shevchenko
2024-04-24 20:00 ` Ondřej Jirman
2024-04-28 16:48 ` Jonathan Cameron [this message]
2024-04-28 16:45 ` Jonathan Cameron
2024-04-25 0:00 ` Aren
2024-04-28 16:34 ` Jonathan Cameron
2024-04-24 12:34 ` kernel test robot
2024-04-25 5:31 ` Dan Carpenter
2024-04-28 16:53 ` Jonathan Cameron
2024-06-07 14:19 ` Aren
2024-04-23 22:33 ` [PATCH v2 3/6] iio: light: stk3310: Manage LED power supply Aren Moynihan
2024-04-23 23:08 ` Andy Shevchenko
2024-04-23 22:33 ` [PATCH v2 4/6] iio: light: stk3310: use dev_err_probe where possible Aren Moynihan
2024-04-23 22:33 ` [PATCH v2 5/6] iio: light: stk3310: log error if reading the chip id fails Aren Moynihan
2024-04-23 22:33 ` [PATCH v2 6/6] arm64: dts: allwinner: pinephone: Add power supplies to stk3311 Aren Moynihan
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=20240428174807.2051e3cd@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=aren@peacevolution.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=contact@willowbarraco.fr \
--cc=devicetree@vger.kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=megi@xff.cz \
--cc=robh@kernel.org \
--cc=samuel@sholland.org \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wens@csie.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