Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp918104imn; Tue, 26 Jul 2022 13:01:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ukg4FVcU6vO1pdqFRL59eXMEBYxNMkpJotl64zMyUlJktb7iY/1KAP1LZED0RHLRXwmEGs X-Received: by 2002:a17:903:25cf:b0:16d:1507:10ea with SMTP id jc15-20020a17090325cf00b0016d150710eamr18545467plb.33.1658865665853; Tue, 26 Jul 2022 13:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658865665; cv=none; d=google.com; s=arc-20160816; b=U9Yjw2wpTcmRMeklvcvdQQhZLfzNC9Z+SIXDIE23NnEWpArJ75ACvSFCgmE1GRbYmc SzT2yNgUrP28szinxOzqM/y6cfchqVQHdakAaSP9xGeN2rDPdyKtnTawSJs3YGOdsYSu LfdIJjkDeEUUxhkB/poXDzYoXcP2/qOCgq/t0DrcxskUOnPB6N0KciijxQvwa5FnK4VJ 0A1oUrHCT+oGexv/IW7cZn2jelMzET0RkTVHwqdk186rUjbrlxFw8ZxFJgEMbSvpD8wt 58Ub8AH0DtX5KG2k2OTNsSf+uHD2pC9La6rxU3peJbYcSW9SCWsEQVNhJ+rgA4tr/jc3 Ajqw== 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=yPFBVlu0ObcRvnu08ApRMdRFd37TOD9Ck2WSxYLLAak=; b=wp0pQSfT8ZqKiaA/8bwv2LBZjDrplJQwV4M7VoKS/FlY5rAymUT8SaPaxthXyvkdwj HQouRZnUB6z5T2HiOUummdrzr9x9wL92K+Cj7FErb/SeeV1x1T6gJL0e8/YE1Dj4erMw VxTEXABMIoYL+r6nV1KozvAyx7IV8GXEhIRLtmCKsE0TwOn97dsYQhO/zWMm3Jrj2nyP bAdg3EbGEn1u2Hk9hR8QzZ7rm886eRi/c2rYOI/mdHuAls/g/eJe2uaMno6pxsH1jRvB y6GyyFdSsc4pUE0lvkM9AQaniDtTfVb8BcBG1eKbDRGw6OEiWkU/fW0no96DAM0D8Mxs f/Sg== 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 f15-20020a170902ce8f00b0016d923974ebsi4508940plg.137.2022.07.26.13.00.41; Tue, 26 Jul 2022 13:01:05 -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 S239684AbiGZSuA (ORCPT + 99 others); Tue, 26 Jul 2022 14:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234098AbiGZSt7 (ORCPT ); Tue, 26 Jul 2022 14:49:59 -0400 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99CBA33A0F; Tue, 26 Jul 2022 11:49:58 -0700 (PDT) Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-31f56c42ab5so16171587b3.10; Tue, 26 Jul 2022 11:49:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=yPFBVlu0ObcRvnu08ApRMdRFd37TOD9Ck2WSxYLLAak=; b=xzJHEuceeGaCoGU8Jw71QmNaI4UDtNOXeP9tPrEsg/wnDVliOZm9mM+faE9+BVzRWY kIT2IrEvkwA6F4p4u3/tlOP2GW1lfkakLBfxDYYzzPCW/9ko7xLWpECxG19haL9Y6GwD x/GWWg1GFaip3tHZkcrFf1oY50pAeazHh/vOfdEBlVxqugFpF4ml55OxYKUT9MdE0dMe dFaGTuPgkz/zpsB9yilb/vfcCvD422hycKzQNyhxhi2MULJA5fvQ+XkZomRKUwn3HWuV bD43Zyz64u0/FsSQVIuDvuBpzyJW3sVdDrluSkGIMSJe56QuqiLcFsWU8pmphHk4W4wl KbSA== X-Gm-Message-State: AJIora99fgXEly9SvVDapru5XsJ6wiV+z/LfWu8L2Gr65t9d6Mei1LGF h0T61NGnAfuYqk7wb4tffg4xqKlv/CsmldqTc68= X-Received: by 2002:a81:78c6:0:b0:31e:848b:6e2 with SMTP id t189-20020a8178c6000000b0031e848b06e2mr16334621ywc.301.1658861397853; Tue, 26 Jul 2022 11:49:57 -0700 (PDT) MIME-Version: 1.0 References: <20220715122539.3978614-1-quic_kshivnan@quicinc.com> In-Reply-To: <20220715122539.3978614-1-quic_kshivnan@quicinc.com> From: "Rafael J. Wysocki" Date: Tue, 26 Jul 2022 20:49:46 +0200 Message-ID: Subject: Re: [PATCH v4]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 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 Fri, Jul 15, 2022 at 2:27 PM Shivnandan Kumar wrote: > > CPU frequency should never be negative. > If some client driver calls freq_qos_update_request with > negative value which will be very high in absolute terms, > then qos driver sets max CPU freq at fmax as it considers > it's absolute value but it will add plist node with 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. > > Signed-off-by: Shivnandan Kumar > --- > v3->v4 > -used 0 instead of FREQ_QOS_MIN_DEFAULT_VALUE > v2->v3 > -changed commit text > 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..af51ed6d45ef 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 < 0) > 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 < 0) > return -EINVAL; > > if (WARN(!freq_qos_request_active(req), > -- Applied as 5.20 material, thanks!