Received: by 10.223.176.5 with SMTP id f5csp1256832wra; Fri, 2 Feb 2018 14:06:35 -0800 (PST) X-Google-Smtp-Source: AH8x224UtdHZrQyRIJOgX0wS3D8OrfNFNORTYhPeVRU7RIMIRb5pkYju51XN8NZXKN5f8ZWZs1/V X-Received: by 2002:a17:902:6683:: with SMTP id e3-v6mr35820947plk.22.1517609195565; Fri, 02 Feb 2018 14:06:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517609195; cv=none; d=google.com; s=arc-20160816; b=HgG7sc+P9U+7JhBvCfV7j54yVYd68LkcEZrpn7BdDqa9Re6+eAQJu/tSOyf6uWadDC JWPiDhWJfs0fapJ27z+8uyDIlB4b8a0HMcrDnniJ/SU03OwcvBExI2NtMAmeh1IhVhVD bVibCqQitnd/z7FwJwb2PlEitn7qaEs2pzXphsXdzyCpklvI64aTaU66XAxyf67bA2WS 4ov8t5aziWdtWC3zWn1ouX5PWpY/kt9BwZ1w1nhhigUqIdVcISUG84V58NowSfZgQwNb HipsrIiV/RMnABcOzu5rJsGy1mRET3vqnzFFTQgvIplkEG7tgIwB2QhZIJujk32A/ym8 uqSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=44WWsfD22lBWY7FThFSK51mUuK9xXcbOHT/tZHLCcig=; b=bX3Ifg3sNc0LtrrW37TC9gJOGHSwwfFsVuOtY33/q4h0Tb3SbFMKzxeg67+mdrG2mm wNE3ORgjP4eknxnQk5aeMu0J4D/LAZwZUBqnRzIuZgmEraCWYhMeiU6ak8BzEvpxou3T +wkApVXqSeymKBxPB76R2WjVy5IAEa2xq9Bl05lDGRr8JLDX1u9mug0rMPDwIRel5m/7 jjDMLd2sDh9/e/I+3N8QLGTMsdN4P3sKBCVqp2CFy85/5iEVyRStgDnevOo/NE/ZVpnn nM3ZJadnM8hTJ7YLu8sg8OmDaYrvAmiWQ8M1vnM4v1n7FEbLo7C1+Y1Yc10a4sMdZlL2 0V5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=dKdobBFF; dkim=pass header.i=@codeaurora.org header.s=default header.b=L4vzkBm2; 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 c11-v6si1941097plr.611.2018.02.02.14.06.20; Fri, 02 Feb 2018 14:06:35 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=dKdobBFF; dkim=pass header.i=@codeaurora.org header.s=default header.b=L4vzkBm2; 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 S1753669AbeBBTez (ORCPT + 99 others); Fri, 2 Feb 2018 14:34:55 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:58560 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753109AbeBBTer (ORCPT ); Fri, 2 Feb 2018 14:34:47 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2435D6050D; Fri, 2 Feb 2018 19:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517600087; bh=zzBJNnnPZ4TvWmlpk7GAwEDqj56ytJek2dsuEB1bDEw=; h=Date:From:To:CC:Subject:References:In-Reply-To:From; b=dKdobBFFONVDRdUIUCo8l8zoN32UILzdOeU7FcHa8t2z2LmK4B21YNW91Hczl5sfZ bjN2L8PF/xx9dgAWrsf/I8hX+2s1+0fbPPAzfK9koOchUM3YpinMm4vwJEveDn+l7c ISa5OA5xE8SQzb/n8qMgHyhVFRUSnZ4rgBlVqSS0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.134.64.210] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: skannan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C6E1B6050D; Fri, 2 Feb 2018 19:34:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517600086; bh=zzBJNnnPZ4TvWmlpk7GAwEDqj56ytJek2dsuEB1bDEw=; h=Date:From:To:CC:Subject:References:In-Reply-To:From; b=L4vzkBm22A2qzQtScaOc9ADPwmYiHXaXNEpJhDJF3p4UW+t+UM9Weu817b2TbEGK+ XdW0Za3LLLyVJe+TqozMoNFLXdVDzVjMByYHzhTbgjOX2blbcCBbDrLUrW+8feSO7w pBj/hNNI2o8rD5CtwkLwqVqYq5Img3VWPv95mMvE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C6E1B6050D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=skannan@codeaurora.org Message-ID: <5A74BD55.5000402@codeaurora.org> Date: Fri, 02 Feb 2018 11:34:45 -0800 From: Saravana Kannan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: "Rafael J. Wysocki" CC: Bo Yan , viresh.kumar@linaro.org, sgurrappadi@nvidia.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cpufreq: skip cpufreq resume if it's not suspended References: <1516744675-21233-1-git-send-email-byan@nvidia.com> <1744712.rO4QOLozun@aspire.rjw.lan> <913f1715-bdd0-1c03-ad76-38be9d3d2298@nvidia.com> <17447147.z6jfkRxuEB@aspire.rjw.lan> In-Reply-To: <17447147.z6jfkRxuEB@aspire.rjw.lan> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/02/2018 03:54 AM, Rafael J. Wysocki wrote: > On Wednesday, January 24, 2018 9:53:14 PM CET Bo Yan wrote: >> >> On 01/23/2018 06:02 PM, Rafael J. Wysocki wrote: >>> On Tuesday, January 23, 2018 10:57:55 PM CET Bo Yan wrote: >>>> drivers/cpufreq/cpufreq.c | 4 ++++ >>>> 1 file changed, 4 insertions(+) >>>> >>>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c >>>> index 41d148af7748..95b1c4afe14e 100644 >>>> --- a/drivers/cpufreq/cpufreq.c >>>> +++ b/drivers/cpufreq/cpufreq.c >>>> @@ -1680,6 +1680,10 @@ void cpufreq_resume(void) >>>> if (!cpufreq_driver) >>>> return; >>>> >>>> + if (unlikely(!cpufreq_suspended)) { >>>> + pr_warn("%s: resume after failing suspend\n", __func__); >>>> + return; >>>> + } >>>> cpufreq_suspended = false; >>>> >>>> if (!has_target() && !cpufreq_driver->resume) >>>> >>> Good catch, but rather than doing this it would be better to avoid >>> calling cpufreq_resume() at all if cpufreq_suspend() has not been called. >> Yes, I thought about that, but there is no good way to skip over it >> without introducing another flag. cpufreq_resume is called by >> dpm_resume, cpufreq_suspend is called by dpm_suspend. In the failure >> case, dpm_resume is called, but dpm_suspend is not. So on a higher level >> it's already unbalanced. >> >> One possibility is to rely on the pm_transition flag. So something like: >> >> >> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c >> index dc259d20c967..8469e6fc2b2c 100644 >> --- a/drivers/base/power/main.c >> +++ b/drivers/base/power/main.c >> @@ -842,6 +842,7 @@ static void async_resume(void *data, async_cookie_t >> cookie) >> void dpm_resume(pm_message_t state) >> { >> struct device *dev; >> + bool suspended = (pm_transition.event != PM_EVENT_ON); >> ktime_t starttime = ktime_get(); >> >> trace_suspend_resume(TPS("dpm_resume"), state.event, true); >> @@ -885,7 +886,8 @@ void dpm_resume(pm_message_t state) >> async_synchronize_full(); >> dpm_show_time(starttime, state, NULL); >> >> - cpufreq_resume(); >> + if (likely(suspended)) >> + cpufreq_resume(); >> trace_suspend_resume(TPS("dpm_resume"), state.event, false); >> } > > I was thinking about something else. > > Anyway, I think your original patch is OK too, but without printing the > message. Just combine the cpufreq_suspended check with the cpufreq_driver > one and the unlikely() thing is not necessary. > I rather have this fixed in the dpm_suspend/resume() code. This is just masking the first issue that's being caused by unbalanced error handling. If that means adding flags in dpm_suspend/resume() then that's what we should do right now and clean it up later if it can be improved. Making cpufreq more messy doesn't seem like the right answer. Thanks, Saravana -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project