From patchwork Tue Nov 26 13:48:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 180203 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp4657609ilf; Tue, 26 Nov 2019 05:48:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwIcmgFyT7Qt/DldyB5IgMTLKMNjxsNPi3ovTj2WuBWhHu+U2FQUOLZu6QTuMcoOr0tGMZt X-Received: by 2002:aa7:db0f:: with SMTP id t15mr25510048eds.115.1574776137616; Tue, 26 Nov 2019 05:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574776137; cv=none; d=google.com; s=arc-20160816; b=0+Cfbrh3Y3hc2i87Lhbl0jXaUGrn6f7zJEKqSbcsj2dm0QMn1ohJD9IV+g/BZVQKMZ 573sZgGwdH+dnNIzeqRYYXwybLUPTqxX9rQs0IQ5ENsBDeMnmEiXtpnpbdWFZmvjl/x2 l3441HLl6EHyQ96LsprarsSMtpzpwSa0SuB20LwS8Tg4mhr++AzVwHAFZB42FRIPY36A ohDEyJ7fn15ml2Lc1W1Un5IxVOgXdrgrOBF4dcLvVsfpPRTYAjV6bbRxArIMZzuraXst WpdGCpBACnkw0f4Y2uB1QBDPdYDp+XrXsxNksptbuEXbINgMmH7RWzHK0LJXuyofNGAf li3w== 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:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=o6tdnQdXhY6/zbnPRQz5gsdIvhllvIceiXLYdtiRQVc=; b=H2re+KLkU5RJLNAd23QWDMeI7q1/wFODiw16WiWLuB+2d+YRsbaNmEvilEWPniwNbP exPJM7613tu1cWAPDdzn+kUwapte2XQQLVVmGjDtab9RJdxFYRxKKPwqsTKLyhM+jLU8 xn8vQ3zbw3sG885TnoPWeMaRXMvMLqzwqZN3tw64sUrJzuMth3CAsZHsOTcaAcwSRfzD vQizjtl39TcGU3axInLZgTgcW0A2WtMuZi3HAzWvbamjOmsg6PZ7EBEH85maR9/4Am5O H4mV+XDAw3MxN2U8Dmgnn0D53Uv72Ls1yGuBgHbt5Ghmi/PMiTxFJdwiQQ6Yhc5Pezvv BfUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yexc471G; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u14si741772edy.375.2019.11.26.05.48.57; Tue, 26 Nov 2019 05:48:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=Yexc471G; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727807AbfKZNs4 (ORCPT + 15 others); Tue, 26 Nov 2019 08:48:56 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39016 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbfKZNs4 (ORCPT ); Tue, 26 Nov 2019 08:48:56 -0500 Received: by mail-wr1-f67.google.com with SMTP id y11so19418243wrt.6 for ; Tue, 26 Nov 2019 05:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=o6tdnQdXhY6/zbnPRQz5gsdIvhllvIceiXLYdtiRQVc=; b=Yexc471GQhKXS9R7cWIqe9+fqxo4Hr7jdQ4HUYzls0LXnptQl2pL7m0R2tPEthUw7K 3d38dV/1TbClXFdeFNQtEiV1pj4NXXJtFU1Z+bwJ4Fqlk4FIsRUTEnnjhGjMwqwr/yrs 82QkjjkADkZ0RSveNzA9vO3cica32CcyO9a6ahBhX2oxPgMlQrSaRsBSjPKkuIITygMP InNZJu/2A74pU6BU6R3NJTyLGJxJ9xM+Lv8rUCk14lpfRA4H84jF4AGQ1MaXBxWSD84Q A8L6D5Uatj83LB3sUDbcU+FuHMBUP3/NML5LBDdLPF8LY71biZuf+Mqp/yGu4mFqixA1 mHcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o6tdnQdXhY6/zbnPRQz5gsdIvhllvIceiXLYdtiRQVc=; b=hAVeDAQ3TJWWHLMnusBK7B/IhRcT9jXsEU2CNqKVM1yujsdpFCkpW8odzDInvLSz63 uj0GLoRtETnPuJ1okrKqnzCS/ef9iaHHy/vSJqU/PmSMe6+7d9jW/z69LbDqSymX5GZJ GeVcCNdw+r0T99HevdJXYDZLdhg4xc4fyE7UpLDKXtPeJwYziN4hVIUbscUg7q9AHQqw amsaXBmz6Sd+UzXWDbsw7Dao8JSNqIoJi9Y6UKBhyrhEEpacyXkdbIZgEVGnJqQ2Z/U/ RqLKMu3uMWfCBnyH50BBEIqUrybXZk0UIIrAOHnSejELLgHJ0yYKccNZAdN2HXVm7Ez7 EaWQ== X-Gm-Message-State: APjAAAXSOHU7VBfcsMyQXou0iY8jqWzuyhFj6u2V/5KPZW6+4Ri1Fjjp YS3IPCarAifgI+9tHcgH4eOFMQPW1Mo= X-Received: by 2002:a5d:4810:: with SMTP id l16mr21688298wrq.127.1574776132261; Tue, 26 Nov 2019 05:48:52 -0800 (PST) Received: from localhost.localdomain ([95.149.164.72]) by smtp.gmail.com with ESMTPSA id m9sm14374131wro.66.2019.11.26.05.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 05:48:51 -0800 (PST) From: Lee Jones To: stable@vger.kernel.org Subject: [PATCH 4.19 4/5] cpufreq: Skip cpufreq resume if it's not suspended Date: Tue, 26 Nov 2019 13:48:29 +0000 Message-Id: <20191126134830.12747-4-lee.jones@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191126134830.12747-1-lee.jones@linaro.org> References: <20191126134830.12747-1-lee.jones@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bo Yan [ Upstream commit 7815c05f24b49fe6e70505905e3773cd27c17b6c ] 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 --- drivers/cpufreq/cpufreq.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.24.0 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 4aa3c5331666..52fc08a92bb9 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1673,6 +1673,9 @@ void cpufreq_resume(void) if (!cpufreq_driver) return; + if (unlikely(!cpufreq_suspended)) + return; + cpufreq_suspended = false; if (!has_target() && !cpufreq_driver->resume)