Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp347416imm; Sat, 26 May 2018 00:31:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqHGR5UnzhNh3mQsyoUzIFG3FZNeYkiUdRZCcHHubV9nDzyb+iSyfjIhSSYaA4JlbkSRmQB X-Received: by 2002:aa7:81cc:: with SMTP id c12-v6mr5572677pfn.169.1527319906917; Sat, 26 May 2018 00:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527319906; cv=none; d=google.com; s=arc-20160816; b=DyhNSkpzGLyzjNZzY4IwFGVx0SNO2M5PdoECQxeWntIWU6AjSMNeRrSEZRpZDRkHoh Kmexr0swkYb8+kBWCCw6AGTMeFXCczn1ktCkVFko8nfdmsOK/GWxqGZKIa+KTGINDko4 9BvkwKFYScaqF/uFIkF4d2Yill9lvnl2xNAaa5jMTFggXRRX5jTTcTmNxJN7sW3Y/Shy yXmL/0Es8qx9txoJXW8ulAr9MneTJXNaGnT3VrePYr8pz362qGnVShAFbV+yjJQGsn5E eYH+JyBZUjXCfkYtYQak/67WBzkdAYdbgeAfVOEggriBQYif/RncFrALQ807I9yLfYog TgrQ== 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=KD9bBMzUCu+o5r1cYTCouGCmS3miqCjzG5ZeIjIZb6o=; b=K+fr+FvH1ikzi04pLBXqSrDZ5t5mg07g/34xf28BGJAjVT5QXSY32oqfENfct7DJkx rxWmJtTbnVV6Fe9nPr6oQlMlNEc79nWEvI2dKXvJtfLrLbbpDszic/15qK/2IfZj+BDY qahhMEyg3y5NOh8ocpqrSl9P3Oi27SU/5cgsAXhU18Pxp9kLnNOfdMnzrm+YZAUz8wr0 HiBVnhMaJRdMajowBiivMCsCGldOaB+S028adeAw6QmAhowEkK1t1WQMq8rtNgMXUKt5 rT8RCpxTBVdOjmc8iHWB7j7uhcAxFFVs/qwibcXX5VYWii2U+HedoSA5SGXKwuzt7GqY Ev2g== 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 p6-v6si20013599pga.25.2018.05.26.00.31.29; Sat, 26 May 2018 00:31:46 -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 S1031239AbeEZHbU (ORCPT + 99 others); Sat, 26 May 2018 03:31:20 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7750 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1031156AbeEZHbT (ORCPT ); Sat, 26 May 2018 03:31:19 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A5E5AC5FC2C8F; Sat, 26 May 2018 15:31:01 +0800 (CST) Received: from HSH1000038028.huawei.com (10.177.161.152) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Sat, 26 May 2018 15:30:54 +0800 From: Kevin Wangtao To: , CC: , , , , Kevin Wangtao Subject: [PATCH V2] cpufreq: reinitialize new policy min/max when writing scaling_(max|min)_freq Date: Sat, 26 May 2018 15:16:48 +0800 Message-ID: <1527319008-66663-1-git-send-email-kevin.wangtao@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1527144234-96396-1-git-send-email-kevin.wangtao@hisilicon.com> References: <1527144234-96396-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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b79c532..82123a1 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -697,6 +697,8 @@ static ssize_t store_##file_name \ struct cpufreq_policy new_policy; \ \ memcpy(&new_policy, policy, sizeof(*policy)); \ + 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