Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp311313ybf; Wed, 26 Feb 2020 13:40:09 -0800 (PST) X-Google-Smtp-Source: APXvYqx4OBshpS9uoGY/h0pse0809ZzIN2CZiUICk70cflPL8prrxFw061t24Xh+FYPYy3HV0KSS X-Received: by 2002:aca:d610:: with SMTP id n16mr895072oig.108.1582753209580; Wed, 26 Feb 2020 13:40:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582753209; cv=none; d=google.com; s=arc-20160816; b=Szca2HGCSfthVBUyGwP34mbINDY2Lf8NLJs1hRaQon3Le8xTHKPFEJI8EM/SCNPGSa kiLG2mX5HBktUDJxlnQnj2qt/3LAVF9PW5A13F9L0du9chMr23k46Ebd0NSjDCGLoig5 kHOT1cFBRQzlMyvJ+3tm1yRWRdrZjZd7INrUSll8Zd2WwK/KCYoxrb2lQ6wNkmphFf7a uZEsVcch4+LDERLB+Q7WDvZcmI1nZrp+phd+Beq6M0dQPk3aWlIS/JQ5uvK/5i87u68M X1SveWrJ7p3zFNBOHQ0alAUNZ9nUvngmsei0z71yrd9AmbZXTPGctuIogM9ThcUYZXYJ YuFw== 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 :message-id:date:subject:cc:to:from; bh=A3tl8NASSuXOQqO5eX6tksErCIgee5kwqkseZkCBzaQ=; b=eIA9cU8NA/CWw+ZI0dMWC0nUeDDhVuSxvk2/dPda3QELRIlpxQ+YEJP7bR/6ob1Hjx QIRgAKpGEsMiMaHWDaceUydROgY0ZY+VP7Xjd30nhAXE3hBiXoXTInkyLy5QTSGplXug C0V71qC5pKcpHaukp00oMVVQSpJGcynZQFumPdb9g5/SdmgIUIdM5cstkdvcz9rkHlf7 C+10Ze94GewMW+8KOVI615VZnirY1RAAd0VNaThUJ73f0GAyzXRmnZxmISQlyrJ2eNsm mE4WQHuc9s/ye2iR8x55wHZddrjKSjvXgf82GumlFbcJPescopYSVi8dj9mTF/EptIj4 Gabw== ARC-Authentication-Results: i=1; mx.google.com; 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 b191si242851oii.266.2020.02.26.13.39.57; Wed, 26 Feb 2020 13:40:09 -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; 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 S1727709AbgBZVja (ORCPT + 99 others); Wed, 26 Feb 2020 16:39:30 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:52181 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbgBZVja (ORCPT ); Wed, 26 Feb 2020 16:39:30 -0500 Received: from 79.184.237.30.ipv4.supernova.orange.pl (79.184.237.30) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.341) id 533bfd923ca1b9ab; Wed, 26 Feb 2020 22:39:27 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: "Rafael J. Wysocki" , Viresh Kumar , Srinivas Pandruvada , LKML , Artem Bityutskiy Subject: [PATCH] cpufreq: Fix policy initialization for internal governor drivers Date: Wed, 26 Feb 2020 22:39:27 +0100 Message-ID: <3873122.F9s1CIEcb3@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki 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 --- Note that I'm going to fast-track this patch for 5.6-rc4 which means that it will go into my linux-next branch as soon as it shows up in the lists. Thanks and sorry for the breakage! --- drivers/cpufreq/cpufreq.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -1076,9 +1076,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);