All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Geis <pgwipeout@gmail.com>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Heiko Stuebner <heiko@sntech.de>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	Nicolas Frattaroli <frattaroli.nicolas@gmail.com>,
	Frank Wunderlich <frank-w@public-files.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] mfd: rk808: add reboot support to rk808.c
Date: Fri, 17 Dec 2021 13:16:05 -0500	[thread overview]
Message-ID: <CAMdYzYq=2G1bvu9M_DR0vdQDtcvVBhQFRPTNKo1ySFrMZOk=jg@mail.gmail.com> (raw)
In-Reply-To: <2bebe0ae-27df-f75d-97d6-2e4d2dd032b0@gmail.com>

On Fri, Dec 17, 2021 at 10:29 AM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> 17.12.2021 17:55, Peter Geis пишет:
> > This adds reboot support to the rk808o pmic driver and enables it for
> > the rk809 and rk817 devices.
> > This only enables if the rockchip,system-power-controller flag is set.
> >
> > Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> > Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
> > ---
> > This patch was created to address issues with psci-reset on rk356x
> > chips. Until the rk356x series ATF open source code is released so we
> > can fix the issue at the source, this is the only way to ensure reliable
> > resetting on devices using these chips.
> >
> > After testing the rk808 (thanks Robin!), it was found DEV_OFF_RST does
> > not reset the PMIC to a power on state. Since the rk805 and rk818 match
> > this register layout, I'm removing support for all three in the v2.
> > It may be possible to add support to them using an RTC wakeup, but that
> > has not been explored and is outside the scope of this patch.
> >
> > Changelog:
> > V2:
> > - Squash the patch from Frank Wunderlich for rk809 support.
> > - Remove support for the rk805, rk808, and rk818 devices.
> > - Only register the reset handler for supported devices.
> > - Remove unnecessary dev_err and dev_warn statements.
> > - Register the reset handler directly
> >
> >  drivers/mfd/rk808.c       | 43 +++++++++++++++++++++++++++++++++++++++
> >  include/linux/mfd/rk808.h |  1 +
> >  2 files changed, 44 insertions(+)
> ...
> > +static struct notifier_block rk808_restart_handler = {
> > +     .notifier_call = rk808_restart_notify,
> > +     .priority = 255,
> > +};
>
> Hello!
>
> Please use the default 128 priority if there are no other conflicting
> handlers on this RK.

Unfortunately the psci-reboot handler is set to 129, I'll adjust this
to 192 which is in line with other PMIC reboot drivers.

>
> >  static void rk8xx_shutdown(struct i2c_client *client)
> >  {
> >       struct rk808 *rk808 = i2c_get_clientdata(client);
> > @@ -727,6 +757,19 @@ static int rk808_probe(struct i2c_client *client,
> >       if (of_property_read_bool(np, "rockchip,system-power-controller")) {
> >               rk808_i2c_client = client;
> >               pm_power_off = rk808_pm_power_off;
> > +
> > +             switch (rk808->variant) {
> > +             case RK809_ID:
> > +             case RK817_ID:
> > +                     ret = register_restart_handler(&rk808_restart_handler);
>
> There is no corresponding unregister_restart_handler(), which you should
> add to rk808_remove(). Otherwise kernel will crash on reboot if you'll
> unload this driver module.

Thanks, added!

>
> > +                     break;
> > +             default:
> > +                     dev_info(&client->dev, "pmic controlled board reset not supported\n");
>
> I'd set ret=0 explicitly here. Later on somebody may change the code and
> ret won't be zero anymore, this is not an uncommon trouble in kernel.

It took me a moment to see the logic here, but I understand it now.

>
> > +                     break;
> > +             }
> > +
> > +             if (ret)
> > +                     dev_err(&client->dev, "failed to register restart handler, %d\n", ret);
>
>
>

Thank you for the review.

WARNING: multiple messages have this Message-ID (diff)
From: Peter Geis <pgwipeout@gmail.com>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>,
	Robin Murphy <robin.murphy@arm.com>,
	 Heiko Stuebner <heiko@sntech.de>,
	 "open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	 Nicolas Frattaroli <frattaroli.nicolas@gmail.com>,
	Frank Wunderlich <frank-w@public-files.de>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] mfd: rk808: add reboot support to rk808.c
Date: Fri, 17 Dec 2021 13:16:05 -0500	[thread overview]
Message-ID: <CAMdYzYq=2G1bvu9M_DR0vdQDtcvVBhQFRPTNKo1ySFrMZOk=jg@mail.gmail.com> (raw)
In-Reply-To: <2bebe0ae-27df-f75d-97d6-2e4d2dd032b0@gmail.com>

On Fri, Dec 17, 2021 at 10:29 AM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> 17.12.2021 17:55, Peter Geis пишет:
> > This adds reboot support to the rk808o pmic driver and enables it for
> > the rk809 and rk817 devices.
> > This only enables if the rockchip,system-power-controller flag is set.
> >
> > Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> > Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
> > ---
> > This patch was created to address issues with psci-reset on rk356x
> > chips. Until the rk356x series ATF open source code is released so we
> > can fix the issue at the source, this is the only way to ensure reliable
> > resetting on devices using these chips.
> >
> > After testing the rk808 (thanks Robin!), it was found DEV_OFF_RST does
> > not reset the PMIC to a power on state. Since the rk805 and rk818 match
> > this register layout, I'm removing support for all three in the v2.
> > It may be possible to add support to them using an RTC wakeup, but that
> > has not been explored and is outside the scope of this patch.
> >
> > Changelog:
> > V2:
> > - Squash the patch from Frank Wunderlich for rk809 support.
> > - Remove support for the rk805, rk808, and rk818 devices.
> > - Only register the reset handler for supported devices.
> > - Remove unnecessary dev_err and dev_warn statements.
> > - Register the reset handler directly
> >
> >  drivers/mfd/rk808.c       | 43 +++++++++++++++++++++++++++++++++++++++
> >  include/linux/mfd/rk808.h |  1 +
> >  2 files changed, 44 insertions(+)
> ...
> > +static struct notifier_block rk808_restart_handler = {
> > +     .notifier_call = rk808_restart_notify,
> > +     .priority = 255,
> > +};
>
> Hello!
>
> Please use the default 128 priority if there are no other conflicting
> handlers on this RK.

Unfortunately the psci-reboot handler is set to 129, I'll adjust this
to 192 which is in line with other PMIC reboot drivers.

>
> >  static void rk8xx_shutdown(struct i2c_client *client)
> >  {
> >       struct rk808 *rk808 = i2c_get_clientdata(client);
> > @@ -727,6 +757,19 @@ static int rk808_probe(struct i2c_client *client,
> >       if (of_property_read_bool(np, "rockchip,system-power-controller")) {
> >               rk808_i2c_client = client;
> >               pm_power_off = rk808_pm_power_off;
> > +
> > +             switch (rk808->variant) {
> > +             case RK809_ID:
> > +             case RK817_ID:
> > +                     ret = register_restart_handler(&rk808_restart_handler);
>
> There is no corresponding unregister_restart_handler(), which you should
> add to rk808_remove(). Otherwise kernel will crash on reboot if you'll
> unload this driver module.

Thanks, added!

>
> > +                     break;
> > +             default:
> > +                     dev_info(&client->dev, "pmic controlled board reset not supported\n");
>
> I'd set ret=0 explicitly here. Later on somebody may change the code and
> ret won't be zero anymore, this is not an uncommon trouble in kernel.

It took me a moment to see the logic here, but I understand it now.

>
> > +                     break;
> > +             }
> > +
> > +             if (ret)
> > +                     dev_err(&client->dev, "failed to register restart handler, %d\n", ret);
>
>
>

Thank you for the review.

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  reply	other threads:[~2021-12-17 18:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 14:55 [PATCH v2] mfd: rk808: add reboot support to rk808.c Peter Geis
2021-12-17 14:55 ` Peter Geis
2021-12-17 15:29 ` Dmitry Osipenko
2021-12-17 15:29   ` Dmitry Osipenko
2021-12-17 18:16   ` Peter Geis [this message]
2021-12-17 18:16     ` Peter Geis
2021-12-17 18:30     ` Dmitry Osipenko
2021-12-17 18:30       ` Dmitry Osipenko
2021-12-17 18:42       ` Peter Geis
2021-12-17 18:42         ` Peter Geis
2021-12-20 11:54         ` Robin Murphy
2021-12-20 11:54           ` Robin Murphy

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='CAMdYzYq=2G1bvu9M_DR0vdQDtcvVBhQFRPTNKo1ySFrMZOk=jg@mail.gmail.com' \
    --to=pgwipeout@gmail.com \
    --cc=digetx@gmail.com \
    --cc=frank-w@public-files.de \
    --cc=frattaroli.nicolas@gmail.com \
    --cc=heiko@sntech.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=robin.murphy@arm.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.