* [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S
@ 2024-01-22 11:11 Claudiu
2024-01-22 11:11 ` [PATCH 01/10] clk: renesas: r9a08g045: Add clock and reset support for watchdog Claudiu
` (9 more replies)
0 siblings, 10 replies; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Hi,
Series adds watchdog support for Renesas RZ/G3S (R9A08G045) SoC.
Patches do the following:
- patch 1/10 adds clock and reset support for watchdog
- patches 2-6/10 adds fixes and cleanup for the watchdog driver
- patch 7/10 adds suspend to RAM to the watchdog driver (to be used by
RZ/G3S)
- patch 8/10 documents the RZ/G3S support
- patches 9-10/10 add device tree support
It is expected that the clock and device tree support will go through
Geert's tree while the rest of the patches through the watchdog tree.
Thank you,
Claudiu Beznea
Claudiu Beznea (10):
clk: renesas: r9a08g045: Add clock and reset support for watchdog
watchdog: rzg2l_wdt: Use pm_runtime_resume_and_get()
watchdog: rzg2l_wdt: Check return status of pm_runtime_put()
watchdog: rzg2l_wdt: Remove reset de-assert on probe/stop
watchdog: rzg2l_wdt: Remove comparison with zero
watchdog: rzg2l_wdt: Rely on the reset driver for doing proper reset
watchdog: rzg2l_wdt: Add suspend/resume support
dt-bindings: watchdog: renesas,wdt: Document RZ/G3S support
arm64: dts: renesas: r9a08g045: Add watchdog node
arm64: dts: renesas: rzg3s-smarc-som: Enable the watchdog interface
.../bindings/watchdog/renesas,wdt.yaml | 1 +
arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 14 +++
.../boot/dts/renesas/rzg3s-smarc-som.dtsi | 5 +
drivers/clk/renesas/r9a08g045-cpg.c | 3 +
drivers/watchdog/rzg2l_wdt.c | 100 ++++++++++--------
5 files changed, 76 insertions(+), 47 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 01/10] clk: renesas: r9a08g045: Add clock and reset support for watchdog
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
@ 2024-01-22 11:11 ` 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
` (8 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
RZ/G3S has a watchdog module accessible by the Cortex-A core. Add clock
and reset support for it.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/clk/renesas/r9a08g045-cpg.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/clk/renesas/r9a08g045-cpg.c b/drivers/clk/renesas/r9a08g045-cpg.c
index 2582ba95256e..c3e6da2de197 100644
--- a/drivers/clk/renesas/r9a08g045-cpg.c
+++ b/drivers/clk/renesas/r9a08g045-cpg.c
@@ -193,6 +193,8 @@ static const struct rzg2l_mod_clk r9a08g045_mod_clks[] = {
DEF_MOD("ia55_pclk", R9A08G045_IA55_PCLK, R9A08G045_CLK_P2, 0x518, 0),
DEF_MOD("ia55_clk", R9A08G045_IA55_CLK, R9A08G045_CLK_P1, 0x518, 1),
DEF_MOD("dmac_aclk", R9A08G045_DMAC_ACLK, R9A08G045_CLK_P3, 0x52c, 0),
+ DEF_MOD("wdt0_pclk", R9A08G045_WDT0_PCLK, R9A08G045_CLK_P0, 0x548, 0),
+ DEF_MOD("wdt0_clk", R9A08G045_WDT0_CLK, R9A08G045_OSCCLK, 0x548, 1),
DEF_MOD("sdhi0_imclk", R9A08G045_SDHI0_IMCLK, CLK_SD0_DIV4, 0x554, 0),
DEF_MOD("sdhi0_imclk2", R9A08G045_SDHI0_IMCLK2, CLK_SD0_DIV4, 0x554, 1),
DEF_MOD("sdhi0_clk_hs", R9A08G045_SDHI0_CLK_HS, R9A08G045_CLK_SD0, 0x554, 2),
@@ -219,6 +221,7 @@ static const struct rzg2l_reset r9a08g045_resets[] = {
DEF_RST(R9A08G045_GIC600_GICRESET_N, 0x814, 0),
DEF_RST(R9A08G045_GIC600_DBG_GICRESET_N, 0x814, 1),
DEF_RST(R9A08G045_IA55_RESETN, 0x818, 0),
+ DEF_RST(R9A08G045_WDT0_PRESETN, 0x848, 0),
DEF_RST(R9A08G045_SDHI0_IXRST, 0x854, 0),
DEF_RST(R9A08G045_SDHI1_IXRST, 0x854, 1),
DEF_RST(R9A08G045_SDHI2_IXRST, 0x854, 2),
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 02/10] watchdog: rzg2l_wdt: Use pm_runtime_resume_and_get()
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-22 11:11 ` 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
` (7 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
pm_runtime_get_sync() may return with error. In case it returns with error
dev->power.usage_count needs to be decremented. pm_runtime_resume_and_get()
takes care of this. Thus use it.
Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/watchdog/rzg2l_wdt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 1741f98ca67c..4ab9e7c5e771 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -123,8 +123,11 @@ static void rzg2l_wdt_init_timeout(struct watchdog_device *wdev)
static int rzg2l_wdt_start(struct watchdog_device *wdev)
{
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
+ int ret;
- pm_runtime_get_sync(wdev->parent);
+ ret = pm_runtime_resume_and_get(wdev->parent);
+ if (ret)
+ return ret;
/* Initialize time out */
rzg2l_wdt_init_timeout(wdev);
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 03/10] watchdog: rzg2l_wdt: Check return status of pm_runtime_put()
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-22 11:11 ` [PATCH 02/10] watchdog: rzg2l_wdt: Use pm_runtime_resume_and_get() Claudiu
@ 2024-01-22 11:11 ` Claudiu
2024-01-22 17:31 ` Guenter Roeck
2024-01-22 11:11 ` [PATCH 04/10] watchdog: rzg2l_wdt: Remove reset de-assert on probe/stop Claudiu
` (6 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
pm_runtime_put() may return an error code. Check its return status.
Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/watchdog/rzg2l_wdt.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 4ab9e7c5e771..0554965027cd 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev)
static int rzg2l_wdt_stop(struct watchdog_device *wdev)
{
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
+ int ret;
rzg2l_wdt_reset(priv);
- pm_runtime_put(wdev->parent);
+
+ ret = pm_runtime_put(wdev->parent);
+ if (ret < 0)
+ return ret;
return 0;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 04/10] watchdog: rzg2l_wdt: Remove reset de-assert on probe/stop
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
` (2 preceding siblings ...)
2024-01-22 11:11 ` [PATCH 03/10] watchdog: rzg2l_wdt: Check return status of pm_runtime_put() Claudiu
@ 2024-01-22 11:11 ` Claudiu
2024-01-22 11:11 ` [PATCH 05/10] watchdog: rzg2l_wdt: Remove comparison with zero Claudiu
` (5 subsequent siblings)
9 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
There is no need to de-assert the reset signal on probe as the watchdog
is not used prior executing start. Also, the clocks are not enabled in
probe (pm_runtime_enable() doesn't do that), thus this is another indicator
that the watchdog wasn't used previously like this. Instead, keep the
watchdog hardware in its previous state at probe (by default it is in
reset state), enable it when it is started and move it to reset state
when it is stopped. This saves some extra power when the watchdog is
unused.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/watchdog/rzg2l_wdt.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 0554965027cd..988926e50741 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -129,6 +129,10 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev)
if (ret)
return ret;
+ ret = reset_control_deassert(priv->rstc);
+ if (ret)
+ return ret;
+
/* Initialize time out */
rzg2l_wdt_init_timeout(wdev);
@@ -146,7 +150,9 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev)
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
int ret;
- rzg2l_wdt_reset(priv);
+ ret = reset_control_assert(priv->rstc);
+ if (ret)
+ return ret;
ret = pm_runtime_put(wdev->parent);
if (ret < 0)
@@ -181,6 +187,12 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev,
clk_prepare_enable(priv->osc_clk);
if (priv->devtype == WDT_RZG2L) {
+ int ret;
+
+ ret = reset_control_deassert(priv->rstc);
+ if (ret)
+ return ret;
+
/* Generate Reset (WDTRSTB) Signal on parity error */
rzg2l_wdt_write(priv, 0, PECR);
@@ -231,13 +243,11 @@ static const struct watchdog_ops rzg2l_wdt_ops = {
.restart = rzg2l_wdt_restart,
};
-static void rzg2l_wdt_reset_assert_pm_disable(void *data)
+static void rzg2l_wdt_pm_disable(void *data)
{
struct watchdog_device *wdev = data;
- struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
pm_runtime_disable(wdev->parent);
- reset_control_assert(priv->rstc);
}
static int rzg2l_wdt_probe(struct platform_device *pdev)
@@ -280,10 +290,6 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(priv->rstc),
"failed to get cpg reset");
- ret = reset_control_deassert(priv->rstc);
- if (ret)
- return dev_err_probe(dev, ret, "failed to deassert");
-
priv->devtype = (uintptr_t)of_device_get_match_data(dev);
if (priv->devtype == WDT_RZV2M) {
@@ -304,9 +310,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
priv->wdev.timeout = WDT_DEFAULT_TIMEOUT;
watchdog_set_drvdata(&priv->wdev, priv);
- ret = devm_add_action_or_reset(&pdev->dev,
- rzg2l_wdt_reset_assert_pm_disable,
- &priv->wdev);
+ ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev);
if (ret < 0)
return ret;
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 05/10] watchdog: rzg2l_wdt: Remove comparison with zero
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
` (3 preceding siblings ...)
2024-01-22 11:11 ` [PATCH 04/10] watchdog: rzg2l_wdt: Remove reset de-assert on probe/stop Claudiu
@ 2024-01-22 11:11 ` Claudiu
2024-01-22 11:11 ` [PATCH 06/10] watchdog: rzg2l_wdt: Rely on the reset driver for doing proper reset Claudiu
` (4 subsequent siblings)
9 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
devm_add_action_or_reset() could return -ENOMEM or zero. Thus, remove
comparison with zero of the returning value to make code simpler.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/watchdog/rzg2l_wdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 988926e50741..38607673e1a5 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -311,7 +311,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
watchdog_set_drvdata(&priv->wdev, priv);
ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev);
- if (ret < 0)
+ if (ret)
return ret;
watchdog_set_nowayout(&priv->wdev, nowayout);
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 06/10] watchdog: rzg2l_wdt: Rely on the reset driver for doing proper reset
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
` (4 preceding siblings ...)
2024-01-22 11:11 ` [PATCH 05/10] watchdog: rzg2l_wdt: Remove comparison with zero Claudiu
@ 2024-01-22 11:11 ` Claudiu
2024-01-22 11:11 ` [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support Claudiu
` (3 subsequent siblings)
9 siblings, 0 replies; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
The reset driver has been adapted in commit da235d2fac21
("clk: renesas: rzg2l: Check reset monitor registers") to check the reset
monitor bits before declaring reset asserts/de-asserts as
successful/failure operations. With that, there is no need to keep the
reset workaround for RZ/V2M in place in the watchdog driver.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/watchdog/rzg2l_wdt.c | 39 ++++--------------------------------
1 file changed, 4 insertions(+), 35 deletions(-)
diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 38607673e1a5..9333dc1a75ab 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -8,7 +8,6 @@
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h>
-#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -54,35 +53,11 @@ struct rzg2l_wdt_priv {
struct reset_control *rstc;
unsigned long osc_clk_rate;
unsigned long delay;
- unsigned long minimum_assertion_period;
struct clk *pclk;
struct clk *osc_clk;
enum rz_wdt_type devtype;
};
-static int rzg2l_wdt_reset(struct rzg2l_wdt_priv *priv)
-{
- int err, status;
-
- if (priv->devtype == WDT_RZV2M) {
- /* WDT needs TYPE-B reset control */
- err = reset_control_assert(priv->rstc);
- if (err)
- return err;
- ndelay(priv->minimum_assertion_period);
- err = reset_control_deassert(priv->rstc);
- if (err)
- return err;
- err = read_poll_timeout(reset_control_status, status,
- status != 1, 0, 1000, false,
- priv->rstc);
- } else {
- err = reset_control_reset(priv->rstc);
- }
-
- return err;
-}
-
static void rzg2l_wdt_wait_delay(struct rzg2l_wdt_priv *priv)
{
/* delay timer when change the setting register */
@@ -182,13 +157,12 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev,
unsigned long action, void *data)
{
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
+ int ret;
clk_prepare_enable(priv->pclk);
clk_prepare_enable(priv->osc_clk);
if (priv->devtype == WDT_RZG2L) {
- int ret;
-
ret = reset_control_deassert(priv->rstc);
if (ret)
return ret;
@@ -200,7 +174,9 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev,
rzg2l_wdt_write(priv, PEEN_FORCE, PEEN);
} else {
/* RZ/V2M doesn't have parity error registers */
- rzg2l_wdt_reset(priv);
+ ret = reset_control_reset(priv->rstc);
+ if (ret)
+ return ret;
wdev->timeout = 0;
@@ -292,13 +268,6 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
priv->devtype = (uintptr_t)of_device_get_match_data(dev);
- if (priv->devtype == WDT_RZV2M) {
- priv->minimum_assertion_period = RZV2M_A_NSEC +
- 3 * F2CYCLE_NSEC(pclk_rate) + 5 *
- max(F2CYCLE_NSEC(priv->osc_clk_rate),
- F2CYCLE_NSEC(pclk_rate));
- }
-
pm_runtime_enable(&pdev->dev);
priv->wdev.info = &rzg2l_wdt_ident;
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
` (5 preceding siblings ...)
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 ` Claudiu
2024-01-22 17:39 ` Guenter Roeck
2024-01-22 11:11 ` [PATCH 08/10] dt-bindings: watchdog: renesas,wdt: Document RZ/G3S support Claudiu
` (2 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
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),
},
.probe = rzg2l_wdt_probe,
};
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 08/10] dt-bindings: watchdog: renesas,wdt: Document RZ/G3S support
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
` (6 preceding siblings ...)
2024-01-22 11:11 ` [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support Claudiu
@ 2024-01-22 11:11 ` 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-22 11:11 ` [PATCH 10/10] arm64: dts: renesas: rzg3s-smarc-som: Enable the watchdog interface Claudiu
9 siblings, 2 replies; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Document the support for the watchdog IP available on RZ/G3S SoC. The
watchdog IP available on RZ/G3S SoC is identical to the one found on
RZ/G2UL SoC.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml b/Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml
index 951a7d54135a..220763838df0 100644
--- a/Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml
@@ -29,6 +29,7 @@ properties:
- renesas,r9a07g043-wdt # RZ/G2UL and RZ/Five
- renesas,r9a07g044-wdt # RZ/G2{L,LC}
- renesas,r9a07g054-wdt # RZ/V2L
+ - renesas,r9a08g045-wdt # RZ/G3S
- const: renesas,rzg2l-wdt
- items:
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 09/10] arm64: dts: renesas: r9a08g045: Add watchdog node
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
` (7 preceding siblings ...)
2024-01-22 11:11 ` [PATCH 08/10] dt-bindings: watchdog: renesas,wdt: Document RZ/G3S support Claudiu
@ 2024-01-22 11:11 ` 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
9 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Add the DT node for the watchdog IP accessible by Cortex-A of RZ/G3S
SoC (R9108G045).
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
index 02fd68b06eea..19bbcae01d80 100644
--- a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
@@ -269,6 +269,20 @@ gic: interrupt-controller@12400000 {
<0x0 0x12440000 0 0x60000>;
interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_LOW>;
};
+
+ wdt0: watchdog@12800800 {
+ compatible = "renesas,r9a08g045-wdt", "renesas,rzg2l-wdt";
+ reg = <0 0x12800800 0 0x400>;
+ clocks = <&cpg CPG_MOD R9A08G045_WDT0_PCLK>,
+ <&cpg CPG_MOD R9A08G045_WDT0_CLK>;
+ clock-names = "pclk", "oscclk";
+ interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "wdt", "perrout";
+ resets = <&cpg R9A08G045_WDT0_PRESETN>;
+ power-domains = <&cpg>;
+ status = "disabled";
+ };
};
timer {
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 10/10] arm64: dts: renesas: rzg3s-smarc-som: Enable the watchdog interface
2024-01-22 11:11 [PATCH 00/10] watchdog: rzg2l_wdt: Add support for RZ/G3S Claudiu
` (8 preceding siblings ...)
2024-01-22 11:11 ` [PATCH 09/10] arm64: dts: renesas: r9a08g045: Add watchdog node Claudiu
@ 2024-01-22 11:11 ` Claudiu
2024-01-30 16:51 ` Geert Uytterhoeven
9 siblings, 1 reply; 26+ messages in thread
From: Claudiu @ 2024-01-22 11:11 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, claudiu.beznea, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Enable the watchdog interface (accessible by Cortex-A of RZ/G3S SoC) on
RZ/G3S SMARC SoM.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi
index f062d4ad78b7..2b7fa5817d58 100644
--- a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi
+++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi
@@ -336,3 +336,8 @@ mux {
};
};
};
+
+&wdt0 {
+ timeout-sec = <60>;
+ status = "okay";
+};
--
2.39.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH 08/10] dt-bindings: watchdog: renesas,wdt: Document RZ/G3S support
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
1 sibling, 0 replies; 26+ messages in thread
From: Conor Dooley @ 2024-01-22 17:12 UTC (permalink / raw)
To: Claudiu
Cc: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz, linux-watchdog, devicetree, linux-kernel,
linux-renesas-soc, linux-clk, Claudiu Beznea
[-- Attachment #1: Type: text/plain, Size: 1218 bytes --]
On Mon, Jan 22, 2024 at 01:11:13PM +0200, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> Document the support for the watchdog IP available on RZ/G3S SoC. The
> watchdog IP available on RZ/G3S SoC is identical to the one found on
> RZ/G2UL SoC.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Cheers,
Conor.
> ---
> Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml b/Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml
> index 951a7d54135a..220763838df0 100644
> --- a/Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml
> +++ b/Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml
> @@ -29,6 +29,7 @@ properties:
> - renesas,r9a07g043-wdt # RZ/G2UL and RZ/Five
> - renesas,r9a07g044-wdt # RZ/G2{L,LC}
> - renesas,r9a07g054-wdt # RZ/V2L
> + - renesas,r9a08g045-wdt # RZ/G3S
> - const: renesas,rzg2l-wdt
>
> - items:
> --
> 2.39.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 03/10] watchdog: rzg2l_wdt: Check return status of pm_runtime_put()
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
0 siblings, 1 reply; 26+ messages in thread
From: Guenter Roeck @ 2024-01-22 17:31 UTC (permalink / raw)
To: Claudiu, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, Claudiu Beznea
On 1/22/24 03:11, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> pm_runtime_put() may return an error code. Check its return status.
>
> Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
> drivers/watchdog/rzg2l_wdt.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
> index 4ab9e7c5e771..0554965027cd 100644
> --- a/drivers/watchdog/rzg2l_wdt.c
> +++ b/drivers/watchdog/rzg2l_wdt.c
> @@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev)
> static int rzg2l_wdt_stop(struct watchdog_device *wdev)
> {
> struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
> + int ret;
>
> rzg2l_wdt_reset(priv);
> - pm_runtime_put(wdev->parent);
> +
> + ret = pm_runtime_put(wdev->parent);
> + if (ret < 0)
> + return ret;
>
> return 0;
> }
A simple
return pm_runtime_put();
might do.
However, one question: Given that pm_runtime_put() returns -ENOSYS if
CONFIG_PM is disabled, that means the driver will depend on CONFIG_PM=y.
Assuming this is intentional, would it make sense to explicitly declare
that dependency in Kconfig ? It doesn't seem to make any sense to build
the driver if it won't work anyway.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support
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-23 7:13 ` claudiu beznea
0 siblings, 2 replies; 26+ messages in thread
From: Guenter Roeck @ 2024-01-22 17:39 UTC (permalink / raw)
To: Claudiu, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, Claudiu Beznea
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. 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.
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,
> };
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support
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
1 sibling, 1 reply; 26+ messages in thread
From: Jerry Hoemann @ 2024-01-22 21:05 UTC (permalink / raw)
To: Guenter Roeck
Cc: Claudiu, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz, linux-watchdog, devicetree, linux-kernel,
linux-renesas-soc, linux-clk, Claudiu Beznea
On Mon, Jan 22, 2024 at 09:39:27AM -0800, 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. 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.
>
> 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
Guenter,
I'm working on a similar patch.
Is your concern limited to the use of the "pm_ptr" macro? Or is it
wider?
Thanks
Jerry
--
-----------------------------------------------------------------------------
Jerry Hoemann Software Engineer Hewlett Packard Enterprise
-----------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support
2024-01-22 21:05 ` Jerry Hoemann
@ 2024-01-22 22:00 ` Guenter Roeck
0 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2024-01-22 22:00 UTC (permalink / raw)
To: Jerry.Hoemann
Cc: Claudiu, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz, linux-watchdog, devicetree, linux-kernel,
linux-renesas-soc, linux-clk, Claudiu Beznea
On 1/22/24 13:05, Jerry Hoemann wrote:
> On Mon, Jan 22, 2024 at 09:39:27AM -0800, 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. 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.
>>
>> 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
>
> Guenter,
>
> I'm working on a similar patch.
>
> Is your concern limited to the use of the "pm_ptr" macro? Or is it
> wider?
>
patch 3/10 adds an error check of the return value from pm_runtime_put().
pm_runtime_put() calls __pm_runtime_idle() which returns -ENOSYS if
CONFIG_PM=n. That means checking the return value of pm_runtime_put()
is equivalent to making CONFIG_PM mandatory. My argument is that this
should be expressed in Kconfig to avoid the impression that the driver
works with CONFIG_PM=n. If the driver depends on CONFIG_PM, pm_ptr()
is unnecessary. If it doesn't, the variable referenced by it needs
to be defined as __maybe_unused, but then the driver should actually
work with CONFIG_PM=n.
Yes, I have noticed the recent trend of adding error checks to
pm_runtime_put(), but I only now realized that it has consequences.
Guenter
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 03/10] watchdog: rzg2l_wdt: Check return status of pm_runtime_put()
2024-01-22 17:31 ` Guenter Roeck
@ 2024-01-23 7:02 ` claudiu beznea
2024-01-23 10:00 ` Guenter Roeck
0 siblings, 1 reply; 26+ messages in thread
From: claudiu beznea @ 2024-01-23 7:02 UTC (permalink / raw)
To: Guenter Roeck, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, Claudiu Beznea
On 22.01.2024 19:31, Guenter Roeck wrote:
> On 1/22/24 03:11, Claudiu wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> pm_runtime_put() may return an error code. Check its return status.
>>
>> Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>> ---
>> drivers/watchdog/rzg2l_wdt.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
>> index 4ab9e7c5e771..0554965027cd 100644
>> --- a/drivers/watchdog/rzg2l_wdt.c
>> +++ b/drivers/watchdog/rzg2l_wdt.c
>> @@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device
>> *wdev)
>> static int rzg2l_wdt_stop(struct watchdog_device *wdev)
>> {
>> struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
>> + int ret;
>> rzg2l_wdt_reset(priv);
>> - pm_runtime_put(wdev->parent);
>> +
>> + ret = pm_runtime_put(wdev->parent);
>> + if (ret < 0)
>> + return ret;
>> return 0;
>> }
>
> A simple
> return pm_runtime_put();
> might do.
pm_runtime_put() may return 1 if the device is already suspended though
this call trace:
pm_runtime_put() ->
__pm_runtime_idle() ->
rpm_idle() ->
rpm_suspend() ->
rpm_check_suspend_allowed() [1]
That return value is not considered error thus I wanted to consider it
here, too.
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/base/power/runtime.c#L278
>
> However, one question: Given that pm_runtime_put() returns -ENOSYS if
> CONFIG_PM is disabled, that means the driver will depend on CONFIG_PM=y.
Indeed, the driver depends on CONFIG_PM=y for proper working. It is for
devices selecting ARCH_RZG2L and RZ/V2M (ARM64 based uarch) which select
CONFIG_PM=y:
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L45
The driver is written with CONFIG_PM=y dependency in mind (e.g. the clocks
are enabled though runtime PM APIs).
> Assuming this is intentional, would it make sense to explicitly declare
> that dependency in Kconfig ? It doesn't seem to make any sense to build
> the driver if it won't work anyway.
The dependency exists there for ARCH_RZG2L and RZ/V2M devices but not
directly and it is not strict (in the sense that we allow to build the
driver w/o CONFIG_PM (I think this is good to check build on different
configurations, the COMPILE_TEST is there anyway in [1]) ). E.g.:
RENESAS_RZG2LWDT depends on ARCH_RENESAS [1]
ARCH_RENESAS is the ARMv8 uarch flag [2]
SOC_RENESAS is set if ARCH_RENESAS [3]
ARCH_RZG2L is visible only if SOC_RENESAS [4]
ARCH_RZG2L selects PM [5]
RZ/V2M selects PM [6]
Please let me know what do you think about it?
Thank you,
Claudiu Beznea
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/watchdog/Kconfig#L913
[2]
https://elixir.bootlin.com/linux/latest/source/arch/arm64/Kconfig.platforms#L273
[3]
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L2
[4]
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L9
[5]
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L45
[6]
https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L328
>
> Thanks,
> Guenter
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support
2024-01-22 17:39 ` Guenter Roeck
2024-01-22 21:05 ` Jerry Hoemann
@ 2024-01-23 7:13 ` claudiu beznea
2024-01-23 10:09 ` Guenter Roeck
1 sibling, 1 reply; 26+ messages in thread
From: claudiu beznea @ 2024-01-23 7:13 UTC (permalink / raw)
To: Guenter Roeck, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, Claudiu Beznea
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,
>> };
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 03/10] watchdog: rzg2l_wdt: Check return status of pm_runtime_put()
2024-01-23 7:02 ` claudiu beznea
@ 2024-01-23 10:00 ` Guenter Roeck
0 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2024-01-23 10:00 UTC (permalink / raw)
To: claudiu beznea, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, Claudiu Beznea
On 1/22/24 23:02, claudiu beznea wrote:
>
>
> On 22.01.2024 19:31, Guenter Roeck wrote:
>> On 1/22/24 03:11, Claudiu wrote:
>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>
>>> pm_runtime_put() may return an error code. Check its return status.
>>>
>>> Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
>>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>> ---
>>> drivers/watchdog/rzg2l_wdt.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
>>> index 4ab9e7c5e771..0554965027cd 100644
>>> --- a/drivers/watchdog/rzg2l_wdt.c
>>> +++ b/drivers/watchdog/rzg2l_wdt.c
>>> @@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device
>>> *wdev)
>>> static int rzg2l_wdt_stop(struct watchdog_device *wdev)
>>> {
>>> struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
>>> + int ret;
>>> rzg2l_wdt_reset(priv);
>>> - pm_runtime_put(wdev->parent);
>>> +
>>> + ret = pm_runtime_put(wdev->parent);
>>> + if (ret < 0)
>>> + return ret;
>>> return 0;
>>> }
>>
>> A simple
>> return pm_runtime_put();
>> might do.
>
> pm_runtime_put() may return 1 if the device is already suspended though
> this call trace:
>
> pm_runtime_put() ->
> __pm_runtime_idle() ->
> rpm_idle() ->
> rpm_suspend() ->
> rpm_check_suspend_allowed() [1]
>
> That return value is not considered error thus I wanted to consider it
> here, too.
>
Good point.
> [1]
> https://elixir.bootlin.com/linux/latest/source/drivers/base/power/runtime.c#L278
>
>>
>> However, one question: Given that pm_runtime_put() returns -ENOSYS if
>> CONFIG_PM is disabled, that means the driver will depend on CONFIG_PM=y.
>
> Indeed, the driver depends on CONFIG_PM=y for proper working. It is for
> devices selecting ARCH_RZG2L and RZ/V2M (ARM64 based uarch) which select
> CONFIG_PM=y:
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L45
>
> The driver is written with CONFIG_PM=y dependency in mind (e.g. the clocks
> are enabled though runtime PM APIs).
>
>> Assuming this is intentional, would it make sense to explicitly declare
>> that dependency in Kconfig ? It doesn't seem to make any sense to build
>> the driver if it won't work anyway.
>
> The dependency exists there for ARCH_RZG2L and RZ/V2M devices but not
> directly and it is not strict (in the sense that we allow to build the
> driver w/o CONFIG_PM (I think this is good to check build on different
> configurations, the COMPILE_TEST is there anyway in [1]) ). E.g.:
>
> RENESAS_RZG2LWDT depends on ARCH_RENESAS [1]
> ARCH_RENESAS is the ARMv8 uarch flag [2]
> SOC_RENESAS is set if ARCH_RENESAS [3]
> ARCH_RZG2L is visible only if SOC_RENESAS [4]
> ARCH_RZG2L selects PM [5]
> RZ/V2M selects PM [6]
>
> Please let me know what do you think about it?
>
If the driver indeed depends on CONFIG_PM, that should be made explicit.
Guenter
> Thank you,
> Claudiu Beznea
>
>
> [1]
> https://elixir.bootlin.com/linux/latest/source/drivers/watchdog/Kconfig#L913
> [2]
> https://elixir.bootlin.com/linux/latest/source/arch/arm64/Kconfig.platforms#L273
> [3]
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L2
> [4]
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L9
> [5]
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L45
> [6]
> https://elixir.bootlin.com/linux/latest/source/drivers/soc/renesas/Kconfig#L328
>
>
>>
>> Thanks,
>> Guenter
>>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support
2024-01-23 7:13 ` claudiu beznea
@ 2024-01-23 10:09 ` Guenter Roeck
2024-01-23 11:40 ` claudiu beznea
0 siblings, 1 reply; 26+ messages in thread
From: Guenter Roeck @ 2024-01-23 10:09 UTC (permalink / raw)
To: claudiu beznea, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, Claudiu Beznea
On 1/22/24 23:13, claudiu beznea wrote:
>
>
> 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.
>
Ok, but are you sure you did ? You just mentioned earlier that CONFIG_PM
is set automatically through ARCH_RZG2L.
>> 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.
>
FWIW, COMPILE_TEST dependencies on watchdog drivers fails for most of them.
Regarding pm_ptr(), it is there for practical reasons and not associated with
COMPILE_TEST. Again, if the driver depends on CONFIG_PM to work, using constructs
such as pm_ptr() just hides that and creates the impression that it would work
without it. I do not think that is a good idea. You can use something like
depends on (ARCH_RENESAS && PM) || COMPILE_TEST
to make that explicit. Even if not, I _really_ don't see the point in using
pm_ptr() even without above dependency. What do you see as its benefit ?
Thanks,
Guenter
> 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,
>>> };
>>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 07/10] watchdog: rzg2l_wdt: Add suspend/resume support
2024-01-23 10:09 ` Guenter Roeck
@ 2024-01-23 11:40 ` claudiu beznea
0 siblings, 0 replies; 26+ messages in thread
From: claudiu beznea @ 2024-01-23 11:40 UTC (permalink / raw)
To: Guenter Roeck, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz
Cc: linux-watchdog, devicetree, linux-kernel, linux-renesas-soc,
linux-clk, Claudiu Beznea
On 23.01.2024 12:09, Guenter Roeck wrote:
> On 1/22/24 23:13, claudiu beznea wrote:
>>
>>
>> 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.
>>
>
> Ok, but are you sure you did ? You just mentioned earlier that CONFIG_PM
> is set automatically through ARCH_RZG2L.
Yes, I disabled everything that selected the CONFIG_PM, checked that
CONFIG_PM is disabled in my .config, enabled COMPILE_TEST and
RENESAS_RZG2LWDT (sorry, I missed to mention all these).
>
>>> 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.
>>
>
> FWIW, COMPILE_TEST dependencies on watchdog drivers fails for most of them.
> Regarding pm_ptr(), it is there for practical reasons and not associated with
> COMPILE_TEST. Again, if the driver depends on CONFIG_PM to work, using
> constructs
> such as pm_ptr() just hides that and creates the impression that it would work
> without it.
> I do not think that is a good idea. You can use something like
>
> depends on (ARCH_RENESAS && PM) || COMPILE_TEST
>
Ok, I don't have anything against. I'm not sure if this will trigger any
circular dependency for Kconfig. I'll check it.
> to make that explicit. Even if not, I _really_ don't see the point in using
> pm_ptr() even without above dependency. What do you see as its benefit ?
I remember it comes on the same package with the LATE_SYSTEM_SLEEP_PM_OPS()
kind of macros. Looking at it's definition I see it useful because it sets
properly the struct platform_driver::driver::pm. AFAIK, at the moment there
are no checks on this member in the driver core code so we should be safe
w/o using it. I checked the compilation w/ COMPILE_TEST=y and CONFIG_PM=n
and compilation is good, too.
Thank you,
Claudiu Beznea
>
> Thanks,
> Guenter
>
>> 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,
>>>> };
>>>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 01/10] clk: renesas: r9a08g045: Add clock and reset support for watchdog
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
0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2024-01-30 16:38 UTC (permalink / raw)
To: Claudiu
Cc: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz, linux-watchdog, devicetree, linux-kernel,
linux-renesas-soc, linux-clk, Claudiu Beznea
On Mon, Jan 22, 2024 at 12:11 PM Claudiu <claudiu.beznea@tuxon.dev> wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> RZ/G3S has a watchdog module accessible by the Cortex-A core. Add clock
> and reset support for it.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-clk for v6.9.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 02/10] watchdog: rzg2l_wdt: Use pm_runtime_resume_and_get()
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
0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2024-01-30 16:43 UTC (permalink / raw)
To: Claudiu
Cc: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz, linux-watchdog, devicetree, linux-kernel,
linux-renesas-soc, linux-clk, Claudiu Beznea
Hi Claudiu,
On Mon, Jan 22, 2024 at 12:11 PM Claudiu <claudiu.beznea@tuxon.dev> wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> pm_runtime_get_sync() may return with error. In case it returns with error
> dev->power.usage_count needs to be decremented. pm_runtime_resume_and_get()
> takes care of this. Thus use it.
>
> Fixes: 2cbc5cd0b55f ("watchdog: Add Watchdog Timer driver for RZ/G2L")
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Thanks for your patch!
> --- a/drivers/watchdog/rzg2l_wdt.c
> +++ b/drivers/watchdog/rzg2l_wdt.c
> @@ -123,8 +123,11 @@ static void rzg2l_wdt_init_timeout(struct watchdog_device *wdev)
> static int rzg2l_wdt_start(struct watchdog_device *wdev)
> {
> struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
> + int ret;
>
> - pm_runtime_get_sync(wdev->parent);
> + ret = pm_runtime_resume_and_get(wdev->parent);
> + if (ret)
> + return ret;
>
> /* Initialize time out */
> rzg2l_wdt_init_timeout(wdev);
To actually handle this error condition, rzg2l_wdt_set_timeout() should
be updated to propagate the error to its caller, too.
Anyway, most of this is moot, as pm_runtime_get_sync() won't ever
fail on Renesas arm/risc-v systems...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 08/10] dt-bindings: watchdog: renesas,wdt: Document RZ/G3S support
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
1 sibling, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2024-01-30 16:48 UTC (permalink / raw)
To: Claudiu
Cc: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz, linux-watchdog, devicetree, linux-kernel,
linux-renesas-soc, linux-clk, Claudiu Beznea
Hi Claudiu,
Thanks for your patch!
On Mon, Jan 22, 2024 at 12:11 PM Claudiu <claudiu.beznea@tuxon.dev> wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> Document the support for the watchdog IP available on RZ/G3S SoC. The
> watchdog IP available on RZ/G3S SoC is identical to the one found on
> RZ/G2UL SoC.
Or RZ/G2L, which is considered the baseline here.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 09/10] arm64: dts: renesas: r9a08g045: Add watchdog node
2024-01-22 11:11 ` [PATCH 09/10] arm64: dts: renesas: r9a08g045: Add watchdog node Claudiu
@ 2024-01-30 16:51 ` Geert Uytterhoeven
0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2024-01-30 16:51 UTC (permalink / raw)
To: Claudiu
Cc: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz, linux-watchdog, devicetree, linux-kernel,
linux-renesas-soc, linux-clk, Claudiu Beznea
On Mon, Jan 22, 2024 at 12:11 PM Claudiu <claudiu.beznea@tuxon.dev> wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> Add the DT node for the watchdog IP accessible by Cortex-A of RZ/G3S
> SoC (R9108G045).
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-devel for v6.9.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 10/10] arm64: dts: renesas: rzg3s-smarc-som: Enable the watchdog interface
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
0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2024-01-30 16:51 UTC (permalink / raw)
To: Claudiu
Cc: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel,
biju.das.jz, linux-watchdog, devicetree, linux-kernel,
linux-renesas-soc, linux-clk, Claudiu Beznea
On Mon, Jan 22, 2024 at 12:11 PM Claudiu <claudiu.beznea@tuxon.dev> wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> Enable the watchdog interface (accessible by Cortex-A of RZ/G3S SoC) on
> RZ/G3S SMARC SoM.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-devel for v6.9.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2024-01-30 16:51 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).