Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp277576pxx; Wed, 28 Oct 2020 04:49:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvSqJ4EFJvG66qoISte3P628Z5xskvACnK2+5ZoxF7D8Frmu6aF5X6QOeu8Qvi84fKk7NH X-Received: by 2002:a17:906:9588:: with SMTP id r8mr7301547ejx.389.1603885793273; Wed, 28 Oct 2020 04:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603885793; cv=none; d=google.com; s=arc-20160816; b=PHRMlYwCciJTgQEp8CrGp16pPcxV+DgYuAEGvPObAfB1ENfXWc2m1fy6N9mxluci1M nEPa6ltpMThXp6cSMX6GL8TJ5/6ZMx+mjOa3Y0HqWUGdWHpzbdEHKN2+L2aq3BIOIZZW ZJLPZ49A9ZXm8BKhMYP856VXW0itPKr75xu8piD6u1yf/1QfSOj9W15pRhIXIxhu1KXy 1Zvr3uoHtCieabPI8c/yfyOH93vw/ktPIdnFprB50aPmhs+BymFA38tH4hLWijuTtBKn XwdACEPpF5hb4V56Wga4N5QA8QYgpCu3lRSWFGWIPrzP1sONd7hpwA+sIVyrhw762TRK GPDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U9EG++aN+v5ydKAc4JJ+BUkyB7OjBkU3G5xT2bvg4so=; b=huGXi4bSIF7RFLangQQHNSt1LKxe1zZLVRTg13ymtefEHI87nmyL2ViotXmzS7jrz5 VtnLm2Bml1GbROF1J4Yq7vgIwFNtoXJ7Neq1LIv4C6IakjsGjbVXlgdVvi5lr1/270/f J7wvzDI8zLG+DJPc8VxGLzZTJ/FmX1+9KjOBzxCWgflcM/IjQpUXF+1OzjIqC6Jpyn8j VJmS0rhPBU296js11ZXR/sX6BemjP/36YghqJKKsTIj6CzNzTK9WFBME4k3uFqyE+BrV hNiMYki9/lQGLmrcOLYHzqfb1hvBd7nE4DS0sN+lPYkd4Xb2iCGEDzn09FRTMUcuoiJR rlvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C0nU+G8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si2879649ejg.48.2020.10.28.04.49.31; Wed, 28 Oct 2020 04:49:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C0nU+G8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1794506AbgJ0PMK (ORCPT + 99 others); Tue, 27 Oct 2020 11:12:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:34750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388127AbgJ0PBE (ORCPT ); Tue, 27 Oct 2020 11:01:04 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7DF1322283; Tue, 27 Oct 2020 15:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810863; bh=hee3vS4xuxMewJIgjLMyatYaNaxjQVs7SmePoBuLgQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C0nU+G8mDdXBHT7oaf8VydDXJDTpAWcrf2D0LikB5KsvPdr9lhNi+YgetoWBEyM1G qY0iJWhHXA1iMrlL7Win7MF+zIzHLsz/h471NOhKow+y5X6AbpcSrgmnuEyRY1ynrS +Ssl1AXUm/sKfguaeiQLFxZmHVRKjqo+YlAtwGOA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabrice Gasnier , Ulf Hansson , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.8 290/633] iio: adc: stm32-adc: fix runtime autosuspend delay when slow polling Date: Tue, 27 Oct 2020 14:50:33 +0100 Message-Id: <20201027135536.273702364@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabrice Gasnier [ Upstream commit c537d3457542a398caa1fe58e0976c5f83cf7281 ] When the ADC is runtime suspended and starting a conversion, the stm32-adc driver calls pm_runtime_get_sync() that gets cascaded to the parent (e.g. runtime resume of stm32-adc-core driver). This also kicks the autosuspend delay (e.g. 2s) of the parent. Once the ADC is active, calling pm_runtime_get_sync() again (upon a new capture) won't kick the autosuspend delay for the parent (stm32-adc-core driver) as already active. Currently, this makes the stm32-adc-core driver go in suspend state every 2s when doing slow polling. As an example, doing a capture, e.g. cat in_voltageY_raw at a 0.2s rate, the auto suspend delay for the parent isn't refreshed. Once it expires, the parent immediately falls into runtime suspended state, in between two captures, as soon as the child driver falls into runtime suspend state: - e.g. after 2s, + child calls pm_runtime_put_autosuspend() + 100ms autosuspend delay of the child. - stm32-adc-core switches off regulators, clocks and so on. - They get switched on back again 100ms later in this example (at 2.2s). So, use runtime_idle() callback in stm32-adc-core driver to call pm_runtime_mark_last_busy() for the parent driver (stm32-adc-core), to avoid this. Fixes: 9bdbb1139ca1 ("iio: adc: stm32-adc: add power management support") Signed-off-by: Fabrice Gasnier Reviewed-by: Ulf Hansson Link: https://lore.kernel.org/r/1593615328-5180-1-git-send-email-fabrice.gasnier@st.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/stm32-adc-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c index 0e2068ec068b8..358636954619d 100644 --- a/drivers/iio/adc/stm32-adc-core.c +++ b/drivers/iio/adc/stm32-adc-core.c @@ -794,6 +794,13 @@ static int stm32_adc_core_runtime_resume(struct device *dev) { return stm32_adc_core_hw_start(dev); } + +static int stm32_adc_core_runtime_idle(struct device *dev) +{ + pm_runtime_mark_last_busy(dev); + + return 0; +} #endif static const struct dev_pm_ops stm32_adc_core_pm_ops = { @@ -801,7 +808,7 @@ static const struct dev_pm_ops stm32_adc_core_pm_ops = { pm_runtime_force_resume) SET_RUNTIME_PM_OPS(stm32_adc_core_runtime_suspend, stm32_adc_core_runtime_resume, - NULL) + stm32_adc_core_runtime_idle) }; static const struct stm32_adc_priv_cfg stm32f4_adc_priv_cfg = { -- 2.25.1