Received: by 10.223.176.5 with SMTP id f5csp636546wra; Fri, 2 Feb 2018 03:44:33 -0800 (PST) X-Google-Smtp-Source: AH8x2275sLA6vTuEAlLHHWYXiHojtG6YvSsyqoGoXvEIzVi3Zh1W/iuC9TQXkVN2ba+v7K7gT2Bi X-Received: by 2002:a17:902:ab8f:: with SMTP id f15-v6mr34600288plr.214.1517571873780; Fri, 02 Feb 2018 03:44:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517571873; cv=none; d=google.com; s=arc-20160816; b=HNSAs4/9Ei5LVGLqw80puzD40q360Lm4vq5QCgB9NiCaMu2/ZWVyB5m8CwK1xPzbSv HWFkg6im6vAmFJfQEobAC06ocBPpAPGCV2iIxXcWkMjk7XRdWYsHI8cH9VVAstFHFVVV GhrBURloXX0OUgPFg/+8/L3wLJPG9P0nTAOsrC3QYOLoL67HbzwV5SESRIJ/u3UaWtrO KoIypPWy6gT0DTGJ7Txg9jvqihRc6x0HKjgGPGsI6RgbUJ0VV2ANwOs58kGHtrs1ZYNk u63XedVoWRkll02SlO7Uvj9cCNmuUlwzIHvW2coVPyRhIeJAcajGiRL2qkWnu7Iw7W35 VuYA== 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 :content-language:mime-version:user-agent:date:message-id:subject :from:cc:to:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=cRW8Iw4MC3iQFdjGn58lwDqSYFjH0COX5vIH2BTyugg=; b=ym8Ll3kXIkn/nRK1P1JWbGqIOTpErv/DnXP8noZhtYG/VBQCwoE6r3zeiHX7stV/Tj fSrLaD1TM7PEoDpi1JJFFeamoG41cQI+spG6Akf3DL8WARKYoIN8j6MfLxRute4DFWEQ Iyd3VZQB3FQf+BpdloIKAGrRscalc7T2PIMJpwcEXKxX3Cyo2dQOQWev5hfER/S4movJ hSpEKVJMX+Zj0BcvAJjOiAlhdZEQaDm5PG6EBo96zQ3YzMkCXJYc+TDVkW2kM3zPzkaj YuP27h/0iSHLedjC+sm7XrubgaI7mNGRaKvFy05gNSF/u8Z58FP0GcQgvJcrPpkGSLsO EagQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=fQ6aCZNl; dkim=pass header.i=@codeaurora.org header.s=default header.b=HkbpFpmq; 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 a190si1314947pge.778.2018.02.02.03.44.19; Fri, 02 Feb 2018 03:44:33 -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=fQ6aCZNl; dkim=pass header.i=@codeaurora.org header.s=default header.b=HkbpFpmq; 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 S1751735AbeBBLmT (ORCPT + 99 others); Fri, 2 Feb 2018 06:42:19 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:60766 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750773AbeBBLmN (ORCPT ); Fri, 2 Feb 2018 06:42:13 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 28BCC606AC; Fri, 2 Feb 2018 11:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517571733; bh=o0yL/0/2q9oXruQ4/z3rHQT1vbvrhm2Bn2lkxPt0Zrs=; h=To:Cc:From:Subject:Date:From; b=fQ6aCZNliOAE2WBNw4OR9wBfrUwKzcsX+1ZGOcAjQ/QFUc1zsAYHHMsWnRnSAgYTU 8DeVV1q4fxmETujQyQo2+82xC1I0Cn3Djj6/xIeYkrR/R29HoyeI6ZrD9axNUtOYw4 6V2fdxOusT+CdZe5KII6eOW1gnDSN4zUdffSPCNc= 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.204.79.19] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: prsood@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8524A606AC; Fri, 2 Feb 2018 11:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517571732; bh=o0yL/0/2q9oXruQ4/z3rHQT1vbvrhm2Bn2lkxPt0Zrs=; h=To:Cc:From:Subject:Date:From; b=HkbpFpmqwJyI+/R9RC159qUD83CrmgIOwQhOEN3gU2su3vhpAp7SX1EFv9d+y2yHS VNP35ZinmtlrdoN/rm+hV2aycNqCUNJDulpinriqwzMUaFXk2t8JYL45v6NZWprFks gFAVUkUZt1LEF0ZSY51qgUsuu+eyOvqUQLhuRwxY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8524A606AC 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=prsood@codeaurora.org To: viresh.kumar@linaro.org Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, gkohli@codeaurora.org, linux-arm-msm@vger.kernel.org From: Prateek Sood Subject: Query related to usage of cpufreq_suspend() & cpufreq_resume Message-ID: Date: Fri, 2 Feb 2018 17:11:58 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Viresh, One scenario is there where a kernel panic is observed in cpufreq during suspend/resume. pm_suspend() suspend_devices_and_enter() dpm_suspend_start() dpm_prepare() Failure in dpm_prepare() happend with following dmesg: [ 3746.316062] PM: Device xyz not prepared for power transition: code -16 [ 3746.316071] PM: Some devices failed to suspend, or early wake event detected pm_suspend() suspend_devices_and_enter() dpm_suspend_start() dpm_prepare() //failed dpm_resume_end() dpm_resume() cpufreq_resume() cpufreq_start_governor() sugov_start() cpufreq_add_update_util_hook() After failure in dpm_prepare(), dpm_resume() called cpufreq_resume(). Corresponding cpufreq_suspend() was not called due to failure of dpm_prepare(). This resulted in WARN_ON(per_cpu(cpufreq_update_util_data, cpu)) in cpufreq_add_update_util_hook() and cpufreq_add_update_util_hook->func being inconsistent state. It caused crash in scheduler. Following are some of the ways to mitigate this issue. Could you please provide feedback on below two approaches or suugest a better way to fix this problem. -----------------------8<------------------------------ Co-developed-by: Gaurav Kohli Signed-off-by: Gaurav Kohli Signed-off-by: Prateek Sood diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 02a497e..732e5a2 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1038,6 +1038,7 @@ void dpm_resume(pm_message_t state) { struct device *dev; ktime_t starttime = ktime_get(); + bool valid_resume = false; trace_suspend_resume(TPS("dpm_resume"), state.event, true); might_sleep(); @@ -1055,6 +1056,7 @@ void dpm_resume(pm_message_t state) } while (!list_empty(&dpm_suspended_list)) { + valid_resume = true; dev = to_device(dpm_suspended_list.next); get_device(dev); if (!is_async(dev)) { @@ -1080,7 +1082,8 @@ void dpm_resume(pm_message_t state) async_synchronize_full(); dpm_show_time(starttime, state, 0, NULL); - cpufreq_resume(); + if (valid_resume) + cpufreq_resume(); trace_suspend_resume(TPS("dpm_resume"), state.event, false); } --------------------8<-------------------------------------- Signed-off-by: Prateek Sood diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 421f318..439eab8 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1648,7 +1648,7 @@ void cpufreq_suspend(void) { struct cpufreq_policy *policy; - if (!cpufreq_driver) + if (!cpufreq_driver || cpufreq_suspended) return; if (!has_target() && !cpufreq_driver->suspend) @@ -1683,7 +1683,7 @@ void cpufreq_resume(void) struct cpufreq_policy *policy; int ret; - if (!cpufreq_driver) + if (!cpufreq_driver || !cpufreq_suspended) return; cpufreq_suspended = false; Thanks -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project