Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4221690imm; Wed, 30 May 2018 01:12:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIsh89Bc6UqeNrIwF8FMsF6+UHc1+qJV9h+LX06zw7N+Z1k29uqPWuXPtWld7UUSZey/g2w X-Received: by 2002:a63:7553:: with SMTP id f19-v6mr1464965pgn.314.1527667925626; Wed, 30 May 2018 01:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527667925; cv=none; d=google.com; s=arc-20160816; b=0NlgH4hgRFVt9t/tvf+PHnyp+UPQTJw9iFxn45+zFjd61Y5bbmu030aXny/tzz5Nc6 r2C64zWjqypLjSwxUy7xeA0l9bALaLbrETHNYewRkjTMbu/JFmaowaFsQxqoHnajU8Dm mplsgCA+gGDPsviedbp+1w6PspLapOYg8FWNIU65uAnzy5qDukCG3d7jDfqNNe2hHBW+ pipYzZphGC+HSrS15vu3tsxMrSUvpFdPJ2yN6d2U1mfqf6mctTiivopnl4GjncqiSlYH LK0q04pXu3a/nEd57qoLCyDAjgyQlKPeNtDoxv82u4HOlIlZ4krLYNxw2IWM24gXi0sI BxQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=RaVjSUCy79Cr+OCSU60bAHn848BufJh3aWFlnC7pr/U=; b=0R84ORk3TThrcw5a+a6GEo+7yOa+w4kDo98ptqyzl11vWXY2ezKAicbKtGjVUrqTR6 Teza4SXEaJfpG899Vt0A/zmfxVT15iVQpPjlgIE3yf+w8HsQ6FS1W2EcqbIhpDFggmVa 226pmBxXYZk3Idr79JXWjIdV9gCHsSzdI1K2YiAlVFTQ538yekEkrBK+7+0BP0L8rYnU uTC9lFUSDvN2G9ThY60s9ZBZZtmHEb1O+gbGUy6XXpV6KvXHbaEBbvPFW/wMQ4Qdta88 18EHkOQAiw3Zmxh2R7ljRXLn6fgdsvtzmEnag4S6XlrQ+HqQu+INybe8q4CTG9C7Oybk T7uA== 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 g12-v6si35592738pfi.212.2018.05.30.01.11.51; Wed, 30 May 2018 01:12:05 -0700 (PDT) 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 S937127AbeE3IL2 (ORCPT + 99 others); Wed, 30 May 2018 04:11:28 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8164 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935832AbeE3ILV (ORCPT ); Wed, 30 May 2018 04:11:21 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 205BB767EB2C7; Wed, 30 May 2018 16:11:08 +0800 (CST) Received: from HSH1000038028.huawei.com (10.177.161.152) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.382.0; Wed, 30 May 2018 16:10:59 +0800 From: Kevin Wangtao To: , CC: , , , , Kevin Wangtao Subject: [PATCH V3] cpufreq: reinitialize new policy min/max when writing scaling_(max|min)_freq Date: Wed, 30 May 2018 15:56:47 +0800 Message-ID: <1527667007-48226-1-git-send-email-kevin.wangtao@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1527319008-66663-1-git-send-email-kevin.wangtao@hisilicon.com> References: <1527319008-66663-1-git-send-email-kevin.wangtao@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.161.152] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org consider such situation, current user_policy.min is 1000000, current user_policy.max is 1200000, in cpufreq_set_policy, other driver may update policy.min to 1200000, policy.max to 1300000. After that, If we input "echo 1300000 > scaling_min_freq", then user_policy.min will be 1300000, and user_policy.max is still 1200000, because the input value is checked with policy.max not user_policy.max. if we get all related cpus offline and online again, it will cause cpufreq_init_policy fail because user_policy.min is higher than user_policy.max. The solution is when user space tries to write scaling_(max|min)_freq, the min/max of new_policy should be reinitialized with min/max of user_policy, like what cpufreq_update_policy does. Signed-off-by: Kevin Wangtao --- drivers/cpufreq/cpufreq.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b79c532..a970113 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -697,6 +697,9 @@ static ssize_t store_##file_name \ struct cpufreq_policy new_policy; \ \ memcpy(&new_policy, policy, sizeof(*policy)); \ + /* Initialized with user_policy to keep consistency */ \ + new_policy.min = policy->user_policy.min; \ + new_policy.max = policy->user_policy.max; \ \ ret = sscanf(buf, "%u", &new_policy.object); \ if (ret != 1) \ -- 2.8.1