[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<TY3PR01MB1134692D7D9F5B67116D2BC7786DBA@TY3PR01MB11346.jpnprd01.prod.outlook.com>
Date: Mon, 1 Dec 2025 11:09:50 +0000
From: Biju Das <biju.das.jz@...renesas.com>
To: Uwe Kleine-König <ukleinek@...nel.org>, biju.das.au
<biju.das.au@...il.com>
CC: Philipp Zabel <p.zabel@...gutronix.de>, "linux-pwm@...r.kernel.org"
<linux-pwm@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, Geert Uytterhoeven <geert+renesas@...der.be>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@...renesas.com>,
"linux-renesas-soc@...r.kernel.org" <linux-renesas-soc@...r.kernel.org>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>
Subject: RE: [PATCH v3 6/8] pwm: rzg2l-gpt: Add suspend/resume support
Hi All,
> -----Original Message-----
> From: Uwe Kleine-König <ukleinek@...nel.org>
> Sent: 30 November 2025 08:39
> Subject: Re: [PATCH v3 6/8] pwm: rzg2l-gpt: Add suspend/resume support
>
> On Tue, Sep 23, 2025 at 03:45:10PM +0100, Biju wrote:
> > +static int rzg2l_gpt_suspend(struct device *dev) {
> > + struct pwm_chip *chip = dev_get_drvdata(dev);
> > + struct rzg2l_gpt_chip *rzg2l_gpt = to_rzg2l_gpt_chip(chip);
> > + unsigned int i;
> > +
> > + for (i = 0; i < RZG2L_MAX_HW_CHANNELS; i++) {
> > + if (!rzg2l_gpt->channel_enable_count[i])
> > + continue;
> > +
> > + rzg2l_gpt->hw_cache[i].gtpr = rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTPR(i));
> > + rzg2l_gpt->hw_cache[i].gtccr[0] = rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTCCR(i, 0));
> > + rzg2l_gpt->hw_cache[i].gtccr[1] = rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTCCR(i, 1));
> > + rzg2l_gpt->hw_cache[i].gtcr = rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTCR(i));
> > + rzg2l_gpt->hw_cache[i].gtior = rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTIOR(i));
> > + }
> > +
> > + clk_disable_unprepare(rzg2l_gpt->clk);
> > + clk_disable_unprepare(rzg2l_gpt->bus_clk);
> > + reset_control_assert(rzg2l_gpt->rst_s);
> > + reset_control_assert(rzg2l_gpt->rst);
> > +
> > + return 0;
> > +}
> > +
> > +static int rzg2l_gpt_resume(struct device *dev) {
> > + struct pwm_chip *chip = dev_get_drvdata(dev);
> > + struct rzg2l_gpt_chip *rzg2l_gpt = to_rzg2l_gpt_chip(chip);
> > + unsigned int i;
> > + int ret;
> > +
> > + ret = reset_control_deassert(rzg2l_gpt->rst);
> > + if (ret)
> > + return ret;
> > +
> > + ret = reset_control_deassert(rzg2l_gpt->rst_s);
> > + if (ret)
> > + goto fail_reset;
> > +
> > + ret = clk_prepare_enable(rzg2l_gpt->bus_clk);
> > + if (ret)
> > + goto fail_reset_all;
> > +
> > + ret = clk_prepare_enable(rzg2l_gpt->clk);
> > + if (ret)
> > + goto fail_bus_clk;
> > +
> > + for (i = 0; i < RZG2L_MAX_HW_CHANNELS; i++) {
> > + if (!rzg2l_gpt->channel_enable_count[i])
> > + continue;
> > +
> > + rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTPR(i), rzg2l_gpt->hw_cache[i].gtpr);
> > + rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTCCR(i, 0), rzg2l_gpt->hw_cache[i].gtccr[0]);
> > + rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTCCR(i, 1), rzg2l_gpt->hw_cache[i].gtccr[1]);
> > + rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTCR(i), rzg2l_gpt->hw_cache[i].gtcr);
> > + rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTIOR(i), rzg2l_gpt->hw_cache[i].gtior);
> > + }
> > +
> > + return 0;
> > +fail_bus_clk:
> > + clk_disable_unprepare(rzg2l_gpt->bus_clk);
> > +fail_reset_all:
> > + reset_control_assert(rzg2l_gpt->rst_s);
> > +fail_reset:
> > + reset_control_assert(rzg2l_gpt->rst);
> > + return ret;
>
> I wonder what happens if these calls in the error path fail. I think the correct way would be to track
> the actual state to handle the state on the next invokation for .resume() properly. But note that
> suspend/resume is a somewhat blind spot for me, so I'm unsure here. (And I'm aware that most resume
> callbacks don't cope cleanly here.)
In str case, there is no power on the system during suspend and exit is, SoC reset followed by
restoring registers from DDR. So, it does not matter for the suspend path.
In the resume case, If the calls to error path fail, then device won't work.
>
> I added linux-pm to Cc:, maybe someone can speak up about the expectations here?
Adding logs here to provide some input
root@...rc-rzg3e:/# /pwm-pm-test.sh
Suspend to Idle case: There is always power during suspend/resume
### Executing suspend to Idle ##[ 2234.873041] PM: suspend entry (s2idle)
#
[ 2234.880814] Filesystems sync: 0.002 seconds
[ 2234.886280] Freezing user space processes
[ 2234.890772] Freezing user space processes completed (elapsed 0.004 seconds)
[ 2234.898042] OOM killer disabled.
[ 2234.901418] Freezing remaining freezable tasks
[ 2234.987346] Freezing remaining freezable tasks completed (elapsed 0.081 seconds)
[ 2234.994928] printk: Suspending console(s) (use no_console_suspend to debug)
[ 2235.063373] renesas-gbeth 15c30000.ethernet end0: Link is Down
[ 2241.003506] dwmac4: Master AXI performs any burst length
[ 2241.003589] renesas-gbeth 15c30000.ethernet end0: No Safety Features support found
[ 2241.003686] renesas-gbeth 15c30000.ethernet end0: IEEE 1588-2008 Advanced Timestamp supported
[ 2241.003837] renesas-gbeth 15c30000.ethernet end0: configuring for phy/rgmii-id link mode
[ 2241.012644] dwmac4: Master AXI performs any burst length
[ 2241.012719] renesas-gbeth 15c40000.ethernet end1: No Safety Features support found
[ 2241.012804] renesas-gbeth 15c40000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported
[ 2241.012948] renesas-gbeth 15c40000.ethernet end1: configuring for phy/rgmii-id link mode
[ 2241.060964] usb usb1: root hub lost power or was reset
[ 2241.061005] usb usb2: root hub lost power or was reset
[ 2241.245594] OOM killer enabled.
[ 2241.248732] Restarting tasks: Starting
[ 2241.253795] Restarting tasks: Done
[ 2241.261232] random: crng reseeded on system resumption
[ 2241.266589] PM: suspend exit
[ 2243.565376] renesas-gbeth 15c30000.ethernet end0: Link is Up - 1Gbps/Full - flow control rx/tx
STR case: There is no power during suspend and during resume the PWM is active and enabled.
### Executing STR ###
[ 2249.336476] PM: suspend entry (deep)
[ 2249.341533] Filesystems sync: 0.000 seconds
[ 2249.346768] Freezing user space processes
[ 2249.350597] Freezing user space processes completed (elapsed 0.003 seconds)
[ 2249.358292] OOM killer disabled.
[ 2249.361536] Freezing remaining freezable tasks
[ 2249.367334] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[ 2249.374754] printk: Suspending console(s) (use no_console_suspend to debug)
NOTICE: BL2: v2.10.5(release):2.10.5/rz_soc_dev-329-gb288fa6dd
NOTICE: BL2: Built : 12:27:28, Nov 28 2025
NOTICE: BL2: SYS_LSI_MODE: 0x13e06
NOTICE: BL2: SYS_LSI_DEVID: 0x8679447
NOTICE: BL2: SYS_LSI_PRR: 0x0
NOTICE: BL2: Booting BL31
[ 2249.443353] renesas-gbeth 15c30000.ethernet end0: Link is Down
[ 2249.457488] Disabling non-boot CPUs ...
[ 2249.462415] psci: CPU3 killed (polled 0 ms)
[ 2249.469054] psci: CPU2 killed (polled 0 ms)
[ 2249.475079] psci: CPU1 killed (polled 0 ms)
[ 2249.476779] Enabling non-boot CPUs ...
[ 2249.476986] Detected VIPT I-cache on CPU1
[ 2249.477029] GICv3: CPU1: found redistributor 100 region 0:0x0000000014960000
[ 2249.477068] CPU1: Booted secondary processor 0x0000000100 [0x412fd050]
[ 2249.477934] CPU1 is up
[ 2249.478033] Detected VIPT I-cache on CPU2
[ 2249.478054] GICv3: CPU2: found redistributor 200 region 0:0x0000000014980000
[ 2249.478075] CPU2: Booted secondary processor 0x0000000200 [0x412fd050]
[ 2249.478603] CPU2 is up
[ 2249.478700] Detected VIPT I-cache on CPU3
[ 2249.478723] GICv3: CPU3: found redistributor 300 region 0:0x00000000149a0000
[ 2249.478743] CPU3: Booted secondary processor 0x0000000300 [0x412fd050]
[ 2249.479398] CPU3 is up
[ 2249.497101] dwmac4: Master AXI performs any burst length
[ 2249.497138] renesas-gbeth 15c30000.ethernet end0: No Safety Features support found
[ 2249.497180] renesas-gbeth 15c30000.ethernet end0: IEEE 1588-2008 Advanced Timestamp supported
[ 2249.497248] renesas-gbeth 15c30000.ethernet end0: configuring for phy/rgmii-id link mode
[ 2249.514222] dwmac4: Master AXI performs any burst length
[ 2249.514248] renesas-gbeth 15c40000.ethernet end1: No Safety Features support found
[ 2249.514278] renesas-gbeth 15c40000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported
[ 2249.514339] renesas-gbeth 15c40000.ethernet end1: configuring for phy/rgmii-id link mode
[ 2249.561172] usb usb1: root hub lost power or was reset
[ 2249.561180] usb usb2: root hub lost power or was reset
[ 2249.824165] OOM killer enabled.
[ 2249.827341] Restarting tasks: Starting
[ 2249.831552] Restarting tasks: Done
[ 2249.835021] random: crng reseeded on system resumption
[ 2249.840269] PM: suspend exit
[ 2252.066180] renesas-gbeth 15c30000.ethernet end0: Link is Up - 1Gbps/Full - flow control rx/tx
root@...rc-rzg3e:/#
Cheers,
Biju
Powered by blists - more mailing lists