Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp6335399pxu; Wed, 23 Dec 2020 22:31:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYHnT82tUNVSPXtr3OaTuyAqAwSJKfUule4E3zxkHIOMtLpT6YXRXxqL8HwnTiPwbMnvgV X-Received: by 2002:a50:bac4:: with SMTP id x62mr27067029ede.59.1608791472531; Wed, 23 Dec 2020 22:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608791472; cv=none; d=google.com; s=arc-20160816; b=uXFPve/i1DnolTZ39RVE71fgvDEsVOJT5DTwvFPFCYIG6ukGwAO2LIfStLTUF//A0x 1t5WPaEZ7jZ+MltDQmSXwtIZS5K3JYUQCe+APM2hJwcjkCOkJLHN/d4WRkjhVwWF3iVM fIGmC+J5H4wb+mo7Sz/fDbxiCeiEu4dVFSLXIuzI85gjKnEi6gdjmP7NgrL6aNf/u8At 4EOYbHBPVeWcQ95RbVyHrPnj1Plvio9C9GhZoC18fUcAtyH+mN/BYtXFTb0WA/OCNXbt 7klQHPN1g76h+l9v/XmzGxwpVfgVev+uIrz3m3uMwuGIS2EPyL7cM2LQoRsUR432r9cX 9E5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EjusjKqe1uD5qVIhtNFzzFr/40x6TzvZ/Sd3W/PBS+U=; b=I9DXdjk5PdPLSU+MLWvo4nKvvJhCc+erWLEKN4mIUwbQDjl97TaYYIhQbrvPbGMyyH Z3/4EML9OotCaA5p/u7v7cJWn9l9o+OTj0RqN0kT33AV5Et0bMp0JDt36L6ahmPNxWgC EVt5S7jxVX/vi3etuh8PY3T7XElfxqdntN3h2x2SmzbUhbcuFOVh8BCWc1oPmwbWzD/F 6YDdWOZ8+0JoIkYEVs+ZilmEFtzmgxCp67HcaPWQRO+FWv/4eWhK0/+7BYcCBpDl/4Zq iuCzz1AEQwgfAn0B8nDI+wKvLtWo79u9US7a0k0EVjdofY2z23dRzgyqQ1fzjD4Lfavu epLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fkgyFFom; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z102si14249931ede.307.2020.12.23.22.30.50; Wed, 23 Dec 2020 22:31:12 -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=@linaro.org header.s=google header.b=fkgyFFom; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727134AbgLXG3L (ORCPT + 99 others); Thu, 24 Dec 2020 01:29:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbgLXG3L (ORCPT ); Thu, 24 Dec 2020 01:29:11 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAE0CC0617A7 for ; Wed, 23 Dec 2020 22:28:30 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id f14so637045pju.4 for ; Wed, 23 Dec 2020 22:28:30 -0800 (PST) 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:content-transfer-encoding:in-reply-to :user-agent; bh=EjusjKqe1uD5qVIhtNFzzFr/40x6TzvZ/Sd3W/PBS+U=; b=fkgyFFom2uaI6UYerCixgJyMGXGGZzyzPl2pC34SDHHWr//SHmo19YSii8QHZaSaa0 uZC2skGBke5PtP9vslEZombfKjKIAYRw9D3l2M5uGrJ+VkC9bDxNBcQDONWQUC2dmGxG 6UJpFpuY87irp1H90rXExkNF0g2y+4HLV3Ep3/gdgJBqsszg3FbKmgil0GqbQ6dTgEnh DrDRzMipJyOMadGCFG5+H9D0UVs6y0l4FAVZ+I0/J5ZdR5hXHDE2454h+0iAD/EAVgA3 IDDlN9SUV6QyhslIyk38zgEDS9uC1vEdXUB6uhGhlyh9+PUCifXrT875haF9d9ipr3qB NnsQ== 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:content-transfer-encoding :in-reply-to:user-agent; bh=EjusjKqe1uD5qVIhtNFzzFr/40x6TzvZ/Sd3W/PBS+U=; b=LW1o96SVVCvZLwyL9BjlAHvxQ76B7HM/iC5GQKY85t+Avz+iGqqXmJGknZ/7o+iL5b xRFUjRkJccNVdOAZBGsSHMqYCqwyNFHj4uuNCKLUx3wC1LrcbJTrwoCQj781EV4R3V0F ufqhVDewD07nQfr2C4pf5J06J1liqfrHZ6VJnL0aI8wP2WSYGArSBWmNhtCAJQ/H4mGU W8+/hwBR8JhNkw2fvgsurPu03KT64m5YpQd/5eJEK6LwboGZ1cMAILXuUP1uAmGUsIqh ExEADfbsu2a5F4+gWFN7qx2IoPNs4YRJicrw24q7k0E2ITh2hjM28a4fdvtpoEuvKBP+ aIDw== X-Gm-Message-State: AOAM530ghUkKOuxRl9E0610mjsW8ltvSTENZDb7CPcy3eJUFUodRG8X7 GCoeTovJ0EAZbTTkGXb/JU1qRw== X-Received: by 2002:a17:90a:380c:: with SMTP id w12mr2982286pjb.117.1608791310121; Wed, 23 Dec 2020 22:28:30 -0800 (PST) Received: from localhost ([122.172.20.109]) by smtp.gmail.com with ESMTPSA id t18sm25653088pfl.138.2020.12.23.22.28.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Dec 2020 22:28:29 -0800 (PST) Date: Thu, 24 Dec 2020 11:58:27 +0530 From: Viresh Kumar To: Dmitry Osipenko 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 Subject: Re: [PATCH v2 19/48] opp: Fix adding OPP entries in a wrong order if rate is unavailable Message-ID: <20201224062826.frppxddfinjomfui@vireshk-i7> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7688d6b9-52a2-d30f-123f-43c01e03b968@gmail.com> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.. -- viresh