Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp3948299pjo; Tue, 3 Mar 2020 09:56:33 -0800 (PST) X-Google-Smtp-Source: ADFU+vvVPEqQQCVBSgkWuT+24K/G8ucokt2dFWLnGG9/44xLvHeY5fJsWDOeO/Q7M/ezAVmvw1Hn X-Received: by 2002:aca:75d2:: with SMTP id q201mr1257749oic.81.1583258193407; Tue, 03 Mar 2020 09:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583258193; cv=none; d=google.com; s=arc-20160816; b=Dupg093PJEL2TUIEqqiHe81t8xnLptZj5kc57Pf4rfdzwUF0sCEdQfNwEIY0SGHbYf b6ZG5N+Kxjqr97v5aiUvO8+zE8MwYtLInU7+9FmhwImpnoLwce4Lxz226RZVWH/82kIc 4YfNw5HogHqay8WnjJ6Tr9cRIsA4mIWgsXBQ7dxWey3HBGpHV+kV4CAeS6LZx9MWDvAf 1umv4pFj+aHWI/ZE9okQXBkzSYggfnEO2C826MNA6q3/UgAuZ+UCGvBsMPzeTpmChNZE amhxBnHDJINsp4FH/WLAjg9Bv0Z5YzyqZioi9F7bCFsFi8YxEdDjqOE+ZMe2WXo7iV/C xRnA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=njxEYfRl8medduhEdDUx+lmF02v4CMDL5CgtmkHmnhQ=; b=Pzo2zaRSqOG2DX+Uq2hwwxatZFNow0dP1/xdlxP8cgbE63MovvJXB4YyIvciSQndk6 mST2JoQzhS7cK7MGpQlMbb9JLtmr+nsJAS6Lqo1xP978FApfWka5HSyrryeFe8ZKQaHx a6kT8qto2HF2zhSBWQNIAtNx9SFXhuE5cZ6eUTir51aKYpTA+zl6tmbxRW2XovOaspEI K2lAQ1F0+VzWmXVzmiwuHZMxWU/QOL3bGNW+VAoFO/lQXQ9E3v5NY0cpSjrG5DDRZ9WR OOO4SORE8G0hazrRPDOWosj0N2cosAmZmGbqlE//fyojJk/Ej5nW+kptrQjEqo9PMV2Z 0GuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2cB+Hywv; 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 p7si8622166ota.299.2020.03.03.09.56.21; Tue, 03 Mar 2020 09:56: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=@kernel.org header.s=default header.b=2cB+Hywv; 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 S1732771AbgCCRzt (ORCPT + 99 others); Tue, 3 Mar 2020 12:55:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:37454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729240AbgCCRzk (ORCPT ); Tue, 3 Mar 2020 12:55:40 -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 4168F206D5; Tue, 3 Mar 2020 17:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583258139; bh=rkezNTsilgSGKrW4OUz+0tZo+L5uoL6GV1O/cTXX1GU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2cB+Hywv6HZvgkUVaHyof1vNzQSiQ/wrFRopSBTpYJSZfDUel0ZOoDXrxUPWu8vrR Q/aSOq588RMZMAFY6ET2OxkkAizIRuUAGO4fpxFENX/TO4jO9AFMt8w9OqVHGQFtQt bsnYJv2l1f8yFodMS/BPwdEIklSaducuYMEJbZFU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Artem Bityutskiy , "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 5.4 085/152] cpufreq: Fix policy initialization for internal governor drivers Date: Tue, 3 Mar 2020 18:43:03 +0100 Message-Id: <20200303174312.215998619@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174302.523080016@linuxfoundation.org> References: <20200303174302.523080016@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki commit f5739cb0b56590d68d8df8a44659893b6d0084c3 upstream. Before commit 1e4f63aecb53 ("cpufreq: Avoid creating excessively large stack frames") the initial value of the policy field in struct cpufreq_policy set by the driver's ->init() callback was implicitly passed from cpufreq_init_policy() to cpufreq_set_policy() if the default governor was neither "performance" nor "powersave". After that commit, however, cpufreq_init_policy() must take that case into consideration explicitly and handle it as appropriate, so make that happen. Fixes: 1e4f63aecb53 ("cpufreq: Avoid creating excessively large stack frames") Link: https://lore.kernel.org/linux-pm/39fb762880c27da110086741315ca8b111d781cd.camel@gmail.com/ Reported-by: Artem Bityutskiy Cc: 5.4+ # 5.4+ Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/cpufreq.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1071,9 +1071,17 @@ static int cpufreq_init_policy(struct cp pol = policy->last_policy; } else if (def_gov) { pol = cpufreq_parse_policy(def_gov->name); - } else { - return -ENODATA; + /* + * In case the default governor is neiter "performance" + * nor "powersave", fall back to the initial policy + * value set by the driver. + */ + if (pol == CPUFREQ_POLICY_UNKNOWN) + pol = policy->policy; } + if (pol != CPUFREQ_POLICY_PERFORMANCE && + pol != CPUFREQ_POLICY_POWERSAVE) + return -ENODATA; } return cpufreq_set_policy(policy, gov, pol);