Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp844755imw; Thu, 14 Jul 2022 11:53:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v8rm+aTHJDa+MOu71uZOb6zzP+sRsxJkgfHq0g+jbjllICaqwfjLdfQahf6p4RAk92Kaq5 X-Received: by 2002:a05:6402:358b:b0:43a:d645:e1cb with SMTP id y11-20020a056402358b00b0043ad645e1cbmr14178423edc.334.1657824797299; Thu, 14 Jul 2022 11:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657824797; cv=none; d=google.com; s=arc-20160816; b=hugPxJfYzX09NFkCbJrrRqyeDrXKNZLYjV+TxAWwtUCZwfYz1R0/4qxhwkkH71QuOZ 1G6K0cifcSy5SSrRdHiHok1JMN0zkdYWl/b3vsWCKPRQ1kDeIIaIUqkKD9+yKMEP0J8n joQ/H7afa80VQGb/Pd9li1V73XIdeJ+5Siel6IJolv8g4n7HJkSkoZC31/lTvfyvpTXS HDBleAnJBvertOHzfnfUF/Sd8cQSY4PGbpckRTsCvhghz+tPtas0SIqHdZRXdun/qBnH HXgTZbqDZx9eZAhNrAc3W16/QLsvFTfl8PN57QIsIYviVpTg/TGCkNBeWKa8vyayEMaD 7cSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=vycimkfJJnUL5HYw9lyGFjZXDKTehh2hU0oCewywAvI=; b=ab4Nons9u9GlwXB7bPv91bG45eYjLFH3gBoKtl74kyPYNvPLryrkntGoOiOj2tYN/p Y0RKSlmEYK/7yvBLksCMT7arf+ShZdnIg5ARhwNT6Tm2dmfj5LxCgnzQ29sQ5RyKI7Q5 gAeoMoIA6dkhfBe2XQ2bjExDlIAYfU7UI+BiTmWlAYcux6UcPjppv6hXVR+6/6UHypFO TOky2N7phuwLEUoEoyTWfoJm/2UJ4pcKt2v4hW27AG8PdL6lJFlsU5KSGY0BH1Gknu5m MwCediKwccZdUxked+j4MSAbv9C9zBEBSVFJkv/rEi1q1HZNjYely4PlJKlhaMax/rDN 8AbA== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa40-20020a17090786a800b00722faf491a0si3523997ejc.686.2022.07.14.11.52.52; Thu, 14 Jul 2022 11:53:17 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240812AbiGNSpe (ORCPT + 99 others); Thu, 14 Jul 2022 14:45:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234681AbiGNSpd (ORCPT ); Thu, 14 Jul 2022 14:45:33 -0400 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9914A2655A; Thu, 14 Jul 2022 11:45:32 -0700 (PDT) Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-31c89111f23so26630097b3.0; Thu, 14 Jul 2022 11:45:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vycimkfJJnUL5HYw9lyGFjZXDKTehh2hU0oCewywAvI=; b=DV9o9bOE2Mdx4/RFGQGCclZB9ONoYZwFrhrQcgmJMPU9RAHghOel1DQ5ZfESTR7Ese xYHU8czOYOLn5yGoBkwSzeRlaOVn1M6uYOeevraYU2caa+flKs0aiuFWfBowMOVXMnqX wwGzbcWEmIGpQsmUkGHB0F5qx8qce1Wq4wjUaXqqpF2Lwm7nSvvDKyte7oh3DR8szb4/ u5LFiGnnbi9ZW2J3Upd+ygLkB7GmTtGaFDe8ySvQjk+QUKKWALMvYkzoCcBYkfIVPOcT 9zCTx3WXSTXuPSWyuzulFmU5aW5M5yxhSe2iVVUgVLwrx9G87wrTd+s07n7MklwAj5dh JGfA== X-Gm-Message-State: AJIora9a4Gc7Q+xhBqjLNyoaOE6fnZSCic37yhnDBS8QS0RIA9eJI+ck BcMU8h3Ssfdbte5OTu9RneBi9lQU8tti4IphAZU= X-Received: by 2002:a0d:d952:0:b0:31d:789d:221c with SMTP id b79-20020a0dd952000000b0031d789d221cmr11204391ywe.515.1657824331896; Thu, 14 Jul 2022 11:45:31 -0700 (PDT) MIME-Version: 1.0 References: <20220714134342.3498384-1-quic_kshivnan@quicinc.com> In-Reply-To: <20220714134342.3498384-1-quic_kshivnan@quicinc.com> From: "Rafael J. Wysocki" Date: Thu, 14 Jul 2022 20:45:21 +0200 Message-ID: Subject: Re: [PATCH v2 1/1] PM: QoS: Add check to make sure CPU freq is non-negative To: Shivnandan Kumar Cc: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 On Thu, Jul 14, 2022 at 3:44 PM Shivnandan Kumar wrote: > > CPU frequency should never be 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 CPU frequency. Adding check to > make sure CPU freq is non-negative will fix this problem. The changelog doesn't match the patch any more, please rewrite it. > > Signed-off-by: Shivnandan Kumar > > --- > v1->v2 > -addressed comments from Rafael > -changed commit text accordingly > > kernel/power/qos.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/power/qos.c b/kernel/power/qos.c > index ec7e1e85923e..27e6596f287a 100644 > --- a/kernel/power/qos.c > +++ b/kernel/power/qos.c > @@ -531,7 +531,7 @@ 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) > return -EINVAL; > > if (WARN(freq_qos_request_active(req), > @@ -563,7 +563,7 @@ 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) > return -EINVAL; > > if (WARN(!freq_qos_request_active(req), > -- > 2.25.1 >