Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2393308rda; Wed, 25 Oct 2023 01:04:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHX2TLvLYDnBmPj70smp6x5xX/gTnmebf26n8Q5d8+xid3cj1s6doifxPBDYxzDsufdrTyn X-Received: by 2002:a25:b19a:0:b0:d9a:4d90:feda with SMTP id h26-20020a25b19a000000b00d9a4d90fedamr14320350ybj.62.1698221078248; Wed, 25 Oct 2023 01:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698221078; cv=none; d=google.com; s=arc-20160816; b=Tev26rTVu2vQ7Ih7qxGOKhx5zfLLr9gSLRVOPWlWWppHO0uw284J03RwGiAjcjJqIP Q5ULOZ9ixPb0hHB4ybAfIDiEaq97honw8KxWnRDsmiZpc8DQMiGJRB03e24rxU5xCiCb HmCCj+CdNrdrPNHVbU4kxBUhUchGECAl/tVXItqD6URKalvzjMxb3JxR+B843hZ8yyRw DT93Wyf6WCl7pfYKqs9npyrcBh9UGkXDRsKp4CfR4w7pvq+SlBFrzv40+/K+/j5nq4b4 7+hANgUUXNZBHJNoa/pvg4OzZ03uUO7Mzmo9VzSYhlu23+PZYdcssap3HnLXmn1x50G7 q8Ag== 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 :message-id:date:subject:cc:to:from; bh=5II+uijaAeV6oQBEYKu1kcTbVmT1A8zxC2lYAbWfLO0=; fh=MYfFq4YKRVoxHbYtHwKcL4PUsm8X46gdY0vH8QGcX6c=; b=Py98GHJi9cuy0wiLzDdWOPYiiaoyf0ypgbGyFte7mD1Azb4ly9VRF7cSHFjjZKoLYr +RJe1c4ypXmGYNhaE4WV/92pgn1yKLwfCgCv0XEFcC21urLrxa3X5USFKgAKVQjoc9gx Z8KFomOOcF1RctLeUDT4mPyoFTtDqlRLoUf/8leFRXysjVy2yV+IPouGJHQhNt8Abh8K 8A4nGnZt9un1tdqXdAg2Xce8aPcsOrJVKQKzxrbZG9WC1u7MILnzvdZap/xY3vqc4qAw /4voJAtfPUNq1RYw+cXHChxPTd+hZwhqGzb4KDBztTGHezZDlfXhVOpnY8eh7oyU/zxp 56qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id y6-20020a25ad06000000b00da07267941esi1190260ybi.296.2023.10.25.01.04.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 01:04:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BA9D58030E46; Wed, 25 Oct 2023 01:04:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234338AbjJYIER (ORCPT + 99 others); Wed, 25 Oct 2023 04:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234253AbjJYIEM (ORCPT ); Wed, 25 Oct 2023 04:04:12 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1047B137; Wed, 25 Oct 2023 01:04:09 -0700 (PDT) Received: from kwepemi500024.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SFhDH0G2YzNpYd; Wed, 25 Oct 2023 15:59:59 +0800 (CST) Received: from huawei.com (10.175.103.91) by kwepemi500024.china.huawei.com (7.221.188.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 25 Oct 2023 16:04:01 +0800 From: Zeng Heng To: , CC: , , , , Subject: [PATCH -next] cpufreq: userspace: Keep the current frequency when set userspace policy Date: Wed, 25 Oct 2023 16:09:10 +0800 Message-ID: <20231025080910.3245690-1-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500024.china.huawei.com (7.221.188.100) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 25 Oct 2023 01:04:35 -0700 (PDT) When switching to the userspace policy, if the current frequency is within the range of policy's min and max values, the current frequency value should be remained. The .limit() function is called when changing governor or updating governor limits, so in both cases, there is no need to update frequency if the current frequency does not exceed the threshold. Additionally, when changing to userspace governor, the default value of set_speed is set by reading the current frequency of the CPU, but there is inevitable error between the frequency coming from .get_rate() interface and the actual working frequency. Consequently, when switching to userspace policy, keeping the current frequency can avoid unexpected changes. Signed-off-by: Zeng Heng --- drivers/cpufreq/cpufreq_userspace.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 2c42fee76daa..fe55a7bb663c 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c @@ -117,9 +117,7 @@ static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy) else if (policy->min > userspace->setspeed) __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); - else - __cpufreq_driver_target(policy, userspace->setspeed, - CPUFREQ_RELATION_L); + /* Otherwise, keep the current frequency. */ mutex_unlock(&userspace->mutex); } -- 2.25.1