Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp833978pxb; Tue, 3 Nov 2020 13:53:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxF/E7dI4d+lBnlFYsiRDJzX7d06UDR1NtJZNTg4V4wi60QcvIspYaCPRSHb5yEgk5Z39nT X-Received: by 2002:a17:906:640d:: with SMTP id d13mr21375330ejm.223.1604440438463; Tue, 03 Nov 2020 13:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440438; cv=none; d=google.com; s=arc-20160816; b=1Fcnh4vTwL2GmFSL+OSCduekZZMfP75e5zqR9FuE5YDavosumxtCOuc0e10H3+dUYK E2b+P6lgrUAQC0fBO7P57jlsZabtuBllP+oEJZmA5nGBpLMxU6Bem8mOnUYcZ1vJVvzI r6eG55eEACwcNHJ1NqVxxvEl+hxcXd9yh1kDhRuG1x47xOc4dBzrMcRbLF0HHq2fgxdT 6jiGYWdib4M08JDw2qZWIUQWGXxGnNbF872v4xM6vbxNKaaE3j8tVM/PYUCkTSftMC8E q/6D21Ma7PMdJVezJh41i/YO+H/dC16Z/8ED1m2qZZ7R3H1xhyW46UTWRDiu3N4XGcyI VZdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a1E8R16z7AmH6uewFp5zVHtKqo7lDnulU16U6I1mvR4=; b=HkFctAj28TLp87fmPE6PANxApbiy9uG1rGbr3O368UmhqdEXisfIqhX5xaL0nkUQSj DXRSdXpGN2PJVV7Z4JASiItZ/9QfuIbx7roa9xr4mBrBGy2XVQ7ikO+kWiyqQtWUOjr1 WjC50tLUM4GwH9avaIo/TlXTpQOl6ahJ8zFW1zBf/lH2WGio2ggktsle/8MYXWHYX9Pu uv/LGEW6KxLfXMeMEqFcbX7ICaMsO/c3W0yH51SodNZNtKtKHCDeq+HGRhVX4TiRiO8v yGInkG6IzgMjvv6/8lIGE7fstfU4O4mZKcHkPhiFX6mgKfXMv3/zaxkANMxGXuQF88od sNlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=krFQLH6h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t26si5418ejr.336.2020.11.03.13.53.35; Tue, 03 Nov 2020 13:53:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=krFQLH6h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732260AbgKCVtC (ORCPT + 99 others); Tue, 3 Nov 2020 16:49:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:44916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731819AbgKCUuk (ORCPT ); Tue, 3 Nov 2020 15:50:40 -0500 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 54F1722404; Tue, 3 Nov 2020 20:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436639; bh=P/28zFVrF1olkuFhfzeyQX2oR6hrSTizoEGKCQ8FTTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=krFQLH6hovQ31sDybDUma7kfgow8IZbJeI6XeembbK4tH9OsvpvRytfG2VP2Twi+i u0xjsTRk0qHNX9SPTMgvKvJI+AXSOLhOpTZLGdAIV6TmsHe/AikbTi5NsXrHgZPLDd Q/VMSf5Dq6tavWNSuue/NfoeZ0yVmFpHiNfNdKMQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 5.9 337/391] cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS driver flag Date: Tue, 3 Nov 2020 21:36:28 +0100 Message-Id: <20201103203409.871460397@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki commit 1c534352f47fd83eb08075ac2474f707e74bf7f7 upstream. Generally, a cpufreq driver may need to update some internal upper and lower frequency boundaries on policy max and min changes, respectively, but currently this does not work if the target frequency does not change along with the policy limit. Namely, if the target frequency does not change along with the policy min or max, the "target_freq == policy->cur" check in __cpufreq_driver_target() prevents driver callbacks from being invoked and they do not even have a chance to update the corresponding internal boundary. This particularly affects the "powersave" and "performance" governors that always set the target frequency to one of the policy limits and it never changes when the other limit is updated. To allow cpufreq the drivers needing to update internal frequency boundaries on policy limits changes to avoid this issue, introduce a new driver flag, CPUFREQ_NEED_UPDATE_LIMITS, that (when set) will neutralize the check mentioned above. Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/cpufreq.c | 3 ++- include/linux/cpufreq.h | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2166,7 +2166,8 @@ int __cpufreq_driver_target(struct cpufr * exactly same freq is called again and so we can save on few function * calls. */ - if (target_freq == policy->cur) + if (target_freq == policy->cur && + !(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS)) return 0; /* Save last value to restore later on errors */ --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -293,7 +293,7 @@ __ATTR(_name, 0644, show_##_name, store_ struct cpufreq_driver { char name[CPUFREQ_NAME_LEN]; - u8 flags; + u16 flags; void *driver_data; /* needed by all drivers */ @@ -417,6 +417,14 @@ struct cpufreq_driver { */ #define CPUFREQ_IS_COOLING_DEV BIT(7) +/* + * Set by drivers that need to update internale upper and lower boundaries along + * with the target frequency and so the core and governors should also invoke + * the diver if the target frequency does not change, but the policy min or max + * may have changed. + */ +#define CPUFREQ_NEED_UPDATE_LIMITS BIT(8) + int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);