Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5506584pxu; Tue, 22 Dec 2020 20:37:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYTOR9105sWz8t3McuQIIqeKRHFyKRgdxTnnnif2IV73tSpvaPL34dD2XOwGHdWmTq1Uwi X-Received: by 2002:a17:907:2111:: with SMTP id qn17mr21841782ejb.525.1608698268918; Tue, 22 Dec 2020 20:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608698268; cv=none; d=google.com; s=arc-20160816; b=YYWuCctnO5T1G62q2NzK48BtBLL/a4O3wi1shEgl9Ueb1khWbTlV+O0KGM1lshuFuM OblXZ/uZJmIZzChaPR4pYgVlquESI8McMohQHRB4qH/e3z69yZ+f18fOOXNjAN9oTqp2 N/iJlqml9i71rP+yrLU3BrvTk0cmdzjp0pNYH3TdZuSAwFd3PIZ8c9dgkEbBWU4ZaSxg +4H3BSsZkX1KkVDsznCM1TAfu2OAY2n8uE0cU6WTEOKRIQoPK0norKij5nLAxaBlFnLg mvGSW0c7RFF7FV8aCzB97O11SZd/4GGM2OTQzolr8EEOBQ7D4kT02zbUuxaA2OMHe2tP /BzQ== 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=n/wQ/8FF3ZQQmDW8wRJInIGGffY6h+3NeQmSLgJVsG0=; b=Ak6Afi9ykGyuk9a+TJQFDUEeHmluCRsicU8k5puyyICF8YtJNqr5OPQno7TmD+mkrX kGoJK84ayMNXwoZX3tzrdy/Z4bUmIXBimNd0+BfvEukMv/CRYtqFlg4L4XM51jw5XJgS iIkdWD5xIO04SPrJqOaykeqMTLYLsgpZayZ3+dx9zLk1mDTVxQSi5rHD2eNAH30Z+m2W Dn+UEcR1iw+LQOOBzBqNNsROlLEppf4dMTBT5NQjLDz2r+CyrOVuPLz0KEcd1nqjD2VT eqbHJRGxmz5RfQT3ajOSPolMuz1GuWBcZtCtSZBKBSB6xSHWexDyh+RK+Au4hYK6WkRY 5YfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OFVqi0FZ; 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 r2si13551874eds.180.2020.12.22.20.37.27; Tue, 22 Dec 2020 20:37:48 -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=OFVqi0FZ; 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 S1727188AbgLWEfz (ORCPT + 99 others); Tue, 22 Dec 2020 23:35:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbgLWEfy (ORCPT ); Tue, 22 Dec 2020 23:35:54 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A7A7C061248 for ; Tue, 22 Dec 2020 20:34:50 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id c22so9795907pgg.13 for ; Tue, 22 Dec 2020 20:34:50 -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=n/wQ/8FF3ZQQmDW8wRJInIGGffY6h+3NeQmSLgJVsG0=; b=OFVqi0FZly+cr6h2L4MgV3W+0bqGCFrv37DumbpBBHHWKR10mlk8j96RhehvYC0ZKZ A7gveeGO4wUPNnptPGhKrlG+oY9ETV8EggwWNNJcSxmSKnIhp4D6iv6jEddwltALPRsH XoYuBifhBdhegWVRfh980lFbJW3ZCSqNzWxi8omP37WhPmGjiRZ+cWui/1OKijohx3Ni VZ3o0KDN4OIc1fPJ6UYDAexLzU558i9zpREZpptiCrCuZwWp74C+otCB7ziEAp6JpBCe /0WINPCLg0o7wHc+WB03uTQnpOkKqeEM2Jo/o42Mju6zYgkhMy6UlsZnrI4SeRLP+Rxr M+6A== 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=n/wQ/8FF3ZQQmDW8wRJInIGGffY6h+3NeQmSLgJVsG0=; b=beavCxkcoqWyX6JOXuFZR//IElKAnzCFLK24qC/a/2GOYw5PHu420CRlcLyb5wCpf1 V/eQCPZ5dm2G9YTZWfmT/SAd+YwH25EUo5koXepFapNHfzFr0LNTSWk+W4awvFZ7aiaM ukX7xC+haj6nW1g3HeCV1VELaEKmMhMAdYWrbwJjujWX2DWNHsh3n67KJZXCuTeLH2sl hxCx++iiNxZXGqjYaa1nfCJWpW1pQO7rbXvoCXe0tVth/12Hm4QKJoH2PuXxF8JYhMa2 nNH/tZvQjpLDfCxehGhAdjhc/QcoNQC4skHppGxYW1Mlx7ng1Bzhta3PT3sf/SUWTvmU 2EEg== X-Gm-Message-State: AOAM533ALN/r9gygYbUVfxy+c9rO2IeOMZzAuia6EAqSG+JtfDlP5agY OD14a3s9uD+7A/b+D+ycgntiLw== X-Received: by 2002:a63:6305:: with SMTP id x5mr22354072pgb.216.1608698089700; Tue, 22 Dec 2020 20:34:49 -0800 (PST) Received: from localhost ([122.172.20.109]) by smtp.gmail.com with ESMTPSA id p16sm21154516pju.47.2020.12.22.20.34.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2020 20:34:48 -0800 (PST) Date: Wed, 23 Dec 2020 10:04:43 +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: <20201223043443.rklw5er6hck3gl4y@vireshk-i7> References: <20201217180638.22748-1-digetx@gmail.com> <20201217180638.22748-20-digetx@gmail.com> <20201222091255.wentz5hyt726qezg@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22-12-20, 22:19, Dmitry Osipenko wrote: > 22.12.2020 12:12, Viresh Kumar пишет: > > On 17-12-20, 21:06, Dmitry Osipenko wrote: > >> Fix adding OPP entries in a wrong (opposite) order if OPP rate is > >> unavailable. The OPP comparison is erroneously skipped if OPP rate is > >> missing, thus OPPs are left unsorted. > >> > >> Signed-off-by: Dmitry Osipenko > >> --- > >> drivers/opp/core.c | 23 ++++++++++++----------- > >> drivers/opp/opp.h | 2 +- > >> 2 files changed, 13 insertions(+), 12 deletions(-) > >> > >> diff --git a/drivers/opp/core.c b/drivers/opp/core.c > >> index 34f7e530d941..5c7f130a8de2 100644 > >> --- a/drivers/opp/core.c > >> +++ b/drivers/opp/core.c > >> @@ -1531,9 +1531,10 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp, > >> return true; > >> } > >> > >> -int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2) > >> +int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2, > >> + bool rate_not_available) > >> { > >> - if (opp1->rate != opp2->rate) > >> + if (!rate_not_available && opp1->rate != opp2->rate) > > > > 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 ? > I guess it's not clear by looking at this patch, please see a full > version of the function: > > int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2, > bool rate_not_available) > { > if (!rate_not_available && 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; > } > > Perhaps we could check whether opp1->rate=0, like it's done for the > opp1->bandwidth. I'll consider this variant for v3, thanks. -- viresh