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 2EDCDC433E2 for ; Tue, 15 Sep 2020 23:23:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAEE2208E4 for ; Tue, 15 Sep 2020 23:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600212235; bh=Ksq4dw/hBZ7qlimcLtq60uVBWjdmHx2hSo0wkPFMcb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lDvZ2rS/IexTaXgo6WKOtvk+F0y96076e5A5PI8BE+M2yq7QWJL9xK4c/J4/9P51B noX5Mggl39rBmiFtv+a48S5+CuxmoK2rvMOJFgwpzmQxfDflZgM2KqfVwdZIIcsiR0 VuhNIxENUPynQdaL3fv5OVRyE0oX3+tFNdnVx8hE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727361AbgIOXXz (ORCPT ); Tue, 15 Sep 2020 19:23:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:48832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727183AbgIOOiC (ORCPT ); Tue, 15 Sep 2020 10:38:02 -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 51BEA22461; Tue, 15 Sep 2020 14:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600180071; bh=Ksq4dw/hBZ7qlimcLtq60uVBWjdmHx2hSo0wkPFMcb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AKvJyqU4mHP6rR2uZxbwQmQxEk6fC/WowNkunEqrN4ZFv9QmNZdcbiOGBkiSUOV6R h6zDfn98xScSVJrbQmWzQ0jsyvfz564TNfzVYBmg6QKnuLV4+Huf+UWSoXDq1tHmQj v7VU60lBbh3fIBtc3liRLHHw+fDp6jzJOu6+pTRw= 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.8 098/177] cpufreq: intel_pstate: Refuse to turn off with HWP enabled Date: Tue, 15 Sep 2020 16:12:49 +0200 Message-Id: <20200915140658.339427633@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140653.610388773@linuxfoundation.org> References: <20200915140653.610388773@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 8c730a47e0537..97ed4fd0f1342 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -2534,9 +2534,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