Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp6503460pxu; Thu, 24 Dec 2020 04:16:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2DAUJRcVTZ0zgh5N1uG73S+FXwMLjULgaYoRk0eia3xz3ovhnHlIj+8SHvovS4xuHiZJl X-Received: by 2002:a17:906:94c5:: with SMTP id d5mr27032320ejy.427.1608812182403; Thu, 24 Dec 2020 04:16:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608812182; cv=none; d=google.com; s=arc-20160816; b=S3CHyElByUxaTLszr19pNAF00g0s9nhjqzwaCXBu8iCphmT7KJZKMx8nqYaVVaqi9X tfydpsWIkYRuo+NP+K/+eg5ATicQHS8DKKkaZ8IPeN2YIKXR+Vg2TcypmdSHjUAWx6iH nIxOH2DLU4HhUY6I/Sga7hnb3fkZ09bUaKG1mTXgWRsidZ+QNZvJqDjp/ALxUrYDm8eN yTqQukCFVPyekZr3i31B/6K2wSPoa5Vqtvu1Rjm5Du5rGlPuYkcOxJE0nI2YuYt9yCdj yjobtA7gLRLNmoC4wpzOnRTiwzAfF9WEQgKSlDufDch7d1pfcD2rZvldUVlMpkN7hbqy HZ/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=56xAzTWTQQ5e5SGZuO7IksvEZZ4TGll9FyZCHqwaIyI=; b=b4hsLGUc5I1SZTASOf+rRFXumlw/fVRv3jSJFyCo1jzkHmsO6YtP47ast/0tmm7ohC 8PCRiFMocLGUUFUWFSod4Hb07yOc7qt7iD3AdJ+0s2mulY1ZTXNFb3oM3Ic1lg1L6baD ppJlbjvJ5xvc7kKpoKukKY9ph8Iq2akTMd6/4nO+1MxErccaU4k5gE0UAAIR8+yqlspt DBhj2S0GRPR3CVuu45h32MVgYrW/y9afM18ee4eUeQ+7X+lAPPzqjJpAUjpTeTlgCQv7 jngvhpwrdln0pODU0Xqh4H1BvpuD/1ZLkhjyFHGNt4rrBTCuCWYTK8KDlms+Q5bmYXCw zmrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IEomQfiR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd25si15295113edb.438.2020.12.24.04.16.00; Thu, 24 Dec 2020 04:16:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IEomQfiR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728449AbgLXMOq (ORCPT + 99 others); Thu, 24 Dec 2020 07:14:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbgLXMOp (ORCPT ); Thu, 24 Dec 2020 07:14:45 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02C7BC0617A6; Thu, 24 Dec 2020 04:14:05 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id o13so4394522lfr.3; Thu, 24 Dec 2020 04:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=56xAzTWTQQ5e5SGZuO7IksvEZZ4TGll9FyZCHqwaIyI=; b=IEomQfiR8gvwpl9AJ1ADx1wLAiBTpBe0MzDzBHrVnyksFAtoCQusyt2aOpddZtgnt0 G2xrtk7dkAbPh5mrBpegI3zf7dejgxqz8zhdkTojfBT5HjUiBLt6rBGSE5riltq/UOKr 3ZKU17K+r+LGVo70URY/QRisS+jbgdr71ZJH5blzCGp5+H4gymXTDKfWnCB9KDIcl+HM T4HCqn3iAd24R4Z9GQoCK9zagFdGfHbYb5fdrnMoYTtBGpdwl9FSDpYdZD074Gbqtp4/ p1NmX52oYCijEX+U1K+BtSTXWdk/xK9mxVFoLZQ+izHlWVXianvWcZvnwwq9UECfsz1T g4cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=56xAzTWTQQ5e5SGZuO7IksvEZZ4TGll9FyZCHqwaIyI=; b=uVoqfgfzt/1IW+KBohVGNkK2BOz3Zsk1KlPmBUDLUReY2CQCaBJ0JL8swgeTvYXVZP Yf0EpDCRyDXbw0mdZ4lw2t9A63cwGpmlxD9YdeAZFj0BavHe4noN74aYqKuKTcglGptq FakQRyg5Z54LAAuc3lX+keZYa1XYOw5zxz89iUDPhDIsrYoa8ulV0NC79SXBBfVCR5CY MAf+FfwmOnX3R8w59s/DfrSyrGgs34HQOuAz+MAkX+FbzYoBuFa4YWC/a/0tW+xNAokb zIbKRUmcvR2jSq2vqeGUgc70LzIou7i0D7O9cy+mRDhJwl6xZwX9k/rJMJAmfYu+BApO K0Zw== X-Gm-Message-State: AOAM5302y+5LZh6f3iACoV75LKy+nggYYd+ws03ZarM+8j+2yvXsMVUg Axk3AoVvSysyWBuYZiXn0sex4jSajqc= X-Received: by 2002:a2e:80d4:: with SMTP id r20mr10520885ljg.495.1608812043389; Thu, 24 Dec 2020 04:14:03 -0800 (PST) Received: from [192.168.2.145] (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.googlemail.com with ESMTPSA id c142sm3572365lfg.309.2020.12.24.04.14.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Dec 2020 04:14:02 -0800 (PST) Subject: Re: [PATCH v2 19/48] opp: Fix adding OPP entries in a wrong order if rate is unavailable To: Viresh Kumar Cc: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Mauro Carvalho Chehab , Rob Herring , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Michael Turquette , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org References: <20201217180638.22748-1-digetx@gmail.com> <20201217180638.22748-20-digetx@gmail.com> <20201222091255.wentz5hyt726qezg@vireshk-i7> <20201223043443.rklw5er6hck3gl4y@vireshk-i7> <7688d6b9-52a2-d30f-123f-43c01e03b968@gmail.com> <20201224062826.frppxddfinjomfui@vireshk-i7> From: Dmitry Osipenko Message-ID: Date: Thu, 24 Dec 2020 15:14:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.2 MIME-Version: 1.0 In-Reply-To: <20201224062826.frppxddfinjomfui@vireshk-i7> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 24.12.2020 09:28, Viresh Kumar пишет: > On 23-12-20, 23:36, Dmitry Osipenko wrote: >> 23.12.2020 07:34, Viresh Kumar пишет: >>> On 22-12-20, 22:19, Dmitry Osipenko wrote: >>>> 22.12.2020 12:12, Viresh Kumar пишет: >>>>> rate will be 0 for both the OPPs here if rate_not_available is true and so this >>>>> change shouldn't be required. >>>> >>>> The rate_not_available is negated in the condition. This change is >>>> required because both rates are 0 and then we should proceed to the >>>> levels comparison. >>> >>> Won't that happen without this patch ? >> >> No > > This is how the code looks like currently: > > int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2) > { > if (opp1->rate != opp2->rate) > return opp1->rate < opp2->rate ? -1 : 1; > if (opp1->bandwidth && opp2->bandwidth && > opp1->bandwidth[0].peak != opp2->bandwidth[0].peak) > return opp1->bandwidth[0].peak < opp2->bandwidth[0].peak ? -1 : 1; > if (opp1->level != opp2->level) > return opp1->level < opp2->level ? -1 : 1; > return 0; > } > > Lets consider the case you are focussing on, where rate is 0 for both the OPPs, > bandwidth isn't there and we want to run the level comparison here. > > Since both the rates are 0, (opp1->rate != opp2->rate) will fail and so we will > move to bandwidth check which will fail too. And so we will get to the level > comparison. > > What am I missing here ? I am sure there is something for sure as you won't have > missed this.. > Ah, you're right. It was me who was missing something as I see now, after taking a closer look and trying to implement yours suggestion, my bad. I'll improve this patch in the next revision, thanks!