Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2107676imw; Tue, 5 Jul 2022 23:31:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyEVdUL03MvAj2Ojwniwp9QgNmHecmRMMO4GYkKjyMj8ZeCDnED05WTCfQoObwFYr4WjHf X-Received: by 2002:a05:6a00:2309:b0:527:f0b3:b4b6 with SMTP id h9-20020a056a00230900b00527f0b3b4b6mr39957349pfh.53.1657089108767; Tue, 05 Jul 2022 23:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657089108; cv=none; d=google.com; s=arc-20160816; b=uB9k3sppfQkglfxPvHaw7Pfq65szXbjBFK40HDEMO+x3TabAcCBG4f6nibKZ5yaxIR tSfXz1YYI4pZhuJ8kYD7GyrDflO7uSU+LRLcmRh2tMF2tXmXh5kRL+2NECOPd3gSjq6Z X+yuRMpuVtch2f5xOkGCeOAzLJxDfYG4pfBTnuFtrLMbx34xjObW2cXpPZTSXFRMqvmw 1KYoy8twkETt6gtXKiOzR4YLuoT/SPk78tgJ81p9b1gXfzX/bqZkSjAQKNGHuvU/h42q QmPHTJYVQK0md4fzQUlhIHr4ENgg6VTmujczCs4hv9HWCSd8G9Y42ouRO+JNc2HrBc2M Z/FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=HKgGNtH5+ZCmlx68r1yZkOpQeKz/TE7pn1yL+4sruqo=; b=OjUA80LGumo5lbG3in2J0DpMCz14hiOsMufLoev3VR624XjXAfi5mh0zQ1t4U7cmAj eeAt7Tw34XweWTCu/ASnnRIuYVmfVqzIUkKp3NlD36twacCJZ+8LPVYCf0AuNypaAlj5 wyst0ntkK3rUxzBC83EmT+XqPv7tnGE8TXnbHnLV1TDRfVPh0gpqkXntIyOeEVj+GTiL 8mCb+7vOPu5vEL2tmFWrvHZtNASD9iAgwTuEZdDEOEz1V+N5xxk3fSLBt9Arx7C4mStj 5EMnfAS3VAoj/2sWUM6+IYQQFOKrBHlHIxNndLWFvmSiEmBbZCcuQh4u6kFItZbfTAc9 6+wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=v6hTFnjt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a17090a86ca00b001ef8dd9c0d6si8419532pjv.116.2022.07.05.23.31.30; Tue, 05 Jul 2022 23:31:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=v6hTFnjt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbiGFGbE (ORCPT + 99 others); Wed, 6 Jul 2022 02:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbiGFGak (ORCPT ); Wed, 6 Jul 2022 02:30:40 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C747C1D302; Tue, 5 Jul 2022 23:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657089014; x=1688625014; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=HKgGNtH5+ZCmlx68r1yZkOpQeKz/TE7pn1yL+4sruqo=; b=v6hTFnjtFFVpnBWK+rFPSYNAF0EAcxCanXPIhI4ncLYhImJ1QQ83JUnz DRTGr5ZgoBC1SFmEPTG7CFOcGB9GIXjfBoSJBnTDQZb5Mdee4iIJhP4mZ FXoPfBXt1EmCvZIz0AwSu8Ws/RmU3Jv1hm92tJPxzjfToa4mZr+/1if8d U=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 05 Jul 2022 23:30:13 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2022 23:30:13 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 5 Jul 2022 23:30:12 -0700 Received: from [10.216.8.139] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 5 Jul 2022 23:30:10 -0700 Message-ID: <91421440-578a-ccd1-21b3-7b8e2e8e2e8d@quicinc.com> Date: Wed, 6 Jul 2022 12:00:07 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0 Subject: Re: [PATCH] PM: QoS: Add check to make sure CPU freq is non-negative Content-Language: en-US To: , , CC: , References: <20220623064605.2538969-1-quic_kshivnan@quicinc.com> From: Shivnandan Kumar In-Reply-To: <20220623064605.2538969-1-quic_kshivnan@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Gentle reminder, Thanks, Shivnandan On 6/23/2022 12:16 PM, Shivnandan Kumar wrote: > CPU frequency should never be non-negative. > If some client driver calls freq_qos_update_request with some > value greater than INT_MAX, then it will set max CPU freq at > fmax but it will add plist node with some negative priority. > plist node has priority from INT_MIN (highest) to INT_MAX > (lowest). Once priority is set as negative, another client > will not be able to reduce max CPU frequency. Adding check > to make sure CPU freq is non-negative will fix this problem. > Signed-off-by: Shivnandan Kumar > > --- > kernel/power/qos.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/kernel/power/qos.c b/kernel/power/qos.c > index ec7e1e85923e..41e96fe34bfd 100644 > --- a/kernel/power/qos.c > +++ b/kernel/power/qos.c > @@ -531,7 +531,8 @@ int freq_qos_add_request(struct freq_constraints *qos, > { > int ret; > > - if (IS_ERR_OR_NULL(qos) || !req) > + if (IS_ERR_OR_NULL(qos) || !req || value < FREQ_QOS_MIN_DEFAULT_VALUE > + || value > FREQ_QOS_MAX_DEFAULT_VALUE) > return -EINVAL; > > if (WARN(freq_qos_request_active(req), > @@ -563,7 +564,8 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request); > */ > int freq_qos_update_request(struct freq_qos_request *req, s32 new_value) > { > - if (!req) > + if (!req || new_value < FREQ_QOS_MIN_DEFAULT_VALUE || > + new_value > FREQ_QOS_MAX_DEFAULT_VALUE) > return -EINVAL; > > if (WARN(!freq_qos_request_active(req),