Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3222934imm; Tue, 29 May 2018 03:28:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpky4LKh5LuybYwto/7dDcrbhGZKyj7HHWgS8G8m/rRz3MetJJFfc0p2Qy8bOqMdhVBxsQm X-Received: by 2002:a63:43c6:: with SMTP id q189-v6mr13730125pga.123.1527589696256; Tue, 29 May 2018 03:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527589696; cv=none; d=google.com; s=arc-20160816; b=sfhPIc73MKE8nl0dI0HeSFOXd6cQnzLL2We3ZS2R9N5kO17fI2ib5VysmUNRL0er0Z gc3Z2pKxRTEH1MswTiX9w2ce+TORqBDpkCnDZc0uHjMAz1QhtVtxA0+A0QhTmfwmslss aOS23joy5tL5sNxIqQooachd9/CUDzdlH+QD3UdKV7+Wxj3r2hvdzO/GY4G702faxoWk PDSLtr7epPy+HXM11/fw7kYTqkhfYBM5kM1mjKwEil/s+pIdbshHJN0fKU9TssmhxFq1 EZiLRmju7Vu7g4dDpi8j9h3zfFJeyfu/Tb0LHbEHO9NJcIrolpNeD0LO8EAULj+o9RWk Sp7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=D7O6hrgCp2mFCTKzhae0GJrABYzFK+NgSEeEovh19sU=; b=Fgpzomgi97r7yxv6GI5NIbS+OEmhSABBcv8+y02KV/xyDl2UstmrCjZGYbc9rf0Dyq 22PAS4MQPPn/8J1I42DH5RbjzyVdMO9bYkAC2F92afoVWl9RGaUFbBoFtU+XGp16PbKl OCqlXYUurF9f2tDGkQ8ILZWXP6AI9eAXHRMNfRH32dPyXPSesc+PIN4pQ5g8NlospUOK O7fbtPx+eaIv4wnKngPGRh0GiiS/whbOEXEWBDGB1oLJULcurfhT0zW0DVJFYj30l2Zu 2LDB6jvP3nXojz/km9TYG06RjsWwkHwt8QX/VXGnBXCoASE3ggh3SWzXBDt9MsxD2Hpp MpYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j0edx8Vn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15-v6si12857239pgr.566.2018.05.29.03.28.02; Tue, 29 May 2018 03:28:16 -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; dkim=pass header.i=@linaro.org header.s=google header.b=j0edx8Vn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933084AbeE2K0o (ORCPT + 99 others); Tue, 29 May 2018 06:26:44 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35856 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932971AbeE2K0m (ORCPT ); Tue, 29 May 2018 06:26:42 -0400 Received: by mail-pf0-f196.google.com with SMTP id w129-v6so7074451pfd.3 for ; Tue, 29 May 2018 03:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=D7O6hrgCp2mFCTKzhae0GJrABYzFK+NgSEeEovh19sU=; b=j0edx8Vn5pHlJopQe98GhI2cyKGZfFLUyyRYdwom9qiDwO5X7YrBSDT23EhcyknY0n EezfCNjw7UnsdaRCZVF/uzO6xUb9/wdREjdMJpbzNiovJhU/wwQR3fsReF38D5s2zdLM jUevNQa+dGai1PwUUmDFcUYUPzlAslPXYjytM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=D7O6hrgCp2mFCTKzhae0GJrABYzFK+NgSEeEovh19sU=; b=bmUIxUEWxBsI7MAgBrKRZkGiO0P9hLPLDYe67ZUt/8oBzPUN6Cik5GFyKHDBqoZdYu DM92QjXehENuvRwq6iEP6I6GJl4UIftR4Dhxo4WXFkjIcuP923NEtwDgCD5c43SX7Aui Pqbgdm2c6GVP+qZPu3kaXojVduxI2Bt48EkyKiIOYPcSZLPe71kgBbFR7TIK1JghmdSb Oz8BimSMsGLxuTs6PDhWc5fUzEfJpsyQRh2tXPlX3798d2QCYIXHlz9Lw3MvT5sv7hJ1 qO+ZQET1zosMPDzUCVBlRY/SdFUhmG3IIwsvfTSWji68NMLB1Py94g0hL2afaIozqlz5 yboA== X-Gm-Message-State: ALKqPwfkCPGm9ItlICjqeup2rV8Qw7bq3P+2PufLJ791Rti0Th23xup3 C4uEO8A1Dn8V2Z66Lzq+8njKsg== X-Received: by 2002:a65:5784:: with SMTP id b4-v6mr13411176pgr.317.1527589601612; Tue, 29 May 2018 03:26:41 -0700 (PDT) Received: from localhost ([122.172.112.176]) by smtp.gmail.com with ESMTPSA id z28-v6sm15827980pfl.169.2018.05.29.03.26.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 03:26:40 -0700 (PDT) Date: Tue, 29 May 2018 15:56:38 +0530 From: Viresh Kumar To: Kevin Wangtao Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, gengyanping@hisilicon.com, sunzhaosheng@hisilicon.com Subject: Re: [PATCH V2] cpufreq: reinitialize new policy min/max when writing scaling_(max|min)_freq Message-ID: <20180529102638.ikmw2xjf523sf4kf@vireshk-i7> References: <1527144234-96396-1-git-send-email-kevin.wangtao@hisilicon.com> <1527319008-66663-1-git-send-email-kevin.wangtao@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1527319008-66663-1-git-send-email-kevin.wangtao@hisilicon.com> User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26-05-18, 15:16, Kevin Wangtao wrote: > 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)); \ Maybe add a comment here on why this is required ? > + new_policy.min = policy->user_policy.min; \ > + new_policy.max = policy->user_policy.max; \ > \ > ret = sscanf(buf, "%u", &new_policy.object); \ > if (ret != 1) \ Acked-by: Viresh Kumar -- viresh