From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EE78C2D0A8 for ; Mon, 28 Sep 2020 11:25:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3C5321D46 for ; Mon, 28 Sep 2020 11:25:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="1FazODGc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mFX2vgIw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3C5321D46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SNolBLPLm24Tg1TxUVbNKYmqBSkrVMpFSmflo13rZqU=; b=1FazODGctAnrVlPMtegFpytjj bty6VzUmb7wTpaueegVpaS2EA1zgSRnbdnEMRaDbBEJ2slqtJAkvhlXi8Gkn0xa0N7PBvFf29I4UY NTixYMzPlTV7UJPqX4Hm7YzIWfqpP0n1BYj0YvMhfxESs2ov1PnZCksMbYTkQXZWtQV6rG1BlfXkH rl9Unf9P3ilfSdstqJ0f0Reopi1g3N1nQcYoCqAQCMdBj78B596YgaFEmn0HSIYWYWvWQbVDwcZGA UuvckF2YSN+0L8pe8RglMPePGVpn/8XNIICQl456l3WOaWvQ7Q0xLp64kfg6OVKJuVQiRtD7k0vVe Ablx2ZFTg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMrG5-0001u4-7d; Mon, 28 Sep 2020 11:23:53 +0000 Received: from mail-ua1-x944.google.com ([2607:f8b0:4864:20::944]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMrG2-0001sv-6a for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2020 11:23:51 +0000 Received: by mail-ua1-x944.google.com with SMTP id g16so2059445uan.5 for ; Mon, 28 Sep 2020 04:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dPqyhHPvAKE8oFtG0HXSnceWMN8F9MOf0pO61krCb1Y=; b=mFX2vgIw/ymy13Qjh/G7aVRGOACw1Fj/ADWUfGlozDS641eSx1hWEkFSVu1esESKHB UgvUnxWEKkoyXHt2GQppOniC5F2M/aHpw+xrsCU17sCP31b/bVtTvUtUzBMuGtkJyCO4 9ZwaDtusG19u99CaKHkXc2xtSJnn8TFODC2YHyQo3Z6gziYVZkXmQ4vBrgNUIxjbZI4+ t97q6KS543YUmghrGRJDlHkbJ4o8HddYlWvtYRck7UAj/HYKrCGi+iChzCywW1I8gS0w T3Td0+hsZFLVw3kRqLj32n4oOnePgk7isZFeo5d404mzKKfz0KTHG0yUSnbck3JeA8cf UNmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dPqyhHPvAKE8oFtG0HXSnceWMN8F9MOf0pO61krCb1Y=; b=rE6PubhZiDtdIY64XsbbrQsMdoa25TgRQPzmccwDKtirbjuYHoQve+DGSD3XYvyThH 5uAcuoz4ba7Oet/aFKYW8xCVTKHU8ywf1THyW0nrRHD+yzlMxfVNEkStepCrEOTOryyX UD4vqPeiMTFtlAMtFKHsaraHugyUCSSyiBpwF8O2sCHnlWpSekP+4unkoktIvEgT+LrE KzdhShC+WIAxIZisJ6vgrO/dTyG1ggI97gD4Ykiz/a2AX1fvzcLiLQdLL3Nfz7dA51hl ItyX4Z48FUPigZEJOPSDbcIQmUsJodfhRSbQSjTAy6FSY+lC25SM3T/2wBocgAlc9QIp V8JQ== X-Gm-Message-State: AOAM5325W++ZMiSkCYvSBReHJhXIq9t0lH3Oeg5jqYcTLlOpTzAXlH+Z ereiq77YpgeGi9aVQISFSlZnl3mKJZAoYPejbm45JA== X-Google-Smtp-Source: ABdhPJwt5PJ9h/2t57J8+266psChAvJLx+l73d4OtTMrMI4/BajbmGg2qnHjsErwIH1mVybopUNZ9072O8Zy3kEiT7w= X-Received: by 2002:ab0:2904:: with SMTP id v4mr312369uap.15.1601292227436; Mon, 28 Sep 2020 04:23:47 -0700 (PDT) MIME-Version: 1.0 References: <1593615328-5180-1-git-send-email-fabrice.gasnier@st.com> <045e9e34-f1e0-087b-bc5b-44440db6be27@st.com> <20200926161732.72af96e3@archlinux> In-Reply-To: <20200926161732.72af96e3@archlinux> From: Ulf Hansson Date: Mon, 28 Sep 2020 13:23:11 +0200 Message-ID: Subject: Re: [RESEND PATCH v2] iio: adc: stm32-adc: fix runtime autosuspend delay when slow polling To: Jonathan Cameron , Fabrice Gasnier X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200928_072350_252836_9CA3D5C8 X-CRM114-Status: GOOD ( 39.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: olivier.moysan@st.com, Alexandre Torgue , linux-iio@vger.kernel.org, "Rafael J. Wysocki" , "Rafael J. Wysocki" , Linux Kernel Mailing List , Maxime Coquelin , linux-stm32@st-md-mailman.stormreply.com, Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Jonathan, Fabrice, On Sat, 26 Sep 2020 at 17:17, Jonathan Cameron wrote: > > On Wed, 16 Sep 2020 12:28:00 +0200 > Fabrice Gasnier wrote: > > > On 7/1/20 4:55 PM, Fabrice Gasnier wrote: > > > 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 > > > --- > > > Changes in v2: > > > - Use runtime_idle callback in stm32-adc-core driver, instead of refreshing > > > last_busy from the child (for the parent) at many place. Initial patch v1 > > > looked like "somewhat adhoc solution" as commented by Jonathan. > > > > Hi all, > > > > Gentle reminder for this patch. Earlier discussions on it were as per > > [1] and [2]. > > > > Ideally, Jonathan was looking for an ack from Rafael on this patch. > > This is a long pending issue. I'd like to progress on this. > > > > [1] https://patchwork.kernel.org/patch/11349841/ > > [2] https://lkml.org/lkml/2020/6/11/279 > > Fabrice, I think this one has sat waiting for inputs for > too long. Hence I'm going to take a slight gamble that you are correct > on doing the fix this way (I'm reasonably convinced) My apologies for the huge and unacceptable delay. I have re-started looking at this several times, but just never got the point of writing a proper reply. Let me do this now, better late than never I guess. In general, I think this problem (nicely described by Fabrice), should be solved in the runtime PM core, without having to involve drivers for parents/childs. I have looked into that, but I don't have a patch to propose, at least not yet. FYI, I have also stumbled over the same problem, for a card controller (parent), serving both sd and memstick cards. For that case, we simply decided to skip using autosuspend for the child devices (represented by an sd host and a memstick host), not optimal, but there were other reasons why we decided for this approach as well. That said, I also think the solution proposed in $subject patch, which uses the ->runtime_idle() callback for the parent is perfectly fine, at least until we have figured out something that can replace it. > > Applied to the fixes-togreg branch of iio.git. > It won't go in for 5.9 now, so we have a bit of time for any last > minute comments. Feel free to add: Reviewed-by: Ulf Hansson Kind regards Uffe > > Thanks, > > Jonathan > > > > > Please advise, > > Thanks in advance, > > Fabrice > > > > > --- > > > 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 0e2068e..3586369 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 = { > > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel