From: claudiu beznea <claudiu.beznea@tuxon.dev>
To: Guenter Roeck <linux@roeck-us.net>,
wim@linux-watchdog.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
geert+renesas@glider.be, magnus.damm@gmail.com,
mturquette@baylibre.com, sboyd@kernel.org,
p.zabel@pengutronix.de, biju.das.jz@bp.renesas.com
Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-clk@vger.kernel.org,
Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Subject: Re: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support
Date: Tue, 23 Jan 2024 09:13:30 +0200 [thread overview]
Message-ID: <2af40ace-2779-45a0-a244-e7e9e5cc510c@tuxon.dev> (raw)
In-Reply-To: <a5a807c1-76ef-4cf7-a2cf-bc432c420ded@roeck-us.net>
On 22.01.2024 19:39, Guenter Roeck wrote:
> On 1/22/24 03:11, Claudiu wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> The RZ/G3S supports deep sleep states where power to most of the IP blocks
>> is cut off. To ensure proper working of the watchdog when resuming from
>> such states, the suspend function is stopping the watchdog and the resume
>> function is starting it. There is no need to configure the watchdog
>> in case the watchdog was stopped prior to starting suspend.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>> ---
>> drivers/watchdog/rzg2l_wdt.c | 26 ++++++++++++++++++++++++++
>> 1 file changed, 26 insertions(+)
>>
>> diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
>> index 9333dc1a75ab..186796b739f7 100644
>> --- a/drivers/watchdog/rzg2l_wdt.c
>> +++ b/drivers/watchdog/rzg2l_wdt.c
>> @@ -279,6 +279,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
>> priv->wdev.timeout = WDT_DEFAULT_TIMEOUT;
>> watchdog_set_drvdata(&priv->wdev, priv);
>> + dev_set_drvdata(dev, priv);
>> ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable,
>> &priv->wdev);
>> if (ret)
>> return ret;
>> @@ -300,10 +301,35 @@ static const struct of_device_id rzg2l_wdt_ids[] = {
>> };
>> MODULE_DEVICE_TABLE(of, rzg2l_wdt_ids);
>> +static int rzg2l_wdt_suspend_late(struct device *dev)
>> +{
>> + struct rzg2l_wdt_priv *priv = dev_get_drvdata(dev);
>> +
>> + if (!watchdog_active(&priv->wdev))
>> + return 0;
>> +
>> + return rzg2l_wdt_stop(&priv->wdev);
>> +}
>> +
>> +static int rzg2l_wdt_resume_early(struct device *dev)
>> +{
>> + struct rzg2l_wdt_priv *priv = dev_get_drvdata(dev);
>> +
>> + if (!watchdog_active(&priv->wdev))
>> + return 0;
>> +
>> + return rzg2l_wdt_start(&priv->wdev);
>> +}
>> +
>> +static const struct dev_pm_ops rzg2l_wdt_pm_ops = {
>> + LATE_SYSTEM_SLEEP_PM_OPS(rzg2l_wdt_suspend_late,
>> rzg2l_wdt_resume_early)
>> +};
>> +
>> static struct platform_driver rzg2l_wdt_driver = {
>> .driver = {
>> .name = "rzg2l_wdt",
>> .of_match_table = rzg2l_wdt_ids,
>> + .pm = pm_ptr(&rzg2l_wdt_pm_ops),
>
> I think this will create a build error if CONFIG_PM=n because rzg2l_wdt_pm_ops
> will be unused but is not marked with __maybe_unused.
The necessity of __maybe_unused has been removed along with the
introduction of LATE_SYSTEM_SLEEP_PM_OPS() and friends (and
*SET_*LATE_SYSTEM_SLEEP_PM_OPS along with the other helpers were marked
deprecated for that) and we can use pm_ptr() along with
LATE_SYSTEM_SLEEP_PM_OPS() to avoid build errors you mentioned.
FYI, I just build the driver with CONFIG_PM=n and all good.
> But then the driver
> won't be
> operational with CONFIG_PM=n, so I really wonder if it makes sense to
> include any
> such conditional code instead of making the driver depend on CONFIG_PM.
That's true. The driver wouldn't work if the CONFIG_PM=n but then it
depends on COMPILE_TEST which is exactly for this (just to compile test it
for platforms that don't support it). I see many watchdog drivers depends
on COMPILE_TEST.
Give this, please let me know would you like me to proceed with it.
Thank you,
Claudiu Beznea
>
> I really don't think it is desirable to suggest that the driver would work
> with
> CONFIG_PM=n if that isn't really true.
>
> Guenter
>
>> },
>> .probe = rzg2l_wdt_probe,
>> };
>
next prev parent reply other threads:[~2024-01-23 7:13 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
2024-01-22 11:11 ` [PATCH 01/10] clk: renesas: r9a08g045: Add clock and reset support for watchdog Claudiu
2024-01-30 16:38 ` Geert Uytterhoeven
2024-01-22 11:11 ` [PATCH 02/10] watchdog: rzg2l_wdt: Use pm_runtime_resume_and_get() Claudiu
2024-01-30 16:43 ` Geert Uytterhoeven
2024-01-22 11:11 ` [PATCH 03/10] watchdog: rzg2l_wdt: Check return status of pm_runtime_put() Claudiu
2024-01-22 17:31 ` Guenter Roeck
2024-01-23 7:02 ` claudiu beznea
2024-01-23 10:00 ` Guenter Roeck
2024-01-22 11:11 ` [PATCH 04/10] watchdog: rzg2l_wdt: Remove reset de-assert on probe/stop Claudiu
2024-01-22 11:11 ` [PATCH 05/10] watchdog: rzg2l_wdt: Remove comparison with zero Claudiu
2024-01-22 11:11 ` [PATCH 06/10] watchdog: rzg2l_wdt: Rely on the reset driver for doing proper reset Claudiu
2024-01-22 11:11 ` [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support Claudiu
2024-01-22 17:39 ` Guenter Roeck
2024-01-22 21:05 ` Jerry Hoemann
2024-01-22 22:00 ` Guenter Roeck
2024-01-23 7:13 ` claudiu beznea [this message]
2024-01-23 10:09 ` Guenter Roeck
2024-01-23 11:40 ` claudiu beznea
2024-01-22 11:11 ` [PATCH 08/10] dt-bindings: watchdog: renesas,wdt: Document RZ/G3S support Claudiu
2024-01-22 17:12 ` Conor Dooley
2024-01-30 16:48 ` Geert Uytterhoeven
2024-01-22 11:11 ` [PATCH 09/10] arm64: dts: renesas: r9a08g045: Add watchdog node Claudiu
2024-01-30 16:51 ` Geert Uytterhoeven
2024-01-22 11:11 ` [PATCH 10/10] arm64: dts: renesas: rzg3s-smarc-som: Enable the watchdog interface Claudiu
2024-01-30 16:51 ` Geert Uytterhoeven
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=2af40ace-2779-45a0-a244-e7e9e5cc510c@tuxon.dev \
--to=claudiu.beznea@tuxon.dev \
--cc=biju.das.jz@bp.renesas.com \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=magnus.damm@gmail.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=wim@linux-watchdog.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 NNTP newsgroup(s).