Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5507789ima; Tue, 5 Feb 2019 13:00:29 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib5m0c2EKfL8NBgKQ9ZmHTmpn4CjCxO1AL/prOEouNRIKw9D4mquG1WiNsSJvSVdmzgkuK7 X-Received: by 2002:aa7:8608:: with SMTP id p8mr7066840pfn.125.1549400428690; Tue, 05 Feb 2019 13:00:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549400428; cv=none; d=google.com; s=arc-20160816; b=hkIuGF4vR/atA8RTIrlemB5z1uzTlDzf+S+ChaUzU/dLgjNxujuZPkk305LSzKR+d4 DOnIZQACVrkdzXYYhhkNDRVxABcgg1oFG1SKp+pftSfJiYJYna4NMJVfbvgLyt0vuLLm bJEAHyQ6xx3HH/CWcY8ZaSUnHO2BHXIsxvxj9lQjos3GQlgDoXJgXZRLws1+n9pdIItd i6rGEyg0hWRh+Lf3trhSdGD5I9MIe2mE9EsaQ4PjO21K37L8QxtpEXLRJL54WDt37ZPx CN7CTP0rM35vWf7feMfwWKl0GGD+24cll77mOnQU3rxmrMRtqRpRvl9rG1Otk+bB0X9Z 7wrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=dsxxGbO6XKEPbs6aJln3IYyKD8C6d+rXu+Haa9SoC9I=; b=On9pi2q1avsREeUItR0hA+IfJnGbOhb4vrqycEHtqHkAsW0P+u8uR0cm3ezvtGJkFo onTE5tJB9pHeM2OkuR6dV+E0+LQhzW2nKyJpY89Lz98T/gP4Ya5sgWk3/4iU66wX4VSk Dw6VsEOt0v6F92Dfzs94t1C9bFIZ5asVvBTD25FAcA0xSegDHzinKlZjPrQ3XWIjjwIY 2ZtkzXu6Cn0TpucN+GcGXw1C5Ifn2ATEHcw3WTOztW9I/TkxfUV4E7r9kooZDMih0cqg qxOqkLXFBbELlibuzjgPO8ealG44NddqitGNnOVcBu0IWQRg6365HO0VOvoNc2p4IMh4 BMog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si1637857pgv.426.2019.02.05.13.00.11; Tue, 05 Feb 2019 13:00:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728868AbfBEUrp (ORCPT + 99 others); Tue, 5 Feb 2019 15:47:45 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:56913 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbfBEUro (ORCPT ); Tue, 5 Feb 2019 15:47:44 -0500 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gr7d0-00038p-P4; Tue, 05 Feb 2019 21:47:34 +0100 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1gr7cy-0005Ed-MN; Tue, 05 Feb 2019 21:47:32 +0100 Date: Tue, 5 Feb 2019 21:47:32 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Fabrice Gasnier Cc: jic23@kernel.org, thierry.reding@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, vilhelm.gray@gmail.com, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH 2/4] pwm: stm32-lp: Add power management support Message-ID: <20190205204732.zrbhgyxnvjbwfyw4@pengutronix.de> References: <1549370429-19116-1-git-send-email-fabrice.gasnier@st.com> <1549370429-19116-3-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1549370429-19116-3-git-send-email-fabrice.gasnier@st.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, Feb 05, 2019 at 01:40:27PM +0100, Fabrice Gasnier wrote: > Add suspend/resume PM sleep ops. When going to low power, disable > active PWM channel. Active PWM channel is resumed, by calling > pwm_apply_state(). This is inspired by Thierry's comment in [1]. > Don't touch inactive channels, as it may be used by other LPTimer MFD > child driver. > [1]https://lkml.org/lkml/2017/12/5/175 > > Signed-off-by: Fabrice Gasnier > --- > drivers/pwm/pwm-stm32-lp.c | 38 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c > index 0059b24c..0c40d48 100644 > --- a/drivers/pwm/pwm-stm32-lp.c > +++ b/drivers/pwm/pwm-stm32-lp.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -20,6 +21,8 @@ struct stm32_pwm_lp { > struct pwm_chip chip; > struct clk *clk; > struct regmap *regmap; > + struct pwm_state suspend; > + bool suspended; > }; > > static inline struct stm32_pwm_lp *to_stm32_pwm_lp(struct pwm_chip *chip) > @@ -223,6 +226,40 @@ static int stm32_pwm_lp_remove(struct platform_device *pdev) > return pwmchip_remove(&priv->chip); > } > > +#ifdef CONFIG_PM_SLEEP > +static int stm32_pwm_lp_suspend(struct device *dev) > +{ > + struct stm32_pwm_lp *priv = dev_get_drvdata(dev); > + > + pwm_get_state(&priv->chip.pwms[0], &priv->suspend); > + priv->suspended = priv->suspend.enabled; > + > + /* safe to call pwm_disable() for already disabled pwm */ > + pwm_disable(&priv->chip.pwms[0]); > + > + return pinctrl_pm_select_sleep_state(dev); IMHO a PWM should not stop if the PWM user didn't call pwm_disable() (or pwm_apply_state() with .enabled = false). I don't understand all the PM details, but I think there is no defined order in which devices are signalled to suspend. If so the PWM might be stopped before its consumer. Then the PWM changes state without the consumer being aware of that. I understand Thierry's position in the link you provided in the commit log consistant with my position here. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |