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=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 CE0F8C2D0E3 for ; Wed, 16 Sep 2020 00:00:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83F7A20739 for ; Wed, 16 Sep 2020 00:00:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600214417; bh=lRdWJoPZJCDecDQscJPWWoLzrsXLa/C/xMNN4RMR7ws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KuzVS+WTGohkBofxrEjyE/ELYVFRebqLT6NufZzzDmV7WKfoSlNbF3sKBob07GOAN vfGe5hPJwVO736MfAcMTWAlVMvOf5eAjvQz+6oBDp269EYEnThbUC9Fgc+8mzq9dbg EyIZFp3+AymlYNM6iMcpjmOdhEuR/61dhbOZpHWE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727213AbgIPAAQ (ORCPT ); Tue, 15 Sep 2020 20:00:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:43006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727012AbgIOOaV (ORCPT ); Tue, 15 Sep 2020 10:30:21 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A7C3E22AB0; Tue, 15 Sep 2020 14:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179730; bh=lRdWJoPZJCDecDQscJPWWoLzrsXLa/C/xMNN4RMR7ws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O5OHjvtmwa27G5FF+ZTczmNuLBP6K3iNa8g+Oko1cwmmbSykULJO2tdCmVx5PI4hV JS6FhFHmWl0ZvXjS9OFbS7YCjx820Zq0IZqyuBrEEOxvpyHtfJzUBlhxpeA0MSCVGf hdepreqdvwHIlppnpWQOx45wqEBSYfc57W/KHheY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" , Srinivas Pandruvada , Sasha Levin Subject: [PATCH 5.4 066/132] cpufreq: intel_pstate: Refuse to turn off with HWP enabled Date: Tue, 15 Sep 2020 16:12:48 +0200 Message-Id: <20200915140647.411527839@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140644.037604909@linuxfoundation.org> References: <20200915140644.037604909@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 [ Upstream commit 43298db3009f06fe5c69e1ca8b6cfc2565772fa1 ] After commit f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode with HWP enabled") it is possible to change the driver status to "off" via sysfs with HWP enabled, which effectively causes the driver to unregister itself, but HWP remains active and it forces the minimum performance, so even if another cpufreq driver is loaded, it will not be able to control the CPU frequency. For this reason, make the driver refuse to change the status to "off" with HWP enabled. Signed-off-by: Rafael J. Wysocki Acked-by: Srinivas Pandruvada Signed-off-by: Sasha Levin --- drivers/cpufreq/intel_pstate.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 927eb3fd23660..5bad88f6ddd59 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -2533,9 +2533,15 @@ static int intel_pstate_update_status(const char *buf, size_t size) { int ret; - if (size == 3 && !strncmp(buf, "off", size)) - return intel_pstate_driver ? - intel_pstate_unregister_driver() : -EINVAL; + if (size == 3 && !strncmp(buf, "off", size)) { + if (!intel_pstate_driver) + return -EINVAL; + + if (hwp_active) + return -EBUSY; + + return intel_pstate_unregister_driver(); + } if (size == 6 && !strncmp(buf, "active", size)) { if (intel_pstate_driver) { -- 2.25.1