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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 D9E91C432C0 for ; Wed, 27 Nov 2019 20:38:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2140215A5 for ; Wed, 27 Nov 2019 20:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887081; bh=lq0PX3Vu7TeZOispeOZS+KeWZBBffeqQ/ZHaoCr8Tbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=F9EVzvysyOOoiF4orv2EdJV8oHpAiXrCQQhT4z/FgZBWKJFwjMUsyYU5lB/c+JJ3G VbNaE3pfrCT9JxiYHPx4tBGpuO9N3cGvnRsRndAgX95bV/CWqYGotU73PL8peXp5kP lBoBalgPfSimmqCv4QX6XhaH0aVMX5DG4ijoQaRc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728662AbfK0UiA (ORCPT ); Wed, 27 Nov 2019 15:38:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:41210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728644AbfK0Uh6 (ORCPT ); Wed, 27 Nov 2019 15:37:58 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 6B3BD217AB; Wed, 27 Nov 2019 20:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887077; bh=lq0PX3Vu7TeZOispeOZS+KeWZBBffeqQ/ZHaoCr8Tbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGdEfx6Q7o1AFzUXjcUDbmTq6FrHxW2n9AiqeUW1MPgF5PLoDpVP5QCzJq4BZ6KrL Ubc6uWyxt35p+IUFv20C/zJ6BHY4gx5scqTxKGYdoowOb5phYeU4hKYpBF//3eiwGR 4zRU6tkGXmJWehkfDeskvrd2P1tM70p4+0vmIjNc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bo Yan , Viresh Kumar , "Rafael J. Wysocki" , Lee Jones Subject: [PATCH 4.4 103/132] cpufreq: Skip cpufreq resume if its not suspended Date: Wed, 27 Nov 2019 21:31:34 +0100 Message-Id: <20191127203025.194756012@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127202857.270233486@linuxfoundation.org> References: <20191127202857.270233486@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bo Yan commit 703cbaa601ff3fb554d1246c336ba727cc083ea0 upstream. cpufreq_resume can be called even without preceding cpufreq_suspend. This can happen in following scenario: suspend_devices_and_enter --> dpm_suspend_start --> dpm_prepare --> device_prepare : this function errors out --> dpm_suspend: this is skipped due to dpm_prepare failure this means cpufreq_suspend is skipped over --> goto Recover_platform, due to previous error --> goto Resume_devices --> dpm_resume_end --> dpm_resume --> cpufreq_resume In case schedutil is used as frequency governor, cpufreq_resume will eventually call sugov_start, which does following: memset(sg_cpu, 0, sizeof(*sg_cpu)); .... This effectively erases function pointer for frequency update, causing crash later on. The function pointer would have been set correctly if subsequent cpufreq_add_update_util_hook runs successfully, but that function returns earlier because cpufreq_suspend was not called: if (WARN_ON(per_cpu(cpufreq_update_util_data, cpu))) return; The fix is to check cpufreq_suspended first, if it's false, that means cpufreq_suspend was not called in the first place, so do not resume cpufreq. Signed-off-by: Bo Yan Acked-by: Viresh Kumar [ rjw: Dropped printing a message ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/cpufreq.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1627,6 +1627,9 @@ void cpufreq_resume(void) if (!cpufreq_driver) return; + if (unlikely(!cpufreq_suspended)) + return; + cpufreq_suspended = false; if (!has_target())