lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <TY3PR01MB11346DE28875EFD9B9D86DE5186DBA@TY3PR01MB11346.jpnprd01.prod.outlook.com>
Date: Mon, 1 Dec 2025 14:43:02 +0000
From: Biju Das <biju.das.jz@...renesas.com>
To: Uwe Kleine-König <ukleinek@...nel.org>
CC: biju.das.au <biju.das.au@...il.com>, 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 Uwe,

> -----Original Message-----
> From: Uwe Kleine-König <ukleinek@...nel.org>
> Sent: 01 December 2025 14:16
> Subject: Re: [PATCH v3 6/8] pwm: rzg2l-gpt: Add suspend/resume support
> 
> Hello Biju,
> 
> On Mon, Dec 01, 2025 at 11:09:50AM +0000, Biju Das wrote:
> > > -----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'm not sure you understand my concern. IFAIUI a device that fails to resume stays suspended from the
> POV of the kernel. When in this state the resume is tried again at a later point in time you get
> inconsistencies if the first reset was already deasserted from the previous resume run (because
> reset_control_assert() failed in the resume callback's error path).

I have simulated a possible error condition in driver by adding a hack.

Unlike probe(), .resume() never retries.

For the first time: I got the pwm resume error [2]
For the second time: I got clk related warnings, but device enter into
			   suspend mode and on resume I got pwm resume error [3]


[1]
        ret = reset_control_deassert(rzg2l_gpt->rst);
+       ret = -ETIMEDOUT;

[2]
root@...rc-rzg3e:~# /pwm-pm-test.sh

### Executing ST[   37.482149] PM: suspend entry (deep)
R ###
[   37.487322] Filesystems sync: 0.000 seconds
[   37.494478] Freezing user space processes
[   37.499067] Freezing user space processes completed (elapsed 0.004 seconds)
[   37.506607] OOM killer disabled.
[   37.509906] Freezing remaining freezable tasks
[   37.596288] Freezing remaining freezable tasks completed (elapsed 0.081 seconds)
[   37.603859] 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
[   37.683454] renesas-gbeth 15c30000.ethernet end0: Link is Down
[   37.697777] Disabling non-boot CPUs ...
[   37.702482] psci: CPU3 killed (polled 4 ms)
[   37.711313] psci: CPU2 killed (polled 0 ms)
[   37.717615] psci: CPU1 killed (polled 4 ms)
[   37.720440] Enabling non-boot CPUs ...
[   37.720650] Detected VIPT I-cache on CPU1
[   37.720697] GICv3: CPU1: found redistributor 100 region 0:0x0000000014960000
[   37.720734] CPU1: Booted secondary processor 0x0000000100 [0x412fd050]
[   37.721614] CPU1 is up
[   37.721712] Detected VIPT I-cache on CPU2
[   37.721733] GICv3: CPU2: found redistributor 200 region 0:0x0000000014980000
[   37.721754] CPU2: Booted secondary processor 0x0000000200 [0x412fd050]
[   37.722381] CPU2 is up
[   37.722475] Detected VIPT I-cache on CPU3
[   37.722496] GICv3: CPU3: found redistributor 300 region 0:0x00000000149a0000
[   37.722517] CPU3: Booted secondary processor 0x0000000300 [0x412fd050]
[   37.723239] CPU3 is up
[   37.726063] pwm-rzg2l-gpt 13010000.pwm: PM: dpm_run_callback(): rzg2l_gpt_resume [pwm_rzg2l_gpt] returns -110
[   37.726090] pwm-rzg2l-gpt 13010000.pwm: PM: failed to resume: error -110
[   37.741357] dwmac4: Master AXI performs any burst length
[   37.741390] renesas-gbeth 15c30000.ethernet end0: No Safety Features support found
[   37.741431] renesas-gbeth 15c30000.ethernet end0: IEEE 1588-2008 Advanced Timestamp supported
[   37.741499] renesas-gbeth 15c30000.ethernet end0: configuring for phy/rgmii-id link mode
[   37.758478] dwmac4: Master AXI performs any burst length
[   37.758505] renesas-gbeth 15c40000.ethernet end1: No Safety Features support found
[   37.758536] renesas-gbeth 15c40000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported
[   37.758598] renesas-gbeth 15c40000.ethernet end1: configuring for phy/rgmii-id link mode
[   37.805425] usb usb1: root hub lost power or was reset
[   37.805433] usb usb2: root hub lost power or was reset
[   38.084992] OOM killer enabled.
[   38.088129] Restarting tasks: Starting
[   38.092613] Restarting tasks: Done
[   38.096111] random: crng reseeded on system resumption
[   38.101412] PM: suspend exit

[   40.382923] renesas-gbeth 15c30000.ethernet end0: Link is Up - 1Gbps/Full - flow control rx/tx
root@...rc-rzg3e:~#

[3]

root@...rc-rzg3e:~# /pwm-pm-test.sh
16
pwmchip0

### Executing ST[   47.450128] PM: suspend entry (deep)
R ###
[   47.455333] Filesystems sync: 0.000 seconds
[   47.460719] Freezing user space processes
[   47.466805] Freezing user space processes completed (elapsed 0.006 seconds)
[   47.473786] OOM killer disabled.
[   47.477008] Freezing remaining freezable tasks
[   47.482814] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[   47.490228] 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
[   47.559556] renesas-gbeth 15c30000.ethernet end0: Link is Down
[   47.561796] ------------[ cut here ]------------
[   47.561822] gpt_0_pclk_sfr already disabled
[   47.562021] WARNING: drivers/clk/clk.c:1188 at clk_core_disable+0xa4/0xac, CPU#3: sh/396
[   47.562109] Modules linked in: bluetooth sha256 ecdh_generic cfg80211 ecc rfkill panfrost drm_shmem_helper gpu_sched spi_rpc_if drm_kms_helper pwm_rzg2l_gpt rtc_isl1208 phy_rzg3e_usb3 rcar_canfd renesas_rpc_if can_dev fuse drm backlight ipv6
[   47.562463] CPU: 3 UID: 0 PID: 396 Comm: sh Not tainted 6.18.0-rc7-next-20251201-g6e9da3a50130-dirty #108 PREEMPT
[   47.562512] Hardware name: Renesas SMARC EVK version 2 based on r9a09g047e57 (DT)
[   47.562535] pstate: 604000c5 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   47.562576] pc : clk_core_disable+0xa4/0xac
[   47.562625] lr : clk_core_disable+0xa4/0xac
[   47.562669] sp : ffff800083a83a90
[   47.562688] x29: ffff800083a83a90 x28: ffff0000c9160000 x27: ffff8000826a5d50
[   47.562760] x26: ffff80008280bf28 x25: 0000000000000002 x24: ffff80007a9cf480
[   47.562828] x23: 0000000000000000 x22: ffff0000c08ee890 x21: 0000000000000002
[   47.562896] x20: ffff0000c0138200 x19: ffff0000c0138200 x18: 0000000000000030
[   47.562963] x17: ffff0000c4933280 x16: 0000000000000ffb x15: 00000000000000ba
[   47.563030] x14: fffffffffffc86df x13: 0a64656c62617369 x12: ffff8000822e6c48
[   47.563098] x11: 0000000000000058 x10: 0000000000000018 x9 : ffff8000822e6c48
[   47.563164] x8 : 00000000000001eb x7 : ffff80008233ec48 x6 : ffff80008233ec48
[   47.563231] x5 : 0000000000000001 x4 : 0000000000000000 x3 : 00000000ffffffff
[   47.563296] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000c9160000
[   47.563362] Call trace:
[   47.563381]  clk_core_disable+0xa4/0xac (P)
[   47.563439]  clk_disable+0x30/0x4c
[   47.563495]  rzg2l_gpt_suspend+0x100/0x140 [pwm_rzg2l_gpt]
[   47.563561]  device_suspend+0x140/0x3c8
[   47.563608]  dpm_suspend+0x1ac/0x2a4
[   47.563652]  dpm_suspend_start+0x54/0x70
[   47.563696]  suspend_devices_and_enter+0x1d4/0x590
[   47.563746]  pm_suspend+0x194/0x1c0
[   47.563789]  state_store+0x80/0xf4
[   47.563829]  kobj_attr_store+0x18/0x34
[   47.563875]  sysfs_kf_write+0x7c/0x94
[   47.563933]  kernfs_fop_write_iter+0x130/0x200
[   47.563986]  vfs_write+0x244/0x36c
[   47.564045]  ksys_write+0x70/0x108
[   47.564101]  __arm64_sys_write+0x1c/0x30
[   47.564160]  invoke_syscall+0x48/0x104
[   47.564205]  el0_svc_common.constprop.0+0xc0/0xe0
[   47.564250]  do_el0_svc+0x1c/0x28
[   47.564290]  el0_svc+0x34/0x108
[   47.564345]  el0t_64_sync_handler+0xa0/0xf0
[   47.564401]  el0t_64_sync+0x198/0x19c
[   47.564446] ---[ end trace 0000000000000000 ]---
[   47.564476] ------------[ cut here ]------------
[   47.564492] gpt_0_pclk_sfr already disabled
[   47.564680] WARNING: drivers/clk/clk.c:1188 at clk_core_disable+0xa4/0xac, CPU#3: sh/396
[   47.564748] Modules linked in: bluetooth sha256 ecdh_generic cfg80211 ecc rfkill panfrost drm_shmem_helper gpu_sched spi_rpc_if drm_kms_helper pwm_rzg2l_gpt rtc_isl1208 phy_rzg3e_usb3 rcar_canfd renesas_rpc_if can_dev fuse drm backlight ipv6
[   47.565088] CPU: 3 UID: 0 PID: 396 Comm: sh Tainted: G        W           6.18.0-rc7-next-20251201-g6e9da3a50130-dirty #108 PREEMPT
[   47.565142] Tainted: [W]=WARN
[   47.565159] Hardware name: Renesas SMARC EVK version 2 based on r9a09g047e57 (DT)
[   47.565180] pstate: 604000c5 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   47.565219] pc : clk_core_disable+0xa4/0xac
[   47.565264] lr : clk_core_disable+0xa4/0xac
[   47.565307] sp : ffff800083a83a90
[   47.565325] x29: ffff800083a83a90 x28: ffff0000c9160000 x27: ffff8000826a5d50
[   47.565397] x26: ffff80008280bf28 x25: 0000000000000002 x24: ffff80007a9cf480
[   47.565465] x23: 0000000000000000 x22: ffff0000c08ee890 x21: 0000000000000002
[   47.565533] x20: ffff0000c0138200 x19: ffff0000c0138200 x18: 0000000000000030
[   47.565600] x17: ffff0000c4933280 x16: 0000000000000ffb x15: 00000000000000ba
[   47.565667] x14: fffffffffffc90d7 x13: 0a64656c62617369 x12: ffff8000822e6c48
[   47.565735] x11: 0000000000000058 x10: 0000000000000018 x9 : ffff8000822e6c48
[   47.565803] x8 : 0000000000000216 x7 : ffff80008233ec48 x6 : ffff80008233ec48
[   47.565869] x5 : 0000000000000001 x4 : 0000000000000000 x3 : 00000000ffffffff
[   47.565933] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000c9160000
[   47.565999] Call trace:
[   47.566015]  clk_core_disable+0xa4/0xac (P)
[   47.566071]  clk_disable+0x30/0x4c
[   47.566126]  rzg2l_gpt_suspend+0x114/0x140 [pwm_rzg2l_gpt]
[   47.566183]  device_suspend+0x140/0x3c8
[   47.566228]  dpm_suspend+0x1ac/0x2a4
[   47.566272]  dpm_suspend_start+0x54/0x70
[   47.566317]  suspend_devices_and_enter+0x1d4/0x590
[   47.566363]  pm_suspend+0x194/0x1c0
[   47.566406]  state_store+0x80/0xf4
[   47.566446]  kobj_attr_store+0x18/0x34
[   47.566490]  sysfs_kf_write+0x7c/0x94
[   47.566544]  kernfs_fop_write_iter+0x130/0x200
[   47.566597]  vfs_write+0x244/0x36c
[   47.566654]  ksys_write+0x70/0x108
[   47.566710]  __arm64_sys_write+0x1c/0x30
[   47.566769]  invoke_syscall+0x48/0x104
[   47.566811]  el0_svc_common.constprop.0+0xc0/0xe0
[   47.566855]  do_el0_svc+0x1c/0x28
[   47.566895]  el0_svc+0x34/0x108
[   47.566948]  el0t_64_sync_handler+0xa0/0xf0
[   47.567004]  el0t_64_sync+0x198/0x19c
[   47.567048] ---[ end trace 0000000000000000 ]---
[   47.579777] Disabling non-boot CPUs ...
[   47.584685] psci: CPU3 killed (polled 0 ms)
[   47.590621] psci: CPU2 killed (polled 0 ms)
[   47.596917] psci: CPU1 killed (polled 0 ms)
[   47.599391] Enabling non-boot CPUs ...
[   47.599597] Detected VIPT I-cache on CPU1
[   47.599643] GICv3: CPU1: found redistributor 100 region 0:0x0000000014960000
[   47.599680] CPU1: Booted secondary processor 0x0000000100 [0x412fd050]
[   47.600536] CPU1 is up
[   47.600632] Detected VIPT I-cache on CPU2
[   47.600653] GICv3: CPU2: found redistributor 200 region 0:0x0000000014980000
[   47.600675] CPU2: Booted secondary processor 0x0000000200 [0x412fd050]
[   47.601231] CPU2 is up
[   47.601328] Detected VIPT I-cache on CPU3
[   47.601349] GICv3: CPU3: found redistributor 300 region 0:0x00000000149a0000
[   47.601370] CPU3: Booted secondary processor 0x0000000300 [0x412fd050]
[   47.602191] CPU3 is up
[   47.604890] pwm-rzg2l-gpt 13010000.pwm: PM: dpm_run_callback(): rzg2l_gpt_resume [pwm_rzg2l_gpt] returns -110
[   47.604917] pwm-rzg2l-gpt 13010000.pwm: PM: failed to resume: error -110
[   47.629303] dwmac4: Master AXI performs any burst length
[   47.629336] renesas-gbeth 15c30000.ethernet end0: No Safety Features support found
[   47.629377] renesas-gbeth 15c30000.ethernet end0: IEEE 1588-2008 Advanced Timestamp supported
[   47.629445] renesas-gbeth 15c30000.ethernet end0: configuring for phy/rgmii-id link mode
[   47.646424] dwmac4: Master AXI performs any burst length
[   47.646452] renesas-gbeth 15c40000.ethernet end1: No Safety Features support found
[   47.646484] renesas-gbeth 15c40000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported
[   47.646545] renesas-gbeth 15c40000.ethernet end1: configuring for phy/rgmii-id link mode
[   47.693377] usb usb1: root hub lost power or was reset
[   47.693385] usb usb2: root hub lost power or was reset
[   48.444830] OOM killer enabled.
[   48.447970] Restarting tasks: Starting
[   48.452416] Restarting tasks: Done
[   48.455897] random: crng reseeded on system resumption
[   48.461168] PM: suspend exit

[   50.414488] renesas-gbeth 15c30000.ethernet end0: Link is Up - 1Gbps/Full - flow control rx/tx

root@...rc-rzg3e:~#

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ